Demo code on how to populate search help values dynamically depending upon values of another parameter on F4 button press. We have to use FM "DYNP_VALUES_READ".
The Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
REPORT z_test_program.
TYPES : BEGIN OF x_spfli, carrid TYPE s_carr_id, connid TYPE s_conn_id, END OF x_spfli.
DATA : i_spfli TYPE STANDARD TABLE OF x_spfli INITIAL SIZE 0.
PARAMETERS: p_carrid TYPE x_spfli-carrid OBLIGATORY, p_connid TYPE x_spfli-connid.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_connid.
PERFORM sub_get_f4.
START-OF-SELECTION.
WRITE: / ' this is for testing'.
FORM sub_get_f4 . DATA: l_i_dynpfields TYPE STANDARD TABLE OF dynpread INITIAL SIZE 0, l_wa_dynpfields TYPE dynpread, l_carrid TYPE s_carr_id.
l_wa_dynpfields-fieldname = 'P_CARRID'. APPEND l_wa_dynpfields TO l_i_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING dyname = sy-repid dynumb = sy-dynnr
TABLES dynpfields = l_i_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 . IF sy-subrc = 0.
READ TABLE l_i_dynpfields INTO l_wa_dynpfields WITH KEY fieldname = 'P_CARRID'. IF sy-subrc = 0. l_carrid = l_wa_dynpfields-fieldvalue.
SELECT carrid connid FROM spfli INTO TABLE i_spfli WHERE carrid = l_carrid.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'CONNID' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = 'P_CONNID' value_org = 'S' TABLES value_tab = i_spfli. ENDIF. ENDIF. ENDFORM.
|
No comments:
Post a Comment