Page 1 of 1

Getting last word

PostPosted: Thu Jun 10, 2021 12:51 pm
by samb01
Hello,
i vould like to get the last word of a record with dfsort.
I can't do it with the column number because it changes.
I have this jcl but it works only when the last agument is in column 32 :


 
//*********************************************************************
//ICE01   EXEC PGM=ICETOOL                                              
//INDD    DD DISP=SHR,DSN=FIC.DATASET                        
//TOOLIN  DD *                                                          
  COUNT FROM(INDD) EMPTY USING(HDTL) RC4                                
/*                                                                      
//HDTLCNTL DD *                                                        
  OMIT COND=(32,8,CH,EQ,C'LASTWORD')                                      
/*                                                                      
//TOOLMSG DD SYSOUT=*                                                  
//DFSMSG  DD SYSOUT=*                                                  
 


The last word could be in other column than 32 because of the size of the word just before that could have different lenght
I could use rexx to do that, but i prefer using dfsort.
Thank's for your help.

Re: Getting last word

PostPosted: Thu Jun 10, 2021 2:22 pm
by enrico-sorichetti
read the dfsort manuals about SS - substring search

quite a few examples here and googling

Re: Getting last word

PostPosted: Thu Jun 10, 2021 8:10 pm
by samb01
Hello, ss is not the good solution for me because i would like ta have juste on step and check the return code.

With SS, i have to write an other step to check if the file is empty or not.

Re: Getting last word

PostPosted: Thu Jun 10, 2021 8:42 pm
by enrico-sorichetti
why the need for two steps You are aleady using the OMIT construct

https://www.ibm.com/docs/en/zos/2.1.0?t ... clude-omit

SS is accepted both for INCLUDE and OMIT
quoting the manual example
  INCLUDE COND=(1,75,SS,EQ,C'INTRODUCTION')


so nothing prevents You from using
 OMIT COND=(start,length,SS,EQ,C'LASTWORD')

Re: Getting last word

PostPosted: Sun Jun 13, 2021 2:12 am
by sergeyken
Please, clarify: what did you mean by this -
i vould like to get the last word of a record with dfsort.

Based on your code, you are trying to do vice versa: to ignore (via OMIT) the last word, isn’t it?

Re: Getting last word

PostPosted: Mon Jun 14, 2021 7:49 pm
by samb01
Hello, thank's enrico, finally i use this sysin even if it can't match the last wost of the record but it works.
But with this method, i dont havec to have the same word in the same record :

//S1 EXEC PGM=ICETOOL
//INDD DD DISP=SHR,DSN=MY.DATA.SET
//TOOLIN DD *
COUNT FROM(INDD) EMPTY USING(HDTL) RC4
/*
//HDTLCNTL DD *
OMIT COND=(1,80,SS,EQ,C' SICAP ')
/*


when the word is in the record teh RC is 4, when it isn't teh RC is 0.