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

Calling a Subroutine

Former Member
0 Likes
692

Hi Experts

I have the requirement as follows:

When I press /N or Exit Button(Yellow Arrow) from the screen, it shoud trigger a subroutine to reset some variables or entries.

How to do this?

Rewardable

Santo!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
668

hi,

Check the ok code of it in debug mode and write the perform based on that ... check out SY-UCOMM to know that ...

Regards,

Santosh

Hi Experts

I have the requirement as follows:

When I press /N or Exit Button(Yellow Arrow) from the screen, it shoud trigger a subroutine to reset some variables or entries.

How to do this?

Rewardable

Santo!

4 REPLIES 4
Read only

Former Member
0 Likes
669

hi,

Check the ok code of it in debug mode and write the perform based on that ... check out SY-UCOMM to know that ...

Regards,

Santosh

Read only

0 Likes
668

Hi,

in PAI, create a module EXIT_COMMAND.

module EXIT_COMMAND.

if ok_code = 'BACK'.

...

endif.

endmodule.

Read only

Former Member
0 Likes
668

hope you are having this requirement for a custom screen and not a standart sap screen.

for custom screen, you would have set the ok code for the yellow button in the PF-STATUS settings. Use that ok code and catch it in your program and write your code accordingly there.

I am not very sure if there is an exit/badi available for doing this in a standard SAP Screen.

Read only

Former Member
0 Likes
668

Hi

TABLES kna1.

*-- Declaring the structure,internal table and workarea for Kna1 table.--*

TYPES:BEGIN OF st_kna1,

kunnr TYPE kna1-kunnr,

name1 TYPE kna1-name1,

ort01 TYPE kna1-ort01,

pstlz TYPE kna1-pstlz,

regio TYPE kna1-regio,

stras TYPE kna1-stras,

END OF st_kna1.

DATA:wa_kna1 TYPE st_kna1,

it_kna1 TYPE STANDARD TABLE OF st_kna1.

--


MODULE user_command_0100 INPUT--

MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'DISPLAY'.

SELECT kunnr

name1

ort01

pstlz

regio

stras

FROM kna1

INTO TABLE it_kna1

WHERE kunnr = kna1-kunnr.

IF sy-subrc EQ 0.

LOOP AT it_kna1 INTO wa_kna1.

kna1-kunnr = wa_kna1-kunnr.

kna1-name1 = wa_kna1-name1.

kna1-ort01 = wa_kna1-ort01.

kna1-pstlz = wa_kna1-pstlz.

kna1-regio = wa_kna1-regio.

kna1-stras = wa_kna1-stras.

ENDLOOP.

ELSE.

MESSAGE i001.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

when 'EXIT'.

PERFORM LEAVING_SCREEN.

ENDCASE.

ENDMODULE. "USER_COMMAND_0100 INPUT

--


Module STATUS_0100 OUTPUT--

MODULE status_0100 OUTPUT.

SET PF-STATUS 'S0100'.

SET TITLEBAR 'S100'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Form LEAVING_SCREEN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form LEAVING_SCREEN .

LEAVE PROGRAM.

endform. " LEAVING_SCREEN