This report is a sample program that demonstrates how a user can enter and organize different kinds of input on an SAP screen. It includes simple fields like dates, codes, and names where you can type in values. It also provides choices through radio buttons and checkboxes, allowing users to pick options easily. To keep things clear, inputs are grouped into sections with titles and labels. Visual elements such as lines, spacing, and comments make the screen more structured and easier to read. A button is available for triggering specific actions directly from the screen. The program also uses tabs to separate information into different pages, making it less cluttered. Overall, this example shows how SAP screens can be designed to be interactive, organized, and user-friendly.
*&---------------------------------------------------------------------*
*& Report ZTEST_PROGRAM_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztest_program_2.
*---------------------------------------------------------------------*
* SELECTION-SCREEN DECLARATION
*---------------------------------------------------------------------*
tables: mara.
*--- Simple parameters
PARAMETERS: p_matnr TYPE mara-matnr OBLIGATORY, " Material number
p_mtart TYPE mara-mtart, " Material type
p_date TYPE sy-datum. " Date input
*--- Select-options for ranges
SELECT-OPTIONS: s_matkl FOR mara-matkl, " Material group range
s_ersda FOR mara-ersda. " Creation date range
*--- Radio buttons (same group -> only one active)
PARAMETERS: r_raw RADIOBUTTON GROUP g1 DEFAULT 'X', " Raw materials
r_finsi RADIOBUTTON GROUP g1. " Finished goods
*--- Checkbox
PARAMETERS: p_test AS CHECKBOX DEFAULT 'X'.
*--- Blocks with title
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_user TYPE sy-uname DEFAULT sy-uname.
SELECTION-SCREEN END OF BLOCK b1.
*--- Inline elements
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_len TYPE i DEFAULT 10.
SELECTION-SCREEN COMMENT 25(20) text-002 FOR FIELD p_len.
SELECTION-SCREEN END OF LINE.
*--- Pushbutton
SELECTION-SCREEN PUSHBUTTON 10(20) but1 USER-COMMAND pb1.
*---------------------------------------------------------------------*
* TEXT ELEMENTS
*---------------------------------------------------------------------*
* text-001 = "User Settings"
* text-002 = "Length of Value"
* but1 = "Execute Action"
*---------------------------------------------------------------------*
* START-OF-SELECTION
*---------------------------------------------------------------------*
START-OF-SELECTION.
WRITE: / 'Material Number:', p_matnr,
/ 'Material Type :', p_mtart,
/ 'Date Entered :', p_date.
WRITE: / 'Material Group :', s_matkl,
/ 'Creation Date :', s_ersda.
IF r_raw = 'X'.
WRITE: / 'Material Category: Raw Material'.
ELSE.
WRITE: / 'Material Category: Finished Goods'.
ENDIF.
IF p_test = 'X'.
WRITE: / 'Test Mode Active'.
ENDIF.
WRITE: / 'User:', p_user.
WRITE: / 'Length:', p_len.
" Fetch and display matching materials from MARA
DATA: lt_mara TYPE TABLE OF mara,
ls_mara TYPE mara.
SELECT * FROM mara
INTO TABLE lt_mara
UP TO 20 ROWS
WHERE matnr = p_matnr
AND mtart = p_mtart
AND matkl IN s_matkl
AND ersda IN s_ersda.
IF sy-subrc = 0.
WRITE: / '--- Materials Found ---'.
LOOP AT lt_mara INTO ls_mara.
WRITE: / ls_mara-matnr, ls_mara-mtart, ls_mara-matkl, ls_mara-ersda.
ENDLOOP.
ELSE.
WRITE: / 'No materials found for given criteria.'.
ENDIF.
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENT (for pushbutton handling)
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'PB1'.
MESSAGE 'Pushbutton was pressed!' TYPE 'I'.
ENDCASE.