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 

Problem with Rexx which access multiple DB2 test regions

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Feb 22, 2010 2:32 pm    Post subject: Problem with Rexx which access multiple DB2 test regions Reply with quote

Hi All,

This is my first attempt to use panels in Rexx. I have a rexx exec which interacts with multiple DB2 test regions. The rexx will through out a panel from which user can select one of the five test regions listed in the panel and input a customer number. once the user enters the customer number, the rexx will fetch the customer number from a db2 table and display the fetched data. The rexx exec is working fine for the normal fetch. But for one scenario it is failing.

Some of the DB2 DBs can be accessed from some TSO regions. If the rexx utility is not run in the correct region, it will prompt the user to run the utility in the correct region depending on the DB he selectd from the panel. But the db2 regions DBA1 and DBA2 can be accessed from TSOA. The scenario is as follows.

1. The customer number is actually present in the DBA1 test region.
2. But the customer selects DBA2 initially and enter the customer number.
3. The rexx program will throw a no matching record found error in the panel and prompt the user to enter the values again.
4. The user selects DBA1 and enters customer number and press enter.
5. Ideally he should get the results but in this scenario, user is getting "no matching recors found."

The interesting thing is that if the user uses the same customer number and selects DBA1 in the first time itself, it will give the expected results.

Here is the sturcture of my panel.


