1

I need to combine multiple records into one single record. Each block of records to be merged (transposed) are marked by a numeric key. The delimiter can also be the record with the string CHG. I've tried resize but it mixes different 'blocks' of records. The number of 'tables' can be between 1 and 50. The LRECL of the input file is 60 So, if my input data looks like this:

1 CHG
1 DATA
1 MOTIVE
1 table1
1 table2
1 table3
2 CHG
2 DATA
2 MOTIVO
2 table1
3 CHG
3 DATA
3 MOTIVE
3 table1
3 table2
3 table3
3 table4
3 table5

The output should at least be:

1 CHG 1 DATA 1 MOTIVE 1 table1 1 table2 1 table3
2 CHG 2 DATA 2 MOTIVE 2 table1
3 CHG 3 DATA 3 MOTIVE 3 table1 3 table2 3 table3 3 table4 3 table5

The ideal output (I can remove the first byte of the records, if it helps)

1 CHG DATA MOTIVE table1
1 CHG DATA MOTIVE table2
1 CHG DATA MOTIVE table3
2 CHG DATA MOTIVE table1
3 CHG DATA MOTIVE table1 
3 CHG DATA MOTIVE table2
3 CHG DATA MOTIVE table3
3 CHG DATA MOTIVE table4
3 CHG DATA MOTIVE table5

These were my last attempts and none worked correctly:

 //TOOLIN   DD *                                            
    RESIZE FROM(INDD) TO(OUTDD1) TOLEN(600) USING(CTL1)       


  //TOOLIN   DD *                                            
     RESIZE FROM(INDD) TO(OUTDD1) TOLEN(600) USING(CTL1)       
  //CTL1CNTL DD  *                                           
     INREC BUILD=(1,50)                                       
     OUTFIL FNAMES=OUTDD1,OVERLAY=(1:1,600)                   

/*

csbl
  • 265
  • 1
  • 6
  • 19
  • 1
    Cannot be done using JCL as JCL does not manipulate data. You appear to be using DFSORT or SYNCSORT so the tag should be the appropriate one of those. – NicC Dec 10 '19 at 11:11

1 Answers1

0

I've just come up with the following SORT statements,

SORT FIELDS=(53,1,CH,A)
INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,3,CH,EQ,C'CHG'),PUSH=(15:ID=1)),
  IFTHEN=(WHEN=(3,3,CH,EQ,C'CHG'),BUILD=(1,5,47Z,15,1)),
  IFTHEN=(WHEN=(3,4,CH,EQ,C'DATA'),BUILD=(6Z,3,4,42Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'MOTIVE'),BUILD=(11Z,3,6,35Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'TABLE1'),BUILD=(18Z,3,6,28Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'TABLE2'),BUILD=(25Z,3,6,21Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'TABLE3'),BUILD=(32Z,3,6,14Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'TABLE4'),BUILD=(39Z,3,6,7Z,15,1)),
  IFTHEN=(WHEN=(3,6,CH,EQ,C'TABLE5'),BUILD=(46Z,3,6,15,1))
SUM FIELDS=(1,8,9,8,17,8,25,8,33,8,41,8,49,4),FORMAT=BI
ALTSEQ CODE=(0040)
OUTREC FIELDS=(1,52,TRAN=ALTSEQ)

Input:

1 CHG
1 DATA
1 MOTIVE
1 TABLE1
1 TABLE2
1 TABLE3
2 CHG
2 DATA
2 MOTIVE
2 TABLE1
3 CHG
3 DATA
3 MOTIVE
3 TABLE1
3 TABLE2
3 TABLE3
3 TABLE4
3 TABLE5

Output:

1 CHG DATA MOTIVE TABLE1 TABLE2 TABLE3
2 CHG DATA MOTIVE TABLE1
3 CHG DATA MOTIVE TABLE1 TABLE2 TABLE3 TABLE4 TABLE5

I've used my favourite WHEN=GROUP feature and binary addition technique in DFSORT to achieve this outcome. More details about these features & technique can be found in this answer of mine in SO, as it also suggests a solution for a Record Transpose problem.

ALTSEQ CODE is being used additionally to convert any unused Binary zeros to spaces in the final output.

Although I believe this answer provides you the basic idea of acheiving your output, you might have to repeat the INREC IFTHEN clause for tables from 6 to 50.

Hope this helps.

Srinivasan JV
  • 705
  • 5
  • 12