MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Invoke REXX from COBOL
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Jul 08, 2004 10:38 am    Post subject: Reply with quote

Kolusu,

Our shop currently does not have QW. The licence has expired and they haven't renewed the licence yet. (Don't know when that wud happen) Could you please some documentation.

Thanks a bunch,
Phantom,
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jul 08, 2004 10:40 am    Post subject: Reply with quote

Phantom,


Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=2520

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Jul 08, 2004 1:38 pm    Post subject: Reply with quote

The invocation of REXX from COBOL is rather simple:
Code:

IDENTIFICATION DIVISION.                             
PROGRAM-ID. PROG6.                                   
INSTALLATION.                                         
AUTHOR. SUPERK.                                       
DATE-WRITTEN. 01/16/2004.                             
                                                     
ENVIRONMENT DIVISION.                                 
INPUT-OUTPUT SECTION.                                 
                                                     
  FILE-CONTROL.                                                                     
                                                     
DATA DIVISION.                                       
FILE SECTION.                                         

WORKING-STORAGE SECTION.                     
01  REXX-PARM.                               
    03 FILLER PIC S9(4) BINARY VALUE 5.       
    03 FILLER PIC X(05) VALUE 'PROG6'.       
                                             
PROCEDURE DIVISION.                           
    CALL 'IRXJCL' USING REXX-PARM.           
    DISPLAY 'RETURN-CODE=' RETURN-CODE.       
    MOVE ZEROS TO RETURN-CODE.               
    STOP RUN.             

Please forgive any crudeness - I'm not a programmer by trade. You will, of course, need to define a DD statement for SYSEXEC in your JCL, and the library specified will need to contain the REXX exec. In my case:
Code:

//STEP0001 EXEC PGM=PROG6
//STEPLIB   DD    DISP=SHR,DSN=&SYSUID..COBOL.LOAD
//SYSEXEC  DD   DISP=SHR,DSN=&SYSUID..REXX
//SYSOUT    DD   SYSOUT=*
//*
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jul 08, 2004 1:53 pm    Post subject: Reply with quote

Kevin,
I like the solution. I was led into thinking of calling REXX EXEC load module rather than having invoking it via IRXJCL.

However, the way of calling IRXJCL is not correct. You are calling the program by its name; meaning it is statically called. In other words, it must be available in the load module of PROG6.

When I tested your code, sure enough, the link step failed. It said, IRXJCL symbol is unresolved. However, it works perfectly, when I call it via an identifier.

Here is what worked for me:
Code:

 ID DIVISION.                                         
 PROGRAM-ID.  CBLTRX.                                 
*                                                     
 ENVIRONMENT DIVISION.                               
*                                                     
 DATA DIVISION.                                       
*                                                     
 WORKING-STORAGE SECTION.                             
*                                                     
 01  CALL-IRXJCL          PIC X(6) VALUE "IRXJCL" .   
 01  CALL-PARM.                                       
     05  PARM-LEN         PIC S9(4) BINARY VALUE 2.   
     05  PARM-VALUE       PIC X(2)         VALUE "HI".
*                                                     
 PROCEDURE DIVISION.                                 
     CALL CALL-IRXJCL USING CALL-PARM.               
     DISPLAY "RETURN CODE = " RETURN-CODE.           
     STOP RUN.                                       

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jul 08, 2004 1:58 pm    Post subject: Reply with quote

BTW, Kevin's job would also need a DD name SYSTSPRT where the 'say' of REXX would be printed. Else, the job will abend at run-time.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Jul 08, 2004 4:04 pm    Post subject: Reply with quote

You are correct about also needing SYSTSPRT.

I was just working on a version of this that uses BPXWDYN to dynamically allocate the SYSEXEC and SYSTSPRT DD's. Looks good thus far.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jul 08, 2004 4:07 pm    Post subject: Reply with quote

And, about calling IRXJCL ?
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Jul 08, 2004 7:20 pm    Post subject: Reply with quote

Well, the code compiled and executed just fine the way I originally posted it. However, what you said makes sense, using a dynamic call rather than a static call. I'll make the change tomorrow.
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Fri Jul 09, 2004 1:32 am    Post subject: Reply with quote

Calling a Rexx program in the name of 'security' will only get you into trouble.

  • It is easy to browse any load module that can be loaded into storage. DDLIST;LOAD module is the easiest, but there are many others including causing it to abend and looking at the dump, etc., etc.
  • Once you browse the load module, you can view the strings in it, so unless you encrypt the name, it wll be plainly visible.
  • If the user changes their SYSEXEC/SYSPROC concatenations, your Rexx exec can be substituted with a similarly named one that does whatever the user wants unless you call EXEC with a fully qualified name.
  • If the user frees the ddnames, they may get error messages telling them what commands could not be found.
  • ... it s just too easy to get around.

It is possible to preload and preparse an exec in storage and call that via the IRX... interfaces. It is documented in the Rexx books, but
dynamic allocation (SVC 99, BPXWDYN, etc) of a temporary data set (leave off the dsname) is probably your best bet. All the better if it is allocated to VIO. RACF can provide some additional safeguards like execute-only authority.
Back to top
View user's profile Send private message Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jul 09, 2004 1:37 am    Post subject: Reply with quote

Wow, this is absolutely great. I'm learning lot of new things !!!! Thanks a lot for all of you Very Happy

Superk said
Quote:

I was just working on a version of this that uses BPXWDYN to dynamically allocate the SYSEXEC and SYSTSPRT DD's. Looks good thus far.


Superk, could you please share your piece of code. That wud of great help to me.

Again, Thanks to all for helping me.
Phantom
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jul 09, 2004 9:59 am    Post subject: Reply with quote

Hi All,

