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

Selected Value in Dropdown List Box

Former Member
0 Likes
6,251

This is a problem in Dialog Programming. I want to read the DDLB option selected by the user, but am not getting this value in the PAI module.

I have created a screen '200' in my program and set it as a 'Modal Dialog Box'. It has got the following elements.

1. LBL_REASON Text

2. TXT_REASON I/O

3. OK_CODE OK

The element TXT_REASON is a 'Listbox with Key'. Additionally, I have declared the elements as follows in the TOP Include.

type-POOLs : VRM.

DATA: ok_code TYPE sy-ucomm,

txt_reason TYPE char80.

In the PBO, I have set the values in the DDLB as follows.

  • set the values in the DDLB

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'TXT_REASON'

values = lt_rsn_code_ip.

The passed values are properly available in the DDLB. However, the selected value is not available in the PAI module. The PAI code is given below.

data: dynpfields like dynpread occurs 1 with header line.

dynpfields-fieldname = 'TXT_REASON' .

append dynpfields.

call function 'DYNP_VALUES_READ'

exporting

dyname = sy-cprog "Current program

dynumb = sy-dynnr "Current screen

tables

dynpfields = dynpfields "Relevant screen fields

exceptions

others = 0.

MOVE txt_reason TO gv_sel_reason.

So, I have made two attempts to get the selected value.

1. Used FM 'DYNP_VALUES_READ' to read the field

2. Tried to access the value of txt_reason

Both the internal table dynpfields and the field txt_reason are empty.

Am I missing something? Please help.

Thanks and regards,

Abhinava

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,137

hi,

i am not clear wats ur requirment but wat i understood is tat u have a dropdown list with 3 values for eg 1,2 & 3 thne wen u select 2 u want tat 2 in the pai if tat is ur requirement then assign a fcode to tat field (dropdown field ) in screen painter field attributes .

Hope this help u

This is a problem in Dialog Programming. I want to read the DDLB option selected by the user, but am not getting this value in the PAI module.

I have created a screen '200' in my program and set it as a 'Modal Dialog Box'. It has got the following elements.

1. LBL_REASON Text

2. TXT_REASON I/O

3. OK_CODE OK

The element TXT_REASON is a 'Listbox with Key'. Additionally, I have declared the elements as follows in the TOP Include.

type-POOLs : VRM.

DATA: ok_code TYPE sy-ucomm,

txt_reason TYPE char80.

In the PBO, I have set the values in the DDLB as follows.

  • set the values in the DDLB

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'TXT_REASON'

values = lt_rsn_code_ip.

The passed values are properly available in the DDLB. However, the selected value is not available in the PAI module. The PAI code is given below.

data: dynpfields like dynpread occurs 1 with header line.

dynpfields-fieldname = 'TXT_REASON' .

append dynpfields.

call function 'DYNP_VALUES_READ'

exporting

dyname = sy-cprog "Current program

dynumb = sy-dynnr "Current screen

tables

dynpfields = dynpfields "Relevant screen fields

exceptions

others = 0.

MOVE txt_reason TO gv_sel_reason.

So, I have made two attempts to get the selected value.

1. Used FM 'DYNP_VALUES_READ' to read the field

2. Tried to access the value of txt_reason

Both the internal table dynpfields and the field txt_reason are empty.

Am I missing something? Please help.

Thanks and regards,

Abhinava

4 REPLIES 4
Read only

Former Member
0 Likes
2,138

hi,

i am not clear wats ur requirment but wat i understood is tat u have a dropdown list with 3 values for eg 1,2 & 3 thne wen u select 2 u want tat 2 in the pai if tat is ur requirement then assign a fcode to tat field (dropdown field ) in screen painter field attributes .

Hope this help u

Read only

MarcinPciak
Active Contributor
0 Likes
2,137

No, you are not missing anything. I made a test, the following code works fine


TYPE-POOLS : vrm.
DATA: ok_code TYPE sy-ucomm,
txt_reason TYPE char80.

DATA value_tab TYPE vrm_values WITH HEADER LINE.

CALL SCREEN 100. 

MODULE pbo OUTPUT.

  REFRESH value_tab.
  value_tab-key = '1'.
  value_tab-text = 'TRUE'.
  APPEND value_tab.
  value_tab-key = '0'.
  value_tab-text = 'FALSE'.
  APPEND value_tab.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = 'TXT_REASON'
      values = value_tab[].

ENDMODULE.                 


MODULE pai INPUT.
  DATA: dynpfields LIKE dynpread OCCURS 1 WITH HEADER LINE.
  dynpfields-fieldname = 'TXT_REASON' .
  APPEND dynpfields.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     = sy-cprog "Current program
      dynumb     = sy-dynnr "Current screen
    TABLES
      dynpfields = dynpfields "Relevant screen fields
    EXCEPTIONS
      OTHERS     = 0.

 "here field FIELDVALUE of DYNPFIELDS holds value 0 or 1 (key of selected entry)
ENDMODULE.                    

So it seems very alike to your code. I can only suspect the error comes with screen pbo and pai. Ensure these two are set for this screen modal box. If you use other screen PAI you will not get the values of that field as they simply don't exist there.

But as suggested above there is no reason to use DYNP_VALUES_READ as the txt_reason will receive selected value automatically. Make sure that you have corresponding listbox field txt_reason format set to CHAR as well. All the rest will come as standard.

Also please close duplicating thread

Regards

Marcin

Read only

Former Member
0 Likes
2,137

Visible length of txt_reason was 30 so the value was no coming in the field. Resolved by extending the visible length.

Read only

Former Member
0 Likes
2,137

Visible length of txt_reason was 30 so the value was no coming in the field. Resolved by extending the visible length.