update trailer counts



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

update trailer counts

Postby Manju Venkat » Mon Sep 26, 2011 3:09 pm

I have an input file which has different types of records. Example, 02, 04 types etc.
In the trailer there are separate fields for maintaining the different types of record counts. If there are 26 '02' type records, the trailer for maintenance record count should be 26 and so on for 04 types
I used the below sort card, but its not getting updated. It is simply copying the counts which are present in the input file.

//STEP04  EXEC PGM=SORT                                                                               
//SYSOUT  DD SYSOUT=*                                         
//SORTIN  DD DSN=TEST.ABC.CLASS.COMB.FILE,DISP=SHR       
//SORTOUT DD DSN=TEST.ABC.CLASS.COMB.UPD1,DISP=...
//SYSIN DD *                                                   
  SORT FIELDS=COPY                                             
  SUM FIELDS=NONE                                               
  OUTREC IFOUTLEN=189,                                         
    IFTHEN=(WHEN=(9,2,PD,EQ,2),OVERLAY=(190:SEQNUM,4,ZD,START=1)),
    IFTHEN=(WHEN=(5,3,PD,EQ,99999),OVERLAY=(35:190,4))       
    IFTHEN=(WHEN=(9,2,PD,EQ,4),OVERLAY=(195:SEQNUM,4,PD,START=1)),
    IFTHEN=(WHEN=(5,3,PD,EQ,99999),OVERLAY=(39:195,4))       
