SAP-abap学习记录(30)

SAP-abap学习记录(30)_第1张图片

 

*&---------------------------------------------------------------------*
*& Report  ZTEST_ABAP_30
*&
*&---------------------------------------------------------------------*
*&SCREEN屏幕交互
*&
*&---------------------------------------------------------------------*
REPORT ztest_abap_30.


DATA: forinput(20) TYPE c VALUE 'INITIAL VALUE',
      forcode(20)  TYPE c.

TYPES: BEGIN OF list,       "下拉列表值的存储
         para TYPE text20,
       END OF list.

DATA: itab_list TYPE STANDARD TABLE OF list WITH HEADER LINE.

*功能码返回值
DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

START-OF-SELECTION.
*直接调用窗口
CALL SCREEN 100.

WRITE: forinput, / forcode.


MODULE status_0100 OUTPUT.
*定义状态条、包括菜单、工具条按钮、系统按钮等
  SET PF-STATUS 'TEST_BAR'.
*将变量值输出至屏幕字段
  forcode = save_ok.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
*分析功能码,如果是工具条上的第2个按钮,则退出当前屏幕
  CASE save_ok.
    WHEN 'BIN2'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.


MODULE check INPUT.

  IF forinput = 'AA'.
    MESSAGE e005(ymess) WITH 'FORINPUT ERROR!'.
  ENDIF.

  IF forinput = 'AAA'.
    MESSAGE i005(ymess) WITH 'FORINPUT WARMING!'.

  ENDIF.

ENDMODULE.


*&---------------------------------------------------------------------*
*&      Module  SET_VALUE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE set_value INPUT.

  itab_list-para = 'CHINESE'. APPEND itab_list.
  itab_list-para = 'ENGLISH'. APPEND itab_list.
  itab_list-para = 'FRENCH'. APPEND itab_list.

*  将内表中的值通过函数传递给调用本模组列表

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'PARA'
      value_org       = 'S'
    TABLES
      value_tab       = itab_list
    EXCEPTIONS
      parameter_error = 1
      no_value_found  = 2
      OTHERS          = 3.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDMODULE.

你可能感兴趣的:(SAP)