2019年9月24日星期二

F4 help Multi-fields

REPORT ZMULTIHELP.
PARAMETERS:
  P_EBELN TYPE LENGTH 20,
  P_EBELP TYPE LENGTH 10.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EBELN.

  DATA:
        LT_EKPO TYPE STANDARD TABLE OF EKPO,
        LT_FIELDS TYPE STANDARD TABLE OF DFIES,
        LT_MAPPING TYPE STANDARD TABLE OF DSELC.

  "Fetching only 100 sales documents
  SELECT FROM EKPO
    INTO TABLE LT_EKPO
    UP TO 100 ROWS.

  "Adding the fields we need to be shown in the
  "search help
  PERFORM ADD_FIELD
    TABLES LT_FIELDS
    USING 'EKPO'
          'EBELN'.

  PERFORM ADD_FIELD
    TABLES LT_FIELDS
    USING 'EKPO'
          'EBELP'.



  "Adding fields that has to be mapped to
  "selection screen fields
  PERFORM APPEND_MAPPING
    TABLES LT_MAPPING
    USING 'EBELN' 'P_EBELN'.

    PERFORM APPEND_MAPPING
    TABLES LT_MAPPING
    USING 'EBELP' 'P_EBELP'.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
     RETFIELD               'EBELN'
     DYNPPROG               SY-REPID
     DYNPNR                 SY-DYNNR
     DYNPROFIELD            'P_EBELN'
     VALUE_ORG              'S'
    TABLES
     VALUE_TAB              LT_EKPO
     FIELD_TAB              LT_FIELDS
     DYNPFLD_MAPPING        LT_MAPPING
    EXCEPTIONS
     PARAMETER_ERROR        1
     NO_VALUES_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.

*&------------------------------------------------------*
*&      Form  add_field
*&------------------------------------------------------*
*  Add field info to fieldtab given its table name and
*  field name
*-------------------------------------------------------*
*      -->TABNAME    text
*      -->FIELDNAME  text
*-------------------------------------------------------*
FORM ADD_FIELD
  TABLES P_FIELDS
  USING TABNAME TYPE TABNAME
        FIELDNAME TYPE FIELDNAME.


  DATALS_FIELD TYPE DFIES,
       LT_FIELDS TYPE STANDARD TABLE OF DFIES.

  CALL FUNCTION 'DDIF_FIELDINFO_GET'
   EXPORTING
     TABNAME              TABNAME
     FIELDNAME            FIELDNAME
   TABLES
     DFIES_TAB            LT_FIELDS
   EXCEPTIONS
     NOT_FOUND            1
     INTERNAL_ERROR       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.

  APPEND LINES OF LT_FIELDS TO P_FIELDS.

ENDFORM.                    "add_field

*&------------------------------------------------------*
*&      Form  append_mapping
*&------------------------------------------------------*
*  Append field mapping to mapping table
*-------------------------------------------------------*
*      -->P_MAPPING       Mapping table
*      -->P_FIELD         Field in Itab
*      -->P_DYNPRO_FIELD  Field in screen
*-------------------------------------------------------*
FORM APPEND_MAPPING
  TABLES P_MAPPING
  USING P_FIELD
        P_DYNPRO_FIELD.

  DATA:
        LS_MAPPING TYPE DSELC.

  LS_MAPPING-FLDNAME P_FIELD.
  LS_MAPPING-DYFLDNAME P_DYNPRO_FIELD.
  APPEND LS_MAPPING TO P_MAPPING.

ENDFORM.                    "append_mapping

没有评论:

发表评论

Customer Characteristic

  Characteristic Descriptions are stored in the table - CABNT - Language - SPRAS - Characteristic description - ATBEZ Characteristic Values ...