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

How to find the occurences of a literal.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Tue Oct 13, 2009 7:04 pm
Reply with quote

I have a file with two records which is like the one mentioned below:

record1: ABDUL00000000000000ABDULMMMMMMMMMMMMMMMABDULJJJJJJJJJJJJJJJ
record2: OOOOOOOOOOABDULIIIIIIIIIIIABDULNNNNABDULQQQQQQQQQQQQQQQ


Kindly give me a jcl to find the occurences of the name "ABDUL" from the two records so that the ouput should be 6. Note that the literal "ABDUL" is placed at different columns in the two records given
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 13, 2009 8:41 pm
Reply with quote

Hello,

Why is this posted again here?

What about the same request in the IMS part of the forum. . .

d
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 Oct 13, 2009 9:34 pm
Reply with quote

Abdul,

What is the RECFM and LRECL of the input file?

What is the maximum number of times ABDUL can be found in a record?

Is 2 the maximum number of records?

Would the output just be one record with the count? Or would it be the original records with an extra record with the count? Or what? Show the exact expected output for your input example.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Fri Oct 16, 2009 3:59 pm
Reply with quote

The RECFM is FB with LRECL as 80. There can be at the maximum of 100 records. I just want to find the count of "ABDUL" in each record.

This is my requirement.
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: Fri Oct 16, 2009 9:02 pm
Reply with quote

Again:

Quote:
Would the output just be one record with the count? Or would it be the original records with an extra record with the count? Or what? Show the exact expected output for your input example.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Oct 19, 2009 4:01 pm
Reply with quote

The input should be as the one i have posted:
Input file:
ABDUL00000000000000ABDULMMMMMMMMMMMMMMMABDULJJJJJJJJJJJJJJJ
OOOOOOOOOOABDULIIIIIIIIIIIABDULNNNNABDULQQQQQQQQQQQQQQQ

Output file:
Count of "ABDUL" is : 6

This is how my output file has to look. Please give me a JCL to find it out
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 Oct 19, 2009 9:37 pm
Reply with quote

You can use a DSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=5,
    IFTHEN=(WHEN=INIT,PARSE=(%01=(STARTAT=C'ABDUL',FIXLEN=5),
            %02=(STARTAT=C'ABDUL',FIXLEN=5),
            %03=(STARTAT=C'ABDUL',FIXLEN=5),
            %04=(STARTAT=C'ABDUL',FIXLEN=5),
            %05=(STARTAT=C'ABDUL',FIXLEN=5),
            %06=(STARTAT=C'ABDUL',FIXLEN=5),
            %07=(STARTAT=C'ABDUL',FIXLEN=5),
            %08=(STARTAT=C'ABDUL',FIXLEN=5),
            %09=(STARTAT=C'ABDUL',FIXLEN=5),
            %10=(STARTAT=C'ABDUL',FIXLEN=5),
            %11=(STARTAT=C'ABDUL',FIXLEN=5),
            %12=(STARTAT=C'ABDUL',FIXLEN=5),
            %13=(STARTAT=C'ABDUL',FIXLEN=5),
            %14=(STARTAT=C'ABDUL',FIXLEN=5),
            %15=(STARTAT=C'ABDUL',FIXLEN=5),
            %16=(STARTAT=C'ABDUL',FIXLEN=5)),
         BUILD=(%01,%02,%03,%04,%05,%06,%07,%08,
                %09,%10,%11,%12,%13,%14,%15,%16)),
    IFTHEN=(WHEN=INIT,FINDREP=(IN=C'ABDUL',OUT=C'00001')),
    IFTHEN=(WHEN=INIT,
      BUILD=(1,5,UFF,ADD,6,5,UFF,ADD,11,5,UFF,ADD,16,5,UFF,ADD,
             21,5,UFF,ADD,26,5,UFF,ADD,31,5,UFF,ADD,36,5,UFF,ADD,
             41,5,UFF,ADD,46,5,UFF,ADD,51,5,UFF,ADD,56,5,UFF,ADD,
             61,5,UFF,ADD,66,5,UFF,ADD,71,5,UFF,ADD,76,5,UFF,
             TO=ZD,LENGTH=5))
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(30X),
    TRAILER1=('COUNT OF ''ABDUL'' IS: ',TOT=(1,5,ZD,M10,LENGTH=5))
/*
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Tue Oct 27, 2009 10:28 am
Reply with quote

Hi,

Thanks for your help. The code is working fine.

Is there a more optimistic way to perform my operation or is this the only way we can?.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 27, 2009 7:54 pm
Reply with quote

Hello,

"optimistic" - possibly optimal?

What in the provided code do you want to change?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Oct 27, 2009 8:00 pm
Reply with quote

If you take to mind that Frank is the guy that develops and maintains DFSORT / ICETOOL within IBM and he gives a solution to a problem, then his way will most certainly be the most optimal / optimistic / opthalmic solution.
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 Oct 27, 2009 9:34 pm
Reply with quote

Quote:
Is there a more optimistic way to perform my operation or is this the only way we can?


Well, you could certainly write your own program or exit to do it. Whether that would be more optimistic (sic) is for you to determine.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Oct 28, 2009 9:52 am
Reply with quote

Ok frank. I have executed only your code. Thanks a lot.
Back to top
View user's profile Send private message
Shaheen Kalokhe

New User


Joined: 21 Feb 2008
Posts: 21
Location: India

PostPosted: Wed Oct 28, 2009 8:06 pm
Reply with quote

Frank what eaxctly will the following statements do

IFTHEN=(WHEN=INIT,PARSE=(%01=(STARTAT=C'ABDUL',FIXLEN=5),
%02=(STARTAT=C'ABDUL',FIXLEN=5),
%03=(STARTAT=C'ABDUL',FIXLEN=5),
%04=(STARTAT=C'ABDUL',FIXLEN=5),
%05=(STARTAT=C'ABDUL',FIXLEN=5),
%06=(STARTAT=C'ABDUL',FIXLEN=5),
%07=(STARTAT=C'ABDUL',FIXLEN=5),
%08=(STARTAT=C'ABDUL',FIXLEN=5),
%09=(STARTAT=C'ABDUL',FIXLEN=5),
%10=(STARTAT=C'ABDUL',FIXLEN=5),
%11=(STARTAT=C'ABDUL',FIXLEN=5),
%12=(STARTAT=C'ABDUL',FIXLEN=5),
%13=(STARTAT=C'ABDUL',FIXLEN=5),
%14=(STARTAT=C'ABDUL',FIXLEN=5),
%15=(STARTAT=C'ABDUL',FIXLEN=5),
%16=(STARTAT=C'ABDUL',FIXLEN=5)),

What is the use of %01,%02....%16.
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: Wed Oct 28, 2009 9:34 pm
Reply with quote

For an Overview of DFSORT's PARSE function, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG40/2.5?DT=20090519162426

DFSORT's PARSE function is explained in detail in my paper available at:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000086
Back to top
View user's profile Send private message
Shaheen Kalokhe

New User


Joined: 21 Feb 2008
Posts: 21
Location: India

PostPosted: Fri Oct 30, 2009 7:55 pm
Reply with quote

Thank you Frank for your reply. I will definetly have a look at the links given by you.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Need to find a specific STRING COBOL Programming 11
Search our Forums:

Back to Top