Posted: Tue Mar 25, 2003 2:43 am Post subject: Remove commas from input file
Hello all,
I Would like to create a output dataset with fixed structure from a input file which has fields separated by Comma.
Example Input: 12,5678,78,
Output File structure is fixed (Each field is 5 Chars):
000120567800078
How can we do this using JCL or INSYNC ?
Regards,
Bindu
If you have eazytrieve at your shop then you can use the following job to achieve the desired results.The beauty of this program is that it can work for any file whose length is less than or equal to 9999.
W-SUB W 08 N 0
W-IN-START W 08 N 0 VALUE 1
W-IN-END W 08 N 0 VALUE 0
W-PAD-QTY W 08 N 0 VALUE 0
W-START W 08 N 0 VALUE 1
W-DELIM-IND W 08 N 0 VALUE 5
W-LIT-COUNT W 08 N 0 VALUE 0
W-OUT-START W 08 N 0 VALUE 0
W-VAR W 05 N
JOB INPUT FILEIN
W-SUB = 1
DO UNTIL W-SUB > FILEIN:RECORD-LENGTH
IF FILEIN-REC (W-SUB) = ','
PERFORM PAD-PROC
PERFORM FIELD-MOVE
ELSE
W-LIT-COUNT = W-LIT-COUNT + 1
END-IF
W-SUB = W-SUB + 1
END-DO
PUT FILEOUT
PAD-PROC. PROC
W-PAD-QTY = 5 - W-LIT-COUNT
CASE W-PAD-QTY
WHEN 1
MOVE '0' TO O-REC (W-START) W-PAD-QTY
WHEN 2
MOVE '00' TO O-REC (W-START) W-PAD-QTY
WHEN 3
MOVE '000' TO O-REC (W-START) W-PAD-QTY
WHEN 4
MOVE '0000' TO O-REC (W-START) W-PAD-QTY
END-CASE
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Tue Mar 25, 2003 11:01 pm Post subject:
Bindu,
If you want the JCL way, then you can use ICETOOL with two passes. I will just post the basic idea. The code is not complicated but very voluminous.
Assuming (a) there are only three 5 byte fields (b) no comma is a part of data you can do the following in ICETOOL.
1. Split the input file into 125 datasets. This is because, comma can appear at five places for every field. So, 5^3 = 125. For every combination of comma in three fields, (comma for first place in first field, comma for first place in second field, comma for first place in first third field, etc.), code a OUTREC parameter for dropping comma and formatting.
2. Concatenate those 125 datasets again back to the to-be-uploaded dataset.
For testing the splitting limit, I copied one record from my I/P file and wrote it to around 200 datasets. (I created those OUTFIL FNAMES cards using DFSORT!) I did not face any problem. Hope DFSORT would not complain in your case too. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 03 Jan 2003 Posts: 283 Topics: 27 Location: US
Posted: Wed Apr 02, 2003 8:31 am Post subject:
Bindu,
I know Im pretty late on this.But could you please tell me as to what are the possible flavours of input (with commas). Is the comma position fixed for all the records. BTW, I was suprised to see your shop allowing you to code a COBOL pgm rather than a REXX code. Does that still hold good ?
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue May 30, 2006 2:27 pm Post subject:
With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), you can now do this kind of thing quite easily with DFSORT's new PARSE function, as shown by this DFSORT job:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum