Page 1 of 3

testing empty dataset

PostPosted: Fri Jun 05, 2020 7:02 pm
by samb01
Hellon,

i'd like to test if a dataset is empty or not before executing a FTP.
But the dataset was not open by the rexx i ran.

so, in ISPF, i can see :


- Enter "/" to select action                        Tracks %Used   XT  
-----------------------------------------------------------------------
 DATSE.SET                                                
 DATA.SET.G0001V00                         1    ?     1  
 
 


and IDCAMS, ICETOOL doesn't work...

Re: testing empty dataset

PostPosted: Fri Jun 05, 2020 7:28 pm
by enrico-sorichetti
discussed and answered gazillions of times
search this forum or the sibling at http://ibmmainframes.com/

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 1:07 am
by samb01
Hello. I read the post. But my case is different.
The dataset has never been opened.
So i can't use usual program like idcams or icetool.
It dosen't work in my case.

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 2:02 am
by sergeyken
samb01 wrote:The dataset has never been opened.
So i can't use usual program like idcams or icetool.


What did you mean?

Please, clarify. How this is possible, to have a DS never opened???

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 2:31 am
by samb01
I run a rexx and with an output data set in DISP=(NEW,CATLG,),
the condition in the rexx isn't satisfied. Si nothing is written in the output dataset and si it la never opened
My rexx :

     EXEC PGM=IKJEFT01,DYNAMNBR=30,REGION=5000K          
//SYSEXEC  DD DSN=REXX.LIB,DISP=SHR                              
//SYSTSPRT DD SYSOUT=*                                          
//IN       DD DSN=DATA.IN(0),DISP=SHR          
//* FICHIERS GDG ALRTVTS                                        
//OUT      DD DSN=DATA.OUT(+1),DISP=(,CATLG),  
//         SPACE=(TRK,(1,1)),RECFM=FB,LRECL=133,BLKSIZE=27930
//SYSTSIN  DD *                                                
 %REXX01                                                      
//*              
 


and my rexx :

SELECT ALL

/*REXX*/                                                    
TRACE I                                                    
"EXECIO * DISKR IN (FINIS STEM DT."                        
  DO J = 1 TO DT.0                                          
       PTL.J  = SUBSTR(DT.J,22,9)                      
       TEXT.J  = SUBSTR(DT.J,1,80)                          
       TX.J  = SUBSTR(DT.J,34,2)                          
       IF PTL.J = "PTL A" & TX.J > 10 THEN        
       DO                                                  
       QUEUE TEXT.J                                        
       END                                                  
  END                                                      
  QUEUE ""                                                  
"EXECIO * DISKW OUT (FINIS"                                
  EXIT;                                                    
 


the output dataset which is empty have a ? in %Used column.
samb01
 
Posts: 394
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

 

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 2:33 am
by samb01
My jcl

SELECT ALL

//VTS2     EXEC PGM=IKJEFT01,DYNAMNBR=30,REGION=5000K          
//SYSEXEC  DD DSN=REXX.LIB,DISP=SHR                              
//SYSTSPRT DD SYSOUT=*                                          
//IN       DD DSN=DATA.IN(0),DISP=SHR          
//* FICHIERS GDG ALRTVTS                                        
//OUT      DD DSN=DATA.OUT(+1),DISP=(,CATLG),  
//         SPACE=(TRK,(1,1)),RECFM=FB,LRECL=133,BLKSIZE=27930
//SYSTSIN  DD *                                                
 %REXX01                                                      
//*              
 

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 3:08 am
by enrico-sorichetti
But my case is different.

NAHHH
also the case of dataset never opened for output has been discussed gazillions of times
and the general consensus is that it is a flaw of the design


'd like to test if a dataset is empty or not before executing a FTP.
But the dataset was not open by the rexx i ran.


run a rexx and with an output data set in DISP=(NEW,CATLG,),
the condition in the rexx isn't satisfied. Si nothing is written in the output dataset and si it la never opened


FIX THE BROKEN CODE

is it that difficult to write
if queued() = 0 then do
    "EXECIO 0 DISKW OUT (finis "
end
 

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 11:55 am
by samb01
Hello. If i well anderstand i have To change all of my rexx by writting the code tou shown me?
When i want To write info à dataset i end the rexx with execio 0 ?

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 12:51 pm
by enrico-sorichetti
When i want To write info à dataset i end the rexx with execio 0 ?

NO ...
You have to use a <dummy> EXECIO only when the main process does not write anything to the output dataset

it comes at no cost with a proper logic ...


"EXECIO * DISKR <input_ddname> ( FINIS STEM <input_stemvar>. "
if  RC \= 0 then do
    /*  tell the world about the error return code */
     ... ... ...
    /*  leave things in a clean state */
    "EXECIO 0 DISKR <output_ddname_1> ( FINIS "
    ... ... ...
    "EXECIO 0 DISKR <output_ddname_n> ( FINIS "
 
    return
end

/*  process ALL the rows of the stem */
do  i = 1 to <input_stemvar>.0
    ... ... ...
    <output_stemvar>.i = ... ... ...
end
<output_stemvar>.0 = <input_stemvar>.0
/* if the input dataset is empty
    <output_stemvar>.0 will be 0 and just the EOF will be written */  
"EXECIO" <output_stemvar>.0 "DISKW <output_ddname> ( FINIS STEM <output_stemvar>."

return


/*  process only selected rows of the stem */
<output_stemvar>.0 = 0
do  i = 1 to <input_stemvar>.0

    if  <some condition> then do
        <output_stemvar>.0 = <output_stemvar>.0 + 1
        j = <output_stemvar>.0
        <output_stemvar>.j = ... ... ...
    end
   
end
/* if the condition is never satisfied
    <output_stemvar>.0 will be 0 and just the EOF will be written */  
"EXECIO" <output_stemvar>.0 "DISKW <output_ddname> ( FINIS STEM <output_stemvar>."

return
 

Re: testing empty dataset

PostPosted: Sat Jun 06, 2020 1:32 pm
by samb01
Hello enrico and thank's for the example.
I anderstand noxw but sorry to tell you that but your code is a litle bit heavy..

if the file have billions lines, it is not intersting to read all th file as you shown when you procees all the rows...

If i use my code (i found mine more simple)

i just have to add the code you shown me and it will be fine :


if queued() = 0 then do
    "EXECIO 0 DISKW OUT (finis "
end
 


Don't you think so ?