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

Can we read next record when a condition is met in previous.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Wed Apr 09, 2008 4:34 pm
Reply with quote

Hi ,

In sort can we meet the next immediate record when a condition is satisfied in the current record.

Example:

The Error is
PPPP40

So in SORT condition we can add the condtion "The Error is" then we should be able to capture the second record.

I am not able to code the second directly since we can't predict that value. It will keep changing.

Regards
Amar.
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 Apr 09, 2008 9:02 pm
Reply with quote

You need to clarify what you want to do.

Are there always only two records in the input file, and you want to write the second record if the first record meets the condition, but not write the second record if the first record does not meet the condition?

For example, if the two records are:

The Error is
PPPP40

you want the output to be:

PPPP40

but if the two records are:

No error
PPPP40

you don't want any output?

Or are there more than two records in the input file? And if so, what is it you want to do exactly?

Please show a better example of your input and expected output for the various possible cases and explain what it is you want to do exactly.
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Wed Apr 09, 2008 10:26 pm
Reply with quote

Frank,

Actually A program will abend throwing the error statements. There can be many. But the way it will write is it will not write the error statement in a single way. I till split as I said. First it will say the " The error is" and then the immediate the record will have the error code. So I need to search for the string1 in the SYSOUT so in the search where ever I found the "The Error is" I need to read the immediate the next recor which tells the error code and write the same after reading it to an output fiel. So I posted this.

please let me know if this is not clear.

Regards
Amar
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 09, 2008 10:47 pm
Reply with quote

V S Amarendra Reddy,

The following DFSORT/ICETOOL jcl will give you the desired results. I assumed that your input file is 133 bytes in length and FB format

Code:

//STEP0100  EXEC  PGM=ICETOOL   
//TOOLMSG   DD SYSOUT=*         
//DFSMSG    DD SYSOUT=*         
//IN        DD DSN=your input file,Disp=shr
//OUT       DD SYSOUT=*                                     
//TOOLIN    DD *                                             
  SELECT FROM(IN) TO(OUT) ON(134,8,CH) ALLDUPS USING(CTL1) 
//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=INIT,                                 
       OVERLAY=(134:SEQNUM,8,ZD)),                         
        IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),             
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))         
                                                           
  OUTFIL FNAMES=OUT,OMIT=(1,9,CH,EQ,C'THE ERROR'),         
  OUTREC=(01,133)                                           
//*


Hope this helps...
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Fri Apr 11, 2008 12:34 am
Reply with quote

Helllo Skolusu

I am very gald to tell that your code worked fine. But it would be great helpful for me if you explain me the sort controlcard I can learn it.

Please explain the same.

Regards
Amar
icon_smile.gif
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 Apr 11, 2008 12:53 am
Reply with quote

Kolusu will not be available for a few days.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Fri Apr 11, 2008 1:23 am
Reply with quote

Thank you Frank for the update. But in the card can you quickly explain in a simple words what second OVERLAY says which include that ADD fucntion. Please I need only that.



Regards
Amar
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 Apr 11, 2008 2:49 am
Reply with quote

The first OVERLAY creates a sequence number for every record.

The second OVERLAY adds 1 to the sequence number for each record with 'THE ERROR'.

This forces the sequence number for each 'THE ERROR' record to be the same as the sequence number for the record after the 'THE ERROR' record. For example, if the sequence numbers for the first 'THE ERROR' record and the record after it are 5 and 6 after the first OVERLAY, they will be 6 and 6 after the second OVERLAY.

Thus, the SELECT ALLDUPS on the sequence number will select those pairs of records (the 'THE ERROR' record and the record after it) since they have duplicate sequence numbers (e.g. 6 and 6).

The OUTFIL removes the 'THE ERROR' records, so only the record after each 'THE ERROR' record is output.

Does that help?
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Fri Apr 11, 2008 3:04 pm
Reply with quote

Great Help and clear explanation.

I am very clear Frank icon_smile.gif

Thank you very much


Regards
Amar
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Apr 11, 2008 9:27 pm
Reply with quote

V S Amarendra Reddy,

I can't test this right now, but I would give a try to use LASTDUP rather than ALLDUPS, so you will have no need to code a OMIT card.
I would add a SORT FIELDS=COPY because your records are already sorted.

