My program fills a ztable taking values from the selection-screen. Now, if it a record with the same primary keys , then I need to issue a warning saying that 'Entry for the same combination already exist,'.. The user has to have an option of either cancelling the updation or go ahead with the updation. How do I go about it.
If the program is a report, then use message i.... with 'text'. It will show a message on screen and go back to the selection screen.
start-of-selection.
select single from * your ztable where ...
if sy-subrc <> 0
message ... with 'Primary key exists!!!'
else
perform the insert.
endif.
Or...
start-of-selection.
insert ztable.
if sy-subrc <> 0.
message ... with 'Primary key exists!'.
endif.
then use pop_up_to_confirm_step:
data: l_respuesta. "local variable to hold the answer.
clear l_respuesta.
call function 'POPUP_TO_CONFIRM_STEP'
exporting
defaultoption = 'N'
textline1 = 'Primary key exists in the database'
textline2 = 'Do you want to update?'
titel = 'popup Title'
* START_COLUMN = 25
* START_ROW = 6
importing
answer = l_respuesta
exceptions
others = 1.
if l_respuesta = 'J'.
modify ztable.
if sy-subrc = 0.
mesage i ... with 'Data updated'
endif.
else.
mesage i ... with 'No row updated'
endif.
No comments:
Post a Comment