0

I have a 6 row input file which consists of a field(Position 1 to 6) that contains a different value on every line. Based on the different values contained in this field the other fields (From position 7 -80) will be moved to to a single row in output.

E.G.

Input:

035MI 88122              
035ST 72261              
035SU 317786762          
105         06616858     
1601     11              
1651  0000000140006PC

Output:

1      8812272261317786762      06616858   11  0000000140006PC

I need to find out how to read these all in as different rows and then output to a single row. I've tried using something similar to the code to this:

SORT FIELDS=COPY                         
INREC IFTHEN=(WHEN=(1,6,CH,EQ,C'035MI '),
              OVERLAY=(3:7,5)),       

But this will move the data onto the correct position on seperate rows like this:

1      8812272261317786762                            
1                               06616858
1                                          11
1                                              0000000140006PC

So now I think I need to do a sort in one step and a merge in another step. I would prefer to do it in one if it's possible however. I'd appreciate any help on this. Thanks.

cschneid
  • 10,237
  • 1
  • 28
  • 39
randomG765
  • 63
  • 1
  • 13
  • How did you manage to consolidate the first three lines in you sample output data? If you can do that, you should be able to achieve the whole thing. The Control Cards you've shown won't do that. – Bill Woodger Apr 27 '16 at 14:41
  • Sorry Bill, I should have been clearer. The output is currently being produced by a Cobol program,. I am trying to replicate this output with a JCL sort. But when I run the SORT each field is in a dirrent row. I need them to be on the same row, as with the sample output. – randomG765 Apr 27 '16 at 15:16
  • Which sort product do you have? There *may* be different solutions for DFSORT than Syncsort (for example). – cschneid Apr 27 '16 at 16:12

1 Answers1

1

You add a sequence-number to each record.

The use WHEN=GROUP to copy data from one record to one or more subsequent records.

You use OUTFIL INLUDE= to just pick up the final record.

 OPTION COPY 

 INREC IFTHEN=(WHEN=INIT, 
               OVERLAY=(81:SEQNUM,1,ZD)), 

       IFTHEN=(WHEN=GROUP, 
               BEGIN=(81,1,CH,EQ,C'1'), 
               PUSH=(somestuff), 
               RECORDS=6), 

       IFTHEN=(WHEN=GROUP, 
               BEGIN=(81,1,CH,EQ,C'2'), 
               PUSH=(somestuff), 
               RECORDS=5), 

       IFTHEN=(WHEN=GROUP, 
               BEGIN=(81,1,CH,EQ,C'3'), 
               PUSH=(somestuff), 
               RECORDS=4), 

       IFTHEN=(WHEN=GROUP, 
               BEGIN=(81,1,CH,EQ,C'4'), 
               PUSH=(somestuff), 
               RECORDS=3), 

       IFTHEN=(WHEN=GROUP, 
               BEGIN=(81,1,CH,EQ,C'5'), 
               PUSH=(somestuff), 
               RECORDS=2), 


  OUTFIL INCLUDE=(81,1,CH,EQ,C'6'),
          BUILD=(1,80)

You need to do a bit of planning. The sixth record will contain all the data, but perhaps not yet in the order that you want. Either with an IFTHEN=(WHEN=(logical expression) (to identify the sixth record) on the INREC or with the BUILD on the OUTREC, you can do your final formatting.

You need to change the something each time, it will be receivingposition:sourceposition,length

The DFSORT manuals are very good, there is a Getting Started for those new to the product, and everything you'll ever need is in the Application Programming Guide,

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