‎2009 Mar 17 12:49 PM
Hi Experts,
what has to be done if you have three different output tables which you would like
display by the ALV. How can you change between those three tables .
If possible I wold like to use the same alv reference.
data ref_alv TYPE REF TO cl_gui_alv_grid.
If this is not possible
please tell me the other way ?
Regards
sas
‎2009 Mar 17 2:36 PM
Gurpreet the command
CALL METHOD ref_alv->REFRESH_TABLE_DISPLAY
didnt help I have still the same output table.
Regards
sas
‎2009 Mar 17 12:51 PM
Please be more clear with your requirement.
On what conditions would you decide which table to display?
‎2009 Mar 17 12:52 PM
‎2009 Mar 17 12:57 PM
in SE51 when you create a container, split the container to three parts and use the class or OO ABAP to code by using three different container names and pass the values.
‎2009 Mar 17 12:58 PM
‎2009 Mar 17 12:55 PM
At the time of creation of Field Catalog
first create the Field Catalog for first internal table, then for second one and then for the third one.
Thanks.
‎2009 Mar 17 1:05 PM
HI,
It is possible to display three different output using single reference variable.
consider the following points,
1) initially display first display
2) At the end of PAI event you free you reference variable which is belongs to the custom container and control reference using free statement
3) in PBO module of screen you have to fetch the data to internal tablle based on OK_CODE
4) Generate field catalog based on internal table fields
4) Create reference variable for custome container and control and pass your internal table data.
Regards,
Peranandam
‎2009 Mar 17 12:57 PM
‎2009 Mar 17 12:58 PM
Hi,
i believe that u want to show the output of all the tables in alv format...
if that is show r these tables interelated to eachother ...
u need to develop an interactive alv report...
so ,
pls refer to the wiki that may help in your issue!!
Link:[https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/interactive%2balv%2breport%2busing%2bhotspot%2bevent]
thanks
‎2009 Mar 17 1:00 PM
Handle the Click on the Button is PAI:
EX:
IN PAI:
MODULE USER_COMMAND.
CASE SY_UCOMM.
WHEN BUTTON.
REFRESH GRID USING:
CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY
SET AL FLAG VALUE.
IN PBO:
WHEN FLAG = 'X'.
Build FIELD Catlog.
Use :
CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
Regards,
Gurpreet
‎2009 Mar 17 1:02 PM
Hi Sas,
Block ALV is used if you have to display more than one report on the output. Technically speaking if you have multiple internal table with data to be displayed as separate blocks then we go for block report of ALV.
The important functions used for creating this report are in sequence:
1. REUSE_ALV_BLOCK_LIST_INIT - First Call this FM. This function module is used to set the default GUI status etc
2. REUSE_ALV_BLOCK_LIST_APPEND -
The next function module used for block display is REUSE_ALV_BLOCK_LIST_APPEND
Export :
a. is_layout : layout settings for block
b. it_fieldcat : field catalog
c. I_tabname : internal table name with all possible events
Tables :
a. t_outtab : internal table with output data.
This function module adds the data to the block
3. REUSE_ALV_BLOCK_LIST_DISPLAY -
Parameters : All the parameters are optional.
This function module display the list with data appended by the
above function.
Regards,
Sachin
‎2009 Mar 17 2:10 PM
dear Experts I have followed your steps.
It is still unsolved. I have the same outputtable like inital screen when the windows
was displayed the first time
Did I maybe forget a refresh method ?????
Regards
sas
Edited by: erdem sas on Mar 17, 2009 3:10 PM
‎2009 Mar 17 2:15 PM
Hi,
If you need to display an another table in the grid.
Step1:
Use CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY " Mandatory
Step2:
Build the catalog for the new table and pass the table and catalog to Method:
CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DIAPLAY
Note: Use Flag to check conditions to refresh and Pass new Catalogs and tables.
Regards,
Gurpreet
‎2009 Mar 17 3:35 PM
Hi,
Have you deleted you control instances from presentation server by using free statement.
in PAI.
free ref_custom_control.
free ref_grid_control.
following above statement you have to flush changes immediately from automatic handler(presentation server) and CFW in application program by using FLUSH method.
Regards,
Peranandam
‎2009 Mar 17 2:36 PM
Gurpreet the command
CALL METHOD ref_alv->REFRESH_TABLE_DISPLAY
didnt help I have still the same output table.
Regards
sas
‎2009 Mar 17 2:52 PM
When the button is clicked set the flag in PAI.
INSTEAD OF PAI USE IT IN PBO:
Data:t_stbl type lvc_s_stbl.
if FLAG = 'X'. " For second table
CLear W_FCAT.
call method t_grid->refresh_table_display
exporting
is_stable = t_stbl
* i_soft_refresh =
* EXCEPTIONS
* finished = 1
* others = 2
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
w_fcat-fieldname = 'CARRID'. " Field catlog
w_fcat-coltext = 'CARRID'.
w_fcat-col_pos = 1.
w_fcat-emphasize = 5.
append w_fcat to t_fcat.
call method t_grid->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
is_layout = w_layo
* is_print =
* it_special_groups =
* it_toolbar_excluding = lt_exclude
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = <Second table name>
it_fieldcatalog = t_fcat
* it_sort = t_sort
* it_filter =
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* others = 4
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.Regards,
Gurpreet
‎2009 Mar 17 3:03 PM
My suggestion you need to use TABSTRIP + ALV for display of 3 different tables
Check this Uwe's example program
a®
‎2009 Mar 17 3:39 PM
hi,
maybe it helps to understand me better!
<outtab2>
<outtab3>
might be also dislayed as like as <outtab>
PROCESS BEFORE OUTPUT.
MODULE alvgrid_out.
PROCESS AFTER INPUT.
MODULE user_command_0600.MODULE alvgrid_out OUTPUT.
PERFORM init.
ENDMODULE. " ALVGRID_OUT OUTPUTFORM init.
IF NOT r_nsize IS INITIAL AND NOT r_normes IS INITIAL AND gv_flag IS INITIAL.
PERFORM alv_size.
gv_flag = 'X'.
ENDIF.
IF NOT r_slim IS INITIAL AND NOT r_slimes IS INITIAL AND gv_flag IS INITIAL.
PERFORM alv_slimsize.
gv_flag = 'X'.
ENDIF.
IF NOT r_stocky IS INITIAL AND NOT r_stomes IS INITIAL AND gv_flag IS INITIAL.
PERFORM alv_stockysize.
gv_flag = 'X'.
ENDIF.
IF NOT r_nsize IS INITIAL AND NOT r_normes IS INITIAL AND gv_paiflag EQ 'NO'.
PERFORM alv_size.
ENDIF.
IF NOT r_slim IS INITIAL AND NOT r_slimes IS INITIAL AND gv_paiflag EQ 'SL'.
PERFORM alv_slimsize.
ENDIF.
IF NOT r_stocky IS INITIAL AND NOT r_stomes IS INITIAL AND gv_paiflag EQ 'ST'.
PERFORM alv_stockysize.
ENDIF.
ENDFORM. "initMODULE user_command_0600 INPUT.
IF NOT r_nsize IS INITIAL AND NOT r_normes IS INITIAL AND sy-ucomm EQ 'NO'.
gv_paiflag = 'NO'.
ENDIF.
IF NOT r_slim IS INITIAL AND NOT r_slimes IS INITIAL AND sy-ucomm EQ 'SL'.
gv_paiflag = 'SL'.
ENDIF.
IF NOT r_stocky IS INITIAL AND NOT r_stomes IS INITIAL AND sy-ucomm EQ 'ST'.
gv_paiflag = 'ST'.
ENDIF.
FREE: ref_alv, ref_container.
ENDMODULE. " USER_COMMAND_0600 INPUTFORM alv_size .
CHECK ref_alv IS INITIAL.
CREATE OBJECT ref_container
EXPORTING
container_name = 'ALV'.
gv_layout-no_toolbar = 'X'.
CLEAR: gs_fcat, gs_zpd.
READ TABLE lt_sgroup INTO ls_sgr INDEX 1.
gs_fcat-fieldname = 'ORG_SIGN'.
gs_fcat-coltext = ''.
gs_fcat-outputlen = 2.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-fieldname = 'DESCRIPTION'.
gs_fcat-coltext = ls_sgr-sizegroup_name.
gs_fcat-outputlen = 30.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
SORT r_nsize BY low.
DELETE ADJACENT DUPLICATES FROM r_nsize.
LOOP AT r_nsize.
CONDENSE r_nsize-low NO-GAPS.
gs_fcat-fieldname = r_nsize-low.
gs_fcat-coltext = r_nsize-low.
gs_fcat-outputlen = 5.
APPEND gs_fcat TO gt_fcat.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname NE refer.
gs_fcat-edit = 'X'.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname EQ 'DESCRIPTION'.
gs_fcat-edit = ' '.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname EQ 'ORG_SIGN'.
gs_fcat-edit = ' '.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
FIELD-SYMBOLS: <lt_ss> TYPE table,
<test> TYPE ANY.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <outtab>.
CREATE DATA new_line LIKE LINE OF <outtab>.
ASSIGN new_line->* TO <l_line> .
SORT r_normes BY low.
DELETE ADJACENT DUPLICATES FROM r_normes.
LOOP AT r_normes.
ASSIGN COMPONENT 2 OF STRUCTURE <l_line> TO <test>.
<test> = r_normes-low.
APPEND <l_line> TO <outtab>.
ENDLOOP.
CLEAR gs_cpmpon.
REFRESH: gt_compon, gv_comp
.
PERFORM read_comp
TABLES gv_comp
USING
'zpd'
<l_line>.
CREATE OBJECT ref_alv
EXPORTING
i_parent = ref_container
i_appl_events = 'X'
EXCEPTIONS
OTHERS = 5.
CALL METHOD ref_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CREATE OBJECT ref_alv_events.
SET HANDLER ref_alv_events->handle_data_changed FOR ref_alv.
* <outtab2>
* <outtab3>
* might be also dislayed
CALL METHOD ref_alv->set_table_for_first_display
EXPORTING
is_layout = gv_layout
it_toolbar_excluding = it_toolbar_excluding " TYPE UI_FUNCTIONS
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = <outtab>
EXCEPTIONS
OTHERS = 4.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM. " ALV_SIZE
‎2009 Mar 17 3:55 PM
MODULE alvgrid_out OUTPUT.
If <Set condition>. " This codes has to be executed only fiest time program executed say all flags are initial
CREATE OBJECT ref_container
EXPORTING
container_name = 'ALV'.
CREATE OBJECT ref_alv
EXPORTING
i_parent = ref_container
i_appl_events = 'X'
EXCEPTIONS
OTHERS = 5.
endif.
PERFORM init.
ENDMODULE.
FORM alv_size .
CHECK ref_alv IS INITIAL.
Data:t_stbl type lvc_s_stbl.
if <COndition>. " Should not ne excuted for the first time.
call method t_grid->refresh_table_display
exporting
is_stable = t_stbl
* i_soft_refresh =
* EXCEPTIONS
* finished = 1
* others = 2
.
if sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDIF.
gv_layout-no_toolbar = 'X'.
CLEAR: gs_fcat, gs_zpd.
READ TABLE lt_sgroup INTO ls_sgr INDEX 1.
gs_fcat-fieldname = 'ORG_SIGN'.
gs_fcat-coltext = ''.
gs_fcat-outputlen = 2.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
gs_fcat-fieldname = 'DESCRIPTION'.
gs_fcat-coltext = ls_sgr-sizegroup_name.
gs_fcat-outputlen = 30.
APPEND gs_fcat TO gt_fcat.
CLEAR gs_fcat.
SORT r_nsize BY low.
DELETE ADJACENT DUPLICATES FROM r_nsize.
LOOP AT r_nsize.
CONDENSE r_nsize-low NO-GAPS.
gs_fcat-fieldname = r_nsize-low.
gs_fcat-coltext = r_nsize-low.
gs_fcat-outputlen = 5.
APPEND gs_fcat TO gt_fcat.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname NE refer.
gs_fcat-edit = 'X'.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname EQ 'DESCRIPTION'.
gs_fcat-edit = ' '.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
CLEAR gs_fcat.
LOOP AT gt_fcat INTO gs_fcat WHERE fieldname EQ 'ORG_SIGN'.
gs_fcat-edit = ' '.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING edit.
ENDLOOP.
FIELD-SYMBOLS: <lt_ss> TYPE table,
<test> TYPE ANY.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <outtab>.
CREATE DATA new_line LIKE LINE OF <outtab>.
ASSIGN new_line->* TO <l_line> .
SORT r_normes BY low.
DELETE ADJACENT DUPLICATES FROM r_normes.
LOOP AT r_normes.
ASSIGN COMPONENT 2 OF STRUCTURE <l_line> TO <test>.
<test> = r_normes-low.
APPEND <l_line> TO <outtab>.
ENDLOOP.
CLEAR gs_cpmpon.
REFRESH: gt_compon, gv_comp
.
PERFORM read_comp
TABLES gv_comp
USING
'zpd'
<l_line>.
CALL METHOD ref_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CREATE OBJECT ref_alv_events.
SET HANDLER ref_alv_events->handle_data_changed FOR ref_alv.
* CALL METHOD ref_alv->refresh_table_display.
* <outtab2>
* <outtab3>
* might be also dislayed
CALL METHOD ref_alv->set_table_for_first_display
EXPORTING
is_layout = gv_layout
it_toolbar_excluding = it_toolbar_excluding " TYPE UI_FUNCTIONS
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = <outtab>
EXCEPTIONS
OTHERS = 4.
* CALL METHOD cl_gui_cfw=>flush.
ENDFORM. " ALV_SIZERegards,
Gurpreet
‎2009 Mar 17 4:33 PM
Gurpreet Singh
You are the best. I thank you very much many times.
It is working
Regards
sas