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

Count Records with a crietaria in a file using SYNCSORT


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

New User


Joined: 20 Jun 2022
Posts: 3
Location: India

PostPosted: Mon Jun 20, 2022 12:54 pm
Reply with quote

Hi

I need to scan a file which has some records and I need to add a trailer in the end with following format (using SORT).

TRAILER : 122 CUSTOMERS : 11 PRINT = 6 NOPRINT = 5

where
a) 122 is the total number of records in the file (Including Header)
b) 11 are the customers that have C'1a0' at position 1 in ANY OF THE RECORDS
c) 6 are the number of records that have a 'Y' at position 640
d) 5 are the number of records that have a 'N' at position 640.

I am trying various things with IFTHEN , GROUP, PUSH etc but not getting desired results

Please help

Thanks
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Mon Jun 20, 2022 12:58 pm
Reply with quote

Please provide sample input and desired output. Use code tag buttons when presenting any code/data. Thanks!
Back to top
View user's profile Send private message
chopraamit23

New User


Joined: 20 Jun 2022
Posts: 3
Location: India

PostPosted: Mon Jun 20, 2022 1:46 pm
Reply with quote

Hi Joerg

Sample input is


Code:

Øý..............................rrrr¸.99999999Rrrrr¸............................
.... 0          PASZ310   104924..... ..........................................
.... 1a0        PASZ310   104924..... 250006190.....a...........................
.... 1a1a0      PASZ310   104924..... 250006190.....aX                   a......
.... 1a1a1b0    PASZ310   104924..... 250006190.....aX                   a01   
.... 1a1a1a0    PASZ310   104924..... 250006190.....aX                   a75   
TRAILER:        6                                                               



Instead of last row as TRAILER : 6

I need a new trailer as

Code:

TRAILER:    6  DOCMENT : 2  PRINT : 2 NOPRINT : 4


where
a) 6 is the total number of records in the file (Including Header)
b) 2 are the customers that have C'1a0' at position 6 in ANY OF THE RECORDS
c) PRINT : 2 are the number of records that have a 'Y' at position 640
d) NOPRINT : 4 are the number of records that have a 'N' at position 640.

Thanks[/code]
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Mon Jun 20, 2022 5:52 pm
Reply with quote

You can try something like this:
Code:
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:12Z)),           
   IFTHEN=(WHEN=(6,3,CH,EQ,C'1a0'),                       
     OVERLAY=(1001:+1,BI,LENGTH=4),HIT=NEXT),             
   IFTHEN=(WHEN=(640,1,CH,EQ,C'Y'),                       
     OVERLAY=(1005:+1,BI,LENGTH=4),HIT=NEXT),             
   IFTHEN=(WHEN=(640,1,CH,EQ,C'N'),                       
     OVERLAY=(1009:+1,BI,LENGTH=4))                       
  OUTFIL FNAMES=(SORTOUT),                               
    REMOVECC,                                             
    TRAILER1=(C'TRAILER:',COUNT,X,                       
              C'DOCMENT :',TOT=(1001,4,BI,M10,LENGTH=5),X,
              C'PRINT : ',TOT=(1005,4,BI,M10,LENGTH=5),X,
              C'NOPRINT : ',TOT=(1009,4,BI,M10,LENGTH=5))
  END

Change field offsets and lengths to your needs.
Back to top
View user's profile Send private message
chopraamit23

New User


Joined: 20 Jun 2022
Posts: 3
Location: India

PostPosted: Tue Jun 21, 2022 12:23 pm
Reply with quote

Thanks a lot Joerg. I did some tweaking and was able to get the results.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Tue Jun 21, 2022 1:05 pm
Reply with quote

Mind sharing what you have tweaked?
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 Unable to interpret a hex value to De... COBOL Programming 7
No new posts Syncsort help SYNCSORT 3
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts how to eliminate null indicator value... DB2 7
Search our Forums:

Back to Top