Application Development and Automation 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: 
Read only

back, cancel, exit etc.

Former Member
0 Likes
6,197

hey there,

I already have a cancel, exit and back button and i know how to make them leave the program but i don't know how i can go one screen back with the 'back' button (not go to screen XXX, just one screen back wherever you are) and i don't know what the differnce between the exit and the cancel button is and what should happen if someone uses them in my program.

and then there is always an error message if i want to leave the actual screen with fields that have to be filled... but i don't want to fill those fields if i leave the screen anyway... how can i bypass that.

i found a forum post titled "back cancel exit" but there is no answer for my problem in it...

thx for any help!

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,928

Hi,

When you use the back button it will go to the previous screen only.

For that you have to use leave

Diffrence is .

BACK : When press back it will goto the previous screen.

EXIT : It will go to the first screen.

CANCEL: Say you have mandatory fields on your screen.Without

entering values in mandatory fields ,if you want to go out

of the screen CANCEL will work.

8 REPLIES 8
Read only

Former Member
0 Likes
2,929

Hi,

When you use the back button it will go to the previous screen only.

For that you have to use leave

Diffrence is .

BACK : When press back it will goto the previous screen.

EXIT : It will go to the first screen.

CANCEL: Say you have mandatory fields on your screen.Without

entering values in mandatory fields ,if you want to go out

of the screen CANCEL will work.

Read only

Former Member
0 Likes
2,928

hi,

When you assign a function to the standard toolbar, it is also automatically assigned to a reserved function key.

To find out the function keys to which these functions are assigned in the current status, click the Information icon in the Menu Painter.

When the user triggers a function with type ' ' using a button, menu entry, or function key, the system places the relevant function code in the OK_CODE field of the screen.

To allow you to process this field in the PAI event, you must assign a name to the field, which you enter in the element list in the Screen Painter. You must then create a field in your ABAP program with the same name. During the automatic field transport at the beginning of the PAI event, the function code is passed from the screen to the corresponding field in the program.

To avoid the function code leading to unexpected processing steps on the next screen (ENTER does not usually change the command field), you should initialize the identically named ABAP field. The initial value is then automatically transported to the corresponding command field at PBO.


MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.

The SAP Style Guide contains details of how you should set the navigation functions Back, Exit, and Cancel.

The Back and Cancel functions should lead one logical level backwards. From screens on the same level as the initial screen, they lead back to the initial screen. From screens that contain detailed information, they lead back to the screen that called the current screen.

The Cancel function differs from Back in its dialog behavior.

The Exit function should return to where the processing unit was called.

On the initial screen of a program, all three functions Back, Exit, and Cancel lead back to the screen from which the current program was called.

The SAP Style Guide provides a slight change in the navigation functions for single-screen transactions.

Back exits the current transaction and returns to the calling program (for example, the Workplace). The

function works like Exit.

Exit exits the current transaction and returns to the calling program (for example, the Workplace).

The functions Exit and Back are different in terms of their dialog behavior to prevent losing input data.

Cancel displays the screen again with initialized data fields and allows the user to select a new object.

Back Exit

Saves dialog Yes Yes

Checks entries Yes yes

Sequence Checks, then First check then save

"Save" dialog

Function type ' ' 'E'

Function module popup_to_ pop_up_

for dialog confirm_step to_confirm_step

If the user has entered data on the screen (sy-datar = 'X' or your own flag), you can avoid accidental loss

of data by using a predefined security prompt.

As well as specifying the targets of the Back, Exit, and Cancel functions, the SAP Style Guide also

contains information about the dialogs that you should conduct with the user, and the sequence of

dialogs and automatic field checks.

For the Exit and Cancel functions, you should first send a dialog box to the user. Then (in the case of the

Exit function), the system checks the input on the screen. The functions in question must have function

type 'E'.

In the case of the Back function, the input checks come before the dialog.

To solve this problem

and then there is always an error message if i want to leave the actual screen with fields that have to be filled... but i don't want to fill those fields if i leave the screen anyway... how can i bypass that.

