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

Calling IEHPROGM from REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jeff Agosta

New User


Joined: 08 Oct 2022
Posts: 4
Location: United States

PostPosted: Sat Oct 08, 2022 11:08 pm
Reply with quote

Esteemed REXX gurus -

I have a REXX process which gets a list of names via LMDLIST and then calls IDCAMS to do renames which works great for catalogued files. However, I received a requirement to do the same for UNcataloged files. To do so, I need to call IEHPROGM, however, I'm getting an error RC(16).

As a model I'm using a working batch JCL:
Code:
//STEP1    EXEC PGM=IEHPROGM                                           
//SYSPRINT DD  SYSOUT=*                                                 
//DD1      DD  VOLUME=SER=LB2261,UNIT=SYSDA,DISP=OLD                   
//SYSIN    DD  *                                                       
  RENAME   DSNAME=XFER.JEFFA.FLAT1,VOL=SYSDA=LB2261,                   X
               NEWNAME=JEFFA.FLAT1                                     
  RENAME   DSNAME=XFER.JEFFA.PDS1,VOL=SYSDA=LB2261,                    X
               NEWNAME=JEFFA.PDS1



REXX code excerpt:
Code:
Address TSO                                               
"ALLOC FILE(DD1) DATASET('"dsn.di"') VOLUME("volume")",   
           " UNIT(SYSDA) OLD REU"                         
"ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU",   
            " SPACE(1,1) TRACK RECFM(F,B) "               
"ALLOC FILE(SYSIN) BLKSIZE(3280) LRECL(80)  NEW REU",     
            " SPACE(1,1) TRACK RECFM(F,B) "               
output.0 = 2                                               
output.1 = "  RENAME DSNAME="dsn.di",VOL=SYSDA="volume,   
           "                     X"                       
output.2 = "               NEWNAME="newDSN                 
"EXECIO " output.0 " DISKW SYSIN ( FINIS  STEM OUTPUT."   
"CALL 'SYS1.LINKLIB(IEHPROGM)'"                           
end                                                                                                     


Note the difference between the JCL and the REXX, in the REXX I needed to specify the DSN for DD1, since without it the ALLOCATE fails.

I've verified the positions of the sysin and it's correct. I will add code to programmatically do so, since the filenames will very in length. However, I am stuck on the rc(16) and can't determine a anyway to get further diagnostics?


Trace output:
Code:
   128 *-*      RenameDSNs:                                                                                 
   129 *-*      /**/                                                                                       
   130 *-*      parse var dsn.di hlq"."newDSN                                                               
       >>>        "XFER"                                                                                   
       >>>        "JEFFA.FLAT1"                                                                             
   131 *-*      if volume = ''                                                                             
       >>>        "0"                                                                                       
   144 *-*      else                                                                                       
       *-*       do                                                                                         
   145 *-*        Address TSO                                                                               
   146 *-*        /**/                                                                                     
   147 *-*        "ALLOC FILE(DD1) DATASET('"dsn.di"') VOLUME("volume")"," UNIT(SYSDA) OLD REU"             
       >>>          "ALLOC FILE(DD1) DATASET('XFER.JEFFA.FLAT1') VOLUME(LB2261)  UNIT(SYSDA) OLD REU"       
   149 *-*        "ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU"," SPACE(1,1) TRACK RECFM(F,B) "   
       >>>          "ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU  SPACE(1,1) TRACK RECFM(F,B) "   
   151 *-*        "ALLOC FILE(SYSIN) BLKSIZE(3280) LRECL(80)  NEW REU"," SPACE(1,1) TRACK RECFM(F,B) "     
       >>>          "ALLOC FILE(SYSIN) BLKSIZE(3280) LRECL(80)  NEW REU  SPACE(1,1) TRACK RECFM(F,B) "     
   153 *-*        output.0 = 2                                                                             
       >>>          "2"                                                                                     
   154 *-*        output.1 = "  RENAME DSNAME="dsn.di",VOL=SYSDA="volume,"                     X"           
       >>>          "  RENAME DSNAME=XFER.JEFFA.FLAT1,VOL=SYSDA=LB2261                      X"             
   156 *-*        /**/                                                                                     
   157 *-*        output.2 = "               NEWNAME="newDSN                         
       >>>          "               NEWNAME=JEFFA.FLAT1"                             
   158 *-*        /**/                                                               
   159 *-*        "EXECIO " output.0 " DISKW SYSIN ( FINIS  STEM OUTPUT."             
       >>>          "EXECIO  2  DISKW SYSIN ( FINIS  STEM OUTPUT."                   
   160 *-*        "CALL 'SYS1.LINKLIB(IEHPROGM)'"                                     
       >>>          "CALL 'SYS1.LINKLIB(IEHPROGM)'"                                   
       +++ RC(16) +++                                                                 
   161 *-*       end                                                                 
   163 *-*      If rc = '0'                                                           
       >>>        "0"                                                                 
   168 *-*      else                                                                 
   169 *-*       Do                                                                   
   170 *-*        say dsn' rename failed!!! :-('                                     
       >>>          "XFER.JEFFA.FLAT1 rename failed!!! :-("                           
