This program demonstrates how to populate a screen field depending upon another field without triggering PAI using FM DYNP_VALUES_UPDATE.
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 95 96 97 98 99 100 101 102 103 104 105 106
|
REPORT z_test_program1. PARAMETERS: p_name TYPE uname, p_ctry TYPE char2. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_name. PERFORM sub_populate_f4_help USING 'P_NAME'. START-OF-SELECTION. END-OF-SELECTION.
FORM sub_populate_f4_help USING p_retfield TYPE dynfnam. TYPES: BEGIN OF l_x_names, uname TYPE uname, END OF l_x_names. DATA: l_i_names TYPE STANDARD TABLE OF l_x_names INITIAL SIZE 0, l_wa_names TYPE l_x_names, l_i_field_tab TYPE STANDARD TABLE OF dfies INITIAL SIZE 0, l_i_return_tab TYPE STANDARD TABLE OF ddshretval INITIAL SIZE 0, l_wa_return_tab TYPE ddshretval, l_i_dynpfld_mapping TYPE STANDARD TABLE OF dselc INITIAL SIZE 0. l_wa_names-uname = 'TEST1'. APPEND l_wa_names TO l_i_names. l_wa_names-uname = 'TEST2'. APPEND l_wa_names TO l_i_names. l_wa_names-uname = 'TEST3'. APPEND l_wa_names TO l_i_names. l_wa_names-uname = 'TEST4'. APPEND l_wa_names TO l_i_names. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'UNAME' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = p_retfield value_org = 'S' TABLES value_tab = l_i_names field_tab = l_i_field_tab return_tab = l_i_return_tab dynpfld_mapping = l_i_dynpfld_mapping EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc = 0. READ TABLE l_i_return_tab INTO l_wa_return_tab INDEX 1. p_name = l_wa_return_tab-fieldval. ELSE. MESSAGE e001(00) WITH 'Error while displaying F4 help'. ENDIF. DATA: l_i_dynpfields TYPE STANDARD TABLE OF dynpread INITIAL SIZE 0, l_wa_dynpfields TYPE dynpread. IF p_name = 'TEST1'. l_wa_dynpfields-fieldname = 'P_CTRY'. l_wa_dynpfields-fieldvalue = 'IN'. APPEND l_wa_dynpfields TO l_i_dynpfields. ELSE. l_wa_dynpfields-fieldname = 'P_CTRY'. CLEAR l_wa_dynpfields-fieldvalue. APPEND l_wa_dynpfields TO l_i_dynpfields. ENDIF. CALL FUNCTION 'DYNP_VALUES_UPDATE' 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 undefind_error = 7 OTHERS = 8. 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.
|
No comments:
Post a Comment