|
View previous topic :: View next topic
|
| Author |
Message |
ramsri
Active User

Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Hi,
I have an input file (LRECL=80,RECFM-FB) as shown below. I want to overlay type "08" with information from type "02" and "05" records. I have 6 character key starting at 5th position and tried using WHEN=GROUP with BEGIN=(1,2,CH,EQ,C'02') and PUSH but not getting expected results. The information on output type 08 record need to have either "X" or "Y" at 33rd position based on type "05" (error record) along with info overlayed from type "02" record.
Input:-
| Code: |
----+----1----+----2----+----3
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801
08 ABCDE19901
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702
08 XYZAB29502
08 XYZAB28902
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403
|
Output:
| Code: |
----+----1----+----2----+----3----+----4
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801 GEMINI 1971 2014 X
08 ABCDE19901 GEMINI 1971 2014 X
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702 VAHINI 1969 2004 X
08 XYZAB29502 VAHINI 1969 2004 X
08 XYZAB28902 VAHINI 1969 2004 X
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403 RAMANI 1985 1994 Y
|
Please help.
Thanks. |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
OK, you have given us the input records and the expected output records, ( I have assumed that these are the expected output as you have not stated if these are the expected output or actual output), but not the rules of what goes where and why it goes there.
Please expand on what conditions should perform what actions. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Also include the code which is giving you the incorrect results. Do 02 and 05 records always exist for a key? |
|
| Back to top |
|
 |
ramsri
Active User

Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Expat/Bill, these are the rules - What I gave in my first post was expected output. Type 02 and 08 always exist but type 05 does not on all.
| Quote: |
The information on output type 08 record need to have either "X" or "Y" at 33rd position based on type "05" (error record) along with info overlayed from type "02" record.
|
My code (does get me expected results):
| Code: |
//STEP0002 EXEC PGM=SORT
//SORTIN DD *
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801
08 ABCDE19901
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702
08 XYZAB29502
08 XYZAB28902
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'02'),
PUSH=(35:12,7,19,5,25,5)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'05'),
END=(1,2,CH,EQ,C'08'),PUSH=(60:5,1)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'08'),BUILD=(1,14,X,35,17,60,1))
OUTREC IFTHEN=(WHEN=(60,1,CH,NE,C' '),OVERLAY=(33:C'X')),
IFTHEN=(WHEN=(60,1,CH,EQ,C' '),OVERLAY=(33:C'Y'))
|
My output:
| Code: |
02 ABCDE1 GEMINI 1971 2014 N Y GEMINI 1971 2014
05 ABCDE1ERROR RECORD X GEMINI 1971 2014 A
08 ABCDE19801 GEMINI 1971 2014 Y
08 ABCDE19901 GEMINI 1971 2014 Y
02 XYZAB2 VAHINI 1969 2004 N Y VAHINI 1969 2004
05 XYZAB2ERROR RECORD X VAHINI 1969 2004 X
08 XYZAB29702 VAHINI 1969 2004 Y
08 XYZAB29502 VAHINI 1969 2004 Y
08 XYZAB28902 VAHINI 1969 2004 Y
02 EFGHI3 RAMANI 1985 1994 M Y RAMANI 1985 1994
08 EFGHI39403 RAMANI 1985 1994 Y
|
Expected Output:-
| Code: |
----+----1----+----2----+----3----+----4
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801 GEMINI 1971 2014 X
08 ABCDE19901 GEMINI 1971 2014 X
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702 VAHINI 1969 2004 X
08 XYZAB29502 VAHINI 1969 2004 X
08 XYZAB28902 VAHINI 1969 2004 X
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403 RAMANI 1985 1994 Y
|
Thanks. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I think you are quite close, so you've certainly picked up something by asking questions here :-)
Problems:
You are extending your records, which is correct, but you are not chopping them down again when you no longer need the extended data.
You have multiple 08 records per key, but you end the 05 GROUP when you get an 08.
Resolution:
Cut down the records.
END the GROUP for 02 at 08 as well.
Have a third GROUP for the 08 which PUSHes all your new data into the same place.
This should correctly populate your 08s.
Get it working and then we can make some suggestions to tighten it up. |
|
| Back to top |
|
 |
ramsri
Active User

Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Gerry, can you please help here too.
Thanks in advance. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Ramsri,
Use below to get what you need.
| Code: |
//STEP0002 EXEC PGM=SORT
//SORTIN DD *
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801
08 ABCDE19901
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702
08 XYZAB29502
08 XYZAB28902
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'02'),
PUSH=(81:1,30)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'05'),PUSH=(111:1,30))
OUTREC IFTHEN=(WHEN=(1,2,CH,EQ,C'02',OR,1,2,CH,EQ,C'05'),
BUILD=(1,80)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'08',AND,85,6,CH,EQ,115,6,CH),
BUILD=(1,16,92,18,C'X',80:X)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'08',AND,85,6,CH,NE,115,6,CH),
BUILD=(1,16,92,18,C'Y',80:X))
/*
|
Output
| Code: |
02 ABCDE1 GEMINI 1971 2014 N
05 ABCDE1ERROR RECORD
08 ABCDE19801 GEMINI 1971 2014 X
08 ABCDE19901 GEMINI 1971 2014 X
02 XYZAB2 VAHINI 1969 2004 N
05 XYZAB2ERROR RECORD
08 XYZAB29702 VAHINI 1969 2004 X
08 XYZAB29502 VAHINI 1969 2004 X
08 XYZAB28902 VAHINI 1969 2004 X
02 EFGHI3 RAMANI 1985 1994 M
08 EFGHI39403 RAMANI 1985 1994 Y
|
|
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| I am back after long... I might be rusty but it is tested. |
|
| Back to top |
|
 |
ramsri
Active User

Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Escapa, got the results with your code......thanks. this is FYI..
the SYSOUT shows below:
| Code: |
WER238I POTENTIALLY INEFFICIENT USE OF INREC
|
Thanks again. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Sambhaji,
Good to "see" you - wondered where you had gone . . .
Welcome back!
d |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Thanks Dick... I was busy learning Hadoop..
Ramsri, That is because we extended inrec to by PUSH but didnt really brought everything to output.
There is way to get away with it if you really want, I leave that upto you to work on. Do post back your finding if you think of work on.
Cluse is to parse only once rather that in inrec and outrec. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|