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: 

BACK, EXIT, CANCEL

Former Member
0 Kudos

I had called a screen from an executable program with:

CALL SCREEN 100.

How can I continue processing the remaining code of the program after the execution of flow logic in screen 100? (This will be triggered by an EXECUTE button.)

What are the codes for BACK, EXIT, CANCEL button? If those buttons have following functions:

BACK - go back to screen 100 with data filled previously. Just assumed

screen 100 as customized selection screen.

EXIT - go to SAP easy access screen.

CANCEL - back to the point where program was called.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Hong,

When you click on EXECUTE button, you can use the following code to continue with the remaining part of the program.

case sy-ucomm.

when 'EXECUTE'.

leave screen.

endcase.

You can put three push buttons BACK,SAVE,CANCEL in the screen.

The code in PAI would be

case sy-ucomm.

when 'BACK'.

LEAVE TO SCREEN 100.

when 'EXIT'.

LEAVE PROGRAM.

When 'CANCEL'.

LEAVE SCREEN.

Thanks,

Kashyap

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos

Hi Hong,

In the PBO section of your Screen '0100', you should have a module in which you should set your own PF-STATUS.

PBO of screen 0100

module status.

  • main program

module status.

set PF-STATUS 'ABC'.

endmodule.

*double click on "ABC' to create your own PF-Status. You can give the codes for the BACK, EXIT and CANC buttons.

Then in the PAI section, you can write your lagic to handle those buttons

PAI section of screen 0100

module USER_COMMAN_0100.

  • main program

module user_command_0100.

case sy-ucomm.

when '<Whatever Function code you give to BACK button>'.

leave to screen 0. "Go to the called screen

when '<Whatever Function code you give to EXIT button>'.

leave to screen 0. "Go to the called screen

when '<Whatever Function code you give to CANC button>'.

leave to screen 0. "Go to the called screen

endcase.

endmodule.

Former Member
0 Kudos

u can put buttons in the output screen when creating it so that,u can come back to the executable program..or u activate on the application tool bar or menu bar by creating the pf status.. the buttons can also b created otherwise and

write the code PAI as,

MODULE USER_COMMAND_0200 INPUT.

CASE OKCODE2. ( declare sy-ucomm as okcode2 in the screen element list..this is optional u can let it as sy comm also)

WHEN 'BACK'.

LEAVE TO SCREEN 100.

WHEN 'cancel'.

LEAVE TO SCREEN 300.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

&----


*& Module EXIT INPUT

&----


  • text

----


MODULE EXIT INPUT.

CASE OKCODE1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE.

these are the codes for back cancel and exit.

hope this will help..

reward if helps

Former Member
0 Kudos

Write the foll. code in PAI's User command.

when 'BACK'.

Use the command LEAVE TO SCREEN 100.

when 'EXIT'.

LEAVE PROGRAM.

When 'CANCEL'.

LEAVE TO SCREEN <enter the screen number>.

Hope this is helpful...

Former Member
0 Kudos

PROGRAM xxxxxx.

Just go through this hope u can get .

**********table declarations**********

&----


*& Module STATUS_1001 OUTPUT

&----


  • text

----


MODULE STATUS_1001 OUTPUT.

DATA: BEGIN OF IT_FCODE OCCURS 0,

FCODE(4),

END OF IT_FCODE.

SET PF-STATUS 'ZNPI'.

SET PF-STATUS 'ZNPI1'.

SET TITLEBAR '100'.

GET PARAMETER ID 'TCD' FIELD TCODEX.

MOVE TCODEX TO TCODE.

IMPORT MARA-GROES FROM MEMORY ID 'GV_GROES'.

IF ZNPI-MATNR IS INITIAL.

GET PARAMETER ID 'MAT' FIELD MARA-MATNR.

ZNPI-MATNR = MARA-MATNR.

ENDIF.

  • if MM01 then make visible BACK button, if MM02 make visible SAVE and

  • CANCEL buttons

IF TCODE = 'MM01'.

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'SAVE_BUTTON' OR

