‎2009 Jul 31 12:48 AM
I have an application where users enter texts which get stored in a structure. I want a funcitonaluty to tell users when they close the application to make sure that unsaved data is saved before exiting the application.
So i will take the current structure and compare it with the data from the database and then prompt them to save the data.
Is it possible to compare two structures directly without checking for each field of the structure.
Thanks for your help
Regards
Sunil
‎2009 Jul 31 6:51 AM
Hi!
I guess this wont be the best approach to check out whether the user has save the data or not! It may happen that user will do some changes and then have the same entries while saving.
I had a similar requirement. If you are writing dialog program, what you can do is set a flag..(say save_flag), whenever the user saves data. When user tries to exit from application, check the status of of flag. If its set, exit else pop up a message to prompt user to save it.
Please correct me if I am wrong.
PAI-->
MODULE USER_COMMAND_9009 INPUT.
when 'BACK'.
IF SY-TCODE = trans_chg.
if save_flgh = 1 and save_flgi = 1.
LEAVE Program.
clear: save_flgh,save_flgi.
else.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Save Changes'
TEXT_QUESTION = 'The data is not saved, do you wish to save it?'
TEXT_BUTTON_1 = 'YES'(001)
TEXT_BUTTON_2 = 'NO'(002)
IMPORTING
ANSWER = answer
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if answer = 1.
wrk_header-EMPNO = EMPNO.
wrk_header-EMPCO = EMPCO.
modify ZEMPHDR from wrk_header.
if sy-subrc = 0.
save_flgh = 1.
endif.while saving-->
wrk_header-EMPNO = EMPNO.
wrk_header-EMPCO = EMPCO.
wrk_header-EMPNAME = EMPNAME.
modify ZEMPHDR from wrk_header.
if sy-subrc ne 0.
else.
save_flgh = 1.
MESSAGE s000(ztest) WITH temp_empno .
endif.Regards,
Sumit Nene.
Edited by: Sumit Nene on Jul 31, 2009 8:05 AM
‎2009 Jul 31 1:48 AM
Hi Sunil,
Try this way.
Thanks
Venkat.O
CASE SY_UCOMM.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
IF structure_1 NE structure_2.
MESSAGE w020(z7) WITH 'please save the data'.
ELSE.
LEAVE PROGRAM.
ENDIF.
ENDCASE.
‎2009 Jul 31 4:04 AM
Hi,
Try this way
Data : itab type mara.
data : jtab type mara.
pass all the data to the structure jtab from the screen and earlier values will be in itab.
even pass the sy-mandt to the jtab if required.
now
if itab <> jtab.
message 'The data has been changed Please Save it'.
endif.
you can also use the FM POP_TO_CONFIRM to get a pop in the standard way
Regards
Ramchander Rao.K
‎2009 Jul 31 6:10 AM
hi,
make two internal tables using the strucures...
and then compare those tables.. in th following way
IF it_tab1] = it_tab2[.
" Tables contents are the same
ELSE.
" Tables contents are different
\give message to save th data
ENDIF.
Regards
Ashu
‎2009 Jul 31 6:28 AM
‎2009 Jul 31 6:51 AM
Hi!
I guess this wont be the best approach to check out whether the user has save the data or not! It may happen that user will do some changes and then have the same entries while saving.
I had a similar requirement. If you are writing dialog program, what you can do is set a flag..(say save_flag), whenever the user saves data. When user tries to exit from application, check the status of of flag. If its set, exit else pop up a message to prompt user to save it.
Please correct me if I am wrong.
PAI-->
MODULE USER_COMMAND_9009 INPUT.
when 'BACK'.
IF SY-TCODE = trans_chg.
if save_flgh = 1 and save_flgi = 1.
LEAVE Program.
clear: save_flgh,save_flgi.
else.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Save Changes'
TEXT_QUESTION = 'The data is not saved, do you wish to save it?'
TEXT_BUTTON_1 = 'YES'(001)
TEXT_BUTTON_2 = 'NO'(002)
IMPORTING
ANSWER = answer
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if answer = 1.
wrk_header-EMPNO = EMPNO.
wrk_header-EMPCO = EMPCO.
modify ZEMPHDR from wrk_header.
if sy-subrc = 0.
save_flgh = 1.
endif.while saving-->
wrk_header-EMPNO = EMPNO.
wrk_header-EMPCO = EMPCO.
wrk_header-EMPNAME = EMPNAME.
modify ZEMPHDR from wrk_header.
if sy-subrc ne 0.
else.
save_flgh = 1.
MESSAGE s000(ztest) WITH temp_empno .
endif.Regards,
Sumit Nene.
Edited by: Sumit Nene on Jul 31, 2009 8:05 AM