Hi there. Long time lurker first time poster (I think.. its been a while) So lets get to it
I have two requirements where I need to parse data from a file and then convert it to a different format with additional lines (yes it may be easier with Easytrieve but wondering if I can get away with it using sort).
I would like to show the first one for folks to see what I am going for then show the challenge I am stuck with
INPUT file - one record only
FILETEST101821.txt; otherstuff blah blah blah
My sample sort card - this works
Code:
SORT FIELDS=COPY
OUTFIL OUTREC=(C' SIGNON ESF=YES CASE=YES',80:X,/,
C' SUBMIT PROC=XXXXXXX -',80:X,/,
C' &STEP=STEP1 -',80:X,/,
C' &FROMDSN=HARD.CODED.FILE1 -',80:X,/,
C' &TOFILE=',X'7D',C'/hardcoded/directory1/',1,17,
X'7D',80:X,/,
C' SUBMIT PROC=XXXXXXX -',80:X,/,
C' &STEP=STEP2 -',80:X,/,
C' &FROMDSN=HARD.CODED.FILE2 -',80:X,/,
C' &TOFILE=',X'7D',C'/hardcoded/directory1/CK_',1,17,
X'7D',
C'-',80:X,/,
C' SIGNOFF',80:X)
So I am able to just use that one record file and populate the file name in both &TOFILE lines
Challenge
So for the other requirement that I am stuck with:
I need to parse a 4 line record file that contains the source and destination file name for 2 files (the names change but the length of name is fixed) and turn it into the same format as the first challenge.
INPUT FILE2
Code:
PUT 'FILEA.SOURCE.PLACE' +
FILEA.DESTINATION.txt
PUT 'FILEB.SOURCE.PLACE' +
FILEB.DESTINATION.txt
So for above I need to put the parsed text in the &FROMDSN and the &TOFILE IS it possible to extract the file names from INPUT FILE 2 and then put it in the format that I need with the additional lines in just one sort step (using multiple OUTREC ??) or do I need to split up into 4 files and then have another sort step do the merge?
Long-time lurker should know to use the code tags and that they are data sets not files!
sadly as I have not had the chance to post never really got the chance to look at how to do the code tags. Could not find em in the Forum FAQ / User Guide section nor on any sticky. May I ask for a link that explains so please?
As for Datasets and not files, sorry force of habit. I keep talking to a bunch of Datastage/ETL folk over here and their definition of a Dataset is different from ours. Then when I talk to the Java /web folk their eyes glaze over when I say Dataset so I just say File
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Badbeef,
One thing you could do is to build a SYMNAMES data set by reading the 'file names data set', creating 4 symbols corresponding each name. Then use it in the next step.
Stage 4: Using JOINKEYS, PARSE, IFTHEN, and BUILD combine the table-like input, and updated template - replacing $$$PARAMETERS$$$ parts with joined column 2 from table-like input.
PUT 'FILEA.SOURCE.PLACE' +
FILEA.DESTINATION.txt
PUT 'FILEB.SOURCE.PLACE' +
FILEB.DESTINATION.txt
-Include only 1-4 = spaces
-Use RESIZE to place two records to each other
FILEA.DESTINATION.txt FILEB.DESTINATION.txt
Use JOINKEYS to Overlay, respective positions from DS1 to DS2.