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
 

 

Calling DB2 API's in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
aviswam

New User


Joined: 17 Mar 2009
Posts: 9
Location: India

PostPosted: Wed Sep 12, 2012 9:57 pm    Post subject: Calling DB2 API's in REXX
Reply with quote

Hi,

We are having a REXX code in our system, which is calling the DB2 API's and fetching the active thread details for a particular database.

Now it seems like the code is not working as intended,
when ever their is active threads from queryman, the code is supposed to write the details about the token no in the output dataset, which will be used in the subsequent steps to cancel the thread.

We are at DB2 version 9.1 and even if there are active threads from queryman the RC is not set to 1.

It would be great if someone could look at the code, provide pointers to where to zoom in to fix the code


Code:
CMD = '-DIS DB('||dbname||') SP('||tsname||') USE LIMIT(*)'
say CMD
call Command_Processor
alpha = alpha + 1
DO WHILE ( OFFSET < TOTLEN )
  LEN = C2D(SUBSTR(RTRNAREA,OFFSET,2))
  SEQNO = SEQNO + 1
  TEXT = SUBSTR(RTRNAREA,OFFSET+4,LEN-4-1)
  SAY TEXT
  If thfound = 'Y' & pos('MEMBER NAME',TEXT) = 0 Then
    Do
      strpos = pos('=',TEXT) + 1
      thnbr  = word(substr(TEXT,strpos),1)
    End
  If thfound = 'Y' & pos('MEMBER NAME',TEXT) > 0 Then
    Do
      strpos = pos('MEMBER NAME',TEXT)
      thssid = word(substr(TEXT,strpos),3)
      outline.1 = thssid||' CAN THREAD('||thnbr||')'
      "EXECIO 1 DISKW sysout (STEM outline." /* write line */
      thfound = 'N'
      exitrc = 1
    End
  If pos('queryman.exe',TEXT) > 0 Then thfound = 'Y'
  OFFSET = OFFSET + LEN
END
 
call Disconnect_DB2
Exit exitrc
/**********************************************************************/
/* Command_Processor                                                  */
/*                                                                    */
/* Description:                                                       */
/* Issue commands to DB2                                              */
/**********************************************************************/
Command_Processor:
IFCA = '00B4'X||'  IFCA    '||COPIES('00'X,24)'    '
IFCA = IFCA||'0000'X||COPIES(' ',34)||'0000'X
IFCA = IFCA||COPIES(' ',18)||'0000'X||COPIES(' ',82)
IFCA2 = IFCA
COMMAND = SUBSTR("COMMAND",1,18)
RTRNAREASIZE = 131072
RTRNAREA = D2C(RTRNAREASIZE+4,4)LEFT(' ',RTRNAREASIZE,' ')
BUFFER = '00000000'X||'WBUF'||'0000000000000000'X
 
OUTPUT = D2C(LENGTH(CMD)+4,2)||'0000'X||CMD
ADDRESS LINKPGM "DSNWLI2 COMMAND IFCA RTRNAREA OUTPUT BUFFER"
RETCD = C2D(SUBSTR(IFCA,13,4))
REASCD = D2X(C2D(SUBSTR(IFCA,17,4)))
If RETCD <> 0 & REASCD <>  'E60820' Then Do
   Say 'Command did not complete'
   Say 'RETCODE = ' RETCD
   Say 'REASON = ' REASCD
End
 
TOTLEN = C2D(SUBSTR(IFCA,20+1,4))
SEQNO = 0
OFFSET = 4+1
Return



Anu
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Sep 12, 2012 10:10 pm    Post subject:
Reply with quote

And the trace from this code is...?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Sep 12, 2012 10:18 pm    Post subject: Reply to: Calling DB2 API's in REXX
Reply with quote

what was the content of TEXT when You displayed it ???
would have been nice to know icon_cool.gif

also any reason to expect a windoze thing queryman.exe in a zOS environment ???
Back to top
View user's profile Send private message
aviswam

New User


Joined: 17 Mar 2009
Posts: 9
Location: India

PostPosted: Wed Sep 12, 2012 10:48 pm    Post subject: Re: Reply to: Calling DB2 API's in REXX
Reply with quote

enrico-sorichetti wrote:
what was the content of TEXT when You displayed it ???
would have been nice to know icon_cool.gif

also any reason to expect a windoze thing queryman.exe in a zOS environment ???



The TEXT variable is just displaying the output of
-DIS DB (DBNAME) command

I have no idea how queryman is creating a thread in the DB :-(

The Requirement is to get all the token no for the threads for a particular DB, and i have no clue how this REXX serves the purpose icon_rolleyes.gif
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: Wed Sep 12, 2012 10:54 pm    Post subject:
Reply with quote

DB2 9.1 usually means DB2 for LUW not DB2 for z/OS.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Sep 12, 2012 10:59 pm    Post subject: Reply to: Calling DB2 API's in REXX
Reply with quote

Quote:
and i have no clue how this REXX serves the purpose


and if You have no clue why do You meddle ?

I do not give a damn about Your description/understanding ...
I want to SEE the string so I can explain to You if/why the statements that follow work/do not work

icon_evil.gif
Back to top
View user's profile Send private message
aviswam

New User


Joined: 17 Mar 2009
Posts: 9
Location: India

PostPosted: Thu Sep 13, 2012 12:13 pm    Post subject: Reply to: Calling DB2 API's in REXX
Reply with quote

Apologies enrico,

it was never my intention to hide any details of the code
pls find below the TEXT when i just displayed that,

Code:
DSNT360I  DSNT ***********************************
DSNT361I  DSNT *  DISPLAY DATABASE SUMMARY
               *    GLOBAL USE
DSNT360I  DSNT ***********************************
DSNT362I  DSNT     DATABASE = XXXXXXXX  STATUS = RW
                  DBD LENGTH = XXXXX
DSNT397I  DSNT
NAME     TYPE PART  STATUS            CONNID   CORRID       USERID
-------- ---- ----- ----------------- -------- ------------ --------
XXXXXXXXX TS         RW
******* DISPLAY OF DATABASE R5INVTMG ENDED      **********************
DSN9022I  DSNT DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION



I am on DB2 version 9 on ZOS
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Sep 13, 2012 1:12 pm    Post subject: Reply to: Calling DB2 API's in REXX
Reply with quote

it works as designed ... ( as written, with the data posted )
the REXX scripts looks for the strings
queryman.exe and the string is not there ...
'MEMBER NAME' and the string is not there ...

also any reason to have two consecutive IFs for exactly the same condition ?

if You do not come up with consistent script/data info the topic is going to be locked and delete

anyway nothing You could not have found Yourself!
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Fri Sep 14, 2012 2:31 pm    Post subject:
Reply with quote

I'm pretty sure the output of -DIS DATABASE USE has changed in db2 9 vs db2 version 8.
So any rexx who interpretes the output should be changed accordingly.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm


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