0

Suppose we have an input file:

 123456789+123456789+
 FILE1 -X-X-X-X-X-X-X
 ABCD 1234 XOXOXO 001
 WXYZ 5678 YOYOYO 002
 ABCD 0011 XOXOXO 003

I NEED TO SORT OUT THE DATA IN FILE2 WHEN INCLUDE=(11,6,CH,EQ,C'XOXOXO') WHICH IS EASY TO GET.

But I also need to check for first row (which is a header of file) should contain FILE1 written in first row. then only we can check for INCLUDE condition INCLUDE=(11,6,CH,EQ,C'XOXOXO')

I think I need IF then =( something like that)

Agent Mahone
  • 307
  • 3
  • 15
  • 26
  • Are you using DFSort or a different sort routine ???, there may be better solution depending on the actual sort routine – Bruce Martin Aug 12 '14 at 23:12
  • 1
    I am assuming you want to do this with JCL. 1 possible solution is to use three steps step 1 (*sort include with readlimit of 1) step 2 test step (idcams ???) step 3 sort sort step (with if / cond) – Bruce Martin Aug 12 '14 at 23:15

1 Answers1

2

You need to temporarily add a sequence number to your record, test the sequence number for being one in a WHEN=GROUP and PUSH the value of 1,6. Then use OUTFIL INCLUDE= (which is like a "second shot" at INCLUDE COND) and BUILD to return your record to its previous size.

  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
                     OVERLAY=(21:SEQNUM,7,ZD)),
        IFTHEN=(WHEN=GROUP,BEGIN=(21,7,ZD,EQ,1),
                     PUSH=(28:1,6))
  OUTFIL INCLUDE=(28,6,CH,EQ,C'FILE1 ',
                 AND,
                 rest of your condition),
         BUILD=(1,20)

Note that the 7 after the SEQNUM and in the BEGIN are the same field, and this should be long enough to count all the records on your file, else you'll get a pickle.

You can't use INCLUDE COND= because you don't seem to be able to identify the header except by it being the first record, and INCLUDE/OMIT COND= are processed before anything else.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47