Updating multiple trailer count



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

Updating multiple trailer count

Postby tjegan » Wed Oct 29, 2014 3:35 pm

Hi All,

My input record starts with T is a trailer record. We have 3 trailer records from the input file.
Key is in the 10th position with the length 5. I want to update all the trailer records as below. Could you please suggest me on this.

My DFSORT control card is
 SORT FIELDS=COPY                                           
 OUTFIL FILES=01,                                           
 INCLUDE=(10,5,CH,EQ,C'ABC  '),                             
 IFTRAIL=(TRLID=(1,1,CH,EQ,C'T',AND,7,3,CH,EQ,C'ABC'),     
  TRLUPD=(20:COUNT=(EDIT=(TTTT))))                         


Input file -> 80 byte and fixed length:
10 AAAA HI
10 AAAA ABC
10 AAAA XYZ
10 AAAA ABC
10 AAAA XYZ
10 AAAA HI
10 AAAA HI
10 AAAA ABC
10 AAAA HI
10 AAAA HI
10 AAAA HI
TRAIL ABC 100
TRAIL HI 200
TRAIL XYZ 300

After submitting the JOB i am getting the below output:Output file -> 80 byte and fixed length
10 AAAA ABC
10 AAAA ABC
10 AAAA ABC
TRAIL ABC 100 0003

But the expected output format is given below: I want to update the trailer record for all the condition and write it in a single file.
Expected output -> 80 byte and fixed length

10 AAAA HI
10 AAAA ABC
10 AAAA XYZ
10 AAAA ABC
10 AAAA XYZ
10 AAAA HI
10 AAAA HI
10 AAAA ABC
10 AAAA HI
10 AAAA HI
10 AAAA HI
TRAIL ABC 100 0003
TRAIL HI 200 0006
TRAIL XYZ 300 0002


Thank you..
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Updating multiple trailer count

Postby BillyBoyo » Wed Oct 29, 2014 8:05 pm

You should use the Code tags for your data as well. Anything which needs spacing preserved, put it in the Code tags.

You are only INCLUDE CONDing ABC, so you will only get ABC on your output.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Updating multiple trailer count

Postby tjegan » Fri Oct 31, 2014 11:14 am

Hi All,

My input record starts with T is a trailer record. We have 3 trailer records from the input file.
Key is in the 10th position with the length 5. I want to update all the trailer records as below. Could you please suggest me on this.

My DFSORT control card is
 SORT FIELDS=COPY                                           
 OUTFIL FILES=01,                                           
 INCLUDE=(10,5,CH,EQ,C'ABC  '),                             
 IFTRAIL=(TRLID=(1,1,CH,EQ,C'T',AND,7,3,CH,EQ,C'ABC'),     
  TRLUPD=(20:COUNT=(EDIT=(TTTT))))                         


Input file -> 80 byte and fixed length:
10 AAAA HI
10 AAAA ABC
10 AAAA XYZ
10 AAAA ABC
10 AAAA XYZ
10 AAAA HI
10 AAAA HI
10 AAAA ABC
10 AAAA HI
10 AAAA HI
10 AAAA HI
TRAIL ABC 100
TRAIL HI 200
TRAIL XYZ 300


After submitting the JOB i am getting the below output:Output file -> 80 byte and fixed length
10 AAAA ABC
10 AAAA ABC
10 AAAA ABC
TRAIL ABC 100 0003


But the expected output format is given below: I want to update the trailer record for all the condition and write it in a single file.
Expected output -> 80 byte and fixed length

10 AAAA HI
10 AAAA ABC
10 AAAA XYZ
10 AAAA ABC
10 AAAA XYZ
10 AAAA HI
10 AAAA HI
10 AAAA ABC
10 AAAA HI
10 AAAA HI
10 AAAA HI
TRAIL ABC 100 0003
TRAIL HI 200 0006
TRAIL XYZ 300 0002


