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

Screen programming - Return statement

Former Member
0 Likes
540

Hi,

In the middle of a user exit, I have called a screen in which two buttons are there "SAVE and Exit".

If save button is pressed, data should update the value is table and continue with the user exit.

If exit button is pressed, nothing should happen and continue with the user exit.

My problem is, i have called this screen in the middle of the user exit. Exit button works fine, it continues with the next line of the code in the user exit.

But for save button, after updation, it returns to the first line of the user exit. But it should continue with the next line in the user exit.

Which statement will bring the control to next line of the user exit after updation.

Thanks in advance,

Ezhil.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
476

What screen are you calling? Please paste the code for SAVE user-command.

5 REPLIES 5
Read only

Former Member
0 Likes
477

What screen are you calling? Please paste the code for SAVE user-command.

Read only

0 Likes
476

Hi,

Screen is a custom screen.

Below is the code for SAVE and exit button.

{ &----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

IF sy-ucomm = 'SAVE'.

PERFORM confirm_data.

LEAVE PROGRAM.

ELSEIF sy-ucomm = 'EXIT'.

LEAVE PROGRAM.

ENDIF.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


&----


*& Form CONFIRM_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM confirm_data.

TYPES : BEGIN OF ty_data,

sfakn TYPE vbrk-sfakn,

END OF ty_data.

DATA : wa_vbrk TYPE vbrk,

it_upd TYPE STANDARD TABLE OF vbrk WITH HEADER LINE,

it_vbrk TYPE STANDARD TABLE OF vbrk WITH HEADER LINE,

ok_code TYPE sy-ucomm,

it_data TYPE STANDARD TABLE OF ty_data,

wa_data TYPE ty_data.

IF sy-ucomm = 'SAVE'.

CLEAR : wa_data.

REFRESH : it_data.

IMPORT it_data FROM MEMORY ID 'VF11'.

READ TABLE it_data INTO wa_data INDEX 1.

SELECT SINGLE * INTO wa_vbrk FROM vbrk WHERE vbeln = wa_data-sfakn.

wa_vbrk-zrbdc = ztsd_inv_cancel-zrbdc.

APPEND wa_vbrk TO it_upd.

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

mode_rstable = 'E'

tabname = 'VBRK'

varkey = 'VBELN'

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc EQ 0.

CALL FUNCTION 'DB_UPDATE_TABLE'

EXPORTING

tablename = 'VBRK'

TABLES

inttab = it_upd

EXCEPTIONS

db_error = 1

not_found = 2

wrong_param = 3

internal_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

mode_rstable = 'E'

tabname = 'VBRK'

varkey = 'VBELN'.

ENDIF.

ENDIF.

ENDFORM. "confirm_data}

Read only

0 Likes
476

LEAVE PROGRAM unloads the program from the memory. By using LEAVE TO SCREEN 0 you simply end up current screen call sequence. This causes to return to the following intruction after CALL SCREEN, hence continuing your program execution.

Regards

Marcin

Read only

0 Likes
476

Try with:

SET SCREEN 0.
LEAVE SCREEN

instead of LEAVE PROGRAM

Read only

MarcinPciak
Active Contributor
0 Likes
476

If you call the screen using CALL SCREN XXX then LEAVE TO SCREEN 0 should be enough.

However the exit might somehow try to process SAVE function too. I suggest you use different function code in your screen to enter SAVE mode.

Regards

Marcin