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

Join key - Populate Zeros when Unpaired from File 1


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

New User


Joined: 14 Apr 2008
Posts: 78
Location: Mysore

PostPosted: Thu May 12, 2016 12:22 am
Reply with quote

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.

Code:
 X'000000000000'


It should have been
Code:
 0
.

Appreciate your help on this

Code'd
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu May 12, 2016 12:50 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu May 12, 2016 2:18 am
Reply with quote

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
View user's profile Send private message
rexx77

New User


Joined: 14 Apr 2008
Posts: 78
Location: Mysore

PostPosted: Thu May 12, 2016 2:30 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu May 12, 2016 2:35 am
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
rexx77

New User


Joined: 14 Apr 2008
Posts: 78
Location: Mysore

PostPosted: Thu May 12, 2016 3:12 am
Reply with quote

It was copy paste mistake. COPY option was missed while posting.. Thanks Rohit.
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: Thu May 12, 2016 3:25 am
Reply with quote

And in a topic for typos, the 5Z should be 4Z since the fifth byte gets appended.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top