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

Populate one field value of detail record on header record


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

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Wed Jul 28, 2010 10:45 am
Reply with quote

I have a input file and lot of columns and records are there. The records are consist of header and details. Sometimes the header has 2 detail line or 3 detail line. There are thousands of records like this.

I want to copy one value of a field from detail record to header record.

For exp:

H|ACD1384738 |2009-10-01|023
D|ACD1384738 |2009-10-01|023395620
D|ACD1384738 |2009-10-01|023395620
H|ACD1384743 |2009-10-01|023
D|ACD1384743 |2009-10-01|023395624
D|ACD1384743 |2009-10-01|023395624
H|ACD1384756 |2009-10-01|023
D|ACD1384756 |2009-10-01|023395628

here the 4th column field has values in detail line but not in header line.
This fourth field has the PIC 9(09). The 1st 3 characters are populated already. I want the rest 6 fields to populate. i.e. The value in detail record should populate in their header record also. To get more clear, the output data should be like this:

H|ACD1384738 |2009-10-01|023395620
D|ACD1384738 |2009-10-01|023395620
D|ACD1384738 |2009-10-01|023395620
H|ACD1384743 |2009-10-01|023395624
D|ACD1384743 |2009-10-01|023395624
D|ACD1384743 |2009-10-01|023395624
H|ACD1384756 |2009-10-01|023395628
D|ACD1384756 |2009-10-01|023395628

starting position of that field is 28 and length is 9. Please someone can answer if this can be fixed thru any sort. Thanks in advance.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 28, 2010 7:12 pm
Reply with quote

Hello,

What should happen when the 4th field in the detail records has more than one value for the "key" (which is the 2nd field?)?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jul 28, 2010 9:53 pm
Reply with quote

maxsubrat,

Since you haven't provided the LRECL and REFCM of the input and output files, here is a DFSORT JOB which would give you the desired results based on the assumptions

1. Your Input is FB recfm and has an LRECL of 80
2. The header value gets the first detail record value from pos 26 for a length of 9 bytes

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
H|ACD1384738 |2009-10-01|023     
D|ACD1384738 |2009-10-01|023395620                                 
D|ACD1384738 |2009-10-01|023395620                                 
H|ACD1384743 |2009-10-01|023     
D|ACD1384743 |2009-10-01|023395624                                 
D|ACD1384743 |2009-10-01|023395624                                 
H|ACD1384756 |2009-10-01|023     
D|ACD1384756 |2009-10-01|023395628                                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),                 
  PUSH=(81:1,80),RECORDS=2)                                       
  OUTFIL IFOUTLEN=80,OMIT=(1,1,CH,EQ,C'H'),                       
  IFTHEN=(WHEN=(81,1,CH,EQ,C'H'),BUILD=(81,25,26,9,115,46,/,1,80))
//*
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Wed Jul 28, 2010 10:22 pm
Reply with quote

Skolusu you are great
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 split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top