Application Development 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: 

Refresh listbox by using search help values

Martin-Schmid
Explorer
467

Hello experts,

after a long time of research I don't find a suitable solution.

I created a structure with two components. Each component has an explicit search help with its parameters assigned to the components. Component 2 has a search result only when a value in components 1 has been set.

This works fine. Enter comp1, use search help of comp2, get values based on comp1, and select a value.

report z_my_report.
data: ls_data type z_my_structure.
parameters: comp1 like ls_data-comp1,
            comp2 like ls_data-comp2.

This does not: comp2 is empty and never updated automatically.

report z_my_report.
data: ls_data type z_my_structure.
parameters: comp1 like ls_data-comp1 as listbox visible length 30 user-command c1,
            comp2 like ls_data-comp2 as listbox visible length 30 user-command c2.

What is the command to refresh the listbox comp2 with values from it's search help based on the parameters (e.g. in at selection screen after comp1 was selected)?

Best regards,
Martin

1 ACCEPTED SOLUTION

Martin-Schmid
Explorer
380

The elementary search help assigned to comp2 has 1 import parameter (assigned to comp1) and 2 export parameters (key and text). The dialog type is "Display values immeditately".

By debugging I found out that the listbox is just filled once at the initialization of the report and the value of comp1 is not copied to the SHLP_DESCR-INTERFACE-VALUE (as done before clicking the search help button).

I added this code to make it work. Isn't there an easier solution?

ZMY_STRUCTURE
Comp Type Search help
WERKS WERKS_D MM_PUR_PR_SH_PLANT
LGORT LGORT_D MMPUR_UI_ELM_LGORT
report z_my_report.

tables: zmy_structure.

parameters: p_werks like zmy_structure-werks as listbox visible length 30 user-command c1,
p_lgort like zmy_structure-lgort as listbox visible length 30 user-command c2.

at selection-screen.

if sy-ucomm = 'C1'.

clear: p_lgort, zmy_structure-lgort.

" Problem: SHLP_DESCR-INTERFACE-VALUE of VALFIELD = 'WERKS' is not set
" Solution:
" set the parameter in ZMY_STRUCTURE-WERKS
" DD_SHLP_COMBOBOX_FILL will do a dirty assign to get the value
" (fallback method)
zmy_structure-werks = p_werks.

" delete last result
call function 'VRM_DELETE_VALUES'
exporting
id = 'P_LGORT'.

" fill again
call function 'DD_SHLP_COMBOBOX_FILL'
exporting
tabname = 'ZMY_STRUCTURE'
fieldname = 'LGORT'
valueset_id = 'P_LGORT'.

endif.
2 REPLIES 2

Martin-Schmid
Explorer
381

The elementary search help assigned to comp2 has 1 import parameter (assigned to comp1) and 2 export parameters (key and text). The dialog type is "Display values immeditately".

By debugging I found out that the listbox is just filled once at the initialization of the report and the value of comp1 is not copied to the SHLP_DESCR-INTERFACE-VALUE (as done before clicking the search help button).

I added this code to make it work. Isn't there an easier solution?

ZMY_STRUCTURE
Comp Type Search help
WERKS WERKS_D MM_PUR_PR_SH_PLANT
LGORT LGORT_D MMPUR_UI_ELM_LGORT
report z_my_report.

tables: zmy_structure.

parameters: p_werks like zmy_structure-werks as listbox visible length 30 user-command c1,
p_lgort like zmy_structure-lgort as listbox visible length 30 user-command c2.

at selection-screen.

if sy-ucomm = 'C1'.

clear: p_lgort, zmy_structure-lgort.

" Problem: SHLP_DESCR-INTERFACE-VALUE of VALFIELD = 'WERKS' is not set
" Solution:
" set the parameter in ZMY_STRUCTURE-WERKS
" DD_SHLP_COMBOBOX_FILL will do a dirty assign to get the value
" (fallback method)
zmy_structure-werks = p_werks.

" delete last result
call function 'VRM_DELETE_VALUES'
exporting
id = 'P_LGORT'.

" fill again
call function 'DD_SHLP_COMBOBOX_FILL'
exporting
tabname = 'ZMY_STRUCTURE'
fieldname = 'LGORT'
valueset_id = 'P_LGORT'.

endif.

380

Can't do better. Just simplifying to:

TABLES demof4help.
PARAMETERS: carrier2 TYPE demof4help-carrier2 AS LISTBOX VISIBLE LENGTH 30 USER-COMMAND c1 DEFAULT 'LH',
            connid   TYPE demof4help-connid AS LISTBOX VISIBLE LENGTH 30 USER-COMMAND c2.
AT SELECTION-SCREEN OUTPUT.
  demof4help-carrier2 = carrier2.
  CALL FUNCTION 'VRM_DELETE_VALUES'
    EXPORTING
      id           = 'CONNID'
    EXCEPTIONS
      id_not_found = 1.