Alain
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 Apr 11, 2008 9:53 pm
Reply with quote

Excellent suggestions, Alain. I tried them and they worked. Here's the updated DFSORT/ICETOOL job:

Code:

//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD DSN=your input file,Disp=shr
//OUT       DD SYSOUT=*
//TOOLIN    DD *
SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)
//CTL1CNTL DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,
       OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,BUILD=(1,133)
//*
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Apr 11, 2008 10:11 pm
Reply with quote

Frank,

I suppose seqnum field should be removed, shouldn't I ? icon_smile.gif


Alain
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 Apr 11, 2008 10:52 pm
Reply with quote

Yes. Fixed it.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Apr 15, 2008 12:28 pm
Reply with quote

Hi Frank,
I tried the code you provided but nothing was selected.

Code:
//STEP0102  EXEC PGM=ICETOOL                                           
//TOOLMSG   DD SYSOUT=*                                                 
//DFSMSG    DD SYSOUT=*                                                 
//IN        DD *                                                       
THE ERROR IS                                                           
PPPP40                                                                 
//OUT       DD SYSOUT=*                                                 
//TOOLIN    DD *                                                       
SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)               
//CTL1CNTL DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                             
       OVERLAY=(134:SEQNUM,8,ZD)),                                     
        IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),                         
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))                     
  OUTFIL FNAMES=OUT,BUILD=(1,133)                                       
//*                                                                     


TOOLMSG
Code:
1ICE600I 0 DFSORT ICETOOL UTILITY RUN STARTED                                   
                                                                               
 ICE650I 0 VISIT http://www.ibm.com/storage/dfsort FOR ICETOOL PAPERS, EXAMPLES
                                                                               
 ICE632I 0 SOURCE FOR ICETOOL STATEMENTS:  TOOLIN                               
                                                                               
                                                                               
 ICE630I 0 MODE IN EFFECT:  STOP                                               
                                                                               
           SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)             
 ICE606I 0 DFSORT CALL 0001 FOR SORT FROM IN       TO OUT      USING CTL1CNTL CO
 ICE628I 0 RECORD COUNT:  000000000000002                                       
 ICE638I 0 NUMBER OF RECORDS RESULTING FROM CRITERIA:  000000000000000         
 ICE602I 0 OPERATION RETURN CODE:  00                                           
                                                                               
                                                                               
 ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  00                 


DFSMSG
Code:
ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                               
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 16:50 ON TUE APR
            SORT FIELDS=COPY                                                   
            INREC IFTHEN=(WHEN=INIT,                                           
                 OVERLAY=(134:SEQNUM,8,ZD)),                                   
                  IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),                       
                 OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))                   
            OUTFIL FNAMES=OUT,BUILD=(1,133)                                     
ICE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW   
          DEBUG NOABEND,ESTAE                                                   
          OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=IN,SO
                         TOUT=OUT,DYNALLOC,SZERO,EQUALS,NOVLSHRT,LOCALE=NONE,NOC
                         ECK                                                   
          SORT FIELDS=(134,8,CH,A)                                             
          MODS E35=(ICE35DU,12288)                                             
ICE201I 0 RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-K05352 C6-Q95214 C7-K90000 C8-K05352 E9-K06751 C9-BASE   E5-K10929
ICE193I 0 ICEAM2 ENVIRONMENT IN EFFECT - ICEAM2 INSTALLATION MODULE SELECTED   
ICE088I 0 CSCSGLCI.STEP0102.        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,6291456,6262784)                                 
ICE156I 0 MAIN STORAGE ABOVE 16MB = (6217169,6200785)                           
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,
ICE128I 0 OPTIONS: SIZE=6291456,MAXLIM=1048576,MINLIM=450560,EQUALS=N,LIST=Y,ERE
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=FULL ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
ICE130I 0 OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=N,WRKREL=Y,OUTREL=N,CKPT=
ICE131I 0 OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=16384,CINV=Y,CFW=
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=2097152,SOLRF=Y,VLLONG=N
ICE235I 0 OPTIONS: NULLOUT=RC0                                                 
ICE084I 0 BSAM ACCESS METHOD USED FOR IN                                       
ICE231I 0 STORAGE USED FOR OUTFIL : BELOW 16M = 47104, ABOVE 16M = 130048       
ICE210I 0 OUT      : BSAM USED, LRECL = 133, BLKSIZE = 133, TYPE = FB           
ICE751I 1 EF-K10929 CB-K90000 F0-Q84357 E8-K11698                               
ICE055I 0 INSERT 0, DELETE 2                                                   
ICE054I 0 RECORDS - IN: 2, OUT: 0                                               
ICE227I 0 OUT      : DELETED = 0, REPORT = 0, DATA = 0     
ICE228I 0 OUT      : TOTAL IN = 0, TOTAL OUT = 0           
ICE174I 0 NO DATA RECORDS FOR AN OUTFIL DATA SET - RC=0   
ICE052I 0 END OF DFSORT                                   



