SAP ABAP - Sample Program On How To Program On Buttons In A Screen.
This is a sample program on screen painter showing how to program on buttons in a screen.
REPORT ztest_screen_paint_program.
TABLES: mara.
DATA: matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
display TYPE c,
save TYPE c,
delete TYPE c,
clear TYPE c,
exit TYPE c,
ok_code TYPE sy-ucomm.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS_9000'.
SET TITLEBAR 'TITLE_9000'.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'CLEAR'.
CLEAR mara.
WHEN 'DISPLAY'.
SELECT SINGLE ersda ernam mtart matkl FROM mara
INTO (mara-ersda, mara-ernam, mara-mtart, mara-matkl)
WHERE matnr = mara-matnr.
ENDCASE.
ENDMODULE. " STATUS_9000 OUTPUT
On clicking a button a user command is thrown. In this case on clicking DISPLAY Button, the user command thrown is DISPLAY.
Hence it will fetch the respective details from mara table and displays it in the respective fields.
Say, the Output screen (9000) looks as below,
On entering the material, or selecting an appropriate one from the F4 help, and on clicking the DISPLAY button, the remaining fields get automatically filled up.
On clicking DISPLAY Button
REPORT ztest_screen_paint_program.
TABLES: mara.
DATA: matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
display TYPE c,
save TYPE c,
delete TYPE c,
clear TYPE c,
exit TYPE c,
ok_code TYPE sy-ucomm.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS_9000'.
SET TITLEBAR 'TITLE_9000'.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'CLEAR'.
CLEAR mara.
WHEN 'DISPLAY'.
SELECT SINGLE ersda ernam mtart matkl FROM mara
INTO (mara-ersda, mara-ernam, mara-mtart, mara-matkl)
WHERE matnr = mara-matnr.
ENDCASE.
ENDMODULE. " STATUS_9000 OUTPUT
On clicking a button a user command is thrown. In this case on clicking DISPLAY Button, the user command thrown is DISPLAY.
Hence it will fetch the respective details from mara table and displays it in the respective fields.
Say, the Output screen (9000) looks as below,
On entering the material, or selecting an appropriate one from the F4 help, and on clicking the DISPLAY button, the remaining fields get automatically filled up.
On clicking DISPLAY Button