|
View previous topic :: View next topic
|
| Author |
Message |
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
I am using Join keys to for the below example.
File 1:
| Code: |
AAA 10000
BBB 11000 |
File 2:
| Code: |
AAA 20000 000
CCC 21000 000 |
Expected output:
| Code: |
AAA 10000 20000
BBB 11000 0 |
my sort join card is something like below
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,3,A)
JOINKEYS FILE=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,9,F2:5,5),FILL=X'00'
SORT FIELDS=COPY |
Output:
The output file has Zeroes when unpaired F1 exists. But it is being displayed like when I see it with copybook layout. It is missing sign, as module is reading the value into COMP-3 field. How to populate Zeroes for unpaired F1 records.
It should have been
.
Appreciate your help on this
Code'd |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Perhaps you can use 'Overlay' like this:
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,3,A)
JOINKEYS FILE=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,9,F2:5,5),FILL=X'FF'
OUTFIL IFTHEN=(WHEN=(10,5,CH,EQ,X'FFFFFFFFFF'),
OVERLAY=(10:X'000000000C'))
SORT FIELDS=COPY |
. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
RahulG31,
I should have coded before fixing the typos on your post :-)
rexx77,
Please use the Code-tags to preserve spacing.
Look at the use of the match-marker (a ? in the REFORMAT, which is replaced with the result of the join, B for both (a match), 1 for a mismatched file1, 2 for a mismatched file 2).
Use INREC, you need a BUILD to turn the REFORMAT record into the expected output, then an OVERLAY (and use IFOUTLEN to cut the record down) or a conditional BUILD with a second BUILD on WHEN=NONE - one BUILD doing a packed-zero, the other doing the actual value from the REFORMAT record. |
|
| Back to top |
|
 |
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
Thanks Rahul for the solution. This will work.
My fellow colleague gave me below logic, this also worked.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,3,A)
JOINKEYS FILE=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,9,F2:5,5),FILL=C'X'
INREC IFTHEN=(WHEN=(10,1,CH,EQ,C'X'),
BUILD=(1,9,5Z,X'0C')),
IFTHEN=(WHEN=(10,1,CH,NE,C'X'),
BUILD=(1,14))
|
Thanks folks. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Or this may be as per Bill's direction.
| Code: |
REFORMAT FIELDS=(F1:1,9,F2:5,5,?)
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(15,1,CH,EQ,C'B'),BUILD=(1,14)),
IFTHEN=(WHEN=(15,1,CH,EQ,C'1'),
BUILD=(1,9,4Z,+0,TO=PD,LENGTH=1)) |
you are missing a option copy  |
|
| Back to top |
|
 |
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
| It was copy paste mistake. COPY option was missed while posting.. Thanks Rohit. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| And in a topic for typos, the 5Z should be 4Z since the fifth byte gets appended. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|