Skip to Content
author's profile photo Former Member
Former Member

when click BACK then 'save yes/no'

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 *********

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jul 21, 2007 at 02:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2007 at 03:01 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • <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

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2007 at 02:42 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Jul 22, 2007 at 06:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:24 AM

    Thanks Rich.... 4 your valueable help.

    Point has been given

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.