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

To split the record conditionally


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

New User


Joined: 22 Feb 2016
Posts: 5
Location: India

PostPosted: Mon Feb 22, 2016 7:52 pm
Reply with quote

Hello,

I was working on a task where I need to split a record into multiple records conditionally. Below is the example of the requirement

Input records
abcdefghij12345fghij12345klmno90876pqrst12345uvwxy12345zabcd76543efghi
qwertyuiop12345abcde12345fghij67890klmno12345pqrst57876uvwxy12345zfghi
abcdefghij12345fghij12345klmno12345pqrst12345uvwxy12345zabcd12345efghi
qwertyuiop12345abcde12345fghij12345klmno12345pqrst12345uvwxy12345zfghi

As you might have noticed input records would be in the copybook format as below

Code:

01 ws-inrec.
  05 ws-text1   pic x(10).
  05 ws-occ  occurs 5 times.
    07 ws-num1  pic 9(5).
    07 ws-text2  pic X(5).


Now the task is to check if the ws-num1 in above copybook is 12345, if so, then we have to write it in the output record for each occurrence. In the above example on reading first record the output should have 4 records as it has four occurrences of 12345, as below.

abcdefghij12345fghij
abcdefghij12345klmno
abcdefghij12345uvwxy
abcdefghij12345zabcd

Output record should have data as below.

Code:

01 ws-inrec.
  05 ws-text1   pic x(10).
  05 ws-num1  pic 9(5).
  05 ws-text2  pic X(5).


I have already worked this in Cobol, but i'm curious to know if there is any feasible way to accomplish this in dfsort. I would also like to mention, on search I found Link
which shows a similar task. But I felt that logic might be too lengthy in this case.

Let me know if you are looking for any other information.

Thanks,
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Feb 22, 2016 8:59 pm
Reply with quote

probably 2 or 3 statements..
on inrec include only those records that you need
buid your outfile using only the fields you need.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon Feb 22, 2016 9:06 pm
Reply with quote

Hint: Use OUTFIL slash '/' operator.
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: Mon Feb 22, 2016 9:19 pm
Reply with quote

Use ICETOOL's RESIZE operator, with a USING.

In the USING use INREC BUILD to make a long record where each occurrence is prefixed by the key.

in OUTFIL, use INCLUDE= for the key you want.
Back to top
View user's profile Send private message
Lakshmi Prakash

New User


Joined: 22 Feb 2016
Posts: 5
Location: India

PostPosted: Tue Feb 23, 2016 7:42 pm
Reply with quote

Thank you Bill, your solution worked perfectly well. icon_biggrin.gif icon_biggrin.gif icon_smile.gif
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 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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top