vravi
New User
Joined: 28 Mar 2014 Posts: 2 Location: USA
|
|
|
|
Hi All,
I have a input file and it needs to transformed as explained below using
SORT( I execute PGM=SORT)
Input file:
-----------
Code: |
col1 col2 space
DBNAME1 DB2A 10
DBNAME1 DB2B 12
DBNAME1 DB2C 14
DBNAME1 DB2D 20
DBNAME2 DB2A 10
DBNAME2 DB2C 15
DBNAME2 DB2D 20 |
Output :
---------
Code: |
col1 col2 col3 col4 col5
DBNAME1 10 12 14 20
DBNAME2 10 15 20 |
I dont need the DB2* column as the 2nd column in outfile will be populated from DB2A ,3rd column from DB2B, 4th from DB2C and 4th from DB2D.
If space is not found for a system in the 2nd column of input file it has to be filled with spaces.
The input file will be sorted on Column 1 and Column 2
Code'd and de-mangled |
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
If you have a syncsort then you can refer to the below example and try to make the necessary changes as per your requirements otherwise please ignore,
Code: |
//SORT1 EXEC PGM=SORT,PARM='EQUALS'
//STEPLIB DD DSN=WCS.TS.SS12DN,UNIT=SYSDA,DISP=SHR
//SORTIN DD *
KEY1 DATA1
KEY1 DATA2
KEY2 DATA3
KEY2 DATA4
KEY3 DATA5
KEY3 DATA6
KEY4 DATA7
KEY4 DATA8
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(81,1,ZD,EQ,1),
BUILD=(1:1,11,12:6Z)),
IFTHEN=(WHEN=(81,1,ZD,EQ,2),
BUILD=(1:1,5,6:6Z,12:6,5,1Z))
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=(6,4,BI,10,4,BI,14,4,BI) |
Output :
Code: |
KEY1 DATA1 DATA2
KEY2 DATA3 DATA4
KEY3 DATA5 DATA6
KEY4 DATA7 DATA8 |
|
|