0% found this document useful (0 votes)
38 views

Get The Entered Value From A Field On POV of Another Field Using FM DYNP

This document provides code to dynamically populate the search help values for one parameter based on the value of another parameter when the F4 button is pressed. It uses the FM DYNP_VALUES_READ to get the value of the first parameter, then performs a SELECT statement to get matching values from a database table to populate the search help for the second parameter using the F4IF_INT_TABLE_VALUE_REQUEST function.

Uploaded by

Subandi Wahyudi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Get The Entered Value From A Field On POV of Another Field Using FM DYNP

This document provides code to dynamically populate the search help values for one parameter based on the value of another parameter when the F4 button is pressed. It uses the FM DYNP_VALUES_READ to get the value of the first parameter, then performs a SELECT statement to get matching values from a database table to populate the search help for the second parameter using the F4IF_INT_TABLE_VALUE_REQUEST function.

Uploaded by

Subandi Wahyudi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Get the entered value from a field on POV of another field using FM

DYNP_VALUES_READ

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 *& Program : Z_TEST_PROGRAM
4 *& Created on : 23.07.2008 22:55:41
5 *&-------------------------------------------------------------------
6 --*
7 *& Test program for blog http://abap-explorer.blogspot.com/
8 *&-------------------------------------------------------------------
9 --*
10 REPORT z_test_program.
11
12 *Data Declaration
13 TYPES :
14 BEGIN OF x_spfli,
15 carrid TYPE s_carr_id,
16 connid TYPE s_conn_id,
17 END OF x_spfli.
18
19 DATA :
20 i_spfli TYPE STANDARD TABLE OF x_spfli INITIAL SIZE 0.
21 *Parameters
22 PARAMETERS:
23 p_carrid TYPE x_spfli-carrid OBLIGATORY,
24 p_connid TYPE x_spfli-connid.
25
26 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_connid.
27
28 PERFORM sub_get_f4.
29
30 START-OF-SELECTION.
31
32 WRITE: / ' this is for testing'.
33 *&-------------------------------------------------------------------
34 --*
35 *& Form sub_get_f4
36 *&-------------------------------------------------------------------
37 --*
38 * Subroutine to populate F$ help
39 *--------------------------------------------------------------------
40 --*
41 FORM sub_get_f4 .
42 DATA:
43 l_i_dynpfields TYPE STANDARD TABLE OF dynpread INITIAL SIZE 0,
44 l_wa_dynpfields TYPE dynpread,
45 l_carrid TYPE s_carr_id.
46 *Populate the Parameter Name whoso value is required
47
48 l_wa_dynpfields-fieldname = 'P_CARRID'.
49 APPEND l_wa_dynpfields TO l_i_dynpfields.
50
51 *Call the FM to read that value
52 CALL FUNCTION 'DYNP_VALUES_READ'
53 EXPORTING
54 dyname = sy-repid
55 dynumb = sy-dynnr
56 * TRANSLATE_TO_UPPER = ' '
57 * REQUEST = ' '
58 * PERFORM_CONVERSION_EXITS = ' '
59 * PERFORM_INPUT_CONVERSION = ' '
60 * DETERMINE_LOOP_INDEX = ' '
61 TABLES
62 dynpfields = l_i_dynpfields
63 EXCEPTIONS
64 invalid_abapworkarea = 1
65 invalid_dynprofield = 2
66 invalid_dynproname = 3
67 invalid_dynpronummer = 4
68 invalid_request = 5
69 no_fielddescription = 6
70 invalid_parameter = 7
71 undefind_error = 8
72 double_conversion = 9
73 stepl_not_found = 10
74 OTHERS = 11
75 .
76 IF sy-subrc = 0.
77 *Get the value
78 READ TABLE l_i_dynpfields INTO l_wa_dynpfields
79 WITH KEY fieldname = 'P_CARRID'.
80 IF sy-subrc = 0.
81 l_carrid = l_wa_dynpfields-fieldvalue.
82
83 SELECT
84 carrid " Airline Code
85 connid " Flight Connection Number
86 FROM spfli " Flight schedule
87 INTO TABLE i_spfli WHERE carrid = l_carrid.
88
89 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
90 EXPORTING
91 retfield = 'CONNID'
92 dynpprog = sy-repid
93 dynpnr = sy-dynnr
94 dynprofield = 'P_CONNID'
value_org = 'S'
TABLES
value_tab = i_spfli.
ENDIF.
ENDIF.
ENDFORM. " sub_get_f4

You might also like