Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to include a particular field value while counting recs

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to include a particular field value while counting recs
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: 8339
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 06, 2018 8:33 pm    Post subject:
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    Post subject:
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: 8339
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 06, 2018 9:28 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1906
Location: NY,USA

PostPosted: Sat Apr 07, 2018 12:51 am    Post subject:
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: 418
Location: USA

PostPosted: Sat Apr 07, 2018 1:30 am    Post subject: Reply to: How to include a particular field value while counting recs
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    Post subject: Re: Reply to: How to include a particular field value while counting recs
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: 2020
Location: UK

PostPosted: Sat Apr 07, 2018 4:21 pm    Post subject:
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    Post subject:
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    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
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us