‎2009 Jun 08 9:23 AM
Hi expert,
I have a requirement. In a selection screen say there are 4 fields let say f1, f2, f3, f4. Now If a select a value of f1 in the selection screen based on the value of f1, other fields (f2, f3, f4 ) will be populated. How can i do that? All the fields are a part of the tables say Tab1 and Tab2 and they are related.
Thanks in advance,
Abhijit
‎2009 Jun 08 9:24 AM
READ HELP and Search forum for Selection Screen EVENTS.
You will get the reply to it instantly.
‎2009 Jun 08 9:24 AM
READ HELP and Search forum for Selection Screen EVENTS.
You will get the reply to it instantly.
‎2009 Jun 10 12:41 PM
Thanks for your reply. I have got several example but none is meeting my requirement. If possible provide me in details lcode.
Thanks
Abhijit
‎2009 Jun 10 12:46 PM
Try this.
REPORT Z_TEST .
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.
‎2009 Jun 10 12:49 PM
‎2009 Jun 10 12:51 PM
Thanks goutham,
If I want to display both the fields(LTEXT, KTEXT) after selecting the WAERS how can i do that?.
Regards,
Abhijit
‎2009 Jun 10 12:57 PM
Hi,
Read the values of LTEXT, KTEXT in the F4 help of the WAERS and usnig the FM 'DYNP_VALUES_UPDATE' set the values in LTEXT, KTEXT parameters
{codeAT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.
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.
" Select L_KTEXT and L_LTEXT.
DYFIELDS-FIELDVALUE = L_LTEXT.
DYFIELDS-FIELDNAME = 'P_LTEXT'.
APPEND DYFIELDS.
DYFIELDS-FIELDVALUE = L_KTEXT.
DYFIELDS-FIELDNAME = 'P_KTEXT'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
tables
dynpfields = DYFIELDS .{code}