Puffe wrote:In position 5-12 there is a date in format (yyyymmdd) that differs from time to time.
So I want to add one month to that date-value and I want the day to be the first weekday of the new month, so it shouldn't be a saturday or sunday.
Let say that the date is 20120326 so the result I want in my output file should be:
FLD1,'20120402'
I think this can be done by using DFSORT.
Regards,
Mike
Mike,
Your description is confusing. I guess you just need to get the first weekday of the next month. Assuming your input is RECFM=FB and LRECL=80, the following DFSORT JCL will give you the desired results.
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123420120326
123420120430
123420120530
123420120630
123420120731
123420120831
123420120928
123420121031
123420121130
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,4,CH,EQ,C'1234')
INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,
OVERLAY=(81:05,8,Y4T,ADDMONS,+1,TOGREG=Y4T,87:C'01',
81,8,Y4T,WEEKDAY=CHAR3)),
IFTHEN=(WHEN=(89,3,CH,EQ,C'SAT'),
OVERLAY=(5:81,8,Y4T,ADDDAYS,+2,TOGREG=Y4T)),
IFTHEN=(WHEN=(89,3,CH,EQ,C'SUN'),
OVERLAY=(5:81,8,Y4T,ADDDAYS,+1,TOGREG=Y4T)),
IFTHEN=(WHEN=NONE,OVERLAY=(5:81,8))
//*
The output from the above job would be
123420120402
123420120501
123420120601
123420120702
123420120801
123420120903
123420121001
123420121101
123420121203