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: 

Refreshing Application Log while maintaining navigation

Carl_Angus
Newcomer

Hi There,

I have a custom application log and display program which uses FM BAL_DSP_LOG_DISPLAY.

I have added a Refresh Button on the toolbar and working code to refresh the selected application logs from the database, however when the refresh happens the currently displayed Log *(After a log in the tree is double clicked on) is not displayed again and the tree and list revert to what was displayed in the initial call to BAL_DSP_LOG_DISPLAY.

My Question is:

Is there a way to maintain the current selection in the application Log when it is refreshed?

I have already searched for previous solutions here and none match my issue.

Any assistance would be greatly appreciated

Cheers

Cangus.


FYI: Here is the Callback routine I'm using to do the refresh *(It works).

FORM callback_ucomm CHANGING cs_user_command_data TYPE bal_s_cbuc.
DATA: ls_disp_profile TYPE bal_s_prof,
ls_log_filter TYPE bal_s_lfil,
ls_obj TYPE bal_s_obj,
ls_sub_obj TYPE bal_s_sub,
lt_log_handle TYPE bal_t_logh,
ld_log_handle TYPE balloghndl.

*--- Check if Refresh Button was pressed.
IF cs_user_command_data-ucomm = gc_ucomm_ext_push1.
cs_user_command_data-refresh = abap_true.
cs_user_command_data-ucomm_exec = abap_true.

*--- Pass the App log Object name
ls_obj-sign = 'I'.
ls_obj-option = 'EQ'.
ls_obj-low = gc_log_obj.
APPEND ls_obj TO ls_log_filter-object.

*--- Pass the App log Subobject Name
ls_sub_obj-sign = 'I'.
ls_sub_obj-option = 'EQ'.
ls_sub_obj-low = gc_subobject.
APPEND ls_sub_obj TO ls_log_filter-subobject.

*--- Load Application Logs via wrapper Class which calls FM BAL_DB_SEARCH
lt_log_handle = gr_log->search_logs( ls_log_filter ).

*--- Reload from database
CALL FUNCTION 'BAL_DB_RELOAD'
EXPORTING
i_t_log_handle = lt_log_handle
EXCEPTIONS
OTHERS = 0.

*--- Set display output data
CALL FUNCTION 'BAL_DSP_OUTPUT_SET_DATA'
EXPORTING
i_t_log_handle = lt_log_handle
EXCEPTIONS
OTHERS = 0.
ENDIF.

ENDFORM. "callback_ucomm
2 REPLIES 2

pedrohb
Active Participant
0 Kudos

One approach to maintain the current selection in the application log when it is refreshed is to store the current selection in a variable and restore it after the refresh.

Here is an example modification to your code that should accomplish this:

FORM callback_ucomm CHANGING cs_user_command_data TYPE bal_s_cbuc.

DATA: ls_disp_profile TYPE bal_s_prof,

ls_log_filter TYPE bal_s_lfil,

ls_obj TYPE bal_s_obj,

ls_sub_obj TYPE bal_s_sub,

lt_log_handle TYPE bal_t_logh,

ld_log_handle TYPE balloghndl,

lv_selected_log_handle TYPE balloghndl.

*--- Check if Refresh Button was pressed.

IF cs_user_command_data-ucomm = gc_ucomm_ext_push1.

cs_user_command_data-refresh = abap_true.

cs_user_command_data-ucomm_exec = abap_true.

*--- Store the currently selected log handle

lv_selected_log_handle = cl_bsp_wd_runtime_services=>get_selected_element( 'YOUR_TREE_ID' ).

*--- Pass the App log Object name

ls_obj-sign = 'I'.

ls_obj-option = 'EQ'.

ls_obj-low = gc_log_obj.

APPEND ls_obj TO ls_log_filter-object.

*--- Pass the App log Subobject Name

ls_sub_obj-sign = 'I'.

ls_sub_obj-option = 'EQ'.

ls_sub_obj-low = gc_subobject.

APPEND ls_sub_obj TO ls_log_filter-subobject.

*--- Load Application Logs via wrapper Class which calls FM BAL_DB_SEARCH

lt_log_handle = gr_log->search_logs( ls_log_filter ).

*--- Reload from database

CALL FUNCTION 'BAL_DB_RELOAD'

EXPORTING

i_t_log_handle = lt_log_handle

EXCEPTIONS

OTHERS = 0.

*--- Set display output data

CALL FUNCTION 'BAL_DSP_OUTPUT_SET_DATA'

EXPORTING

i_t_log_handle = lt_log_handle

EXCEPTIONS

OTHERS = 0.

*--- Restore the currently selected log handle

IF lv_selected_log_handle IS NOT INITIAL.

CALL METHOD cl_bsp_wd_runtime_services=>set_selected_element

EXPORTING

iv_id = 'YOUR_TREE_ID'

iv_index = lv_selected_log_handle.

ENDIF.

ENDIF.

ENDFORM.

Replace 'YOUR_TREE_ID' with the ID of your application log tree control.

This code stores the currently selected log handle in a variable before the refresh, refreshes the logs, sets the output data, and then restores the selection by setting the selected element in the tree control.

You may need to adjust this code to match your specific implementation, but this should give you a starting point to maintain the selection after a refresh.

0 Kudos

For information, using the CODE button, your answer will look more attractive.