03-10-2010 6:45 AM
Hi,
I have a screen with two fields- One input field and one drop down list field which has to be populated based on the value given in the first field.
How can I populate the drop down list dynamically based on first input field without pressing enter ( i.e with out triggering PAI event ) . I tried using DYNP_VALUES_READ in value request event.
Please give me your suggestions .
03-10-2010 8:11 AM
Refer to this program demo_dynpro_dropdown_listbox . It does what you need.
Regards
Marcin
03-11-2010 12:47 AM
If your first field is a simple input field then you will need to enter PAI so that the application server gets the field value in order for your ABAP logic to know what new values to put in the listbox.
( The demo program mentioned above does enter PAI by putting a user-command of "CARRIER" on the first listbox... that causes it to call screen 200 with the second listbox on )
Jonathan
03-11-2010 2:49 AM
Hhhhmm, I thought initially it should work, but I must admit I couldn't get it to work with a listbox. I just tried a simple report with selection screen, see below. Just enter something for the first parameter and then choose the value help for the second field. You will see that it will pick up the value from the first field, if we don't use a listbox.
Once you comment in the coding the LISTBOX and replace it with the normal field, you can see that the value help works as one would hope. It seems that the problem is that the values for the dropdown list get populated too early (i.e. start-up of the report). I don't have the time at the moment to check this out further, but I'm assuming others must have tried this before. Any comments?
REPORT zvaluehelp.
PARAMETERS:
p_statva TYPE stacust-statva,
p_status TYPE stacust-status AS LISTBOX VISIBLE LENGTH 3. " Doesn't work
* p_status TYPE char1. " Value-help works for this
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_status.
PERFORM value_help.
FORM value_help.
DATA:
dynpread TYPE dynpread,
dynpread_tab TYPE STANDARD TABLE OF dynpread,
stacust TYPE stacust,
stacust_tab TYPE STANDARD TABLE OF stacust.
dynpread-fieldname = 'P_STATVA'.
APPEND dynpread TO dynpread_tab.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
perform_conversion_exits = 'X'
TABLES
dynpfields = dynpread_tab
EXCEPTIONS
OTHERS = 1.
CHECK sy-subrc = 0.
READ TABLE dynpread_tab INTO dynpread INDEX 1.
CHECK dynpread-fieldvalue IS NOT INITIAL.
SELECT * FROM stacust INTO TABLE stacust_tab
WHERE statva = dynpread-fieldvalue.
CHECK sy-subrc = 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
ddic_structure = 'STACUST'
retfield = 'STATUS'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_STATUS'
value_org = 'S'
TABLES
value_tab = stacust_tab
EXCEPTIONS
OTHERS = 0.
ENDFORM.
The coding above was just intended as a quick test - so I know it's not proper (i.e. check of return codes, etc.).
Cheers, harald
03-11-2010 6:04 AM
HI Kusuma,
Check the Below threads, Let us know if you have any issues
There is no way you can trigger PAI without entering with an Input Field but there is a work around
in PBO
refresh fields.
clear fields.
fields-tabname = 'MARA'. " Just Copy and Execute this
fields-fieldname = 'MATNR'.
fields-field_obl = 'X'. " To make this Field mandatory
APPEND fields.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
* NO_VALUE_CHECK = ' '
popup_title = 'Give your Title'
* START_COLUMN = '5'
* START_ROW = '5'
* IMPORTING
* RETURNCODE = RETURNCODE
TABLES
fields = fields " For more info Take Where used List on this FM
* EXCEPTIONS
* ERROR_IN_FIELDS = 1
* OTHERS = 2
" By the time you call the List Box FM(VRM_SET_VALUES) the value entered is available to you
Then as mentioned in the below threads Populate your List Box
I have successfully implemented this in 2 objects
In the second thread dropdown based on another Dropdown but you can adopt the Second drop down based on the First input Field.
Hope this serves your purpose.
Cheerz
Ram
03-12-2010 6:45 AM
Hi Kusuma,
Try this FM SAPGUI_SET_FUNCTIONCODE before your code for drop-down population. This actually gives the funtionality of ENTER within the program itself. Here is the sample code:
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
EXPORTING
functioncode = '/00'
EXCEPTIONS
function_not_supported = 1.
IF sy-subrc <> 0.
MESSAGE w000 WITH text-001.
ENDIF.
'/00' is the code for ENTER.
Regards,
Pranaam.