/*


The input and output files are VB, 189 length.

Input file content: (first few columns)
0 2 0 0 ................
3202 2 531 2 ............
3202 2 531 4
8202 2 3530 2
8202 2 10138 2
8202 2 10138 4
8202 2 10138 4
8202 2 11231 2
8202 2 11231 4
8202 2 11231 4
8202 2 12238 2
8202 2 12238 4 ........
99999 2 9999999 999 ......+3 +3
('02' cnts) (04 cnts)



Manju
Manju Venkat
 
Posts: 16
Joined: Tue Mar 15, 2011 9:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: update trailer counts

Postby BillyBoyo » Mon Sep 26, 2011 3:44 pm

Your positions and type of data look wrong from your sort cards to your data. Are the 02 and 04 "packed decimal" (and the trailer?) or not? What position do they start in (looks way off).

It looks like your JOB has been "coded" (a moderator has used the Code tags, via the Code button) for you.

If you can better explain your file, and use the Code tags for that, we can see if there is still a problem.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: update trailer counts

Postby Manju Venkat » Mon Sep 26, 2011 4:23 pm

Hi Billy, Thanks for your reply.
The input file is a VB and might contain different data records ranging from 30 - 185 characters.

Copybook layout is as below for one of the format.
field1: PIC 9(5) COMP-3.
field2: PIC 9(3) COMP-3.
field3: PIC 9(7) COMP-3.
field4: PIC 9(3) COMP-3.
field5: pic x(60)

In this, the field4 above contains the record type. 02/04 etc. In the sort card I had mentioned IFTHEN=(WHEN=(9,2,PD,EQ,2) for counting records containing value 2 and for counting records having 4, IFTHEN=(WHEN=(9,2,PD,EQ,4).


Copybook layout for trailer:
field1: PIC 9(5) COMP-3. (value will be 99999)
field2: PIC 9(3) COMP-3.
field3: PIC 9(7) COMP-3.
field4: PIC 9(3) COMP-3.
field5: pic x(23)
field6: pic s9(7) comp-3.
field7: pic s9(7) comp-3.
filler...

To write the rec counts for 2 type, in trailer I had used (5,3,PD,EQ,99999),OVERLAY=(35:190,4)) where the 02 maintenance counts should be updated in position 35 (field6) of the trailer record. And the trailer record can be identified by 99999 in the 5th position of trailer.
similarly, for 4 type record counts, =(5,3,PD,EQ,99999),OVERLAY=(39:195,4)) where 04 maintenance counts should be updated in position 39 (field7) of trailer.

Please guide.
Manju Venkat
 
Posts: 16
Joined: Tue Mar 15, 2011 9:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: update trailer counts

Postby enrico-sorichetti » Mon Sep 26, 2011 4:27 pm

when posting out of a COBOL forum it would be better to talk not in COBOL terms

but in language independent fashion

char, binary, packed, zoned, signed-zoned

COBOL speak will certainly prevent some people from answering
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: update trailer counts

Postby BillyBoyo » Mon Sep 26, 2011 5:38 pm

Manju Venkat wrote:[...]
The input file is a VB and might contain different data records ranging from 30 - 185 characters.

Copybook layout is as below for one of the format.
field1: PIC 9(5) COMP-3.
field2: PIC 9(3) COMP-3.
field3: PIC 9(7) COMP-3.
field4: PIC 9(3) COMP-3.
field5: pic x(60)

In this, the field4 above contains the record type. 02/04 etc. In the sort card I had mentioned IFTHEN=(WHEN=(9,2,PD,EQ,2) for counting records containing value 2 and for counting records having 4, IFTHEN=(WHEN=(9,2,PD,EQ,4).

[...]


field1 is three bytes long, 2 is two bytes, 3 is four bytes. That gives you nine bytes, but, your are using a variable-record-length file. Which means each record has a four-byte RDW at the beginnning. So, you have to adjust all your field references to take account of the four bytes of the RDW. All your IFs are missing their targets.

So, with (13,2,PD,EQ,2) you might get some progress. Don't forget to change all, including on the trailer.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: update trailer counts

Postby enrico-sorichetti » Mon Sep 26, 2011 5:42 pm

when posting out of a COBOL forum it would be better to talk not in COBOL terms

but in language independent fashion

char, binary, packed, zoned, signed-zoned

COBOL speak will certainly prevent some people from answering
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: update trailer counts

Postby skolusu » Mon Sep 26, 2011 10:14 pm

ManjU Venkat,

You cannot pad the constants at the end of a VB file. If you do so you are making all of the records a fixed length records. Also since your input file is VB your actual data starts at position 5 as the first 4 bytes have the RDW. So your record indicator (02,04 are actually at pos 13 and the trailer counts that need to update are at position 39 and 43.

Use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD DSN=Your input VB 189 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                 
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)),       
  IFTHEN=(WHEN=(21,2,PD,EQ,2,OR,13,3,PD,EQ,99999), 
  OVERLAY=(5:SEQNUM,4,PD,START=0),HIT=NEXT),       
  IFTHEN=(WHEN=(21,2,PD,EQ,4,OR,13,3,PD,EQ,99999), 
  OVERLAY=(9:SEQNUM,4,PD,START=0))                 
                                                   
  OUTFIL IFTHEN=(WHEN=(13,3,PD,EQ,99999),           
  BUILD=(1,4,13,34,5,8,57)),                       
  IFTHEN=(WHEN=NONE,BUILD=(1,4,13))                 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: update trailer counts

Postby Manju Venkat » Tue Sep 27, 2011 2:00 pm

Hi Skolusu,

Thanks a lot!! the counts are working fine. I just changed the 21 in the below to 22 (with 21 the counts were 0 as field4 starts in the 10th position, so 10+4+8(u had for padding) = 22 )
=(WHEN=(22,2,PD,EQ,2,OR,13,3,PD,EQ,99999),

But, I did not understand the logic completely. Can you please explain? Especially, the BUILD=(1,4,13,34,5,8,57)) part of it.
Also, in the trailer after it updates the 04 type record counts field, it should copy the rest of the fields from the input file in the same format as in input. Now it is not doing so.
I think if you throw more light on the Build, I would be able to understand it better.

Thanks in advance,
Priya
Manju Venkat
 
Posts: 16
Joined: Tue Mar 15, 2011 9:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: update trailer counts

Postby Manju Venkat » Tue Sep 27, 2011 2:16 pm

Also, the trailer has one more field (field13) for updating the total number of records present in the file (including the header and trailer). The fields8-12 should be copied from input file.

Copybook layout for trailer:
field1: PIC 9(5) COMP-3. (value will be 99999)
field2: PIC 9(3) COMP-3.
field3: PIC 9(7) COMP-3.
field4: PIC 9(3) COMP-3.
field5: pic x(23)
field6: pic s9(7) comp-3.
field7: pic s9(7) comp-3.
field8: PIC S9(7) COMP-3.
field9: PIC S9(7) COMP-3.
field10: PIC S9(9)v99 COMP-3.
field11: PIC S9(7) COMP-3.
field12: PIC S9(9)V99 COMP-3.
field13: PIC S9(9) COMP-3.
Manju Venkat
 
Posts: 16
Joined: Tue Mar 15, 2011 9:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: update trailer counts

Postby BillyBoyo » Tue Sep 27, 2011 2:26 pm

Manju/Priya,

Have you got your DFSORT manuals handy? There's a very nice getting started one, progamming guide, and sort tricks.

BUILD=(1,4,13,34,5,8,57))


The 1,4 takes the first four bytes from the input record, and places them at the first not-already-used location in the output record.

The 13,34 takes the 34 bytes starting at position 13 in the input record, and places them at the next not-already-used location in the output record.

The 5,8 takes the eight bytes (which are the two four-byte counts which have been temporarily added to each record to do the totally) starting at position 5 in the input record, and places them at the next not-already-used location in the output record.

The 57 takes all the bytes from position 57 on the input record to the end of the input record (remembering that they are variable-length records), and places them at the next not-already-used location in the output record.

The new length for the output RDW (the original 1,4 above) is re-calculated from all they byte positions that are now "used" in the output record.

Also check on the descriptions of OUTREC and OUTFIL in the manuals, and compare to INREC and INFIL to improve your understanding of the process.

I really can't see anything with what Kolusu has provided for the trailer problem you have. Can you check that you have coded the same as Kolusu has provided. If you think so, post you JCL, messages output, and sample of your file included the trailer record, please
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post