Gerry
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 Apr 15, 2008 8:51 pm
Reply with quote

Gerry,

It's not working for you because you don't have z/OS DFSORT V1R5 PTF UK90007 installed. That PTF has been available since April, 2006 and it's needed to use INREC with SPLICE. When I run your job here with that PTF, the output is:

PPPP40

When I run your job without the PTF, I get no output.

Ask your System Programmer to install that PTF (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Tue Apr 15, 2008 9:58 pm
Reply with quote

Frank,

But in the code why did we include SORT FIELDS=COPY and then removal of SEQNUM how this is going to impact?
If we remove SEQNUM then our whole IFTHEN need to be removed na??

Please clarify

Regards
Amar
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 Apr 15, 2008 10:13 pm
Reply with quote

Quote:
But in the code why did we include SORT FIELDS=COPY and then removal of SEQNUM how this is going to impact?
If we remove SEQNUM then our whole IFTHEN need to be removed na??


We included SORT FIELDS=COPY because the ON(134,8,ZD) field is already in sorted order. No need to sort on a field that's already in sorted order. COPY is more efficient.

We don't remove the SEQNUM until after the INREC and SPLICE are processed (INREC is processed before SPLICE; OUTFIL is processed after SPLICE). We're done with the SEQNUM at that point.
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Wed Apr 16, 2008 3:54 pm
Reply with quote

.
Quote:
No need to sort on a field that's already in sorted order. COPY is more efficient.


Can you please clarify me where are we sorting earlier?
You said no need to sort,COPY is more efficient.


Quote:
We don't remove the SEQNUM until after the INREC and SPLICE are processed (INREC is processed before SPLICE; OUTFIL is processed after SPLICE). We're done with the SEQNUM at that point.


Frank,
Sorry to say that I didnt get the above explanation. Are we using any splice in our code?

Previous time when Alian suggested to remove SEQNUM you said

Quote:
Yes. Fixed it.


Means what change you have done to the exisitng code. Did you really remove it out of that. Then can I assume code format is as follows now.

Code:

//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD DSN=your input file,Disp=shr
//OUT       DD SYSOUT=*
//TOOLIN    DD *
SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)
//CTL1CNTL DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,BUILD=(1,133)
//*


If that is the code how the ADD is going to work out as we don't have any seqnum field.

Please clarify
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 Apr 16, 2008 9:59 pm
Reply with quote

The final job was this as posted:

Code:

//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD DSN=your input file,Disp=shr
//OUT       DD SYSOUT=*
//TOOLIN    DD *
SELECT FROM(IN) TO(OUT) ON(134,8,CH) LASTDUP USING(CTL1)
//CTL1CNTL DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,
       OVERLAY=(134:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,9,CH,EQ,C'THE ERROR'),
       OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,BUILD=(1,133)
//*


I did NOT remove the SEQNUM from the first OVERLAY. I removed some other unneeded SEQNUM I had in the original job, but I don't really remember where it was at this point.

Quote:
Are we using any splice in our code?


We are using SELECT, not SPLICE.

Quote:
Can you please clarify me where are we sorting earlier?
You said no need to sort,COPY is more efficient.


We are NOT sorting - that's the point. SELECT would normally sort on the ON field of 134,8,CH. But since the values we created for 134,8,CH with the INREC statement are sequence numbers that are already in sorted order, we don't need to sort them.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top