My requirement is to parse & split the below input csv file (vb) by removing double quotes & comma and also each ouput file should have only detail records for current,MTD & YTD.
>>> Current-Date 20081130 TA <<< ** This is header record
"000000001203802","CXX HS EF 038C52464","988606108",0,0,
>>> Month-to-Date 20081031 TA <<< ** This is header record ***
"000000001103802","CYY HS AB 038C52464","304412209",0,0,
"000000001003802","CZZ HS CD 038C52464","65671D857",0,0,
>>> Year-to-Date 20081031 TA <<< ** This is header record
"000000001903802","DXY HS ZZ 038C52464","135671857",0,0,
"000000001503802","EXY HS YY 038C52464","25671D857",0,0,
I was able to parse the file & remove the double quotes. But could not split the file .
Any help is appreciated in this regard.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not clear what you want to do. I assume those are the input records you're showing. Please show the expected output file(s). Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file and output file(s).
Quote:
I was able to parse the file & remove the double quotes.
Your assumption is correct . what i had shown is the input file(lrecl=996, recfm=vb) which has 3 headers and corresponding detail records under each header. I am expecting 3 output files(lrecl=996,recfm=vb) as mentioned below from the input file
output1 - should contain the following from Today file
000000001203802 CXX HS EF 038C52464 988606108 0 0
output2 - should contain the following from Month-to-Date file
000000001103802 CYY HS AB 038C52464 304412209 0 0
000000001003802 CZZ HS CD 038C52464 65671D857 0 0
output3 - should contain the following from Year-to-date file
000000001903802 DXY HS ZZ 038C52464 135671857 0 0
000000001503802 EXY HS YY 038C52464 25671D857 0 0
So far i could code the following. But i want to split into 3 outputs
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
FINDREP is a better choice for this then PARSE. Here's a DFSORT job that will do what you asked for. If you don't have PTF UK90013 (July, 2008) that supports FINDREP, ask your System Programmer to install it.
Thanks for your reply. It worked perfectly . But i have one more addition to it.Before i write the input records to the output, i would like to assign fixed lengths to some of the fields.
For example , i want field2 from input to be moved to 17 byte length
& field4 from input should be moved to 8 byte length .
Please let me know.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It isn't clear to me what you want. Please show the expected output records for your example input records. Use ubb code tags to show the output properly (or use b for each blank if you can't use ubb tags).
For example, I am expecting the following output for the detail records under Month-to-date header in input file.
000000001103802 CYS HS AB 038C52464bbbbb 304412209 0bbbbbbb 0bbbb
000000001003802 CZZ HS CD 038C52464bbbbb 65671D857 0bbbbbbb 0bbbb
I would like to convert one of the field to ZD before it is being written to output. I made some changes to the code provided by you . It is giving error. Could you please correct me?
That's invalid syntax. You can't do the conversion while parsing. You need to do the conversion while building. The correct control statements would be:
In the example below , i would like to have the sorted output files (vb) on the first 16 bytes. Sort statement has been included but it shows syntax error. Could you please let me know where i can include the sort statement to sort the output?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
When I ran your job, the only message I got was:
ICE002I 0 DUPLICATE OR CONFLICTING SORT STATEMENT
That's not a syntax error - it's just a warning that you have multiple SORT statements.
You can only have one SORT statement and since you are sorting on the same keys for each of the OUTFIL data sets, you only need one SORT statement. However, you left in the OPTION COPY statement so you'll get a COPY rather than a SORT (COPY overrides SORT).
You can use these control statements. The records will be sorted on positions 6-21 of the reformatted INREC records - I assumed that's what you wanted, but I wasn't sure. (I put the SORT statement between the INREC statement and OUTFIL statements to correspond to the order in which the statements are processed - where you put the statements has no effect on that processing order).
Following are the statements shown after the job is run
Code:
ICE235I 0 OPTIONS: NULLOUT=RC0
ICE084I 0 EXCP ACCESS METHOD USED FOR SORTIN
ICE750I 0 DC 27994 TC 0 CS DSVNN KSZ 23 VSZ 23
ICE752I 0 FSZ=27994 BC IGN=0 E AVG=501 0 WSP=35 C DYN=2 56664
ICE218A 3 84 BYTE VARIABLE RECORD IS SHORTER THAN 261 BYTE MINIMUM FOR
ICE751I 1 D8-K24705 D4-K24705 E8-K90013
ICE052I 0 END OF DFSORT
Please ignore the informational messages shown in my previous note .Consider the informational messages shown below
Code:
ICE235I 0 OPTIONS: NULLOUT=RC0
ICE084I 0 EXCP ACCESS METHOD USED FOR SORTIN
ICE750I 0 DC 27994 TC 0 CS DSVNN KSZ 23 VSZ 23
ICE752I 0 FSZ=27994 BC IGN=0 E AVG=501 0 WSP=35 C DYN=2 56664
ICE218A 3 84 BYTE VARIABLE RECORD IS SHORTER THAN 265 BYTE MINIMUM FOR
ICE751I 1 D8-K24705 D4-K24705 E8-K90013
ICE052I 0 END OF DFSORT
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I don't see how you got that error message for that job. They don't match. Please check that.
If you are getting those error messages for that set of control statements, I'd need to see the source for your job and the complete set of JES messages, and DFSORT messages in //SYSOUT, for the run. Please send them to me offline (yaeger@us.ibm.com).
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
The message indicates that you have a "short" record ... one that is shorter than the second SORT field you asked for. But the values shown in the message DO NOT match the fields shown in the SORT statement (they should match), and the use of the IFTHEN clauses would NOT allow that situation to be created. So I don't think what you've posted here is what you got that error message for (unless there's something else going on that you're not showing or aware of).
If you send me the source for the JOB and the complete set of JES and DFSORT messages, then I can probably figure out what's really going on.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I received your messages offline.
I was looking at your original post that showed 261 in the ICE218A message and missed your correction to 265 in the ICE218A message. That makes more sense.
I guess you're only building certain records out to 265 bytes. It looks like the header records can end up being shorter than 265 bytes. So when you try to use a SORT field of 262,4,CH,A for one of these short records, you get the error message. The way to get around that normally is to use VLSHRT, but VLSHRT is being turned off because you're using INREC.
The solution would be to use two passes - one with INREC and the other with VLSHRT, SORT and OUTFIL like this.