I have two screens (screen A and screen B) in my module pool program. Screen A displays ALV grid and has 1 button on the toolbar and Screen B also displays ALV grid and 1 button on the toolbar.
When I press the button "Show orders" on screen A, I am directed to the screen B. Then I do some edit operations on screen B, click 'Save' button on the toolbar and then 'Back' button.
When I press the button "Show orders" on screen A for a different row, I am directed to the screen B again, but ALV grid still shows data from the first material, i.e. it doesn't display new data, but displays old data.
Does it have to do with cl_gui_cfw=>flush method somehow? If yes, then where exactly in the code should I call it in order to display correct data?
PBO module of Screen B.
CREATE OBJECT zclmz_pp_md_create=>go_container_charg
EXPORTING
parent = cl_gui_container=>screen0
side = cl_gui_docking_container=>dock_at_top
extension = 800.
CREATE OBJECT zclmz_pp_md_create=>go_alv_charg
EXPORTING
i_parent = zclmz_pp_md_create=>go_container_charg.
zclmz_pp_md_create=>go_alv_charg->set_table_for_first_display( EXPORTING
is_layout = ls_layout CHANGING it_outtab = zclmz_pp_md_create=>gs_plz-
charg it_fieldcatalog = lt_fieldcat ).
PAI module of Screen B.
zclmz_pp_md_create=>go_alv_charg->refresh_table_display( EXPORTING is_stable = ls_stable ).
CALL METHOD cl_gui_cfw=>flush.
Method refresh_table_display should be called in the PBO of screen B, not in the PAI.
IF zclmz_pp_md_create=>go_alv_charg is NOT BOUND.
CREATE OBJECT zclmz_pp_md_create=>go_container_charg
EXPORTING
parent = cl_gui_container=>screen0
side = cl_gui_docking_container=>dock_at_top
extension = 800.
CREATE OBJECT zclmz_pp_md_create=>go_alv_charg
EXPORTING
i_parent = zclmz_pp_md_create=>go_container_charg.
zclmz_pp_md_create=>go_alv_charg->set_table_for_first_display( EXPORTING
is_layout = ls_layout CHANGING it_outtab = zclmz_pp_md_create=>gs_plz-
charg it_fieldcatalog = lt_fieldcat ).
ELSE.
zclmz_pp_md_create=>go_alv_charg->refresh_table_display( ).
ENDIF.
That's a well-known issue with controls. If you instantiate a control (your ALV) inside a container in which there was already a control which has not been freed up, then the old control still shows up.
Two solutions :
Either you keep instantiating the control, but then you must free the previous control. For this, you must use the method FREE, which is available for all kinds of controls (even the container itself can be freed, all its inner controls are then freed up).
Or you change the logic by instantiating the control only once, and you refresh its contents, like Laurens said.
(the issue is not related to cl_gui_cfw=>flush by the way)
See also this other answer.
Related
My task is to customize the Header Details Screen of the ME33K transaction, the goal is to add a box with new fields that should appear only if the Agreement type is the one I defined by using the transaction SPRO (ex: Agreement type ABC).
I started making an enhancement to that screen by using the CMOD transaction, I created a dummy box and field with some hard-coded input value and it's working fine.
My next step would be to make these new fields appear only if the Agreement is of type ABC, but I cannot find the correct approach.
I tried doing some Screen-Loop programming and deactivating the box and/or fields, but the only ones that get deactivated are the standard ones that exist already, the ones I added with the enhancement are not affected.
EDIT :
The enhancement I used was 'MM06E005'.
I wrote the following Screen-Loop code in the include provided in the 'EXIT_SAPMM06E_006' user exit :
loop at screen.
if screen-name = 'CUSTOM_FIELDS'.
screen-active = 0.
modify screen.
endif.
endloop.
The enhancement MM06E005 refers to the subscreen SAPLXM06 0101, that you have created with a box with all your custom screen fields.
To hide your custom screen fields, you must:
Call a PBO (Process Before Output) module, to be done in the flow logic of your subscreen (the one which contains the screen fields):
PROCESS BEFORE OUTPUT.
...
MODULE modify_screen_field_attributes.
...
PROCESS AFTER INPUT.
...
In the include LXM06O01 (preferrably), do this:
MODULE modify_screen_field_attributes OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'CUSTOM_FIELDS'. " name of one screen field
screen-active = 0. " hide the screen field
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.
How to remove the Execute button (ONLI) from the screen above ALV display in set_table_for_first_display?
I want to remove from ALV display screen, not from Main screen(selection screen) where user enters parameters?
The available events of cl_gui_alv_grid does not have fcode as 'ONLI'.
I assume you are using the class cl_gui_alv_grid to show the ALV-Grid and you don't mean the toolbar of the ALV-Grid. The GUI status (execute and other buttons) are normally set in your program with the command SET PF-STATUS. Now you can remove it dynamically with
DATA: exclude_buttons TYPE slis_t_extab.
APPEND 'ONLI' TO exclude_buttons.
SET PF-STATUS 'MY_STATUS' EXCLUDING exclude_buttons.
or you remove the button statically from the GUI status.
The solution was simple.
I just added SET PF-STATUS ' ' before the ALV call and it worked.
I created a TableView with some data from database table. This view opens in a pop-up window.
When I select any row from the pop-up, my selected value is saved into some global variable.
How can I close the pop-up window after the row is selected? How to redirect to the view from where the pop-up was triggered?
Make this:
Create on_close event and put its name into lc_close var
Assign it to your table view click and to popup like this
<htmlb:tableView>
....
onRowSelection = "ON_CLOSE" >
</htmlb:tableView>
gr_pop_up->set_on_close_event( iv_event_name = lc_close iv_view = me ).
gr_pop_up->open( ).
Make in popup outbound plug named EXIT
Fire this plug inside itself recursively
method OP_EXIT.
me->fire_outbound_plug( iv_outbound_plug = 'EXIT' ).
endmethod.
This will close your popup.
You can save your value in a data base table or in a Singelton-Object.
What type of pop-up are you using? POPUP_TO_CONFIRM? Or a DynPro?
If it's the Function Module POPUP_TO_CONFIRM then just implement your logic based on a if statement checking the attribute "answer" of the FM.
If it's a DynPro then you need to add logic on the closing event. In a PAI Module.
Dear all I need your help on the below desperately.
I have created an ALV from SALV and I have copied a GUI Status SALV_STANDARD from a standard program. Firstly I added 2 buttons the POSTNEW & POSTDIFF and after a day I added the SELECT button.
Depending on the selection of the user I want to enable or disable the buttons according to the business requirements.
I have this code in a procedure:
r_alv type reference CL_SALV_TABLE.
if status_name is not initial and report_name is not initial.
set pf-status status_name.
r_alv->set_screen_status(
pfstatus = status_name
report = report_name
set_functions = r_alv->c_functions_all ).
endif.
data: lit_functions_list type salv_t_ui_func,
lwa_functions_list like line of lit_functions_list.
r_functions = r_alv->get_functions( ). "Get Toolbar functions
lit_functions_list = r_functions->get_functions( ).
if i_button_name is not initial.
** Now hide the BUTTON
loop at lit_functions_list into lwa_functions_list.
if lwa_functions_list-r_function->get_name( ) = i_button_name.
lwa_functions_list-r_function->set_visible( i_button_visable ).
endif.
endloop.
endif.
The variables status_name, report_name, i_button_name and i_button_visable are parameters of the procedure and I think that their names show what they are carrying.
The internal table lit_functions_list has 60 records and the last 2 have data for the first 2 buttons and this is the reason that I can enable/disable them.
But there is no record with my 3rd button SELECT. Instead there is a record with the button MYFUNCTION which I have already deleted.
Can someone tell me what to do in order to have the 3rd button available in the lit_functions_list?
Can someone tell me why this itab has so many garbages?
Thanks in advance
Elias
Even I had the same problem. After I ran the report BALVBUFDEL it solved the issue.
Newly created buttons now coming inside the function list ..
lit_functions_list = r_functions->get_functions( ).
For Adding 3rd button in the lit_functions_list, You can use below code.
r_functions->set_function( NAME = 'BUT3' BOOLEAN = 'X' ).
you can also use add_function to add new button.
try.
r_functions->add_function(
name = 'BUT3'
icon = l_icon
text = l_text
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_existing cx_salv_wrong_call.
endtry.
itab does not have garbage. It contains all the data related to status like menu bar, application tool bar and function keys.
Finally I found the answer at least to my problem. Let me describe again what I did:
I copy the GUI Status from the standard program SALV_DEMO_TABLE_FUNCTIONS to my program through Tcode SE41. I added 2 buttons POSTNEW & POSTDIF. Until now all working perfect and I can Enable/Disable these 2 buttons.
Next day the business asked me to add a button SELECT with which the user can make editable the corresponding SELECT column of the itab in order to choose which record to be posted. And here started my problem where the itab with the functions didn't contain the last created button SELECT. What I did was, I created a button through the design process of the GUI Status but I could not get it through the below code:
lit_functions_list = r_functions->get_functions( ).
With your answers I found other problems in my code but still I could not get the new button in the above itab.
Finally, yesterday evening I remembered, what someone told me in the past. In old systems (like oursSAP ECC 6.0 R701 SP007) sometimes the ALV buffer stuck and we have to reset it. So I run the program BALVBUFDEL and vuala the button SELECT appeared in the itab and I can now Enable or Disable.
So keep in mind that sometimes the ALV buffer needs a reset.
Thanks all for your help.
Elias
Is it possible to call the function MAT1_F4_HELP_EXIT in the PBO module of the screen to trigger search help for a material field on a custom screen (assigning the search help using se11 and search help exit is not working).
I am confused regarding the parameters that are being passed in the function.
Edit (taken from discussion)
I have a field called material, and I want to trigger a search help (MAT1). I have assigned it the table field and it is not letting the user do it automatically. So, I want to call it explicitly.
I have reproduced the issue (cf minimal code and screen at the bottom).
Steps to reproduce :
start the program (-> ALV displayed)
double click one line of the ALV (-> screen 0100 displayed)
press F4 on screen field defined with search help (-> popup 'abnormal situation' instead of search help!)
Reason: the active GUI status reassigns the F4 function key a classic function key behavior instead of calling the search help and as you didn't set a GUI status in your screen, the one of the previous screen is used again.
Solution: define your own GUI status and set it in the PBO of the screen (and don't redefine F4 of course!)
Rule of thumb : always define your own buttons and menus for every screen (why would you display buttons and menus from other screens which make no sense).
Minimal code:
REPORT.
SELECT * FROM sflight INTO TABLE #DATA(flights).
" does a CALL SCREEN which does SET PF-STATUS 'STANDARD_FULLSCREEN' (in program SAPLKKBL)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SFLIGHT'
TABLES
t_outtab = flights
EXCEPTIONS
OTHERS = 2.
FORM user_command
USING
r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF r_ucomm = '&IC1'.
CALL SCREEN 100.
ENDIF.
ENDFORM.
MODULE pbo OUTPUT.
" missing part !! ==> create GUI status 0100 and do SET PF-STATUS '0100'
ENDMODULE.
MODULE pai INPUT.
CASE sy-ucomm.
WHEN '&F03'.
SET SCREEN 0.
WHEN '&F4'.
" corresponds to F4 key inherited from ALV GUI status 'STANDARD_FULLSCREEN'
MESSAGE 'abnormal situation -> define your own GUI status !' TYPE 'I'.
ENDCASE.
ENDMODULE.
Screen 0100 :
Any field with search help (same as you did)
Flow logic of screen 0100 :
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai.