Function module 'POPUP_GET_VALUES'允许用户在对话框中输入值,且看实例
TYPES: ty_t_sval TYPE STANDARD TABLE OF sval.
DATA: gv_ret_code(5) TYPE c,
gt_flds TYPE ty_t_sval.
CONSTANTS: cn_dlg_tit(10) TYPE c VALUE 'HELLO!'.
START-OF-SELECTION.
* set dialog structure attributes
PERFORM frm_set_tab_attr CHANGING gt_flds.
* pop dialog to ask user input data
PERFORM frm_pop_dialog CHANGING gt_flds gv_ret_code.
END-OF-SELECTION.
IF gv_ret_code IS INITIAL.
* output result of input by user
PERFORM frm_output_rslt USING gt_flds.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FRM_SET_TAB_ATTR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_FLDS text
*----------------------------------------------------------------------*
FORM frm_set_tab_attr CHANGING p_gt_flds TYPE ty_t_sval.
DATA: lw_sval TYPE sval.
* set each field's attribute
DEFINE set_fld_attr.
lw_sval-tabname = 'MAKT'.
lw_sval-fieldname = &1.
append lw_sval to p_gt_flds.
clear lw_sval.
END-OF-DEFINITION.
set_fld_attr: 'MATNR', 'SPRAS', 'MAKTX'.
ENDFORM. " FRM_SET_TAB_ATTR
*&---------------------------------------------------------------------*
*& Form FRM_POP_DIALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_FLDS text
* <--P_GV_RET_CODE text
*----------------------------------------------------------------------*
FORM frm_pop_dialog CHANGING p_gt_flds TYPE ty_t_sval
p_gv_ret_code TYPE c.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
popup_title = cn_dlg_tit
IMPORTING
returncode = p_gv_ret_code
TABLES
fields = p_gt_flds
EXCEPTIONS
error_in_fields = 1
OTHERS = 2.
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. " FRM_POP_DIALOG
*&---------------------------------------------------------------------*
*& Form FRM_OUTPUT_RSLT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FLDS text
*----------------------------------------------------------------------*
FORM frm_output_rslt USING p_gt_flds TYPE ty_t_sval.
DATA: lw_sval TYPE sval.
LOOP AT p_gt_flds INTO lw_sval.
WRITE:/ lw_sval-tabname, lw_sval-fieldname, lw_sval-value.
ULINE.
ENDLOOP.
ENDFORM. " FRM_OUTPUT_RSLT