XFER.JEFFA.FLAT1 rename failed!!! :-(                                                 
   171 *-*        Address ISPEXEC                                                     
   172 *-*        "LMINIT DATAID(DATAID) DDNAME(SYSPRINT)"                           
       >>>          "LMINIT DATAID(DATAID) DDNAME(SYSPRINT)"                         
   173 *-*        "VIEW DATAID(&DATAID)"                                             
       >>>          "VIEW DATAID(&DATAID)"
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Sun Oct 09, 2022 2:45 am
Reply with quote

Rd 16 means 'An unrecoverable error exists. The utility is ended' so something is clearly wrong.
You don't have UNIT for neither SYSIN nor SYSPRINT.
Suggest allocate SYSPRINT to DA(*) to get the messages immediately while testing.
Did you check the SYSLOG for possible security or other mesages?
One suggestion, use blksize 0 for new output datasets.
Check ISRDDN afterwards, view SYSIN and SYSPRINT DDnames.
Back to top
View user's profile Send private message
Jeff Agosta

New User


Joined: 08 Oct 2022
Posts: 4
Location: United States

PostPosted: Sun Oct 09, 2022 6:34 pm
Reply with quote

@Willy Jensen-
DA(*) was a HUGE help. the issue was that the ',' at the end of

Code:
output.1 = "  RENAME DSNAME="dsn.di",VOL=SYSDA="volume",
           "                    X"                     


Added the ',' and it works perfectly! Funny when a dirt spec on the screen isn't enuf! icon_lol.gif

Code:
output.1 = "  RENAME DSNAME="dsn.di",VOL=SYSDA="volume",",
           "                    X"                     


Now I just need to clean up the code to be flexible to handle different dataset name lengths (up to 44 bytes) to ensure the continuation character is in the 72 position.

Once complete, I'll share a copy if anyone is interested.

Again, Willy a huge thanks!!!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Oct 10, 2022 7:21 am
Reply with quote

Code:
output.1 = Left( "  RENAME DSNAME="dsn.di",VOL=SYSDA="volume",", 71 ),
          || "X"                     
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Oct 10, 2022 7:42 am
Reply with quote

Code:
. . . . . . . . . . . .                                       
Queue Left( " RENAME DSNAME="dsn.di",”, 71) || “X”
Queue Left( Copies( “ “, 15) || “VOL=SYSDA="volume”,”, 71) || "X"                       
Queue Copies( “ “, 15 ) || "NEWNAME="newDSN       
"EXECIO" Queued() "DISKW SYSIN (FINIS"   
. . . . . . . . .                                                                                           
Back to top
View user's profile Send private message
Jeff Agosta

New User


Joined: 08 Oct 2022
Posts: 4
Location: United States

PostPosted: Mon Oct 10, 2022 7:20 pm
Reply with quote

SergeyKen -
Thank you, that's exactly what I needed!

I had to restrict the input DSN length to <= 38 due to the SYSIN line length of 72, otherwise it works like a charm!

Code:
else if length(dsn.di) <= maxDSNlen then do                                 
  Address TSO                                                               
  "ALLOC FILE(DD1) DATASET('"dsn.di"') VOLUME("volume")",                   
              " UNIT(SYSDA) OLD REU"                                         
  "ALLOC FILE(SYSPRINT) DA(*)"  /* use for testing */                       
/*"ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU",                   
              " SPACE(1,1) TRACK RECFM(F,B) " */                             
  "ALLOC FILE(SYSIN) BLKSIZE(3280) LRECL(80)  NEW REU",                     
              " SPACE(1,1) TRACK RECFM(F,B) "                               
  output.0 = 2                                                               
  output.1 = Left( " RENAME DSNAME="dsn.di",VOL=SYSDA="volume",", 71 ),     
              || "X"                                                         
  output.2 = "               NEWNAME="newDSN                                 
  "EXECIO " output.0 " DISKW SYSIN ( FINIS  STEM OUTPUT."                   
  "CALL 'SYS1.LINKLIB(IEHPROGM)'"                                           
  end                                                                       
  else do                                                                   
    rc=99                                                                   
    say dsn.di 'renamed failed due to name length= 'length(dsn.di),         
      ' maximum allowed in newOSDSN is 'maxDSNlen                           
  end                                                                       
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Oct 10, 2022 7:29 pm
Reply with quote

Jeff Agosta wrote:
SergeyKen -
Thank you, that's exactly what I needed!

I had to restrict the input DSN length to <= 38 due to the SYSIN line length of 72, otherwise it works like a charm!

Code:
else if length(dsn.di) <= maxDSNlen then do                                 
  Address TSO                                                               
  "ALLOC FILE(DD1) DATASET('"dsn.di"') VOLUME("volume")",                   
              " UNIT(SYSDA) OLD REU"                                         
  "ALLOC FILE(SYSPRINT) DA(*)"  /* use for testing */                       
/*"ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU",                   
              " SPACE(1,1) TRACK RECFM(F,B) " */                             
  "ALLOC FILE(SYSIN) BLKSIZE(3280) LRECL(80)  NEW REU",                     
              " SPACE(1,1) TRACK RECFM(F,B) "                               
  output.0 = 2                                                               
  output.1 = Left( " RENAME DSNAME="dsn.di",VOL=SYSDA="volume",", 71 ),     
              || "X"                                                         
  output.2 = "               NEWNAME="newDSN                                 
  "EXECIO " output.0 " DISKW SYSIN ( FINIS  STEM OUTPUT."                   
  "CALL 'SYS1.LINKLIB(IEHPROGM)'"                                           
  end                                                                       
  else do                                                                   
    rc=99                                                                   
    say dsn.di 'renamed failed due to name length= 'length(dsn.di),         
      ' maximum allowed in newOSDSN is 'maxDSNlen                           
  end                                                                       


1) Split your first statement line in two parts (as in my example), to not limit your DSN length

2) Instead of stem variable, better use the program stack for input/output (as in my example)
Back to top
View user's profile Send private message
Jeff Agosta

New User


Joined: 08 Oct 2022
Posts: 4
Location: United States

PostPosted: Mon Oct 10, 2022 8:46 pm
Reply with quote

SergeyKen -
Indeed! I am in your awe! icon_biggrin.gif

I've attached the results of our collective labors. Thanks to you and Willy for all your help!
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top