Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple CL,RPG

Status
Not open for further replies.

shmo

IS-IT--Management
Nov 25, 2002
18
0
0
US
This is the entry in a CL program. 0109 represents month and year. I want to automate that using a system date or some other source. How can I do that in CL? IF not,
RPG? How?


CPYF FROMFILE(#FILE/CHRG) +
TOFILE(#FILE/CHRG0109) MBROPT(*NONE) +
CRTFILE(*YES)
CPYF FROMFILE(#FILE/GLAU) +
TOFILE(#FILE/GLAU0109) MBROPT(*NONE) +
CRTFILE(*YES)
CPYF FROMFILE(#FILE/ACCT) +
TOFILE(#FILE/ACCT0109) MBROPT(*NONE) +
CRTFILE(*YES)
 
Use QDATE and QDATFMT system values to do so as shown below.

Code:
pgm                                           
dcl &qdate *char 6                            
dcl &qdatfmt *char 3                          
dcl &month   *char 2                          
dcl &year    *char 2                          
dcl &filenm *char 10                          
RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&QDATE)       
RTVSYSVAL  SYSVAL(QDATFMT) RTNVAR(&QDATFMT)   
/* QDATFMT can be YMD, MDY, DMY, JUL */       
if ( &qdatfmt = 'YMD' ) do                    
   chgvar &month %sst(&qdate 3 2)             
   chgvar &year  %sst(&qdate 1 2)             
enddo                                         
if ( &qdatfmt = 'MDY' ) do                    
   chgvar &month %sst(&qdate 1 2)             
   chgvar &year  %sst(&qdate 5 2)             
enddo                                                
/* ...and so on */                                   
chgvar &filenm  ( 'CHRG' *cat &month *cat &year )    
sndpgmmsg &filenm                                    
CPYF       FROMFILE(#FILE/CHRG) +                     
               TOFILE(#FILE/&filenm) MBROPT(*NONE)    
...
 
I'm sure that at V5R1 and greater, you can also RTYSYSVAL QMONTH and QYEAR directly - then you don't have to parse the date. I do that all the time on V5R3.

-- Francis
I'd like to change the world, but I can't find the source code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top