Wednesday, March 24, 2010

Multiple Field Selection in F4 Help

*&---------------------------------------------------------------------*
*& Report ZF4_MULTIPLE_FIELD_SEL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZF4_MULTIPLE_FIELD_SEL.

PARAMETERS carrid TYPE sflight-carrid.
DATA : BEGIN OF itab OCCURS 0,
carrid TYPE sflight-carrid,
END OF itab.
DATA : rtab TYPE TABLE OF ddshretval WITH HEADER LINE,
ptab TYPE TABLE OF ddshretval WITH HEADER LINE.
REFRESH rtab.
rtab-fieldname = 'CARRID'.
APPEND rtab.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR carrid.
SELECT carrid FROM sflight INTO TABLE itab.
IF sy-subrc = 0.
SORT itab BY carrid.
DELETE ADJACENT DUPLICATES FROM itab COMPARING carrid.
ENDIF.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'CARRID'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
* DYNPROFIELD = ' '
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
multiple_choice = 'X' " Allows to select multiple records
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = itab
* FIELD_TAB =
return_tab = rtab " This holds multiple records
* DYNPFLD_MAPPING =
* EXCEPTIONS
* PARAMETER_ERROR = 1
* NO_VALUES_FOUND = 2
* OTHERS = 3 .

IF sy-subrc = 0.
ptab[] = rtab[]. " After F4 event rtab holds one value
* only so store them in other internal table
ENDIF.

START-OF-SELECTION. " Press F8 to see the output

LOOP AT ptab.
WRITE :/ ptab-fieldval. " This is a test program
ENDLOOP.

No comments: