SAP ABAP 选择屏幕代码
时间: 2024-01-25 19:03:15 浏览: 160
以下是一个简单的SAP ABAP屏幕选择代码示例,可以帮助您开始编写您自己的选择屏幕:
REPORT Z_SELECT_SCREEN.
TABLES: MARA.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_matnr LIKE mara-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
SELECT * FROM MARA INTO TABLE @DATA(lt_mara)
WHERE matnr = @p_matnr.
IF sy-subrc = 0.
LOOP AT lt_mara INTO DATA(ls_mara).
WRITE: / ls_mara-matnr, ls_mara-maktx.
ENDLOOP.
ELSE.
WRITE: 'No materials found for selected material number.'.
ENDIF.
在此示例中,我们首先定义了一个选择屏幕块,其中包含一个必填的材料号参数。然后,在START-OF-SELECTION部分中,我们使用SELECT语句从MARA表中获取所有与输入的材料号匹配的行,并将结果输出到屏幕上。如果没有找到匹配的行,则输出一条消息。
相关问题
sap abap选择屏幕的文本
在 SAP ABAP 中,您可以使用以下代码选择屏幕上的文本:
```abap
DATA: lv_str TYPE string.
" Select text from screen
CALL FUNCTION 'RS_SELECTION_SCREEN_TEXTS'
EXPORTING
i_fieldname = 'FIELD_NAME' " Field name on screen
IMPORTING
e_text = lv_str. " Text selected on screen
```
在上面的示例中,您需要将 `FIELD_NAME` 替换为您要选择文本的屏幕字段的名称。选择的文本将存储在 `lv_str` 变量中。
sap longon abap选择屏幕代码
以下是 ABAP 中的 SAP 登录屏幕代码示例:
```
REPORT zlogin_screen.
TABLES: dd02l.
PARAMETERS: p_uname TYPE sy-uname,
p_pass TYPE char10.
DATA: lpass TYPE string,
l_exit TYPE sy-subrc,
wa_usr02 TYPE usr02.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'P_PASS'.
screen-input = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
CONCATENATE p_pass cl_abap_char_utilities=>cr_lf INTO lpass.
CALL FUNCTION 'RSAQ_REMOTE_LOGIN'
EXPORTING
client = sy-mandt
userid = p_uname
password = lpass
EXCEPTIONS
communication = 1
system_failure = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc = 0.
SELECT SINGLE bname name lname
INTO wa_usr02
FROM usr02
WHERE bname = p_uname.
IF sy-subrc = 0.
WRITE: / 'Welcome', wa_usr02-lname.
ENDIF.
ELSEIF sy-subrc = 4.
MESSAGE 'Invalid User ID or Password' TYPE 'E'.
ELSE.
MESSAGE 'Logon Error' TYPE 'E'.
ENDIF.
```
以上代码中,PARAMETERS 语句用于定义输入参数,AT SELECTION-SCREEN OUTPUT 语句用于修改输入屏幕,START-OF-SELECTION 语句用于执行登录操作,使用 CALL FUNCTION 调用函数 RSAQ_REMOTE_LOGIN 实现登录。
阅读全文