The code is working fine for Single condition. But i dont know how to update the control cards with multiple conditions(for the key values 'HI' and 'XYZ')
So can any you please let me know where to insert for multiple condition to get the expected result.

Thanks in Advance.
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Updating multiple trailer count

Postby BillyBoyo » Sat Nov 01, 2014 2:16 pm

You're not going to be able to do it with IFTRAIL. You can only have one IFTRAIL per OUTFIL.

Can you fully explain the actual trailer records that you want. I don't want to hear later "yeah, but that was only an example, the real thing is like this" that may require a different solution.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Updating multiple trailer count

Postby tjegan » Mon Nov 03, 2014 12:16 am

I want the output as mention in the "Expected output" specified in my previous note. That is i would like to copy all the detail records from the input file and update all the 3 trailer records to a single output file.
I tried in google and found the above logic but it works for a single condition and i dont know how to incorporte the code to get the desired output. So can you please share me the sample code..
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Updating multiple trailer count

Postby BillyBoyo » Mon Nov 03, 2014 1:01 am

I was hoping to find out if the "100", "200" and "300" were always literal values, or if they are sample values you have show which may change are some point.

If they are literal values, such that the only thing which will every vary on the trailer records is the count, then you can use TRAILER1 and output three records (in much thse same way as you output two records on your JOINKEYS).

If they are not literal values, it is more tricky.

IFTRAIL/TRLUPD and TRAILER1 can get totals of amounts, so you can make three "amounts" which are either one or zero, depending which record you have. You put the amounts, along with the type of record, in an extension to your record.

You OMIT= the TRAIL records on OUTFIL, and then in TRAILER1 you output the three records, using TOT/TOTAL for the amounts to get the count of each type of record.

If the 100/200/300 are not fixed, you need to do something extra. Which is more complicated. Which is why I asked.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Updating multiple trailer count

Postby tjegan » Mon Nov 03, 2014 12:53 pm

Yes. 100", "200" and "300 are literal valules and they do not change.
The thing is i am able to update the trailer record for a single condition and i am not sure
how to include 3 condition and update trailer records in a single step.
SORT FIELDS=COPY                                           
OUTFIL FILES=01,
INCLUDE=(10,5,CH,EQ,C'ABC  '),
 IFTRAIL=(TRLID=(1,1,CH,EQ,C'T',AND,7,3,CH,EQ,C'ABC'),     
  TRLUPD=(20:COUNT=(EDIT=(TTTT))))

SORT FIELDS=COPY                                           
OUTFIL FILES=01,
INCLUDE=(10,5,CH,EQ,C'XYZ  '),
 IFTRAIL=(TRLID=(1,1,CH,EQ,C'T',AND,7,3,CH,EQ,C'XYZ'),     
  TRLUPD=(20:COUNT=(EDIT=(TTTT))))

SORT FIELDS=COPY                                           
OUTFIL FILES=01,
INCLUDE=(10,5,CH,EQ,C'HI   '),
 IFTRAIL=(TRLID=(1,1,CH,EQ,C'T',AND,7,3,CH,EQ,C'HI '),     
  TRLUPD=(20:COUNT=(EDIT=(TTTT))))


The above control card gives the result for "ABC" alone.
Could you please update the control card to get the result for XYZ and HI too.
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Updating multiple trailer count

Postby BillyBoyo » Mon Nov 03, 2014 5:33 pm

You need to use INREC IFTHEN=(WHEN=NONE to extend your record for three one-byte counts, so OVERLAY=(81:C'000') would do.

You then need IFTHEN=(WHEN=(logical expression) to test for each of your types, and relate a type to one of the three one-byte counts.

In OUTFIL, use OMIT= to get rid of all your existing trailers! Sounds drastic, but what the heck.

Use TRAILER1 to write the three separate TRAIL records, which are a mixture of the literals and the TOT/TOTAL for each of the three counts.

Use BUILD=(1,80) to get rid if the three-byte extension made earlier.
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