Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Field value selection on a selection screen

Former Member
0 Likes
932

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

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
887

READ HELP and Search forum for Selection Screen EVENTS.

You will get the reply to it instantly.

6 REPLIES 6
Read only

amit_khare
Active Contributor
0 Likes
888

READ HELP and Search forum for Selection Screen EVENTS.

You will get the reply to it instantly.

Read only

0 Likes
887

Thanks for your reply. I have got several example but none is meeting my requirement. If possible provide me in details lcode.

Thanks

Abhijit

Read only

GauthamV
Active Contributor
0 Likes
887

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.

Read only

0 Likes
887

This message was moderated.

Read only

0 Likes
887

Thanks goutham,

If I want to display both the fields(LTEXT, KTEXT) after selecting the WAERS how can i do that?.

Regards,

Abhijit

Read only

0 Likes
887

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}