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



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

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

Postby noorkh » Wed Oct 07, 2015 6:18 pm

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.
noorkh
 
Posts: 4
Joined: Wed Oct 07, 2015 5:48 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Wed Oct 07, 2015 7:41 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby noorkh » Thu Oct 08, 2015 9:54 am

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.
noorkh
 
Posts: 4
Joined: Wed Oct 07, 2015 5:48 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby noorkh » Thu Oct 08, 2015 3:29 pm

any help pls
noorkh
 
Posts: 4
Joined: Wed Oct 07, 2015 5:48 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby noorkh » Thu Oct 08, 2015 3:32 pm

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),
noorkh
 
Posts: 4
Joined: Wed Oct 07, 2015 5:48 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby BillyBoyo » Thu Oct 08, 2015 3:40 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post