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

REXX code - Empty file check


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Mon Nov 12, 2007 10:34 pm
Reply with quote

Hi,

I am checking empty dataset in REXX using the following code. If empty file I am allocationg two files and if it is not empty, I am leavin g


What is the wrong in this. I am not getting proper result

Code:

"ALLOC DD(INDD) DA('CAA1035.EMPTY.CHECK') SHR REU"
"EXECIO 1 DISKR INDD (STEM IN. FINI"
      Return_Code = RC                   
        "ISPEXEC REMPOP"                 
        If Return_Code = 2 Then
     Do     
     Say 'allocate'
   End         
Exit 0                         
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Nov 12, 2007 10:43 pm
Reply with quote

Please post your runtime TRACE output.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Nov 12, 2007 10:45 pm
Reply with quote

Code:
        "ISPEXEC REMPOP"   


what has that statement in common with what You are trying to achieve ??
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Mon Nov 12, 2007 11:32 pm
Reply with quote

I use this REXX program to check for empty files. It works very similiar to your code:

Code:

/* ---------- REXX: RESTRUCTURED EXTENDED EXECUTOR LANGUAGE --------- */
/* EMPTY RETURNS A COND COND OF 04                                    */
/* RECORDS RETURN A COND COND OF 00                                   */
PARSE ARG DSN                                                           
IDSN = STRIP(DSN,'B')                                                   
ALLOC:                                                                 
"ALLOC FI(INPUTCK) DA('"||IDSN||"') SHR REUSE"                           
IF RC > 0 THEN DO                                                       
    SAY "ALLOCATE ERROR RC= " RC                                       
    EXIT RC                                                             
END                                                                     
READUMIN:                                                               
/* READ IN THE INPUT FILES AS STEM VARIABLES        */                 
"EXECIO 1 DISKR INPUTCK (STEM IN.. FINIS)"                             
ADDRESS TSO "FREE F(INPUTCK)"                                           
IF IN.0 = 0 THEN EXIT 4                                               
IF IN.0 ¬= 0 THEN EXIT 0                                               


It brings in a dataset as an argument and attempts to READ one record. It then checks the zero stem variable and passes a RC of 0 if there are records and a RC of 4 if there are not records. You can probably adapt this to your requirement.
Back to top
View user's profile Send private message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Tue Nov 13, 2007 12:45 am
Reply with quote

Thank you verymuch. I will take this.
Back to top
View user's profile Send private message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Tue Nov 13, 2007 12:55 am
Reply with quote

Hi,

See the below code. If empty condition, it is perfectly going inside the loop, but why it is not creating the new dataset. After executing this rexx. I am not able to see the new dataset.

CPDTT.CIF.SYST.BLK#OC13.CIFMCH3M.AXAB300N - Empty dataset


Code:
 300_alloc:                                                             
/* getting new block string from panel                    */           
  NEWBLOCK = 'OC13'                                                       
say 'here newblock' newb                                               
 "ALLOC DD(INDD) DA('CPDTT.CIF.SYST.BLK#"NEWBLOCK".CIFMCH3M.AXAB300N') 
                                            SHR REU"                   
    "EXECIO 1 DISKR INDD (STEM IN. FINI"                               
    Return_Code = RC                                                   
    say 'retrun code ' rc                                               
      If Return_Code = 2 Then                                           
         say 'inside rcc ' return_code                                 
          Do                                                           
            Call Msg('OFF')                                             
            Psname1 = "CPDTT.CIF.SYST."NEWBLOCK".CIFMCH5M.AXAB4004"     
            say 'dataset1 : ' psname1                                   
            "Alloc FI(SORTOUT) DA("Psname1") NEW UNIT(SYSDA)",         
            "SP(10, 90) TRA DSORG(PS) DIR(0) BLKSIZE(27896)",   
            "LRECL(317) RECFM(F B) REUSE"                             
             Call Msg('On')                                           
                                                                     
            Call Msg('OFF')                                           
             Psname2 = "CPDTT.CIF.SYST."NEWBLOCK".CIFMCH5M.AXAB4005" 
             "Alloc FI(SORTOUT) DA("Psname2") NEW UNIT(SYSDA)",       
             "SP(10, 90) TRA DSORG(PS) DIR(0) BLKSIZE(27993)",       
             "LRECL(301) RECFM(F B) REUSE"                           
             Call Msg('On')                                           
             End                                                     
 Return       


The output say messages

here1
here newblock OC13
retrun code 2
inside rcc 2
dataset1 : CPDTT.CIF.SYST.OC13.CIFMCH5M.AXAB4004
here end
***
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Tue Nov 13, 2007 1:38 am
Reply with quote

I'm do not see anything specific that is wrong with your ALLOC statements.

I would ask?

Is SP valid for the word SPACE?
Is TRA valid for TRACKS?
If its is a PS dataset, you do not need DIR(0).

Do the DA("Psname1") and DA("Psname2") parameters need to have a single quote surrounding them? Like DA('"PSNAME1"') and DA('"PSNAME2"')?

You can always add TRACE "I" at the top of the code you are running and TRACE OFF at the bottom to see how REXX performs your instructions.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Nov 13, 2007 2:52 am
Reply with quote

Code:
             "Alloc FI(SORTOUT) DA("Psname2") NEW UNIT(SYSDA)",       
             "SP(10, 90) TRA DSORG(PS) DIR(0) BLKSIZE(27993)",       
             "LRECL(301) RECFM(F B) REUSE"       


I do not see anything telling the system whart to do with Your dataset...
I would add the operand "CATLG" ..

To be sure,check with SDSF the log of Your tso session
to see what happens when You free the ddname/dataset
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 5
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top