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: 

Problem with sub-screen <actions on Cancel button>

Former Member
0 Kudos

Hi all,

I have a problem with sub-screen.

I created a subscreen (screen sequence in MM01/MM02/MM03). When users leave this screen, I call POPUP_TO_CONFIRM to ask if they want to save the data.

1) My goal is: when they choose Cancel, no actions are performed and users will see the current screen. However, I cannot use command: SET SCREEN 0 or LEAVE TO SCREEN 0 because the system gives an error message:

 *SET SCREEN not allowed in subscreens*. 

2) How can we determine when the user leaves the screen? which value of SY-UCOMM will be used to check this?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

for dis SET SCREEN is not required.

Consider d code given below as n eg:

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = 'SAVE'

text_question = 'SOME _QUS'

text_button_1 = 'YES'

text_button_2 = 'NO'

default_button = '2'

display_cancel_button = ' '

IMPORTING

answer = l_ans

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e066.

ENDIF.

IF l_ans EQ '1'. " when yes is pressed

MODIFY db.

commit work.

leave program.

ELSEIF l_ans EQ '2'. "when no is pressed

leave program.

ELSE. " when cancel is pressed

ENDIF.

In above module when Yes is pressed it saves data den leave prog.

As no action is specified for cancel button it will remain on that screen only from which popup is called, in this way ur problem can be solved.

Reward properly.

8 REPLIES 8

Former Member
0 Kudos

for dis SET SCREEN is not required.

Consider d code given below as n eg:

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = 'SAVE'

text_question = 'SOME _QUS'

text_button_1 = 'YES'

text_button_2 = 'NO'

default_button = '2'

display_cancel_button = ' '

IMPORTING

answer = l_ans

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e066.

ENDIF.

IF l_ans EQ '1'. " when yes is pressed

MODIFY db.

commit work.

leave program.

ELSEIF l_ans EQ '2'. "when no is pressed

leave program.

ELSE. " when cancel is pressed

ENDIF.

In above module when Yes is pressed it saves data den leave prog.

As no action is specified for cancel button it will remain on that screen only from which popup is called, in this way ur problem can be solved.

Reward properly.

0 Kudos

Thank Brajvir for quick reply.

Actually, I also did leave blank when Cancel is pressed. But 'coz this is a sub-screen, so after the code in its PAI it go to the process of main screen.

For example, this sub-screen is displayed as one of tabs in transaction MM02. When I leave this tab to go to another tab, or leave MM02, I need to pop up the question. When I leave no code in CANCEL part, it still goes to another tab.

So, my question is: I want to stay at the current when pressing CANCEL.

2) which value of SY-UCOMM to check in my scenario?

Thank you.

0 Kudos

Hi

U should insert a break-point in the PAI of your subscreen and check the value of SY-UCOMM where the pushbutton or the icon to leave the screen is pressed.

We can't know that value because wa can't know where you've placed your subscreen.

For example I saw if I press the icon to back (when I'm in the view for base data) the value of the sy-ucomm is BABA, but I can't know if it's good for you.

Max

Edited by: max bianchi on Mar 19, 2008 10:51 AM

0 Kudos

Thank Max,

Your suggestion is great. I will try to get the right value of sy-ucomm.

About the my first question, do you have any ideas?

0 Kudos

Hi

I suppose u need only to clear all variable for OK-CODE: so SY-UCOMM but also the variable defined in the main screen where your subscreen is placed.

Max

0 Kudos

Thank you all,

Max, your suggestion is close to my solution. Thank you so much.

After hours of debugging MM02, I found the structure that stores OK-CODE and it used FM GET to retrieve the value of OK-CODE.

I cannot change directly the value, instead I have to use FM SET to overwrite the OK-CODE of the system.

For example, when users go to my tab, it sets OK-CODE = SP30 (and SY-UCOMM as well. Actually, we cannot depend on SY-UCOMM too much, it will change value for every action, use OK-CODE instead).

When he/she leaves the screen, OK-CODE is changed to different values. Re-setting values of SY-UCOMM or OK-CODE is useless because after the program leaves my sub-screen, it does not access their values but it will retrieve values from memory via FM GET, I suppose.

Because this is sub-screen, any code relating to SET SCREEN 0 or LEAVE SCREEN is impossible. It will cause error message.

Once again, thank you all.

Former Member
0 Kudos

Create a screen with message 'Do you want to log off'.

call tat screen starting at 60 5..

case 'LOGOUT'.

when 'YES'.

clear w_podoc.

clear w_doc.

call screen 100.

when 'NO'.

message 'ACTION CANCELLED' type 'I'.

set screen 0.

leave screen.

endcase.

Try this.

Reward if helpful.

Thanks,

Chinmaye

Edited by: chinmaye ramamurthy on Mar 19, 2008 11:54 AM

Former Member
0 Kudos

Same kind of development I've also done, U don't need to give POPUP_TO_CONFIRM explicitly, system itself ask.

Also subscreen can't have OK_CODE so can't use SY-UCOMM in PAI of subscreen.

I think it's sufficient, still if have any doubt pls fill free to ask.

don't forget to reward,

S@meer