IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Trailer count based on condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krk_kumar1

New User


Joined: 14 Mar 2006
Posts: 39

PostPosted: Mon Sep 29, 2008 7:39 pm
Reply with quote

Hi,
is it possible to find the count based on a condition (e.g)count the number of '03's in the position 20 of a VB file and put that count in the trailer record.

Thanks
Krishna
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Sep 29, 2008 9:43 pm
Reply with quote

Yes, you can use IFTHEN to insert a 1-byte field after the RDW with a value of 1 for the given condition, otherwise a value of 0, in each record, and do a TOT on that value in the TRAILER record to get the count. Don't forget to remove the 1 byte value.

If you need more specific help, show an example of the records in your input file and what you expect for output. Also, give the LRECL of the input file and the starting position, length and format of each relevant field.
Indicate whether the starting positions count the RDW in positions 1-4 or not.
Back to top
View user's profile Send private message
krk_kumar1

New User


Joined: 14 Mar 2006
Posts: 39

PostPosted: Mon Sep 29, 2008 10:24 pm
Reply with quote

Thanks for the reply Frank
The below are the details about the input file

The input file is VB of record length 1004 and the format is

Input

...0000000000000000000001 Header record
...000020128382$$$$$$$$05DATA1
...000020128382$$$$$$$$40DATA1
...000020128383$$$$$$$$05DATA2
...000020128383$$$$$$$$10DATA2
...000020128383$$$$$$$$40DATA2

The required output is VB of record length 1004 and the format is

Output

...0000000000000000000001 Header record
...000020128382$$$$$$$$05DATA1
...000020128382$$$$$$$$40DATA1
...000020128383$$$$$$$$05DATA2
...000020128383$$$$$$$$10DATA2
...000020128383$$$$$$$$40DATA2
999999999999999999999999000000007000000002


$ represents the spaces
999999999999999999999999000000007000000002 is the trailer record with the 25 9's followed by the total number of records(000000007) followed by total number of '05's (000000002).
In addition to the above i need perform sort based on first 25 bytes of the record.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Sep 29, 2008 11:47 pm
Reply with quote

Here's a DFSORT job that will do what you asked for. It was difficult to tell where your '05' field started so I assumed it started in position 25 (counting the RDW). Change it if appropriate.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  SORT FIELDS=(5,25,CH,A)
  OUTREC IFTHEN=(WHEN=(25,2,CH,EQ,C'05'),
     BUILD=(1,4,5:8C'0',13:C'1',14:5)),
    IFTHEN=(WHEN=NONE,
     BUILD=(1,4,5:8C'0',13:C'0',14:5))
  OUTFIL REMOVECC,BUILD=(1,4,5:14),
    TRAILER1=(25C'9',COUNT+1=(M11,LENGTH=9),
       TOT=(5,9,ZD,M11,LENGTH=9))
/*
Back to top
View user's profile Send private message
krk_kumar1

New User


Joined: 14 Mar 2006
Posts: 39

PostPosted: Tue Sep 30, 2008 1:16 am
Reply with quote

Thanks for the sort card Frank.i just made a small change as
SORT FIELDS=(14,25,CH,A). because SORT FIELDS=(5,25,CH,A) made all the '05' records to come at the bottom since we were assigning the '000000001' at position 5 thru 13 in the inrec and sorting based on 5 thru 29.The sort card helped me a lot thanks for your help Frank.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Sep 30, 2008 2:22 am
Reply with quote

Oops. I didn't notice the output records were in the wrong order when I tested my job. I should have used an OUTREC statement to change the records AFTER sorting. I've edited my job accordingly.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top