2022 Jul 22 9:31 AM
Hi Everyone,
When i select any country name from listbox it is not reflecting. Only first value of the listbox is showing. Can anyone help me to resolve this issue.
type-POOLs:vrm.
PARAMETERS:
p_land1 as LISTBOX VISIBLE LENGTH 8 USER-COMMAND CMD.
data: it_list type vrm_values,
wa_list like LINE OF it_list.
at SELECTION-SCREEN OUTPUT.
clear: it_list[].
select
DISTINCT
land1
from kna1
into CORRESPONDING FIELDS OF table it_kna1.
if sy-subrc eq 0.
loop at it_kna1 into wa_kna1.
wa_list-text = wa_kna1-land1.
append wa_list to it_list.
ENDLOOP.
endif.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_LAND1'
values = it_list
* EXCEPTIONS
* ID_ILLEGAL_NAME = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
2022 Jul 22 10:04 AM
You must fill the key with the country code, and you must define P_LAND1 as type LAND1 (country code 3 characters). Visible length is for displaying the text (country name) so you'd better increase the length.
The key corresponds to the value of the screen field, and they should have same type (country code = 3 characters).
The text is just the information displayed (country name in full text).
When you select a value, it will fill P_LAND1 with the key.
2022 Jul 22 10:04 AM
You must fill the key with the country code, and you must define P_LAND1 as type LAND1 (country code 3 characters). Visible length is for displaying the text (country name) so you'd better increase the length.
The key corresponds to the value of the screen field, and they should have same type (country code = 3 characters).
The text is just the information displayed (country name in full text).
When you select a value, it will fill P_LAND1 with the key.
2022 Jul 22 10:12 AM
And it is also unnecessary to execute the code at every dynpro round-trip.
It can be moved to INITIALIZATION event, or a check should be added to validate whether the listbox table has been filled.
2022 Jul 22 10:15 AM
Hi Sandra Rossi
Now it's working. When i select country name from listbox it is displaying. But one more issue is facing. Issue is when i select any country name it shows but it disappear within few seconds.
type-POOLs:vrm.
data:n type i value 1.
PARAMETERS:
p_land1 type land1 as LISTBOX VISIBLE LENGTH 8 USER-COMMAND CMD.
data: it_list type vrm_values,
wa_list like LINE OF it_list.
at SELECTION-SCREEN OUTPUT.
clear: it_list[].
select
DISTINCT
land1
from kna1
into CORRESPONDING FIELDS OF table it_kna1.
if sy-subrc eq 0.
loop at it_kna1 into wa_kna1.
wa_list-key = n.
wa_list-text = wa_kna1-land1.
append wa_list to it_list.
n = n + 1.
ENDLOOP.
endif.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_LAND1'
values = it_list
* EXCEPTIONS
* ID_ILLEGAL_NAME = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
2022 Jul 22 10:35 AM
The key must be the country code. Sorry to not mention it explicitly -> answer edited.
When you select a value, it will fill P_LAND1 with the key.
2022 Jul 22 10:39 AM