SCREEN-NAME EQ 'CANCEL_BUTTON' OR

SCREEN-NAME EQ 'BACK_BUTTON'.

SCREEN-INVISIBLE = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

REFRESH IT_FCODE.

MOVE 'SAVE' TO IT_FCODE-FCODE.

MOVE 'CANC' TO IT_FCODE-FCODE.

APPEND IT_FCODE.

SET PF-STATUS 'ZNPI' EXCLUDING IT_FCODE.

IMPORT v_rmatn FROM MEMORY ID 'R_MATNR'.

if v_rmatn is not initial.

import znpi from memory id 'ZNPI_TABLE'.

endif.

ENDIF.

IF TCODE = 'MM02'.

IMPORT V_MATERIAL FROM MEMORY ID 'ZNPI'.

if sy-subrc ne 0.

GET PARAMETER ID 'MAT' FIELD MARA-MATNR.

v_material = MARA-MATNR.

endif.

SELECT * FROM ZNPI INTO TABLE IT_ZNPI

WHERE MATNR = V_MATERIAL.

IF NOT IT_ZNPI[] IS INITIAL.

READ TABLE IT_ZNPI WITH KEY MATNR = V_MATERIAL.

IF SY-SUBRC = 0.

ZNPI-NPI = IT_ZNPI-NPI.

ZNPI-RTS = IT_ZNPI-RTS.

ZNPI-VCP = IT_ZNPI-VCP.

ENDIF.

ENDIF.

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'BACK_BUTTON' OR

SCREEN-NAME EQ 'SAVE_BUTTON' OR

SCREEN-NAME EQ 'CANCEL_BUTTON'.

SCREEN-INVISIBLE = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

MOVE 'BACK' TO IT_FCODE-FCODE.

MOVE 'SAVE' TO IT_FCODE-FCODE.

MOVE 'CANC' TO IT_FCODE-FCODE.

APPEND IT_FCODE.

SET PF-STATUS 'ZNPI' EXCLUDING IT_FCODE.

ENDIF.

IF TCODE EQ 'MM03'.

IMPORT V_MATERIAL FROM MEMORY ID 'ZNPI'.

if sy-subrc ne 0.

GET PARAMETER ID 'MAT' FIELD MARA-MATNR.

v_material = MARA-MATNR.

endif.

GET PARAMETER ID 'MAT' FIELD MARA-MATNR.

if mara-matnr is not initial.

ZNPI-MATNR = mara-MATNR.

endif.

CLEAR MARA.

SELECT SINGLE * FROM MARA WHERE MATNR = V_MATERIAL.

SELECT * FROM ZNPI INTO TABLE IT_ZNPI

WHERE MATNR = V_MATERIAL.

IF NOT IT_ZNPI[] IS INITIAL.

READ TABLE IT_ZNPI WITH KEY MATNR = V_MATERIAL.

IF SY-SUBRC = 0.

ZNPI-MATNR = IT_ZNPI-MATNR.

ZNPI-NPI = IT_ZNPI-NPI.

ZNPI-RTS = IT_ZNPI-RTS.

ZNPI-VCP = IT_ZNPI-VCP.

ENDIF.

ENDIF.

LOOP AT SCREEN.

IF SCREEN-NAME = 'ZNPI-NPI' OR

SCREEN-NAME = 'ZNPI-RTS' OR

SCREEN-NAME = 'ZNPI-VCP' OR

SCREEN-NAME = 'MARA-GROES'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME EQ 'BACK_BUTTON'.

SCREEN-ACTIVE = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

REFRESH IT_FCODE.

MOVE 'BACK' TO IT_FCODE-FCODE.

APPEND IT_FCODE.

ENDIF.

ENDMODULE. " STATUS_1001 OUTPUT

&----


*& Module USER_COMMAND_1001 INPUT

&----


  • text

----


MODULE USER_COMMAND_1001 INPUT.

EXPORT MARA-GROES TO MEMORY ID 'GV_GROES'.

CASE SY-UCOMM.