If the user chooses a pushbutton that has the function type ' ' (space), the PAI event is processed.

If the user chooses a pushbutton that has the function type "E", the system processes a module with the

addition AT EXIT-COMMAND. This happens before the automatic field transport and the field input

checks. The system places the function code that has been triggered into the OK_CODE field, which you

can then query in the module.

After the AT EXIT-COMMAND module, the system continues processing the screen normally (field input

checks, followed by PAI processing).



MODULE exit INPUT.
CASE ok_code.
WHEN 'CANCEL'.
CLEAR ok_code.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

Hope this helps, Do reward.

Edited by: Runal Singh on Mar 19, 2008 2:01 PM

Read only

Former Member
0 Likes
2,928

Hi,

For going back to the previous screen, try

LEAVE TO SCREEN 0. 

Sample code



CASE OKCODE.
  WHEN 'BACK'.
    LEAVE TO SCREEN 0.
  ...
ENDCASE.

Hope this helps.

Thanks,

Balaji

Read only

Former Member
0 Likes
2,928

hai rafee,

when 'BACK'.

Leave screen.

when 'CANCEL'..

LEAVE TO PROGRAM.

when 'EXIT'.

LEAVE PROGRAM.

"Even though Mandatory fields are not field then we can come to main screen.

regards.

Eshwar.

Read only

Former Member
0 Likes
2,928

hi,

To leave exactly one screen back.

Just you have to declare

LEAVE TO SCREEN 0.

1.BACk- Leave to one Screen Back.

2. Cance- when done changes to screen and trying to go back

and when you want to be in the same screen at that time you cancel

it will make to be in the same screen.

3. EXIT-this exit from the application itself .

reg: POP_UP_MESSAGE-

If there are any mandatory fields in that screen it will popup error message

to enter the mandatory values.

Read only

Former Member
0 Likes
2,928

with back when u do codin in PAI like:

when back.

call screeen 101.

where 101 is previous screen no it will obviously go back to the previous screen

now the difference between exit and cancel

Exit helps us to leave the appication or our curerent program.

ie we do coding like this for exit in PAI.

WHEN EXIT.

LEAVE PROGRAM.

and the same way if we have created exit button in menu painter of function-code type 'E' then we create one module in PAI ie:

MODULE EXIT AT EXIT_COMMAND and do coding for it

when exit.

leave program.

cancel helps us to clear the contents of the fields we have entered in the screen.for cancel we can do coding in the PAI ie

CASE OK-CODE.

WHEN CANCEL.

CLEAR OK-CODE.

LEAVE TO SCREEN 100.

or anothe way could be

a pop up asking do you want to save data would appear when u press cancel by calling a function module

POP_UP_TO_DISPLAY. for that.

in this case when you press yes data should be saved to the database and when you press no codin would be say: LEAVE SCREEN. or LEAVE PROGRAM.

now if you want to exit the application when user presses cancel and he has not entered anything on the screen ie no validations shoud take place.no pop asking do you want to save data should appear and user must exit the application.

for this in coding of cancel firsly check if user has entered anything ie:

WHEN CANCEL.

IF SY-SUBRC = 0.

LEAVE PROGRAM

ELSE

< DO CODING TO CALL FUNCTION MODULE FOR

POP UP>

ENDIF.

this would solve the problem

reward if useful.

Read only

Former Member
0 Likes
2,928

thx for all your help...

but "call screen XXX" or "leave to screen XXX" doesnt work...

and i still don't know how to ignore mandatory fields when someone triggers cancel

im a bit hard of understanding...

only the pai event on screen 100 seems to work... can't i make a user_command module in include dynpros?

maybe i should read more in my abap book

Read only

0 Likes
2,928

LEAVE TO SCREEN 0

This line backs up using the screen stack. You do NOT want to leave to another screen number than 0.

To ignore the required fields, you likely need to set the CANCEL in your GUI STATUS so that function type is E and handle CANCEL in the MODULE exit_0100 AT EXIT-COMMAND.