Split variable length record



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

Split variable length record

Postby GabHof2611 » Thu Aug 06, 2015 3:45 pm

Hallo,

I have a variable length record with following format:

Main (Byte 1 to 80)
Number of Dependents (2 Bytes Packed)
Dependent 1 (30 Bytes)
Dependent 2 (30 Bytes)
..
Dependent N
Tail (50 Bytes after all Dependents)

Output should be 3 files:
File1 Main
File2 all Dependents (1 row for each Dependent)
File3 Tail

Is it possible with DFSORT/ICETOOL?

Thank You.
GabHof2611
 
Posts: 3
Joined: Thu Aug 06, 2015 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split variable length record

 

Re: Split variable length record

Postby BillyBoyo » Thu Aug 06, 2015 4:10 pm

Yes, with three OUTFILs. As long as you can identify two of the types easily, use the INCLUDE= for the OUTFILs for those two types and SAVE for the third OUTFIL (which will get all records not otherwise processed in an OUTFIL).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Split variable length record

Postby GabHof2611 » Thu Aug 06, 2015 4:15 pm

sorry, I didn't asked correctly.

The variable record looks like this:

Main Dep1 Dep2 ... DepN Tail
GabHof2611
 
Posts: 3
Joined: Thu Aug 06, 2015 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split variable length record

Postby BillyBoyo » Thu Aug 06, 2015 4:19 pm

What's the maximum number of dependants?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Split variable length record

Postby GabHof2611 » Thu Aug 06, 2015 4:51 pm

maximum number of dependants is 40
GabHof2611
 
Posts: 3
Joined: Thu Aug 06, 2015 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split variable length record

Postby BillyBoyo » Thu Aug 06, 2015 5:51 pm

OK, three OUTFILs.

The first outputs the first part of each record.

The second contains 40 IFTHEN=(WHEN=(logicalexpressions) testing the value of your count, and uses the slash-operator (/) to output the correct number of records.

The third also contains 40 IFTHEN=(WHEN=(logicalexpressions) also testing the value of your count and outputs the trailer from the correct location.

A variation on that, especially if you have DFSORT 2.1, would be to extend the record to maximum length and then use PARSE, where you can use a repetition. Your trailer-data would exist in two PARSEd fields. You'd still need the 80 IFTHENs to identify which PARSEd fields to use when and for what, but the negative influence of typos would be reduced.

You could look at using ICETOOL's RESIZE, but that would require another pass of the data to make the records fixed-length, then in a USING on the RESIZE you'd have to format each part to the maximum length (80 bytes, your main data). In three OUTFILs in the USING, you'd then do roughly my first suggestion, but you'd not be able to use SAVE as there will always be blank records to ignore completely. You'd need to be able to identify the record-types, so may require the addition of a marker (depending on your data).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post