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

Copy field to subsequent records


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

New User


Joined: 28 Sep 2007
Posts: 2
Location: St Louis

PostPosted: Fri Sep 28, 2007 1:45 am
Reply with quote

I need to sort a file on account number but the account number exists on the header record but not the detail records. Can I utilize dfsort or icetool to copy the account number to detail records? I should be able to..... but have been trying for a couple of hours to no avail. The rest of the record should remain the same as input.

I will simplify the example. The record group is in col 1 and the account # is in col 2. The record is 200 bytes long with fb format. The before and after records are as follows:

Before:

a001 header
a
a
b009 header
b
c002 header
c
c
d005 header
d

After:

a001 header
a001
a001
b009 header
b009
c002 header
c002
c002
d005 header
d005

Thus, I need for the account number to 'drop down' to the next record until a new account number is encountered. There is also a code for header and detail records. Header records can be a 0,1 or 9 while detail records can be a 3, 4, 5, or D. I left that out of the example but it exists if needed. Is this task difficult? Thank you in advance for any help you can provide.

Thank you,

Jim Kuhn
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: Fri Sep 28, 2007 1:59 am
Reply with quote

Hello Jim and welcome to the forums,

Quote:
Header records can be a 0,1 or 9 while detail records can be a 3, 4, 5, or D. I left that out of the example but it exists if needed
I'm confused on how this would be used.

As posted your question made sense to me, but with this new info, i'm not sure how to apply it to your requirement.
Back to top
View user's profile Send private message
jim kuhn

New User


Joined: 28 Sep 2007
Posts: 2
Location: St Louis

PostPosted: Fri Sep 28, 2007 2:27 am
Reply with quote

Thank you. The header record code should not be significant but is available if the data can't be appended otherwise. The header record will always be the first record in a 'new group' as noted by a change in column 1.

With my example think of the header record as the product information regarding a sell. Detail record 1 could be the associated commission. Detail record 2 could be a regulatory fee. That information is insignificant and I think the record type code (header or trailer) is also insignificant.

If I can append the account number on all records I will sort the file on account number, record group and sequence number that I will be adding with an 'overlay seqno step'. Thank you for any help you can provide.

Thanks,

Jim
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Sep 28, 2007 5:03 pm
Reply with quote

jim kuhn
I have considered the i/p in this fashion
Code:
H001           
A               
A               
A               
H002           
B               
B               
B               

All header records will start with H in first position.
detail records may start with any character other than H
The following DFSORT/ICETOOL JCL, drops down the content in the header record from 2nd position to 4th position, to the detail records untill it encounters next header record.
Code:
//*******************************************************               
//STEP001  EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                         
H001                                                                   
A                                                                       
A                                                                       
A                                                                       
H002                                                                   
B                                                                       
B                                                                       
B                                                                       
/*                                                                     
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
 COPY FROM(IN1)  TO(TMP1) USING(CP01)                                   
 SPLICE FROM(TMP1)  TO(OUT)  ON(93,8,ZD) WITH(1,1) WITH(5,75)-         
  KEEPBASE WITHALL USING(CP02)                                         
/*                                                                     
//CP01CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(93:SEQNUM,8,ZD)),                   
        IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),                                 
                OVERLAY=(93:SEQNUM,8,ZD,101:C'00000000')),             
        IFTHEN=(WHEN=NONE,                                             
                OVERLAY=(101:SEQNUM,8,ZD,                               
                         93:93,8,ZD,SUB,101,8,ZD,M11,LENGTH=8))         
/*                                                                     
//CP02CNTL DD *                                                         
  OUTFIL BUILD=(1,80)                                                   
/*                                                                     

O/P will be 80 byte file(FB).
O/p OUT contains:
Code:
---+----1
H001     
A001     
A001     
A001     
H002     
B002     
B002     
B002     
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Sep 28, 2007 8:25 pm
Reply with quote

Jim,

Here's a DFSORT/ICETOOL job that will do what you asked for in one pass.

Code:

//S1    EXEC  PGM=ICETOOL                                         
//TOOLMSG DD SYSOUT=*                                             
//DFSMSG  DD SYSOUT=*                                             
//IN DD DSN=&&IN,DISP=(OLD,PASS)                                   
//OUT DD SYSOUT=*                                                 
//TOOLIN   DD    *                                                 
SPLICE FROM(IN) TO(OUT) ON(201,8,ZD) KEEPBASE KEEPNODUPS -         
  WITHALL WITH(1,1) WITH(5,196) USING(CTL1)                       
/*                                                                 
//CTL1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(201:SEQNUM,8,ZD)),             
        IFTHEN=(WHEN=(1,1,SS,EQ,C'019'),                           
                OVERLAY=(201:SEQNUM,8,ZD)),                       
        IFTHEN=(WHEN=NONE,                                         
                OVERLAY=(209:SEQNUM,8,ZD,                         
                         201:201,8,ZD,SUB,209,8,ZD,M11,LENGTH=8)) 
  OUTFIL FNAMES=OUT,BUILD=(1,200)                                 


It would have helped if you'd shown your input as it actually looks. I created the following input file with RECFM=FB and LRECL=200 based on your description:

Code:

0001 header     
3    detail a   
4    detail a   
1009 header     
5    detail b   
0006 header m   
9002 header     
D    detail c   
5    detail c   
0005 header     
3    detail d   


OUT would have:

Code:

0001 header       
3001 detail a     
4001 detail a     
1009 header       
5009 detail b     
0006 header m     
9002 header       
D002 detail c     
5002 detail c     
0005 header       
3005 detail d     
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Sep 28, 2007 9:29 pm
Reply with quote

Frank without trying your code, am asking one query:
is KEEPNODUPS required in the SPLICE statement of your JCL?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Sep 29, 2007 2:08 am
Reply with quote

Krisprems,

I used KEEPNODUPS for completeness in case there is a header without detail records. In my example, I had

0006 header m

for that case and it would not appear in the output file without KEEPNODUPS. If the input file doesn't contain any headers without detail records, then KEEPNODUPS is not needed.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Sep 29, 2007 12:09 pm
Reply with quote

Thanks for that explanation frank, i was really wondering as to why KEEPNODUPS was required.
Now its clear.
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top