Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Split data into different lines using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
hiravibk
Warnings : 1

Active User


Joined: 14 Dec 2008
Posts: 103
Location: India

PostPosted: Thu Jan 19, 2012 5:20 pm    Post subject: Split data into different lines using DFSORT
Reply with quote

Hi,

Any help on the below requirement would be very much appreciated:
Input:
Code:
1234567890123 000000000002500 DEBIT USER1 2012-01-18-11:08:54.567890
1234567890124 000000000003500 CREDITUSER2 2012-01-18-12:08:54.567890
1234567890125 000000000002500 DEBIT USER3 2012-01-18-13:08:54.567890
1234567890126 000000000002500 CREDITUSER4 2012-01-18-14:08:54.567890

Output:
Code:
SYS1               XF0 2012-01-19
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 DEBIT
SYS1 2012-01-19    XF2 2012-01-19 USER1 2012-JAN-18
SYS1 2012-01-19    XF3 ACCOUNT 1234567890123
SYS1 2012-01-19    XF1 2012-01-19 000000000003500 CREDIT
SYS1 2012-01-19    XF2 2012-01-19 USER2 2012-JAN-18
SYS1 2012-01-19    XF3 ACCOUNT 1234567890124
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 DEBIT
SYS1 2012-01-19    XF2 2012-01-19 USER3 2012-JAN-18
SYS1 2012-01-19    XF3 ACCOUNT 1234567890125
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 CREDIT
SYS1 2012-01-19    XF2 2012-01-19 USER4 2012-JAN-18
SYS1 2012-01-19    XF3 ACCOUNT 1234567890126
SYS1               XF9 0000000000004 0000000005000 0000000006000

Requirements:
- The XF0 and XF9 at position 20 in output indicate that they are the header and trailer of the output file.
- Each line in the input will be split into three lines in the output file named as XF1, XF2 and XF3 in position 20.
- The input file will have amounts at position 15 in 9(13)V99 format, the next field indicating whether its credit or debit.
- The trailer XF9 will have the total number of transactions in the input file in position 24. The position 38 in trailer will have sum of all the debits in the input file in 9(13)V99. The position 52 in trailer will have sum of all the credits in the input file with 9(13)V99.
- The postion 24 in output will have the current date, where as the postion 41 in XF2 lines will have the date from the input file in position 43.

I could use HEADER1 to get the first record in output and i could get the counts in trailer using TRAILER1. But i could not figure out how to split one line in input file to three lines in output file.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7255

PostPosted: Thu Jan 19, 2012 6:20 pm    Post subject: Reply to: Split data into different lines using DFSORT
Reply with quote

You can use the slash (/) operator of the OUTFIL statement to generate multiple output records from a single input record.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jan 19, 2012 10:56 pm    Post subject:
Reply with quote

hiravibk wrote:
The trailer XF9 will have the total number of transactions in the input file in position 24. The position 38 in trailer will have sum of all the debits in the input file in 9(13)V99. The position 52 in trailer will have sum of all the credits in the input file with 9(13)V99.


Aren't the totals overlaying each other? If the debits total starts in position 38 and needs 15 bytes it will end up at pos 52 and you want the total of credits to start at the same position? Assuming that these are typos and the output file lrecl is 80 bytes the following DFSORT JCL will give you the desired results.
Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
//SORTIN   DD *                                                       
1234567890123 000000000002500 DEBIT USER1 2012-01-18-11:08:54.567890   
1234567890124 000000000003500 CREDITUSER2 2012-01-18-12:08:54.567890   
1234567890125 000000000002500 DEBIT USER3 2012-01-18-13:08:54.567890   
1234567890126 000000000002500 CREDITUSER4 2012-01-18-14:08:54.567890   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:2C'+000000000000000',48,2,X)),   
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=113,                             
  INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',C'04',C'APR',         
         C'05',C'MAY',C'06',C'JUN',C'07',C'JUL',C'08',C'AUG',         
         C'09',C'SEP',C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'))),       
  IFTHEN=(WHEN=(31,6,CH,EQ,C'CREDIT'),OVERLAY=(82:15,15)),             
  IFTHEN=(WHEN=(31,5,CH,EQ,C'DEBIT'),OVERLAY=(97:C'-',15,15))         
                                                                       
  OUTFIL REMOVECC,                                                     
  BUILD=(C'SYS1 ',DATE1(-),20:C'XF1 ',DATE1(-),X,15,22,/,             
         C'SYS1 ',DATE1(-),20:C'XF2 ',DATE1(-),X,37,11,113,3,50,3,/,   
         C'SYS1 ',DATE1(-),20:C'XF3 ',C'ACCOUNT ',1,13,80:X),         
  HEADER1=('SYS1',20:'XF0 ',DATE=(4MD-)),                             
  TRAILER1=('SYS1',20:'XF9 ',COUNT=(M11,LENGTH=13),                   
            38:TOT=(97,16,SFF,EDIT=(TTTTTTTTTTTTTTT)),                 
            54:TOT=(81,16,SFF,EDIT=(TTTTTTTTTTTTTTT)))                 
//*


The output from the above job is
Code:

SYS1               XF0 2012-01-19                                   
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 DEBIT             
SYS1 2012-01-19    XF2 2012-01-19 USER1 2012-JAN-18                 
SYS1 2012-01-19    XF3 ACCOUNT 1234567890123                       
SYS1 2012-01-19    XF1 2012-01-19 000000000003500 CREDIT           
SYS1 2012-01-19    XF2 2012-01-19 USER2 2012-JAN-18                 
SYS1 2012-01-19    XF3 ACCOUNT 1234567890124                       
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 DEBIT             
SYS1 2012-01-19    XF2 2012-01-19 USER3 2012-JAN-18                 
SYS1 2012-01-19    XF3 ACCOUNT 1234567890125                       
SYS1 2012-01-19    XF1 2012-01-19 000000000002500 CREDIT           
SYS1 2012-01-19    XF2 2012-01-19 USER4 2012-JAN-18                 
SYS1 2012-01-19    XF3 ACCOUNT 1234567890126                       
SYS1               XF9 0000000000004 000000000005000 000000000006000
Back to top
View user's profile Send private message
hiravibk
Warnings : 1

Active User


Joined: 14 Dec 2008
Posts: 103
Location: India

PostPosted: Mon Jan 23, 2012 5:29 pm    Post subject:
Reply with quote

Thanks Bill. Thank you for the detailed code Kolusu, especially for the date logic part!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us