abap代码写帮助

SELECTION-SCREEN BEGIN OF BLOCK RDG1 WITH FRAME TITLE TEXT-001.
  PARAMETERS:     P_WERKS TYPE AUFK-WERKS OBLIGATORY.
  SELECT-OPTIONS  S_AUFNR FOR AFKO-AUFNR.
  PARAMETERS:     P_LGORT TYPE T001L-LGORT.
SELECTION-SCREEN END OF BLOCK RDG1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LGORT.
*对库存地点输入框配置搜查功能
  PERFORM SUB_MODIFY_HELP.

FORM SUB_MODIFY_HELP.
  TYPES: BEGIN OF TYP_F4_HELP,
    LGORT TYPE T001L-LGORT,
    LGOBE TYPE T001L-LGOBE,
  END OF TYP_F4_HELP.

  DATA: LIT_F4_HELP TYPE TABLE OF TYP_F4_HELP.

  SELECT LGORT LGOBE
    FROM T001L
    INTO CORRESPONDING FIELDS OF TABLE LIT_F4_HELP
    WHERE WERKS = 'X295'.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
     RETFIELD               = 'LGORT'      "LIT_F4_HELP中要显示的字段名
     DYNPPROG               = SY-REPID     "返回的输入框所在程序
     DYNPNR                 = SY-DYNNR     "返回的输入框所在屏幕
     DYNPROFIELD            = 'P_LGORT'    "返回的输入框名
     VALUE_ORG              = 'S'          "该参数不可或缺
    TABLES
     VALUE_TAB              = LIT_F4_HELP.

    IF SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
ENDFORM.

注释:select语句中条件可以直接写where werks=p_werks 或 where werks in r_werks(如果是个range类型的变量)。
如果p_werks或r_werks取不到值,可以用function DYNP_VALUES_READ,读取屏幕上的值如:
  DATA LIT_DYNP TYPE TABLE OF DYNPREAD.
  DATA LWA_DYNP LIKE LINE OF LIT_DYNP.

  LWA_DYNP-FIELDNAME = 'P_WERKS'.
  APPEND LWA_DYNP TO LIT_DYNP.

CALL FUNCTION 'DYNP_VALUES_READ'
              EXPORTING
                DYNAME                               = SY-REPID  "程序名称
                DYNUMB                               = SY-DYNNR  "屏幕编号
*               TRANSLATE_TO_UPPER                   = ' '
*               REQUEST                              = ' '
*               PERFORM_CONVERSION_EXITS             = ' '
*               PERFORM_INPUT_CONVERSION             = ' '
*               DETERMINE_LOOP_INDEX                 = ' '
*               START_SEARCH_IN_CURRENT_SCREEN       = ' '
*               START_SEARCH_IN_MAIN_SCREEN          = ' '
*               START_SEARCH_IN_STACKED_SCREEN       = ' '
*               START_SEARCH_ON_SCR_STACKPOS         = ' '
*               SEARCH_OWN_SUBSCREENS_FIRST          = ' '
*               SEARCHPATH_OF_SUBSCREEN_AREAS        = ' '
              TABLES
                DYNPFIELDS                           = LIT_DYNP  "读当前屏幕数值的表格
*             EXCEPTIONS
*               INVALID_ABAPWORKAREA                 = 1
*               INVALID_DYNPROFIELD                  = 2
*               INVALID_DYNPRONAME                   = 3
*               INVALID_DYNPRONUMMER                 = 4
*               INVALID_REQUEST                      = 5
*               NO_FIELDDESCRIPTION                  = 6
*               INVALID_PARAMETER                    = 7
*               UNDEFIND_ERROR                       = 8
*               DOUBLE_CONVERSION                    = 9
*               STEPL_NOT_FOUND                      = 10
*               OTHERS                               = 11
  READ TABLE LIT_DYNP INTO LWA_DYNP WITH KEY FIELDNAME = 'P_WERKS'.
  IF SY-SUBRC EQ 0.
    SELECT LGORT LGOBE FROM T001L
      INTO CORRESPONDING FIELDS OF TABLE LIT_LGORT
      WHERE WERKS = LWA_DYNP-FIELDVALUE.
  ENDIF. 
下面再紧接 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'..
另外F4IF_FIELD_VALUE_REQUEST的用法见http://blog.csdn.net/liangziyisheng/article/details/6951941               .

你可能感兴趣的:(abap)