physical file name

265 pts.
I am running cpysplf command and create new file everyday. I would  like to give the file name with date extension on it. For example: before I run cpysplf command, I create PF INVOICE0305 (03/05/10). Is there any way to do so? Help please.   

Software/Hardware used:

Answer Wiki

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

dcl &Date *char 6
dcl &FName *char 10
rtvsysval QDATE rtnvar( &Date )
chgvar &FName ( ‘INVC’ *cat %sst( &Date 1 4 ) )
crtpf MyLib/&FName …</pre>
Retrieve the QDATE system value into a *CHAR(6) variable. Generate your file name into a *CHAR(10) variable. The code above takes the letters ‘INVC’ and concatenates them with four characters from the beginning of the date.

If the system date format is MDY and it is 5 March 2010, then &Date will contain ‘030510’. The first four characters are ‘0305’. When those are concatenated to ‘INVC’, the value in &FName becomes ‘INVC0305 ‘.

If the system date format is DMY, then &Date would be ‘050310’. You might need to retrieve the QDATFMT system value to see what the format is. You would take the substring of the month and day portions as appropriate for the date format. Alternatively, you could simply retrieve the QMONTH and QDAY system values. (But then you’d need to be careful of Julian as a system date format. Various possibilities arise when trying to use some troublesome value like a “date” as part of a name.)

Since names of physical files are limited to ten characters, you need to use six letters or less when you use four characters from the date.

Personally, I’d never use part of a “date” as a name. Dates are already made available as part of the object header. Why try to duplicate that in a name? After all, this is “programming”. Use a different method and code your program accordingly.


Discuss This Question: 5  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.
  • pwopen12
    Alternatively, you create a PF with multiple members and add member with the System date. OVRDBF To that member before you issue a copy command
    245 pointsBadges:
  • Larisagas
    Thank a lot, I'll try that.
    265 pointsBadges:
  • Larisagas
    Could you, please write me CL Code addpfm with qdate extension.
    265 pointsBadges:
  • Splat
    Just replace the CRTPF in the above example with ADDPFM.
    12,915 pointsBadges:
  • Larisagas
    Thank you, it worked!
    265 pointsBadges:

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.

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


Share this item with your network: