Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to write REXX which call DB2 COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Thu May 22, 2014 6:37 pm    Post subject: How to write REXX which call DB2 COBOL program
Reply with quote

I have a REXX which will call DB2 COBOL program A and it could be executed successfully. I didn't specify any DB2 parms (SSID and PLAN) in the REXX. I just specified those DB2 related libraries in the JCL JOBLIB.
The only execution clause in REXX is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm
BBBB is the second parm

Now I want to use this REXX to call another DB2 COBOL program B. I thought this would be easy. But I got SQL return code -991.

I don't know why it doesn't work for program B. I'm not sure if it's because below difference between program A and program B:
Program A use 'DECLARE', 'OPEN', 'FETCH', 'CLOSE' to read DB2 tables.
Program B directly use 'SELECT' to read DB2 tables.

Is there anyone who knows how to write the REXX to call program B?
I searched existing topics and tried. But all failed.
I'm thinking maybe I should specify the SSID and PLAN in JCL SYSTSIN or in REXX. But I have no idea how to do it. icon_cry.gif
Could anyone help me? Thank you! icon_smile.gif
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu May 22, 2014 6:47 pm    Post subject:
Reply with quote

Hi Joyce,

Can you paste the Rexx code which was successful and which was not?


Also,What are you trying to achieve by that?
When you have JCL to do the same thing.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Thu May 22, 2014 6:55 pm    Post subject: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

I suspect that ALL your SQ: stuff must be either in the called (COBOL) program or in the calling (Rexx) program not split across the two. Did you do the connect, declare, open cursor in the Rexx program? If so, how did you pass the cursor to the COBOL program?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu May 22, 2014 7:34 pm    Post subject: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

In your "Program A", do you have calls to special routines (like DSNRLI) ?
Quote:
The only execution clause in REXX is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm
BBBB is the second parm
Because of this, I would say "Program A" is using RRSAF to connect to DB2.
Meanwhile, "Program B" returns -991 which means it should run under the DSN stub. Which means "Program B" is using CAF to connect to DB2.

Try using the following commands:
Code:
Queue "RUN PROGRAM(Program B) PARM('"YourParm"') ",
   "PLAN(YourPlan) LIB("YourLib")"                   
Queue "END"                                           
"DSN SYSTEM("YourDB2Name")"                               
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Thu May 22, 2014 7:45 pm    Post subject:
Reply with quote

Pandora-Box wrote:
Hi Joyce,

Can you paste the Rexx code which was successful and which was not?


Also,What are you trying to achieve by that?
When you have JCL to do the same thing.


Hi Pandora-Box,

I cannot access TSO now.
There is only one 'useful' clause in the successful REXX. Others are 'SAY' clause or 'AAAA=ABCD' (initialize)clause. The 'useful' clause is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm for XXXXXXXX
BBBB is the second parm for XXXXXXXX

Actually XXXXXXXX is a DB2 COBOL sub-routine program. In our production, it will be called by a main DB2 COBOL program. In production, the main program will pass parm AAAA and BBBB to XXXXXXXX and XXXXXXXX will return the required information in AAAA and BBBB to the main.

I found the result of main program is incorrect. But I'm not sure where is issue from. I don't have the right to prepare a temp CM PKG for testing as I'm working in a QA team. Else, I would add some 'DISPLAY' clause to do it.

I used the existing REXX program for several times with different sub-routine programs. It works fine. When I use it for different sub-routine program, I just replace XXXXXXXX, AAAA and BBBB (no change for JCL).

But now, it return SQL return code -991 and joblog message shows it occurs in the SQL SELECT clause in the sub-routine program B.

For my JCL, I only add those DB2 environment libraries in the JOBLIB.

I'm thinking if there is someway in JCL or REXX to tell which SSID and PLAN should be used.

Thank you
Joyce
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Thu May 22, 2014 7:53 pm    Post subject: Re: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

Nic Clouston wrote:
I suspect that ALL your SQ: stuff must be either in the called (COBOL) program or in the calling (Rexx) program not split across the two. Did you do the connect, declare, open cursor in the Rexx program? If so, how did you pass the cursor to the COBOL program?


Hi Clouston,

There is no SQL clause in my REXX.
There is only one 'useful' clause in the successful REXX. Others are 'SAY' clause or 'AAAA=ABCD' (initialize) clause. The 'useful' clause is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm for XXXXXXXX
BBBB is the second parm for XXXXXXXX

Only the DB2 COBOL program has the SQL clause. The DB2 COBOL program is a sub-routine program and it is called by DB2 COBOL main program in production.
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Thu May 22, 2014 7:59 pm    Post subject: Re: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

