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

TBSARG fetching lastrecord of a Particular KEY in 2nd search


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
iqbal.mallick

New User


Joined: 13 Dec 2012
Posts: 14
Location: India

PostPosted: Wed Jun 11, 2014 12:44 pm
Reply with quote

Hi,
I am new to ISPF tables and got struck with below problem.
I have designed a REXX tool which will take 3 char key from user and will search the key in ispf table(Master table) and and capture all the records which is getting satisfy with the particular key in another ISPF table(temporary) and display the temporary ispf table on the Panel

Rexx tool
Code:
Enter the 3 char key(AREA CODE):___


ISPF Table(Master table) in Readable format

Code:
KEY             NAME              ADDRESS
011             Genifer1          Home address 1
011             Genifer2          Home address 2
011             Genifer3          Home address 3
011             Genifer4          Home address 4
012             James1            Home address 1
012             James2            Home address 2
012             James3            Home address 3
013             Stacy1            Home address 1
013             Stacy2            Home address 2
013             Stacy3            Home address 3

Master table-KEYLIST(KEY NAME) NAMELIST(ADDRESS)

The issue is when the user is giving the area code 012 for the first time it is able to fetch all the data with 012 key in temporary table

Rexx tool --1st call
Code:
Enter the 3 char key(AREA CODE):012

1st call
Tempory ispf table-KEYLIST(KEY NAME) NAMELIST(ADDRESS)
Code:
012             James1            Home address 1
012             James2            Home address 2
012             James3            Home address 3


On doing F3 it is returing me to the rexx screen where the Key is being saved and again pressing enter is giving me below result

Code:
Enter the 3 char key(AREA CODE):012

2nd call
Tempory ispf table-KEYLIST(KEY NAME) NAMELIST(ADDRESS)
Code:
012             James3            Home address 3
Back to top
View user's profile Send private message
iqbal.mallick

New User


Joined: 13 Dec 2012
Posts: 14
Location: India

PostPosted: Wed Jun 11, 2014 1:09 pm
Reply with quote

Sorry forget to post the code.

REXX tool variable name:KEYVAR (3 char)

Code:
/* REXX */
PNLLIB='XXXXXX.REXXPANL' 
TABLIB='XXXXXX.TABLES'                     
MSGLIB='XXXXXX.MSGLIB' 
   
topscreen:
address ispexec "libdef ispplib dataset id('"PNLLIB"')"
address ispexec "libdef isptabl dataset id('"TABLIB"')"
address ispexec "libdef isptlib dataset id('"TABLIB"')"
address ispexec "libdef ispmlib dataset id('"MSGLIB"')"

address ispexec "display panel(rexxtool)"   

if KEYVAR<>''
then call processing
exit
                       
processing:
  KEY         = KEYVAR                                           
  Main_KEY = KEY                                         
  return_code = 0                                           
  $tn$='MAINSPF'                                           
  tblds = 'XXXXXX.ISPF.TABLES'                             
  "TBSTATS" $tn$ "STATUS1(s1) STATUS2(s2) ROWCURR(rowct)"   
   if s1 > 1 then do                         
   say "Table" $tn$ "not available."     
   exit                                   
   end; else,       
   if s2 = 1 then,                 
     "TBOPEN " $tn$ "NOWRITE"                   
   else do                                       
    address ispexec "TBEND" $tn$                 
    address ispexec "TBOPEN " $tn$ "NOWRITE"     
   end               
    "LIBDEF ISPTLIB"                   
                                           
    "TBQUERY" $tn$  "KEYS(keylist)",       
                    "NAMES(nmlist)"       
    parse var keylist "(" keylist ")"     
    parse var  nmlist "("  nmlist ")"     
    if rc=0 then do                                                   
      createTEMPISPF:                                                     
      "TBCREATE  TEMPISPF  KEYS("keylist") NAMES("nmlist") NOWRITE   SHARE"
      if rc > 0                                                         
      then do                                                           
        "TBSTATS TEMPISPF  STATUS1(s1) STATUS2(s2) ROWCURR (rowct)"       
      if s2 > 1  then "TBCLOSE TEMPISPF"                               
      signal createTEMPISPF;                                                                   
      end     

      "TBTOP "$tn$                                                                                             
      do while(return_code=0)                           
        "TBSARG MAINSPF NEXT NAMECOND(KEY,EQ)"         
        "TBSCAN MAINSPF"                               
        "TBGET  MAINSPF"                               
        if KEY=Main_KEY                               
        then do                                                                     
          address ispexec "TBADD TEMPISPF "               
        end                                             
        else return_code=8                               
        address ispexec "TBSKIP  MAINSPF"               
      end       

      "TBBOTTOM MAINSPF"                 
      "TBEND MAINSPF"                     
      "TBTOP TEMPISPF"                                         
      "TBDISPL TEMPISPF PANEL(TBLPANEL)"   
      if PFKEY='PF03' then do 
       "TBEND TEMPISPF"             
       signal topscreen;             /* Goes back to the rexx tool */               
      end                                 
      "TBEND TEMPISPF"                     
   end   
return
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Jun 12, 2014 12:37 am
Reply with quote

Show us a trace.

fyi. I think you are using SIGNAL where it should be a DO loop process. For example:
Code:
rc= 0
Do while (rc=0)
  address ispexec "display panel(rexxtool)"   

  If (rc=) & (KEYVAR<>'') Then
    call processing
End
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jun 12, 2014 6:43 pm
Reply with quote

Here are you duties for the upcoming week-end:
  1. Learn about VER in )PROC section of panel.
  2. Learn about )MODEL ROWS(SCAN) in panel.
  3. Learn about TBSARG.
  4. Rewrite your program without checking KEYVAR, without using SIGNAL and without duplicating the ISPF table.
I'll come back in a few days and check your work... icon_smile.gif
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jun 12, 2014 6:50 pm
Reply with quote

Personally, my favorite loop is:
Code:
Do Forever
   "DISPLAY PANEL(rexxtool)"
   If RC ¬= 0 Then Leave
   Call Processing
End
Exit
Back to top
View user's profile Send private message
iqbal.mallick

New User


Joined: 13 Dec 2012
Posts: 14
Location: India

PostPosted: Thu Jun 12, 2014 7:00 pm
Reply with quote

Hi,

The problem got resolved when I am using different columns names in both MAINSPF and TEMPISPF, instead of using same column names in both the tables as in the current scenario.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Jun 12, 2014 9:10 pm
Reply with quote

Quote:
I am new to ISPF tables

It is not clear if you followed Marso's advice. You should.
Back to top
View user's profile Send private message
iqbal.mallick

New User


Joined: 13 Dec 2012
Posts: 14
Location: India

PostPosted: Thu Jun 12, 2014 11:34 pm
Reply with quote

I will definately try the same as adviced by Marso
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 -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts first column truncated in search result IBM Tools 13
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top