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
 

 

TBSARG fetching lastrecord of a Particular KEY in 2nd search

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
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    Post subject: TBSARG fetching lastrecord of a Particular KEY in 2nd search
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    Post subject:
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

Senior Member


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

PostPosted: Thu Jun 12, 2014 12:37 am    Post subject: Reply to: TBSARG fetching lastrecord of a Particular KEY in
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: 1219
Location: Israel

PostPosted: Thu Jun 12, 2014 6:43 pm    Post subject: Reply to: TBSARG fetching lastrecord of a Particular KEY in
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: 1219
Location: Israel

PostPosted: Thu Jun 12, 2014 6:50 pm    Post subject: Re: Reply to: TBSARG fetching lastrecord of a Particular KEY
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    Post subject:
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

Senior Member


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

PostPosted: Thu Jun 12, 2014 9:10 pm    Post subject: Reply to: TBSARG fetching lastrecord of a Particular KEY in
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> TSO/ISPF All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can we use OPTIMIZE FOR 1 ROWS for fe... cvijay784 DB2 1 Fri Aug 05, 2016 11:56 am
No new posts Search a Load Module sreekanth1984 TSO/ISPF 8 Tue Jun 07, 2016 8:45 pm
No new posts Copy one PDS to another PDS based on ... alluri12 JCL & VSAM 10 Tue Sep 29, 2015 8:10 pm
No new posts Fetching CLOB data suzeet COBOL Programming 2 Thu Jul 23, 2015 11:47 am
No new posts Search and replace the key in the report V S Amarendra Reddy SYNCSORT 1 Thu Jul 09, 2015 7:41 pm


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