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

Calling DB2 API's in REXX


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 1788
Location: Bloomington, IL

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

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Sep 12, 2012 10:18 pm
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
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: 765
Location: Whitby, ON, Canada

PostPosted: Wed Sep 12, 2012 10:54 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Sep 12, 2012 10:59 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Sep 13, 2012 1:12 pm
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: 1281
Location: Belgium

PostPosted: Fri Sep 14, 2012 2:31 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


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