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

Copy key from previous record till it encounters another key


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

Active User


Joined: 02 Jan 2009
Posts: 115
Location: Hyderabad

PostPosted: Wed Aug 26, 2015 7:47 pm
Reply with quote

Code:

0155555
02ADRS1
02ADRS2
02ADRS3
0166666
02ADRS4
02ADRS5


Hi,

I have the file like above.
.
Bytes 1,2 identifies the record type. 01 record is the group head till it finds another 01 record.

All the 02 records belong to the previous 01 record type.

If record type is 01, then byte 3 thru 7 is the key.

Is there a way get the file like the below using sort/icetool?

Code:

555550155555
5555502ADRS1
5555502ADRS2
5555502ADRS3
666660166666
6666602ADRS4
6666602ADRS5


The key from 01 record has to be copied to all it's corresponding records (including that 01 record) till it finds another 01 record.

I found this can be done using inrec overlay for 01 record type alone. But can some please help me to get an idea on how to do this for all it's 02 records till it finds another 01 record.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Aug 26, 2015 7:58 pm
Reply with quote

Use IFTHEN=(WHEN=GROUP with BEGIN for the C'01' value and PUSH the key to the position you. The PUSH gets done for each record.
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 115
Location: Hyderabad

PostPosted: Wed Aug 26, 2015 8:36 pm
Reply with quote

Thanks Bill for a prompt response. How about this?

Code:

SORT FIELDS=COPY                                         
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'01'),PUSH=(1:3,5))


I'm home, I cant test it till tomorrow morning.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Aug 26, 2015 10:36 pm
Reply with quote

That's along the right lines. Problem is that PUSH is like OVERLAY, so you need something to overlay:

Code:
  INREC IFTHEN=(WHEN=INIT,
              BUILD=(5X,1,length)),


and then your GROUP and PUSH, remembering in the PUSH that the position is five to the right of where it was originally.
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 115
Location: Hyderabad

PostPosted: Thu Aug 27, 2015 1:38 pm
Reply with quote

Thanks bill. I am ok to get the key at the end of each record also. So, I modified "push" accordingly.

Do you have any link where latest SORT manual is located. I would like to learn more about these advanced sort techniques.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Aug 27, 2015 2:31 pm
Reply with quote

If you click on the DFSORT/ICETOOL link above your question, it'll take you to the forum itself, which includes a number of "stickies" you may find useful, as well as links to the documentation.
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 115
Location: Hyderabad

PostPosted: Fri Aug 28, 2015 9:47 am
Reply with quote

Thankyou. Links provided are very useful.
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 Execute step regardless of previous s... JCL & VSAM 2
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
No new posts Checking the total counts inside a re... JCL & VSAM 5
This topic is locked: you cannot edit posts or make replies. Copy list of files from PS to another... CLIST & REXX 11
This topic is locked: you cannot edit posts or make replies. Splice JCL into one record for DD sta... SYNCSORT 2
Search our Forums:

Back to Top