I searched the forum, but could not find something specific to my requirement. So I am continuing to post the query.
I have two input files F1 of length 1000 and F2 of length 800. I have joined them on multiple keys.
I want to create a single output file with matched records from F2. While creating the output, I want check for a filed in F2, if it is blank I have to overwrite it with a value from F1. I am able to write F2 to output, but I am unable to overwrite the field in case of blank.
If you are Including the records which have position 1092,12 greater than or equal to Spaces, then how would you use the condition 1092,12 equal to spaces in IFTHEN ? You've already filtered those records with INCLUDE that you are trying to get with IFTHEN.
Moreover, you've already built the Outfil record as 800 bytes. IFTHEN is Not going to work after you are already done with OUTFIL BUILD (this is 'usually' the last statement in a sort card). The IFTHEN here will give an error.
You'll need to remove the INCLUDE and BUILD and just run with OUTFIL IFTHEN as below (get the positions correct to build 1,800 bytes record or instead of OVERLAY, do a BUILD):
If you are Including the records which have position 1092,12 greater than or equal to Spaces, then how would you use the condition 1092,12 equal to spaces in IFTHEN ? You've already filtered those records with INCLUDE that you are trying to get with IFTHEN.
I realized that this is Not correct since GE includes Equal.
In OUTFIL statement, parameters BUILD, and IFTHEN=(...OVERLAY...) are incompatible at the same level.
Whenever IFTHEN is used, any of BUILD/OVERLAY are allowed only as sub-parameters of IFTHEN.
And vice versa: whenever separate BUILD is used, IFTHEN is not allowed in the same statement.
SYNCSORT should give you the message
Quote:
WER270A OUTFIL STATEMENT : DUPLICATE PARM FOUND
did it not appear?
In your case you must use two IFTHEN with different BUILD in each of them.
Two steps are not needed.
Just re-organize your OUTFIL (please verify my re-calculated offsets :-) ):
Code:
OUTFIL FNAMES=SORTOUT,
INCLUDE=(1092,12,CH,GE,C' '),
IFTHEN=(WHEN=(1092,12,CH,NE,C' '),
BUILD=(1001,800)), full F2
IFTHEN=(WHEN=NONE,
BUILD=(1001,91, begin of F2
236,12, replacement from F1
1103,697)) end of F2
In order to simplify, and to clarify the idea, I would re-organize it further:
Code:
. . . . . . . .
REFORMAT FIELDS=(F2:1,800, full F2
F1:92,12) the only needed part of F1
OUTFIL FNAMES=SORTOUT,
INCLUDE=(92,12,CH,GE,C' '),
IFTHEN=(WHEN=(92,12,CH,NE,C' '),
BUILD=(1,800)), full F2
IFTHEN=(WHEN=NONE,
BUILD=(1,91, begin of F2
801,12, replacement from F1
103,697)) end of F2
END