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

How to include a particular field value while counting recs


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

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Fri Apr 06, 2018 8:27 pm
Reply with quote

Hi,

Lets take like below is my VB input file:

Code:

111109A0000A1234
222208C000005678
333307M000019012
444406M000009013
555505M000029014
666604M000029015
777703A000019016
888802C000019017
999901M000029018
121201M000019019


I need my output report in output file as below:

Code:

Total Records: 0006
CERTIFY         COUNT
0                0001
1                0002
2                0003


Basically I need to include only "M" records in the 7th column & display the count (Both total count & count of each CERTIFY)

I used below ICETOOL code:

Code:

//JOBNAM2 JOB    ('FDFS'),NOTIFY=&userid
//STEP001  EXEC  PGM=ICETOOL
//INP          DD     DSN=ABC.DEF.INP,DISP=SHR
//TOOLMSG DD    SYSOUT=*
//DFSMSG   DD    SYSOUT=*
//TOOLIN    DD    *
COUNT FROM(INP) USING(CTL1) WRITE(OUT) TEXT('TOTAL RECORDS')
OCCUR FROM(INP) LIST(OUT) -
HEADER('CERTIFY') ON (12,1,CH) -
HEADER('COUNT')  ON(VALCNT)
/*
//CTL1CNTL    DD  *
  SORT FIELDS=COPY
  INCLUDE COND=(7,1,CH,EQ,C'M')
/*


My input file is VB file....
First I tried COUNTING the total records in a separate step by creating out1 using SORT step converting VB to FB fille & in the 2nd step used icetool to display the total records for each CERTIFY.

But then I tried the above code to make everything in a single step. I am getting the count of records correctly. But I don't know how to include only "M" type records for counting each of the CERTIFY.

Can some one please give some idea about it.

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 06, 2018 8:33 pm
Reply with quote

With VB you have to account for the RDW, so should you not be using
Code:
  INCLUDE COND=(11,1,CH,EQ,C'M')
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Fri Apr 06, 2018 8:57 pm
Reply with quote

Robert Sample wrote:
With VB you have to account for the RDW, so should you not be using
Code:
  INCLUDE COND=(11,1,CH,EQ,C'M')



Yes you are right that's my mistake...I will correct that, so that I will get total count.
Can you also give idea of how to include only "M" type records to get the count value of each CERTIFY.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 06, 2018 9:28 pm
Reply with quote

If you tell SORT that you want to INCLUDE records, you are not going to get anything but those records in your output. There are other options for processing records -- you need to review the SORT user's guide manual.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Sat Apr 07, 2018 12:51 am
Reply with quote

Quote:
Can you also give idea of how to include only "M" type records to get the
Ain't you already doing that?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Sat Apr 07, 2018 1:30 am
Reply with quote

If you copy your records to a temp file first, then it'll be easier to achieve.
Code:
//TOOLIN    DD    *
COPY FROM(INP) USING(CTL1) TO(TMP)
COUNT FROM(TMP) WRITE(OUT) TEXT('TOTAL RECORDS')
OCCUR FROM(TMP) LIST(OUT) -
HEADER('CERTIFY') ON(12,1,CH) -
HEADER('COUNT')  ON(VALCNT)
/*
//CTL1CNTL    DD  *
  INCLUDE COND=(7,1,CH,EQ,C'M')
/*

I tried this on FB, you can add RDW length wherever necessary.

.
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Sat Apr 07, 2018 9:59 am
Reply with quote

RahulG31 wrote:
If you copy your records to a temp file first, then it'll be easier to achieve.
Code:
//TOOLIN    DD    *
COPY FROM(INP) USING(CTL1) TO(TMP)
COUNT FROM(TMP) WRITE(OUT) TEXT('TOTAL RECORDS')
OCCUR FROM(TMP) LIST(OUT) -
HEADER('CERTIFY') ON(12,1,CH) -
HEADER('COUNT')  ON(VALCNT)
/*
//CTL1CNTL    DD  *
  INCLUDE COND=(7,1,CH,EQ,C'M')
/*

I tried this on FB, you can add RDW length wherever necessary.

.



Right now i cannot access mainframe...I will try this way by monday...And one more help can I add TITLE & DATE with this report....?? I tried using the same after OCCURS statement but I need it before the COUNT statement, but when I tried, it resulted in RC12.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Apr 07, 2018 4:21 pm
Reply with quote

Quote:
resulted in RC12

All sorts of things could gve a return code of 12. Show what you tried and the messages resulting from those attempts (note plural).
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Sat Apr 07, 2018 4:46 pm
Reply with quote

Nic Clouston wrote:
Quote:
resulted in RC12

All sorts of things could gve a return code of 12. Show what you tried and the messages resulting from those attempts (note plural).



I can show only the code now as I dont have mainframe access now to get the error messages.

So Below are the options I tried one by one to get the needed result but dint get it in any way:

First try:
Code:

//TOOLIN    DD    *
COUNT FROM(INP) USING(CTL1) WRITE(OUT) TEXT('TOTAL RECORDS:')  WIDTH(121)
OCCUR FROM(INP) LIST(OUT) -
DISPLAY PAGE TITLE('SUMMARY REPORT') -
HEADER('CERTIFY') ON(12,1,CH) -
HEADER('COUNT')  ON(VALCNT)
/*
//CTL1CNTL    DD  *
  INCLUDE COND=(11,1,CH,EQ,C'M')
/*


The output that I got for above code is:

Code:

TOTAL RECORDS: 6
   [-1-]      SUMMARY REPORT
CERTIFY             COUNT
A                        0001
0                        0002
1                        0004
2                        0003


Here I got 2 things wrong
1) The SUMMARY REPORT was not before the TOTAL RECORDS
2) COUNT value for CERTIFY is taken wrong (i.e) It dint take only "M" type records.

So then I tried as below to display SUMMARY REPORT before the count, but this resulted in error:

Code:

//TOOLIN    DD    *
DISPLAY PAGE TITLE('SUMMARY REPORT') -
COUNT FROM(INP) USING(CTL1) WRITE(OUT) TEXT('TOTAL RECORDS:') WIDTH(121)
OCCUR FROM(INP) LIST(OUT) -
HEADER('CERTIFY') ON(12,1,CH) -
HEADER('COUNT')  ON(VALCNT)
/*
//CTL1CNTL    DD  *
  INCLUDE COND=(11,1,CH,EQ,C'M')
/*


Then I searched google to see how can I display only the title with no values below so that I display the title & also searched to see if I can INCLUDE "M" type records. But no luck then posted my question here...

Now I got an idea of How to include "M" type records alone in the CERTIFY-COUNT.

But dint know to place the title before the TOTAL RECORDS
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top