|
View previous topic :: View next topic
|
| Author |
Message |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Why is this posted again here?
What about the same request in the IMS part of the forum. . .
d |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
"optimistic" - possibly optimal?
What in the provided code do you want to change? |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
| 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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
abdulrafi
Active User
Joined: 14 Sep 2009 Posts: 184 Location: Coimbatore
|
|
|
|
| Ok frank. I have executed only your code. Thanks a lot. |
|
| Back to top |
|
 |
Shaheen Kalokhe
New User
Joined: 21 Feb 2008 Posts: 21 Location: India
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
| Back to top |
|
 |
Shaheen Kalokhe
New User
Joined: 21 Feb 2008 Posts: 21 Location: India
|
|
|
|
| Thank you Frank for your reply. I will definetly have a look at the links given by you. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|