Code:
**************** Top of Data ************************
)ATTR DEFAULT(%+_)                                               
  $ TYPE(INPUT) INTENS(LOW) PAD(_) CAPS(OFF)                     
  ! TYPE(INPUT) INTENS(LOW) PAD(' ') CAPS(OFF)                   
  ` TYPE(OUTPUT) INTENS(HIGH)                                     
  { TYPE(TEXT)   INTENS(HIGH) SKIP(ON)  COLOR(GREEN)             
  } TYPE(OUTPUT)   INTENS(HIGH) SKIP(ON)  COLOR(RED)             
)BODY EXPAND(//) WIDTH(80)                                       
%/-/ XXXXXXXXXX UTILITY /-/+                                 
%COMMAND ===>_ZCMD                                               
+                                                                 
+ENTER THE %CN+           %===>$CN        +                     
+                                                                 
%/-/ SELECT THE REGION /-/+                                       
+                                                                 
+                       $N{ ==> % DBA1 +                   
+                       $T{ ==> % DBA2 +                   
+                       $P{ ==> % DBA3 +                   
+                       $W{ ==> % DBA4 +                   
+                       $B{ ==> % DBA5 +                   
+                                                                       
+ENTER%CLR+TO CLEAR ALL FIELDS OR%END+TO EXIT.                         
+                                                                       
+}TEXTLN00                                                             
+}TEXTLN01                                                             
+}TEXTLN02                                                             
+                                                                       
)INIT                                                                   
)PROC                                                                   
VER (&CN,NB)                                                           
)END                                                                   
**************************** Bottom of Data **********


Here is my REXX Exec

Code:
**************************** Start of Data **********

ADDRESS TSO                                         
"ISPEXEC LIBDEF ISPPLIB DATASET ID('panel.library')"
"ISPEXEC DISPLAY PANEL(panelname)"                   
SHOW_PANEL1:                                         
  IF RC <> 0 THEN EXIT(0)                           
  PARSE UPPER VAR ZCMD THECMD .                     
  IF THECMD = "X" THEN EXIT (0)                     
  IF THECMD = "CLR " THEN                           
    DO                                               
      PARSE VALUE "" WITH CN A B C D E                   
      ZCMD = ""                                     
      SIGNAL SHOW_PANEL                             
    END                                             
ROW1 = ' '                                           
CN = STRIP(CN)                                     
ROW1 = "SELECT * FROM ABC.TABLE WHERE CN ="           
SQLSTMT =  ROW1 || CN                                     
   SELECT                                                 
     WHEN A <> ' ' THEN                                   
        $DB2SSID=DBA1                                     
     WHEN B <> ' ' THEN                                   
        $DB2SSID=DBA2                                     
     WHEN C <> ' ' THEN                                   
        $DB2SSID=DBA3                                     
     WHEN D <> ' ' THEN                                   
        $DB2SSID=DBA4                                     
     WHEN E <> ' ' THEN                                   
        $DB2SSID=DBA5                                     
     OTHERWISE;                                           
        DO                                                 
          TEXTLN00 = 'INVALID REGION SPECIFIED'           
          TEXTLN01 = 'PLEASE ENTER THE CN AND SELECT A REGION'     
          ADDRESS TSO                                               
          "ISPEXEC DISPLAY PANEL(panelname)"                         
          SIGNAL SHOW_PANEL1                                         
        END                                                         
   END                                                               
   ADDRESS TSO                                                       
     "STEPLIB '"$DB2SSID".SDSNLOAD'"                                 
ADDRESS TSO "SUBCOM DSNREXX" /* HOST CMD ENV AVAILABLE? */           
IF RC THEN /* NO, LET'S MAKE ONE */                                 
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX') /* ADD HOST CMD ENV */   
                                                                     
SELECT                                                               
    WHEN $DB2SSID=DBA1 THEN                                         
         ADDRESS DSNREXX "CONNECT" DBA1                             
    WHEN $DB2SSID=DBA2 THEN                                         
         ADDRESS DSNREXX "CONNECT" DBA2                             
    WHEN $DB2SSID=DBA3 THEN                                         
         ADDRESS DSNREXX "CONNECT" DBA3                             
     WHEN $DB2SSID=DBA4 THEN                                           
          ADDRESS DSNREXX "CONNECT" DBA4                               
     WHEN $DB2SSID=DBA5 THEN                                           
          ADDRESS DSNREXX "CONNECT" DBA5                               
     OTHERWISE;                                                       
 END                                                                   
                                                                       
  IF RC <> 0 THEN                                                     
  DO                                                                   
   TEXTLN00 = 'ERROR CONNECTING TO ' || $DB2SSID                       
   TEXTLN00 = TEXTLN00 || '. FOR DBA1 / DBA2 ,RUN THE UTILITY IN TSOA.'
   TEXTLN01 ='FOR IMSP  (PRODUCTION) RUN THE UTILITY IN TSOC'         
   ADDRESS TSO                                                         
   "ISPEXEC DISPLAY PANEL(PANELNAME)"                                   
   SIGNAL SHOW_PANEL1                                                 
  END                                                                 
 ADDRESS DSNREXX                                                     
 'EXECSQL DECLARE C1 CURSOR FOR S1'                                   
 IF SQLCODE <> 0   THEN                                               
    DO                                                               
    SAY 'THE SQL CODE RETUREND WAS ' SQLCODE                         
    SAY ' ERROR IN DECLARING CURSOR '                                 
    EXIT                                                             
    END                                                               
 'EXECSQL PREPARE S1  FROM :SQLSTMT'                                 
 IF (SQLCODE <> 0)   THEN                                             
    DO                                                               
    SAY 'THE SQL CODE RETUREND WAS ' SQLCODE                         
    SAY ' ERROR IN PREPARING SQL '                                   
    SAY ' THE SQL IS '                                               
    SAY SQLSTMT                                                       
    EXIT                                                             
    END                                                               
'EXECSQL OPEN C1'                                                     
IF SQLCODE <> 0   THEN                                               
   DO                                                                 
    SAY 'THE SQL CODE RETUREND WAS ' SQLCODE                             
    SAY ' ERROR IN OPENING CURSOR '                                     
    EXIT                                                                 
    END                                                                 
 'EXECSQL FETCH C1 INTO :FIELD1 :FIELD2 :FIELD3
                                                                         
IF SQLCODE = 100 THEN DO                                               
    TEXTLN00 = 'NO RECORDS FOR CN ' || CN || 'IN '           
    TEXTLN00 = TEXTLN00 || $DB2SSID                                     
 ADDRESS TSO                                                         
   "ISPEXEC DISPLAY PANEL(PANELNAME)"                                   
   SIGNAL SHOW_PANEL1                                                 
AGAIN'           
    EXIT (0)                                                             
    END                                                                 
 IF SQLCODE <> 0   THEN                                                 
    DO                                                                   
    SAY 'THE SQL CODE RETUREND WAS ' SQLCODE                             
    SAY ' EITHER YOU ENTERED THE WRONG DATA OR YOU DONT HAVE AUTHORITY '
    EXIT                                                                 
    END                                                                 

Display results
**************************** Bottom of Data **********


I suspect that this is because the SDSNLOAD which was added to the steplib initially was for DBA2. But i dont know how to initialize all those values. Or should i disconnect from DBA2 before accessing DBA1?

Waiting for your valuable inputs.

Thanks & Regards
bade_miya
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Mon Feb 22, 2010 11:14 pm    Post subject: Reply with quote

bade_miya, Never tried disconnecting and then connecting to a different subsytem. But my approach will be this

Based on the ZSYSID i usually route the connection to the remote system instead of requesting the user to select. This way the rexx will work from all the regions. But if there are 2 DB2 subsystems, then what will be criteria to determine whether customer record will be there in DBA1 or DBA2. Based on that criteria, you can route to that subsystem.
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Tue Feb 23, 2010 5:17 am    Post subject: Reply with quote

I am missing the DISCONNECT statement in your REXX. If you code this at the end of your procedure, you could then start fresh for a second run of the procedure.

In this version of the REXX, the connection will stay and the results are as you have described.

regards
Christian
Back to top
View user's profile Send private message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Tue Feb 23, 2010 4:23 pm    Post subject: Thank you. Reply with quote

CZerfas, Thanks a lot. I knew i was missing something Smile. It worked as expected when i incorporated the Disconnect. But as a work around, what i did yesterday was i gave the fully qualified database name (DBA1.ABC.TABLE) and that too worked out. But i had to make a few adjustments in the code. Your solution will help me to attain the same results without changing the code much. Thanks again.
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 -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
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