09-15-2008 10:35 AM
Hello Experts,
I am currently developing a report wherein I need to display 3 different tables but the
catch is, I need to replicate those 3 tables depending on the sort criteria. Lets
say I have a sort criteria by company code(BUKRS) and in my tables I have 3 company codes. So
what I need to do is to display 3 ALV blocks per company code so in my case I need to
display 9 ALV blocks because per company = 3 display.
My problem is only the last company code is being displayed. Below is my code:
* Initialize ALV
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = gv_repid.
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
* Prepare fields of internal tables for fieldcatalog
DO lv_lines TIMES.
ADD 1 TO lv_tabix.
LOOP AT lt_itab_name INTO wa_itab_name.
CALL METHOD cl_abap_structdescr=>describe_by_name
EXPORTING
p_name = wa_itab_name-itab_name
RECEIVING
p_descr_ref = lcl_typedescr
EXCEPTIONS
type_not_found = 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.
REFRESH lt_components.
lcl_structdescr ?= lcl_typedescr.
lt_components = lcl_structdescr->components.
me->prepare_components( ).
me->build_layout( ).
me->set_print( ).
me->build_events( ).
ASSIGN (wa_itab_name-itab_name2) TO <fs_itab>.
CASE 'X'.
WHEN rb_bukrs.
READ TABLE lcl_process_data=>gt_sort_crit ASSIGNING <fs_sort_crit>
INDEX lv_tabix.
IF sy-subrc = 0.
CASE wa_itab_name-itab_name2.
WHEN 'LT_OUTPUT_ACQ'.
lt_output_acq[] = lt_output_acq_dum[].
DELETE lt_output_acq WHERE bukrs <> <fs_sort_crit>-bukrs.
WHEN 'LT_OUTPUT_RET'.
lt_output_ret[] = lt_output_ret_dum[].
DELETE lt_output_ret WHERE bukrs <> <fs_sort_crit>-bukrs.
WHEN 'LT_OUTPUT_NET'.
lt_output_net[] = lt_output_net_dum[].
DELETE lt_output_net WHERE bukrs <> <fs_sort_crit>-bukrs.
ENDCASE.
ENDIF.
WHEN rb_kostl.
READ TABLE lcl_process_data=>gt_sort_crit ASSIGNING <fs_sort_crit>
INDEX lv_tabix.
IF sy-subrc = 0.
CASE wa_itab_name-itab_name2.
WHEN 'LT_OUTPUT_ACQ'.
lt_output_acq[] = lt_output_acq_dum[].
DELETE lt_output_acq WHERE kostl <> <fs_sort_crit>-kostl.
WHEN 'LT_OUTPUT_RET'.
lt_output_ret[] = lt_output_ret_dum[].
DELETE lt_output_ret WHERE kostl <> <fs_sort_crit>-kostl.
WHEN 'LT_OUTPUT_NET'.
lt_output_net[] = lt_output_net_dum[].
DELETE lt_output_net WHERE kostl <> <fs_sort_crit>-kostl.
ENDCASE.
ENDIF.
ENDCASE.
* Append internal table for ALV block
me->call_alv_block_fm( "<---This is where I append the internal tables
EXPORTING
im_itab_name = wa_itab_name-itab_name2
im_itab = <fs_itab> ).
ENDLOOP.
ENDDO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
EXCEPTIONS
program_error = 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.
09-15-2008 10:40 AM
Hi
Try to use function REUSE_ALV_BLOCK_LIST_APPEND instead
of REUSE_ALV_LIST_DISPLAY.
A good example for using this function is program
BALVBT01.
BLOCK REPORT
This is used to display multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_DISPLAY
D. REUSE_ALV_BLOCK_HS_LIST_APPEND
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
a. I_CALLBACK_PROGRAM
b. I_CALLBACK_PF_STATUS_SET
c. I_CALLBACK_USER_COMMAND
This function module is used to set the default GUI status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Export :
a. IS_LAYOUT : layout settings for block
b. IT_FIELDCAT : field catalog
c. I_TABNAME : Internal table name of the output data
d. IT_EVENTS : 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.
INTERNAL TABLES IN SLIS
Slis_t_fieldcat_alv :
This internal table contains the field attributes. This internal table can be populated automatically by using u2018REUSE_ALV_FIELDCATALOG_MERGEu2019.
Important Attributes:
a. col_pos : position of the column
b. fieldname : internal fieldname
c. tabname : internal table name
d. ref_fieldname : fieldname (dictionary)
e. ref_tabname : table (dictionary)
f. key(1) : column with key-color
g. icon(1) : icon
h. hotspot(1) : hotspot
i. Symbol(1) : symbol
j. Checkbox(1) : checkbox
k. just(1) : (R)ight (L)eft (C)ent
l. do_sum(1) : sum up
m. no_out(1) : (O)blig. (X)no out
n. outputlen : output length
o. seltext-l : long key word
p. seltext_m : middle key word
q. seltext_s : short key word
r. reptext_ddic : heading(ddic)
s. ddictxt(1) : (S)hort (M)iddle (L)ong
t. datatype : datatype
SLIS_T_EVENT :
Internal table for storing all the possible events of the ALV. This can be populated by the function module Reuse_alv_events_get
The columns are :
name : name of the event
form : name of the routine
SYNTAXES FOR THE ROUTINES
I_CALLBACK_PF_STATUS_SET
Syntax :
FORM set_pf_status USING rt_extab TYPE slis_t_extab
The table RT_EXTAB contains the function codes which are hidden in the standard interface.
I_CALLBACK_USER_COMMAND
Syntax :
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
The parameter r_ucomm contains the function code.
The structure rs_selfield has the details about the current cursor position.
Check this link
http://www.sap-basis-abap.com/abap/sample-program-on-block-lists.htm
Regards
Pavan
09-15-2008 10:40 AM
Hi
Try to use function REUSE_ALV_BLOCK_LIST_APPEND instead
of REUSE_ALV_LIST_DISPLAY.
A good example for using this function is program
BALVBT01.
BLOCK REPORT
This is used to display multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_DISPLAY
D. REUSE_ALV_BLOCK_HS_LIST_APPEND
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
a. I_CALLBACK_PROGRAM
b. I_CALLBACK_PF_STATUS_SET
c. I_CALLBACK_USER_COMMAND
This function module is used to set the default GUI status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Export :
a. IS_LAYOUT : layout settings for block
b. IT_FIELDCAT : field catalog
c. I_TABNAME : Internal table name of the output data
d. IT_EVENTS : 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.
INTERNAL TABLES IN SLIS
Slis_t_fieldcat_alv :
This internal table contains the field attributes. This internal table can be populated automatically by using u2018REUSE_ALV_FIELDCATALOG_MERGEu2019.
Important Attributes:
a. col_pos : position of the column
b. fieldname : internal fieldname
c. tabname : internal table name
d. ref_fieldname : fieldname (dictionary)
e. ref_tabname : table (dictionary)
f. key(1) : column with key-color
g. icon(1) : icon
h. hotspot(1) : hotspot
i. Symbol(1) : symbol
j. Checkbox(1) : checkbox
k. just(1) : (R)ight (L)eft (C)ent
l. do_sum(1) : sum up
m. no_out(1) : (O)blig. (X)no out
n. outputlen : output length
o. seltext-l : long key word
p. seltext_m : middle key word
q. seltext_s : short key word
r. reptext_ddic : heading(ddic)
s. ddictxt(1) : (S)hort (M)iddle (L)ong
t. datatype : datatype
SLIS_T_EVENT :
Internal table for storing all the possible events of the ALV. This can be populated by the function module Reuse_alv_events_get
The columns are :
name : name of the event
form : name of the routine
SYNTAXES FOR THE ROUTINES
I_CALLBACK_PF_STATUS_SET
Syntax :
FORM set_pf_status USING rt_extab TYPE slis_t_extab
The table RT_EXTAB contains the function codes which are hidden in the standard interface.
I_CALLBACK_USER_COMMAND
Syntax :
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
The parameter r_ucomm contains the function code.
The structure rs_selfield has the details about the current cursor position.
Check this link
http://www.sap-basis-abap.com/abap/sample-program-on-block-lists.htm
Regards
Pavan
09-15-2008 10:42 AM
Hi Praveen,
Yes, I am using the said FM inside my method. Please see code below:
* METHOD call_alv_block_fm
METHOD call_alv_block_fm.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fieldcat
i_tabname = im_itab_name
it_events = gt_events
it_sort = gt_sort
* I_TEXT = ' '
TABLES
t_outtab = im_itab
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD. "call_alv_block_fm
09-15-2008 10:56 AM