WHEN 'SAVE'.

IF TCODE = 'MM01' OR

TCODE = 'MM02'.

ZNPI-MATNR = ZNPI-MATNR.

ZNPI-NPI = ZNPI-NPI.

ZNPI-RTS = ZNPI-RTS.

ZNPI-VCP = ZNPI-VCP.

ZNPI-CHGDT = SY-DATUM.

ZNPI-USERID = SY-UNAME.

if ( znpi-rts is initial AND znpi-npi is initial AND

znpi-vcp is initial ).

delete from znpi where matnr = znpi-matnr.

MESSAGE I002(SY) WITH 'ZNPI data is incomplete'.

ELSE.

MODIFY ZNPI.

IF SY-SUBRC = 0 .

MESSAGE I002(SY) WITH 'ZNPI data changes were successful'.

ENDIF.

ENDIF.

IF SY-SUBRC = 0.

UPDATE MARA SET GROES = MARA-GROES WHERE MATNR = ZNPI-MATNR.

ENDIF.

EXPORT ZNPI-MATNR TO MEMORY ID 'ZNPI'.

ENDIF.

SET SCREEN 0.

LEAVE SCREEN.

WHEN 'ENTER'.

IF TCODE = 'MM01' OR

TCODE = 'MM02'.

ZNPI-MATNR = ZNPI-MATNR.

ZNPI-NPI = ZNPI-NPI.

ZNPI-RTS = ZNPI-RTS.

ZNPI-VCP = ZNPI-VCP.

ZNPI-CHGDT = SY-DATUM.

ZNPI-USERID = SY-UNAME.

if ( znpi-rts is initial AND znpi-npi is initial AND

znpi-vcp is initial ).

delete from znpi where matnr = znpi-matnr.

MESSAGE I002(SY) WITH 'ZNPI data is incomplete'.

ELSE.

MODIFY ZNPI.

IF SY-SUBRC = 0 .

MESSAGE I002(SY) WITH 'ZNPI data changes were successful'.

ENDIF.

ENDIF.

IF SY-SUBRC = 0.

UPDATE MARA SET GROES = MARA-GROES WHERE MATNR = ZNPI-MATNR.

ENDIF.

EXPORT ZNPI-MATNR TO MEMORY ID 'ZNPI'.

ENDIF.

SET SCREEN 0.

LEAVE SCREEN.

WHEN 'CANC'.

IF TCODE = 'MM01' OR

TCODE = 'MM02'.

SET SCREEN 0.

LEAVE SCREEN.

ENDIF.

WHEN 'BACK'.

IF TCODE = 'MM03' OR

TCODE = 'MM02' OR

TCODE = 'MM01'.

SET SCREEN 0.

LEAVE SCREEN.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_1001 INPUT

Thanks

abdul_hakim
Active Contributor
0 Kudos

Hi Lee,

You need to use the statement SET PF-STATUS xxxx in PBO of the screen to declare the GUI attributes for eg BACK,EXIT and CANCEL Buttons and u have to validate the same in PAI event of the screen.use the transaction ABAPDOCU for sample programs of this topic.

Cheers,

Hakim

Former Member
0 Kudos

Thanks for all the replies.

The PF-STATUS do help for those three buttons. However, i had LEAVE TO LIST-PROCESSING when press execute button, so the PF-STATUS does not work.

Former Member
0 Kudos

Hi Hong,

When you click on EXECUTE button, you can use the following code to continue with the remaining part of the program.

case sy-ucomm.

when 'EXECUTE'.

leave screen.

endcase.

You can put three push buttons BACK,SAVE,CANCEL in the screen.

The code in PAI would be

case sy-ucomm.

when 'BACK'.

LEAVE TO SCREEN 100.

when 'EXIT'.

LEAVE PROGRAM.

When 'CANCEL'.

LEAVE SCREEN.

Thanks,

Kashyap

Former Member
0 Kudos

Set pf-status for list buffer screen by suppress dialog. Another alternative may be leave to list processing and return to screen. However, this only apply to BACK button.