Date field default value – RPG

105 pts.
Tags:
RPG
RPG Programming
I have a date field defined in a file to hold the date we expect an order to be delivered. However there may be no orders open for an item and I expect I will get an error if I then leave this field blank. Any ideas on how I can handle this to avoid the error?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Typically you would set the field default to loval or load loval when you write the record.
Throughout your application you would use this value to indicate that the date doesn’t exist.

Alternatively you could set the field to allow nulls and leave this field null when a value doesn’t exist.
Phil

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    How is the field actually defined now (what are its attributes)? Is this a DDS file or SQL table? Tom
    125,585 pointsBadges:
    report
  • DanTheDane
    If your datefield is defined as a 'datefield', I recommend to use null as 'no date'. You will understand this recommandation when you run query on the data column; - never more the ugly '0001-01-01' but a nice '-' indicating that the datefield has no data in it. DanF
    2,555 pointsBadges:
    report
  • FrankStacey
    The file is defined by DDS. I have tried adding ALWNULL but this has provided me with compile errors relating to providing a default value. I added a DFT(*NULL) but this apparently conflicts with the DATFMT(*DMY) keyword.
    105 pointsBadges:
    report
  • aceofdelts
    Seems like you want to know upcoming demand for items by date. You could set a default of the last date of the period in process. Mike L.
    1,870 pointsBadges:
    report
  • WoodEngineer
    Date-type fields require a valid date, which may be the reason null values generate errors. The recommendation from Dan the Dane is popular.
    6,435 pointsBadges:
    report
  • FrankStacey
    Sorry to open this again but I didn't understand DanTheDane's response "If your datefield is defined as a ‘datefield’, I recommend to use null as ‘no date’" How do I accomplish "use null 'no date' " ??
    105 pointsBadges:
    report
  • TomLiotta
    How do I accomplish “use null ‘no date’ ” ? Assuming ILE RPG, try the ALWNULL() parameter when you compile the module. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following