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
 

 

Copy field to subsequent records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Copy field to subsequent records
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

Site Director


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

PostPosted: Fri Sep 28, 2007 1:59 am    Post subject:
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    Post subject: Thank you!
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    Post subject:
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 Moderator


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

PostPosted: Fri Sep 28, 2007 8:25 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Sat Sep 29, 2007 2:08 am    Post subject:
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    Post subject:
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    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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am


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