2019 Sep 03 6:39 AM
Hello experts,
I have 2 fields in selection screen.when I press f4 on first field and select the values...It should populate the value automatically on second field....can anyone look into this and tell the answer...
Thanks in advance,
Shivani.
2019 Sep 03 7:27 AM
Hi Shivani,
You can write the code in the at selection screen output, after selecting the data from the F4 help,press enter other field will be auto populated.
PARAMETERS: P_matnr TYPE mara-matnr,
P_test TYPE maktx .
at SELECTION-SCREEN OUTPUT.
IF P_matnr = 'CBC-2'.
p_test = 'Test'.
ENDIF.
2019 Sep 03 10:11 AM
Hi Shivani,
Kindly find the below code.
TYPES: BEGIN OF ty_matnr,
werks TYPE marc-werks,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF ty_matnr.
DATA: gwa_matnr TYPE ty_matnr,
gt_matnr TYPE TABLE OF ty_matnr.
DATA: gt_return TYPE TABLE OF ddshretval,
gwa_return TYPE ddshretval.
DATA: gwa_dynpfields TYPE dynpread,
gt_dynpfields TYPE TABLE OF dynpread.
DATA: gv_werks TYPE marc-werks.
PARAMETERS: p_werks TYPE marc-werks OBLIGATORY.
PARAMETERS: p_matnr TYPE mara-matnr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
REFRESH gt_dynpfields.
gwa_dynpfields-fieldname = 'P_WERKS'.
APPEND gwa_dynpfields TO gt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = gt_dynpfields
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 gt_dynpfields INTO gwa_dynpfields
WITH KEY fieldname = 'P_WERKS'.
IF sy-subrc = 0.
gv_werks = gwa_dynpfields-fieldvalue.
ENDIF.
SELECT a~werks
a~matnr
b~maktx
UP TO 10 ROWS
INTO TABLE gt_matnr
FROM marc AS a
INNER JOIN makt AS b
ON a~matnr = b~matnr
WHERE a~werks = gv_werks
AND b~spras = 'EN'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
value_org = 'S'
TABLES
value_tab = gt_matnr
return_tab = gt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
READ TABLE gt_return INTO gwa_return INDEX 1.
IF sy-subrc = 0.
p_matnr = gwa_return-fieldval.
ENDIF.
Regards,
Chitme
2019 Sep 03 2:47 PM