IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Split data into different lines using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hiravibk
Warnings : 1

Active User


Joined: 14 Dec 2008
Posts: 107
Location: India

PostPosted: Thu Jan 19, 2012 5:20 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 19, 2012 6:20 pm
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
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: 107
Location: India

PostPosted: Mon Jan 23, 2012 5:29 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top