Page 1 of 1

Parse/Format file based on header value and then skip header

PostPosted: Wed Oct 07, 2015 6:18 pm
by noorkh
Hi,

I have file that has values as below:

H|FILE1|DATE
D|1234|TEST DATA|2222|....|XXXX|||
D|32|TESTDDD|2324|...|XXX|X||
..............
.............
.............

I would like to build sort card that reads my header record, and identfiy 'FILE1' (it can be 'FILE2 or 3 also some time), and format my remaining output records as below:

1. Output shouldn't contain header record.
2. It shoudl only pick up entries upt 3 pipes delimited.remaining piped delimited data should be ignored.

Output should look as below:

D|1234|TEST DATA|
D|32|TESTDDD|
.................
.................

Can it be achieved by Sort INREC IFTHEN statement etc.,? Pls advise.

Re: Parse/Format file based on header value and then skip he

PostPosted: Wed Oct 07, 2015 7:41 pm
by NicC
If cc1 identifies the record type (H = header D = data) then include only the data records parse the first three fields to individual % variables and build your output records from them.

Re: Parse/Format file based on header value and then skip he

PostPosted: Thu Oct 08, 2015 9:54 am
by noorkh
Header along with file name should be checked for validation. ONly if specific file name ie 'FILE1' is present, then it should format below detailed records and also skip header record.

for other file names other than file1, it shoudl simply skip header record, and doesn't modify detailed record.

Re: Parse/Format file based on header value and then skip he

PostPosted: Thu Oct 08, 2015 3:29 pm
by noorkh
any help pls

Re: Parse/Format file based on header value and then skip he

PostPosted: Thu Oct 08, 2015 3:32 pm
by noorkh
I tried using IFTHEN WHEN=GROUP, but it didnt' give me desired output

INREC IFTHEN=(WHEN=GROUP,BEGIN=(12,7,CH,EQ,C'FILE1'),
PUSH=(23030:ID=1),HIT=NEXT),

Re: Parse/Format file based on header value and then skip he

PostPosted: Thu Oct 08, 2015 3:40 pm
by BillyBoyo
RECFM and LRECL of input and output. How do you want to identify "FILE1" (or whatever)? Is it always a fixed-length value? What do you want to happen if no data is output?