Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Trailer count based on condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Trailer count based on condition
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 Moderator


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

PostPosted: Mon Sep 29, 2008 9:43 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Sep 29, 2008 11:47 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue Sep 30, 2008 2:22 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us