‎2006 Sep 01 8:31 PM
hi I am fetching the values into second field based on first field by reading them like this
<b>
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ST_NAME.
CLEAR: FIELD_VALUE, DYNPRO_VALUES.
REFRESH DYNPRO_VALUES.
FIELD_VALUE-FIELDNAME = 'EXCH'.
APPEND FIELD_VALUE TO DYNPRO_VALUES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = DYNPRO_VALUES.
READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE.
IF FIELD_VALUE-FIELDVALUE IS NOT INITIAL.
IF SY-SUBRC = 0 AND FIELD_VALUE-FIELDVALUE = 1.
FIELD_VALUE-FIELDVALUE = 'BSE'.
ELSEIF SY-SUBRC = 0 AND FIELD_VALUE-FIELDVALUE = 2.
FIELD_VALUE-FIELDVALUE = 'NSE'.
ENDIF.
SELECT STOCK ST_NAME
FROM
ZEXCH
INTO TABLE TEMP_ITAB
WHERE EXCH = FIELD_VALUE-FIELDVALUE.
IF SY-SUBRC = 0.
FLAG = 'X'.
ENDIF.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'ST_NAME'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'ST_NAME'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = TEMP_ITAB.
ENDIF.</b>
This is working fine, now my requirement is to fetch a value into 3rd field from database table when the user selects a value through 'F4IF_INT_TABLE_VALUE_REQUEST'
Please help me with this, hope u got my problem, i want to know how to continue and fill value into third field after filling the field ST_NAME
points guaranteed
‎2006 Sep 01 8:50 PM
So I'm thinking all you need to do is add something like this after your F4 call.
call function'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'ST_NAME'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'ST_NAME'
value_org = 'S'
tables
value_tab = temp_itab.
<b> field_value-fieldname = '3RDFIELD'. <-- The 3rd field name
field_value-fieldvalue = 'Some Value'. <-- The value
append field_value to dynpro_values .
* Update the dynpro values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynpro_values
exceptions
others = 8.</b>
Regards,
Rich Heilman
‎2006 Sep 01 8:35 PM
Please see this example program as it will show you how to use the DYNPRO_VALUES_UPDATE.
report zrich_0002 .
parameters: p_bukrs type t001-bukrs,
p_butxt type t001-butxt,
p_ort01 type t001-ort01,
p_land1 type t001-land1.
data: dynfields type table of dynpread with header line.
data: return type table of ddshretval with header line.
at selection-screen on value-request for p_bukrs.
call function 'F4IF_FIELD_VALUE_REQUEST'
exporting
tabname = 'T001'
fieldname = 'BUKRS'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'P_BUKRS'
tables
return_tab = return
exceptions
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4
others = 5.
read table return with key fieldname = 'P_BUKRS'.
* Add it back to the dynpro.
dynfields-fieldname = return-retfield.
dynfields-fieldvalue = return-fieldval.
append dynfields.
* Get the company code from db and add to dynpro
data: xt001 type t001.
clear xt001.
select single * into xt001
from t001
where bukrs = return-fieldval.
dynfields-fieldname = 'P_BUTXT'.
dynfields-fieldvalue = xt001-butxt.
append dynfields.
dynfields-fieldname = 'P_ORT01'.
dynfields-fieldvalue = xt001-ort01.
append dynfields.
dynfields-fieldname = 'P_LAND1'.
dynfields-fieldvalue = xt001-land1.
append dynfields.
* Update the dynpro values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynfields
exceptions
others = 8.
start-of-selection.
Regards,
Rich Heilman
‎2006 Sep 01 8:44 PM
Hi,
If you have two parameters, you want to display values(f4) in parameter 2
depending on the values entered in parameter 1.
REPORT Z_SRI_HELP_VALUE_FOR_TABLES .
tables tcurt.
DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency
P_LTEXT LIKE TCURT-LTEXT, "Long Text
P_KTEXT LIKE TCURT-KTEXT. "Short Text
*----
*--- Example of updating value of another field on the screen -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
CLEAR: DYFIELDS[], DYFIELDS.
*--- select currency
CALL FUNCTION 'HELP_VALUES_GET'
EXPORTING
fieldname = 'WAERS'
tabname = 'TCURT'
IMPORTING
SELECT_VALUE = P_WAERS.
*--- get long text for the selected currency
SELECT SINGLE LTEXT FROM TCURT
INTO DYFIELDS-FIELDVALUE
WHERE SPRAS = SY-LANGU
AND WAERS = P_WAERS.
IF SY-SUBRC <> 0.
CLEAR DYFIELDS-FIELDVALUE.
ENDIF.
*--- update another field
DYFIELDS-FIELDNAME = 'P_LTEXT'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
tables
dynpfields = DYFIELDS .
*----
*--- Example of reading value of another field -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.
*--- read another field
CLEAR: DYFIELDS[], DYFIELDS.
DYFIELDS-FIELDNAME = 'P_WAERS'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = DYFIELDS .
READ TABLE DYFIELDS INDEX 1.
*--- get short text and update current field
SELECT SINGLE KTEXT FROM TCURT
INTO P_KTEXT
WHERE SPRAS EQ SY-LANGU
AND WAERS EQ DYFIELDS-FIELDVALUE.
*----
How to add F4 functionality to a paramter variable? Say P_name ie Parameters: P_name like dbtab-fieldname
in At selection-screen on value-request for p_name. How should I add the values john, abraham, linga etc so that these values appear when f4 is pressed on the field in the selection screen?
PARAMETERS: p_name(10).
DATA: BEGIN OF value_tab OCCURS 0,
name(10),
END OF value_tab.
DATA :field_tab LIKE dfies OCCURS 0 WITH HEADER LINE.
DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE. DATA : x TYPE string.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_name.
REFRESH value_tab[].
REFRESH field_tab[].
REFRESH return_tab[].
field_tab-fieldname = 'ERNAM'.
field_tab-tabname = 'VBAK'.
APPEND field_tab.
value_tab-name = 'John'.
APPEND value_tab.
value_tab-name = 'Abraham'.
APPEND value_tab.
value_tab-name = 'Lingam'.
APPEND value_tab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = field_tab-fieldname
TABLES
value_tab = value_tab
field_tab = field_tab
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
p_name = return_tab-fieldval.
ENDIF.
Regards
Sudheer
‎2006 Sep 01 8:50 PM
So I'm thinking all you need to do is add something like this after your F4 call.
call function'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'ST_NAME'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'ST_NAME'
value_org = 'S'
tables
value_tab = temp_itab.
<b> field_value-fieldname = '3RDFIELD'. <-- The 3rd field name
field_value-fieldvalue = 'Some Value'. <-- The value
append field_value to dynpro_values .
* Update the dynpro values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynpro_values
exceptions
others = 8.</b>
Regards,
Rich Heilman
‎2006 Sep 01 8:58 PM
hi rich
thats wonderful
when I press F4, i will get a menu because of the function'F4IF_INT_TABLE_VALUE_REQUEST', i select a value from it, will it automatically update into any of the dynpro field so that I can use that variable for further selection
please guide me
‎2006 Sep 01 9:09 PM
You can fill any dynpro field that you want with anyvalue using the DYNPRO_VALUES_UPDATE.
The value that you select from the F4 help will be populated in the ST_NAME field on the selection screen, because that is how you have defined in the funciton call. After the function call you may fill any other field in the selection screen with the above sample coding.
Please be sure to award points for any helpful answers and mark as solved when solved completely. Thanks.
Regards,
Rich Heilman
‎2006 Sep 01 9:09 PM
HEY RICH
THANKS IT WORKS,
YOU ARE GREAT MAN
JUST NEEDED TO ADD THE READ STATEMENT AGAIN
READ TABLE DYNPRO_VALUES INDEX 2 INTO FIELD_VALUE.
‎2006 Sep 01 9:12 PM