Page 1 of 1

Need to concatenate last months ccyy

PostPosted: Fri May 28, 2010 9:50 pm
by KParrish
I need to concatenate ccyy to the beginning of each record. I know I need to use OUTREC BUILD stmt, but can't seem to get the format to just put the ccyy. I don't want the mm or dd portion of last month's complete date. Anyone know how to do this?

Re: Need to concatenate last months ccyy

PostPosted: Fri May 28, 2010 10:14 pm
by Frank Yaeger
Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of all relevant fields. Give the RECFM and LRECL of the input file.

Re: Need to concatenate last months ccyy

PostPosted: Fri May 28, 2010 10:32 pm
by KParrish
Input file
04ADA007060209295
04ADA007060242698

desired output if run 05/2010
201004ADA007060209295
201004ADA007060242698

desired output if run 01/2010
200904ADA007060209295
200904ADA007060242698

Not understanding "rules" stmt. Trying to use DFSORT/ICETOOL to add ccyy to beginning of each record using the OUTREC BUILD control stmt.
Something like OUTREC FIELDS=(DATE2-1,1,17) but I only want and need the "year" component" of the previous month's date to concatenate to the beginning of each.
LRECL and BLKSZ are irrelevant in this case I think

Re: Need to concatenate last months ccyy

PostPosted: Fri May 28, 2010 10:46 pm
by Frank Yaeger
LRECL and BLKSZ are irrelevant in this case I think


I asked for RECFM and LRECL, not LRECL and BLKSZ. The RECFM and LRECL are NOT irrelevant. Please give the RECFM and LRECL for the input file AND output file.

Re: Need to concatenate last months ccyy

PostPosted: Sat May 29, 2010 12:32 am
by KParrish
RECFM=FB LRECL=200

Re: Need to concatenate last months ccyy

PostPosted: Sat May 29, 2010 1:23 am
by Frank Yaeger
Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
YRMON,S'&YR4.&MON'
/*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
    IFTHEN=(WHEN=INIT,
     BUILD=(C'PRYR,''YYYY''',81:YRMON)),
    IFTHEN=(WHEN=(85,2,CH,EQ,C'01'),
      OVERLAY=(7:81,4,ZD,SUB,+1,EDIT=(TTTT))),
    IFTHEN=(WHEN=NONE,
      OVERLAY=(7:81,4))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file (FB/200)
//SORTOUT DD DSN=...  output file (FB/200)
//SYSIN DD *
  OPTION COPY
  INREC BUILD=(PRYR,1,196)
/*

Re: Need to concatenate last months ccyy

PostPosted: Tue Jun 01, 2010 6:48 pm
by KParrish
Greatness! Thank you VERY much, works like a champ