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: 

POPUP_TO_CONFIRM_LOSS_OF_DATA: how to remain in same screen when "NO"

Former Member
0 Kudos

Hi all,

I am using POPUP_TO_CONFIRM_LOSS_OF_DATA function module to give a pop-up message when the data is changed in the screen.

I am triggering this POP-UP when the 'BACK' button is hit.

But I when we select 'NO' also in the Pop-up it is coming out of the screen. How to handle the answer = 'N' option? how to remain in the same screen when we select 'NO'.

Can anyone help me plz?

Regards,

Nag

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

You can use like this:

      CALL FUNCTION 'POPUP_TO_CONFIRM_LOSS_OF_DATA'
           EXPORTING
                TEXTLINE1 = TEXT-PC1
                TEXTLINE2 = TEXT-PC2
                TITEL     = TEXT-PC3
           IMPORTING
                ANSWER    = LV_ANSWER.

      IF LV_ANSWER = 'N' OR LV_ANSWER = 'A'.
        STOP.
      else.
*       process of loosing       
      ENDIF.

Regards,

Naimesh Patel

6 REPLIES 6

naimesh_patel
Active Contributor
0 Kudos

You can use like this:

      CALL FUNCTION 'POPUP_TO_CONFIRM_LOSS_OF_DATA'
           EXPORTING
                TEXTLINE1 = TEXT-PC1
                TEXTLINE2 = TEXT-PC2
                TITEL     = TEXT-PC3
           IMPORTING
                ANSWER    = LV_ANSWER.

      IF LV_ANSWER = 'N' OR LV_ANSWER = 'A'.
        STOP.
      else.
*       process of loosing       
      ENDIF.

Regards,

Naimesh Patel

Former Member
0 Kudos

What is the code following your call to the function module?... the logic will not normally exit the screen flow unless you tell it to, so set a break-point after the call and watch where it goes next.

Jonathan

0 Kudos

I did not write any code for the 'NO' option, but as it is standard SAP 'BACK' button, it is going out of the screen even if we select 'NO'. We need prevent exiting from the screen when 'NO' option is selected.

0 Kudos

You need to code when you have option "NO"

Like this:

      IF LV_ANSWER = 'N' OR LV_ANSWER = 'A'.
*       save data to database table here.
      else.
      
      ENDIF.

Regards,

Naimesh Patel

0 Kudos

It should not leave the screen unless you tell it to... check the PF-STATUS you are using and what is defined for the "BACK" button - does it have a special function type, or is it blank or "E"... if it has "E" then that should cause the flow logic to head into your "Module dxxx_exit-check AT EXIT-COMMAND" in PAI where you may have implemented your popup, yes? And unless you "leave screen", "set screen" etc etc, or call some other code then your logic should just follow through the subsequent PAI modules. So what happened when you put a break-point in -> where do you see it exiting your logic?

Jonathan

Former Member
0 Kudos

&----


*& Module exit INPUT

&----


  • text

----


*

*on selecting the cancel button

module exit input.

case ok_code2.

when 'CANCEL'.

data answer type c.

set hold data on.

  • if sy-datar eq 'X'.

call function 'POPUP_TO_CONFIRM'

exporting

text_question = 'Would you like to save the data?'(a02)

importing

answer = answer

exceptions

text_not_found = 1

others = 2.

case answer.

when '1'.

perform save.

when '2'.

message 'SUCCESS: EXITING...SUCCESSFUL' type 'S'.

leave program.

when 'A'.

set screen 200.

endcase.

set hold data off.

  • else.

  • leave program.

  • endif.

*on selecting the exit button

when 'EXIT'.

leave program.

endcase.

endmodule. " exit INPUT