Hi,
Try below code.
TABLES: MARA.
types: begin of ty,
matnr type matnr,
werks type werks_d,
end of ty.
data: it2 type standard table of dselc,
wa2 type dselc.
data: it type standard table of ty,
wa_return type ddshretval,
i_return type standard table of ddshretval,
repid type sy-repid,
dynnr type sy-dynnr.
parameters:
p_matnr type mara-matnr,
p_werks type marc-werks.
SELECT-OPTIONS: S_BUKRS FOR MARA-MATNR.
at selection-screen output.
** loop at screen.
** if screen-name = 'P_WERKS'.
** screen-input = '0'.
** screen-DISPLAY_3D = 'X'.
** modify screen.
** endif.
** endloop.
at selection-screen on value-request for p_matnr.
repid = sy-repid.
dynnr = sy-dynnr.
select matnr werks
from marc up to 20 rows
into table it.
check sy-subrc = 0.
wa2-fldname = 'F0001'.
wa2-dyfldname = 'P_MATNR'.
append wa2 to it2.
wa2-fldname = 'F0002'.
wa2-dyfldname = 'P_WERKS'.
append wa2 to it2.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'WERKS'
dynpprog = repid
dynpnr = dynnr
dynprofield = 'P_WERKS'
value_org = 'S'
display = 'F'
tables
value_tab = it
dynpfld_mapping = it2
exceptions
parameter_error = 1
no_values_found = 2
others = 3.