04-25-2008 12:29 PM
Dear All,
I have complete data in ine internal table.
I want to display this Data in ALV List form splitted as per Company Code, in the way as:
List Header
All Records related to Company Code 1000
List Header
All Records related to Company Code 2000
List Header
All Records related to Company Code 2000
.................................
So how to display this way.i.e. List splitted as per Compnay Codes
Please help ASAP.
Thanks in advance.
Best Regards,
Prasad
04-25-2008 12:35 PM
Hi,
Sort the final internal table by Company Code.
loop at itab into wa.
at end of bukrs.
new-page.
endat.
endloop.
Regards
Kannaiah
04-25-2008 12:33 PM
Hi Parsad
If you have data in a single ITAB you can do it by specifying both column and row position in fieldcatalog
fieldcat-column-pos = 1.
fieldcat-row-pos = 1.
(for heading)
fieldcat-column-pos = 1.
fieldcat-row-pos = 2.
fieldcat-column-pos = 2.
fieldcat-row-pos = 2.
fieldcat-column-pos = 3.
fieldcat-row-pos = 2.
(for other fields)
Thanks
Aditya
04-25-2008 12:35 PM
Hi,
Sort the final internal table by Company Code.
loop at itab into wa.
at end of bukrs.
new-page.
endat.
endloop.
Regards
Kannaiah
04-25-2008 12:35 PM
Hi,
Use sort group by company code
&----
*
*& Form sub_sort
&----
FORM sub_sort .
CLEAR wa_sort.
wa_sort-fieldname = 'PSPID'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
ENDFORM. " IT_SORT
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'SUB_USER_COMMAND'
is_layout = it_layout
it_fieldcat = it_fieldcat
it_sort = it_sort
i_save = 'A'
it_events = events
it_event_exit = lt_event_exit
TABLES
t_outtab = it_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards,
Raj.
04-25-2008 12:38 PM
Hi,
Please refer the code below:
*---------------------------------------------------------------------*
* Declarations for BLOCK ALV DISPLAY
*---------------------------------------------------------------------*
*--type pools
TYPE-POOLS:slis.
DATA:x_layout TYPE slis_layout_alv,
t_field TYPE slis_t_fieldcat_alv,
*--field catalog
x_fldcat LIKE LINE OF t_field,
*--to hold all the events
t_events TYPE slis_t_event,
x_events TYPE slis_alv_event,
t_sort TYPE slis_t_sortinfo_alv,
x_sort LIKE LINE OF t_sort ,
*--Print Layout
x_print_layout TYPE slis_print_alv.
*----Macro to add field catalog.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
DEFINE add_catalog.
clear x_fldcat.
x_fldcat-fieldname = &1.
x_fldcat-seltext_m = &2.
x_fldcat-outputlen = &3.
x_fldcat-tech = &4.
x_fldcat-col_pos = &5.
x_fldcat-no_zero = 'X'.
x_fldcat-ddictxt = 'M'.
x_fldcat-datatype = &6.
x_fldcat-ddic_outputlen = &7.
if &6 = 'N'.
x_fldcat-lzero = 'X'.
endif.
*--build field catalog
append x_fldcat to t_field.
END-OF-DEFINITION.
*----- data declerations.
data: v_repid like sy-repid.
data: begin of itab occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
meins like mara-meins,
end of itab.
data: begin of jtab occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
end of jtab.
select matnr ernam meins
up to 20 rows
from mara
into table itab.
select matnr maktx
up to 20 rows
from makt
into table jtab.
v_repid = sy-repid.
*DISPLAY alv
* Initialize Block
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = v_repid.
*Block 1:
*INITIALIZE
refresh t_field. clear t_field.
refresh t_events.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
add_catalog:
'MATNR' 'Material' '18' '' '1' 'C' '18',
'ERNAM' 'Created By' '12' '' '2' 'C' '12',
'MEINS' 'Unit' '5' '' '3' 'C' '3'.
*--build table for events.
x_events-form = 'TOP_OF_LIST1'.
x_events-name = slis_ev_top_of_list.
append x_events to t_events.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'ITAB'
it_events = t_events
it_sort = t_sort
tables
t_outtab = 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.
*--BLOCK 2(SUMMARY REPORT)
*INITIALIZE
refresh t_field. clear t_field.
refresh t_events.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
add_catalog:
'MATNR' 'Material' '20' '' '1' 'C' '18',
'MAKTX' 'Description' '40' '' '2' 'C' '40'.
*--build table for events.
x_events-form = 'TOP_OF_LIST2'.
x_events-name = slis_ev_top_of_list.
append x_events to t_events.
* Append table block.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'JTAB'
it_events = t_events
tables
t_outtab = jtab
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.
*--CALL FM TO DISPLAY THE BLOCK REPORT.
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* exporting
* is_print = x_print_layout
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.
form top_of_list1.
skip 1.
write: 10 'List 1',
/5 '--------------------'.
skip 1.
format reset.
endform.
form top_of_list2.
skip 1.
write: 10 'List 2',
/5 '--------------------'.
skip 1.
format reset.
endform.
Thanks,
Sriram Ponna.