Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

when click BACK then 'save yes/no'

Former Member
0 Kudos

dear All,

like mm02 when user change anything and click on back button it should ask

want to save before exit.

and when i don't change any value then it shold not ask .

for this i tried using SY-DATAR but for first screen No. '1111' its showing

SY-DATAR = 'X' a but when i make chages in another screen No '2222' it showing SY-DATAR = ' '.

also i used flag but its not working . Any other logic please.

                    • Point is assured *********

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I guess it would depend on your flag. It should work. Anytime you leave any screen, you should check the SY-DATAR flag and set your global.

If sy-datar = 'X'.
   global_datar = 'X'.
endif.

Can you post your coding?

Regards,

RIch Heilman

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I guess it would depend on your flag. It should work. Anytime you leave any screen, you should check the SY-DATAR flag and set your global.

If sy-datar = 'X'.
   global_datar = 'X'.
endif.

Can you post your coding?

Regards,

RIch Heilman

Former Member
0 Kudos

see rich

code is very big i make comment on my logic when OK_CODE = 'BACK'.

module exit_screen9006 input.

  • clear amount9006.

clear zinit.

ok_code = sy-ucomm.

case ok_code.

when 'BACK'.

if ztcode = 'ZCAPX3'.

leave to screen '9005'.

else.

**mks ON 20.07.2007 ZCAPX2 TCODE TO CHANGE OR EDIT

  • if ztcode = 'ZCAPX2' AND SY-DYNNR = '9006' AND FLAG_SAVE_CHECK = 'X'.

  • FLAG_SAVE_CHECK = ' '.

  • LEAVE TO SCREEN '9005'.

  • endif.

**mke

clear zanswer.

call function 'POPUP_TO_CONFIRM'

exporting

titlebar = 'Confirmation'

text_question = 'Do you want to save ?'

text_button_1 = 'Yes'

text_button_2 = 'No'

default_button = '1'

display_cancel_button = 'X'

importing

answer = zanswer.

case zanswer.

when 'A'.

when '2'.

if yflag ne '1'.

clear amount9006.

endif.

clear: tdetail,tdetail[],ttdetail,ttdetail[].",amount9006.

leave to screen '9005'.

when '1'.

*----


copy of function code SAVE

flag_save_check = 'X'.

if ztcode ne 'ZCAPXA'.

loop at tdetail." where zquant ne ''.

read table finalit transporting no fields with key anlhtxt = tdetail-anlhtxt

anlkl = tdetail-anlkl.

if sy-subrc = 0 .

move-corresponding tdetail to finalit.

modify finalit from finalit transporting meins zquant zamtrt zamtrs liefe anlhtxt zareapsf where anlhtxt = tdetail-anlhtxt.

else.

move-corresponding tdetail to finalit.

append finalit.

endif.

endloop.

  • move tdetail[] to ttdetail[].

clear: tdetail,tdetail[],ttdetail,ttdetail[].

leave to screen '9005'.

endif.

*----


endcase.

endif.

when 'SAVE'.

flag_save_check = 'X'.

loop at tdetail." where zquant ne ''.

read table finalit transporting no fields with key anlhtxt = tdetail-anlhtxt

anlkl = tdetail-anlkl.

if sy-subrc = 0 .

move-corresponding tdetail to finalit.

modify finalit from finalit transporting meins zquant zamtrt zamtrs liefe anlhtxt zareapsf where anlhtxt = tdetail-anlhtxt.

else.

move-corresponding tdetail to finalit.

append finalit.

endif.

endloop.

  • move tdetail[] to ttdetail[].

clear: tdetail,tdetail[],ttdetail,ttdetail[].

leave to screen '9005'.

when others.

  • loop at tdetail." where zquant ne ''.

  • read table finalit transporting no fields with key anlhtxt = tdetail-anlhtxt

  • ANLKL = tdetail-anlkl.

  • if sy-subrc = 0 .

  • move-corresponding tdetail to finalit.

  • modify finalit from finalit transporting meins zquant zamtrt zamtrs liefe anlhtxt zareapsf where anlhtxt = tdetail-anlhtxt.

  • else.

  • move-corresponding tdetail to finalit.

  • append finalit.

  • endif.

  • endloop.

move tdetail[] to ttdetail[].

endcase.

endmodule. " exit_screen9006 INPUT

0 Kudos

Well, this is a little lengthy, encapsulation of logic would help a bit, but anyway. You would need to set the global variable just before leaving any screen.

If sy-datar = 'X'.
  global_datar = 'X'.
endif.
leave to screen xxx.

Then just before calling the function module to popup, you need to again check the global variable, if it is set, then call the funciton module, otherwise don't.

Make sense?

Regards,

Rich Heilman

Former Member
0 Kudos

you are right rich,

but

if i make any chages first screen then only SY-DATAR Is set to 'X'.

actully i m changing code in second screen then sy-datar in not set to 'X'.

problem is that eventhoug i make some changes in second screen it is not asking me ' do you want to Exit' . and as a result its back to first screen without saving.

0 Kudos

<i>i m changing code in second screen then sy-datar in not set to 'X'.</i>

So you are saying that even though you have changed something in the second screen sy-datar is still not set to 'X'? If that is the case, you may want to abandon the use of this system value and simply check for changes yourself. For example, when going to that screen, first make a copy of any/all data into tmp structures and internal tables, then when leaving compare the old and new and if different, set your global varible.

Regards,

Rich Heilman

nitesh_jain3
Active Participant
0 Kudos

Dear Jim,

You'll need to go the 'Change Object' as is done by SAP normally in their standard transactions.. But yes for that you'll need to check the feasibility of creating the Change Object...

Else go the route Rich has advised..

Cheers

Nitesh

Former Member
0 Kudos

Thanks Rich.... 4 your valueable help.

Point has been given