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
 

 

Updating table's keyfield using panel

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
View previous topic :: :: View next topic  
Author Message
rameyshkanthan v

New User


Joined: 15 Nov 2013
Posts: 10
Location: India

PostPosted: Fri Nov 22, 2013 4:49 pm    Post subject: Updating table's keyfield using panel
Reply with quote

Hi All,

I am new to ISPF/REXX.

I wrote a program to insert,modify,delete a table row thru panel.
All functionality are working fine but when I try to update a key field of my table,the updated one is getting inserted as a new row. I used TBMOD function for this.

Here is my code , Tablename : TSTABL1 Key: Keyfld Namefield: name1 name2 name3
Code:

'TBOPEN 'TSTABL1''                                                     
cursor = 0                                                           
do forever                                                             
  option = ' '                                                       
   'TBTOP 'TSTABL1''                                                 
   'TBSKIP 'TSTABL1' NUMBER('cursor')'                           
   'TBDISPL 'TSTABL1' PANEL(RANE001)'                             
   if RC  = 8 then leave                                         
   var = ZTDSELS                                                 
   if var > 0 then do                                             
     do o = 1 to var                                             
       'CONTROL DISPLAY SAVE'                                     
          call tab_handle                                         
       'CONTROL DISPLAY RESTORE'                                       
       if ZTDSELS = 1 then nop                                         
       else 'TBDISPL 'TSTABL1''                                     
     end                                                               
   end                                                               
end                                                                   
'TBCLOSE 'TSTABL1''                                                     
exit                                                                 
                                                                       
/*-----------------------BEGIN PROCEDURES-----------------------------*/
tab_handle:                                                           
  select                                                               
    when option = 'I' then do                                         
      'ADDPOP'                                                         
      'DISPLAY PANEL(RANE002)'                                         
      if RC = 0 then 'TBADD 'TSTABL1''                                 
      'REMPOP'                                                         
    end                                                                 
    when option = 'D' then do                                           
      'ADDPOP'                                                         
      'DISPLAY PANEL(RANE003)'                                         
      if DELOK = 'Y' then 'TBDELETE 'TSTABL1''                         
      'REMPOP'                                                         
       DELOK = 'N'                                                     
    end                                                               
    when option = 'M' then do                                           
      'ADDPOP'                                                         
      'DISPLAY PANEL(RANE004)'                                         
      if RC = 0 then 'TBMOD 'TSTABL1''                                 
      'REMPOP'                                                       
    end                                                                 
    otherwise nop                                                       
  end                                                                   
return       


Please clarify whether it can be done.

CODE tags added
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Nov 22, 2013 5:23 pm    Post subject:
Reply with quote

Not sure if I remember correctly, but you may have to delete the old record and insert the new record if you are updating a key variable.

also, please learn very quickly to use the code tags - shown below

Code:
[code]
your code goes here
[/code]
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Fri Nov 22, 2013 5:35 pm    Post subject:
Reply with quote

TBMOD, IMNSHO, is a dangerous thing to use, as there are too many assumptions made so that it will never fail; it's better to use TBPUT, check the return code, and then use TBDELETE/TBADD if necessary.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 662
Location: Pennsylvania

PostPosted: Fri Nov 22, 2013 6:21 pm    Post subject:
Reply with quote

You can not 'update' the key fields.

If you want to let the user think that is what is being done, then fine.

You will need to keep track of the old key, then do a TBDELETE/TBADD as stated above.

I however do not allow the KEY fields to be updatable on the screen.

I make the user do the Add/Delete so that they understand the Database better.

There is an alternative. You can TBCREATE the table with out any key fields.

This way you can use a TBPUT which behaves like this (from the manual):
Quote:
For tables without keys, the row pointed to by the CRP is always updated.
Back to top
View user's profile Send private message
rameyshkanthan v

New User


Joined: 15 Nov 2013
Posts: 10
Location: India

PostPosted: Fri Nov 22, 2013 6:35 pm    Post subject: Reply to: Updating table's keyfield using panel
Reply with quote

Thanks all.

I will go with daveporeclan view,"I however do not allow the KEY fields to be updatable on the screen.

I make the user do the Add/Delete so that they understand the Database better."


icon_biggrin.gif
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 unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts ISPF - How to come out of ISPF Panel parasmalik20 TSO/ISPF 5 Tue Feb 21, 2017 7:44 pm


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