View previous topic :: View next topic
|
Author |
Message |
Lakshmi Prakash
New User
Joined: 22 Feb 2016 Posts: 5 Location: India
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Hint: Use OUTFIL slash '/' operator. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Lakshmi Prakash
New User
Joined: 22 Feb 2016 Posts: 5 Location: India
|
|
|
|
Thank you Bill, your solution worked perfectly well. |
|
Back to top |
|
|
|