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
cursor = 0
option = ' '
'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'
'CONTROL DISPLAY RESTORE'
if ZTDSELS = 1 then nop
else 'TBDISPL 'TSTABL1''
when option = 'I' then do
if RC = 0 then 'TBADD 'TSTABL1''
when option = 'D' then do
if DELOK = 'Y' then 'TBDELETE 'TSTABL1''
DELOK = 'N'
when option = 'M' then do
if RC = 0 then 'TBMOD 'TSTABL1''
Joined: 03 Oct 2009 Posts: 1789 Location: Bloomington, IL
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.