Marso wrote:
In your "Program A", do you have calls to special routines (like DSNRLI) ?
Quote:
The only execution clause in REXX is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm
BBBB is the second parm
Because of this, I would say "Program A" is using RRSAF to connect to DB2.
Meanwhile, "Program B" returns -991 which means it should run under the DSN stub. Which means "Program B" is using CAF to connect to DB2.

Try using the following commands:
Code:
Queue "RUN PROGRAM(Program B) PARM('"YourParm"') ",
   "PLAN(YourPlan) LIB("YourLib")"                   
Queue "END"                                           
"DSN SYSTEM("YourDB2Name")"                               


Hi Marso,

In my REXX, there is no calls to any special routines.
There is only one 'useful' clause in the REXX. Others are 'SAY' clause or 'AAAA=ABCD' (initialize) clause. The 'useful' clause is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm for XXXXXXXX
BBBB is the second parm for XXXXXXXX
So, it is using RRSAF to connect to DB2.

I cannot access TSO now. I'll try it tomorrow and then post my result here. Thank you!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu May 22, 2014 9:25 pm    Post subject: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

Quote:
Which means "Program B" is using CAF to connect to DB2.


I beg to disagree, whatever the reason IT IS NOT CAF in se
I have a couple of REXX functions using CAF
- My own implementation of REXX SQL interface -
and they work nicely
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Fri May 23, 2014 4:36 pm    Post subject: Re: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

Marso wrote:
In your "Program A", do you have calls to special routines (like DSNRLI) ?
Quote:
The only execution clause in REXX is:
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"
XXXXXXXX is the DB2 COBOL program
AAAA is the first parm
BBBB is the second parm
Because of this, I would say "Program A" is using RRSAF to connect to DB2.
Meanwhile, "Program B" returns -991 which means it should run under the DSN stub. Which means "Program B" is using CAF to connect to DB2.

Try using the following commands:
Code:
Queue "RUN PROGRAM(Program B) PARM('"YourParm"') ",
   "PLAN(YourPlan) LIB("YourLib")"                   
Queue "END"                                           
"DSN SYSTEM("YourDB2Name")"                               


Hi Marso,

I tried but it doesn't work. Error message is:
'DSNE960E PARAMETER STRING EXCEEDS ALLOWABLE LIMIT OF 100 (DECIMAL) CHARACTERS'

For program B, it has two parms. The first parm AAAA is 3795 chars in length. The second parm BBBB is 8 chars in length.

Thank you
Joyce
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Fri May 23, 2014 4:42 pm    Post subject: Re: Reply to: How to write REXX which call DB2 COBOL program
Reply with quote

enrico-sorichetti wrote:
Quote:
Which means "Program B" is using CAF to connect to DB2.


I beg to disagree, whatever the reason IT IS NOT CAF in se
I have a couple of REXX functions using CAF
- My own implementation of REXX SQL interface -
and they work nicely


Hi Sorichetti,

Do you have any sample REXX and JCL on this?

Thank you
Joyce
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Fri May 23, 2014 6:39 pm    Post subject:
Reply with quote

Enrico: I believe that the reason that the messages and codes description of the -991 SQLCODE mentions CAF is that, in the absence of any other information about the connection, DB2 will attempt to use CAF as the default.

The -991 occurs because DB2 is trying to use CAF but the program has not been properly set up for CAF execution. (Either the STEPLIB is incorrect, or the program was not linked with the CAF flavour of DSNHLI).

So, as you mentioned, CAF is not the problem. The TS needs to look at the program to figure out what connection type it has been set up for, and then make sure that the execution time requirements are met.
Back to top
View user's profile Send private message
Joyce

New User


Joined: 15 Aug 2013
Posts: 8
Location: China

PostPosted: Wed May 28, 2014 12:49 pm    Post subject:
Reply with quote

Dear All,

I found a way to call program B.

As I mentioned before, program B is a sub-routine program. It is called by main-program and let's call it program C.

At the beginning of program C, it will call another sub-routine program D to 'CONNECT' DB2.

So I added below execution clause in my REXX:
ADDRESS LINKPGM "YYYYYYYY CCCC"
YYYYYYYY is the sub-routine program D
CCCC is the parm

Now my REXX reads as below and it works for program B:
ADDRESS LINKPGM "YYYYYYYY CCCC"
ADDRESS LINKPGM "XXXXXXXX AAAA BBBB"

Thank you all! icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 3 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us