I wrote a COBOL program that calls BPXWPDYN. I was able to successfully create a DATASET (PS), Open it in OUTPUT mode, write some data, close it & Free the allocated dataset. Everything worked fine !!!.

The only problem was I was trying to allocate a DDNAME to SYSOUT=* using the following command but ended with an error.
Code:

WORKING-STORAGE SECTION.                                       
                                                               
01  WS-SUB-PGM            PIC  X(08) VALUE 'BPXWDYN'.           
  -  -  -  -  -  -  -  -  -  -  -  -  - 78 Line(s) not Displayed
01  WS-COMMAND-STRING.                                         
    05  WS-CMD-LEN        PIC  S9(04) BINARY VALUE +190.       
    05  WS-CMD-DATA       PIC  X(190).                         
                                                               
PROCEDURE DIVISION.                                             
0000-MAIN-ROUTINE.                                             
  -  -  -  -  -  -  -  -  -  -  -  -  - 39 Line(s) not Disp
DISPLAY 'CREATE TOOLMSG CARD'                           
MOVE ' ALLOC DD(TOOLMSG) SYSOUT(*) '  TO  WS-CMD-DATA.   
DISPLAY WS-COMMAND-STRING                               
CALL WS-SUB-PGM      USING WS-COMMAND-STRING.           
DISPLAY RETURN-CODE                                     
                                                         
DISPLAY 'CREATE DFSMSG CARD'                             
MOVE ' ALLOC DD(DFSMSG) SYSOUT [*] '  TO  WS-CMD-DATA.   
CALL WS-SUB-PGM      USING WS-COMMAND-STRING.           
DISPLAY RETURN-CODE                                     
                                                         
DISPLAY 'CREATE SORTOUT CARD'                           
MOVE ' ALLOC DD(SORTOUT) SYSOUT * '  TO  WS-CMD-DATA.   
CALL WS-SUB-PGM      USING WS-COMMAND-STRING.           
DISPLAY RETURN-CODE                                     


The first allocation (TOOLMSG) ended with a return code of 0024 and the other two allocations ended with a return of code of 002M.

Could you please let me know how to allocate a DDNAME to SYSOUT=*.

Thanks in advance for your kind help
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Jul 09, 2004 10:28 am    Post subject: Reply with quote

Check this:

ftp://ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html#Section_2.3

for return codes.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jul 09, 2004 10:32 am    Post subject: Reply with quote

Cogito,

Our shop has a firewall that does not allow us to browse FTP sites. Could you please post the return codes in your message itself. That wud of great help to me.

Also, please let me know whether the syntax I used for allocating to SYSOUT=* was right. ( I used three different commands, but none of them worked). Please guide me,

Thanks,
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Jul 09, 2004 10:46 am    Post subject: Reply with quote

Try
Code:

"ALLOC FI(SYSOUT) DA(*)"


FI and DD are practically the same.

In any case, here is the return-codes part:
Quote:

Return Codes
When BPXWDYN is called as a REXX function or subroutine, the return code can be accessed in RESULT or as the value of the function. When called as a program, the return code is available in R15.

BPXWDYN returns the following codes:

0
Success
20
Invalid parameter list. See Calling Conventions for parameter list formats.
-21 to -9999
Key error
-100nn
Message processing error. IEFDB476 returned code nn.
>0
Dynamic allocation or dynamic output error codes

Understanding Key Errors
The low order two digits is the number of the key that failed the parse, offset by 20. The first key will have the value 21.

The high order two digits is a diagnostic code that indicates where in the code the parse failed. If the high digits are 0, the key itself was probably not recognized. Other values usually indicate a problem with the argument for the failing keyword. Likely causes are blanks in arguments that are not quoted and spelling of key names.


Understanding Dynamic Allocation Error Codes
The return code contains the dynamic allocation error reason code in the high two bytes and the information reason code in the low two bytes.

You can use the high four hex digits to lookup the error code in the dynamic allocation error reason codes table found in the Application Development Guide for Authorized ASM Programs.


Understanding Dynamic Output Error Codes
The return code contains the dynamic output return code in the high two bytes (S99ERROR) and the information code (S99INFO) in the low two bytes.

You can use the high four hex digits to lookup the error code in the dynamic output return codes table found in the Application Development Guide for Authorized ASM Programs and the low four digits to look up the information code.

There is no indication of the key that is in error.

Some of the most likely reason codes are:

300-30C,312,380
Make sure the arguments are specified correctly
401
The output descriptor already exists
402
The output descriptor does not exist
403
Output descriptors created by JCL cannot be deleted by dynamic output
Messages are not produced for dynamic output errors.

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Jul 12, 2004 8:46 am    Post subject: Reply with quote

Hi All,

Thanks a lot for all you help.

I Still have some problems directing a output file to SYSOUT=*. The Syntax provided in the BPXWDYN documentation didn't work for me. I'm not sure whether I made any mistake. Please guide me.

Syntax:
Code:

SYSOUT[(class)]

Specifies that a sysout data set is to be allocated and optionally defines the output class


SUBSYS(subsys name[,subsys parm]...)


The following command failed with a return code of 002M
Code:

' ALLOC DD(OUTRPT) SYSOUT(*) '


I tried Cogito's solution
Code:

"ALLOC FI(SYSOUT) DA(*)"

This didn't work either.

But when I tried giving the below command, It worked fine.
Code:

' ALLOC DD(OUTRPT) SYSOUT '


I am not sure how this worked ? (Is '*' the default class always or does that vary with installations ?) and If I have to specify some classes other than '*' how do I specify them ?

2. When I create any file using BPXWDYN, the file name is not listed in JCL but I could see them in the JESYSMSG. This wud spoil the whole purpose of hiding the filename. Is there any way to keep the file & its name totally hidden ? or do I have to go for Temporary datasets ?

Thanks in advance,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group