07-06-2006 9:14 AM
Hi guys,
I need a page break in alv hirarchy for every new customer..
say for example
123 ttt 888(header data)
xxxxx xxxx xxxx xxx(item data)
xxxxx xxxx xxxx xxx(item data)
456 ttt 888(header data)
xxxxx xxxx xxxx xxx(item data)
xxxxx xxxx xxxx xxx(item data)
now what i want is i need a page break after printing the
123 ttt 888(header data)
xxxxx xxxx xxxx xxx(item data)
xxxxx xxxx xxxx xxx(item data)
any body could provide the solution for this then it will be appreciated
thanks & regards
Ravi v Ganji
07-06-2006 9:18 AM
hi,
it is very simple.
you need to fill the sort table info based on customer, and pass it to ALV FM.
sort-fieldname = 'KUNNR'.
sort-tabname = 'ITEM'.
sort-up= 'X'.
<b>sort-group = '*'.</b>"this is important for page break
append sort to it_sort.
now pass this to ALV heirarchial FM.
Regards
vijay
07-06-2006 9:55 AM
hi,
check the sample code..
report ZTEST_HIER line-count 65
line-size 200
no standard page heading
message-id zz.
type-pools: slis.
types: begin of ty_head,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
name like kna1-name1,
end of ty_head.
types: begin of ty_item,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
maktx like makt-maktx,
check(1),
end of ty_item.
data: it_item type table of ty_item.
data: it_header type table of ty_head,
it_events type slis_t_event, "Events.
it_fieldcat type slis_t_fieldcat_alv.
data: x_layout type slis_layout_alv,
x_fieldcat type slis_fieldcat_alv,
x_key type slis_keyinfo_alv,
x_events type slis_alv_event, "Event
x_vbeln like vbak-vbeln,
x_item type ty_item.
constants: c_s(1) value '/'.
data: v_flag.
*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
selection-screen begin of block blk with frame title text-001.
select-options: s_vbeln for x_vbeln. "Sales order Number
selection-screen end of block blk.
at selection-screen.
if not s_vbeln[] is initial.
select single vbeln
into x_vbeln
from vbak
where vbeln in s_vbeln.
if sy-subrc <> 0.
message e002 with 'Please enter valid Sales Order'(020).
endif.
endif.
*----------------------------------------------------------------------*
* CLASS lcl_bill_complete DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_bill_complete definition.
public section.
methods:get_header_data,
get_item_data,
show_data,
fill_fieldcat,
fill_events,
top_of_page.
endclass. "lcl_bill_complete DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_bill_complete IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_bill_complete implementation.
method get_header_data.
select vbak~vbeln
vbak~kunnr
kna1~name1
into table it_header
from vbak join kna1
on vbak~kunnr = kna1~kunnr
where vbak~vbeln in s_vbeln.
endmethod. "get_header_data
method get_item_data.
select vbap~vbeln
vbap~posnr
vbap~matnr
makt~maktx
into corresponding fields of table it_item
from vbap join makt
on vbap~matnr = makt~matnr
where vbap~vbeln in s_vbeln
and makt~spras = 'EN'.
endmethod. "get_item_data
method show_data.
x_key-header01 = 'VBELN'.
x_key-item01 = 'VBELN'.
x_key-item02 = 'POSNR'.
data: it_sort type SLIS_T_SORTINFO_ALV,
sort type SLIS_SORTINFO_ALV.
<b>sort-fieldname = 'VBELN'.
sort-tabname = 'IT_HEADER'.
sort-up = 'X'.
sort-group = '*'."this is important for page break
append sort to it_sort.</b>
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = x_layout
it_fieldcat = it_fieldcat[]
i_tabname_header = 'IT_HEADER'
i_tabname_item = 'IT_ITEM'
is_keyinfo = x_key
it_events = it_events
it_sort = it_sort
tables
t_outtab_header = it_header
t_outtab_item = it_item
exceptions
program_error = 1
others = 2.
endmethod. "show_data
method fill_fieldcat.
data: l_pos type i.
x_layout-header_text = 'HEADER'.
x_layout-item_text = 'ITEM'.
x_layout-default_item = ' '.
x_layout-no_keyfix = 'X'.
x_layout-box_tabname = 'IT_ITEM'.
l_pos = l_pos + 1.
*- Sales Order Number
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'IT_HEADER'.
x_fieldcat-seltext_m = 'Sales Order'(017).
x_fieldcat-outputlen = 11.
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'KUNNR'.
x_fieldcat-tabname = 'IT_HEADER'.
x_fieldcat-seltext_m = 'Sold-to Party'(010).
x_fieldcat-outputlen = 13.
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'NAME'.
x_fieldcat-tabname = 'IT_HEADER'.
x_fieldcat-outputlen = 15.
x_fieldcat-seltext_m = 'Sold-to name'(011).
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'CHECK'.
x_fieldcat-tabname = 'IT_ITEM'.
x_fieldcat-checkbox = 'X'.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-seltext_m = ' '.
x_fieldcat-outputlen = 2.
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'IT_ITEM'.
x_fieldcat-seltext_m = 'Sales Order'(017).
x_fieldcat-outputlen = 11.
x_fieldcat-tech = 'X'.
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
*- Sales Order Item
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-tabname = 'IT_ITEM'.
x_fieldcat-seltext_m = 'SO Item'(018).
x_fieldcat-outputlen = 7.
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'MATNR'.
x_fieldcat-tabname = 'IT_ITEM'.
x_fieldcat-outputlen = 18.
x_fieldcat-seltext_m = 'Material number'(012).
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-fieldname = 'MAKTX'.
x_fieldcat-tabname = 'IT_ITEM'.
x_fieldcat-outputlen = 40.
x_fieldcat-seltext_m = 'Material Description'(013).
x_fieldcat-col_pos = l_pos.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.
endmethod. "fill_fieldcat
*--Fill the events table
method fill_events.
*- Top of page
x_events-name = 'TOP_OF_PAGE'.
x_events-form = 'TOP_OF_PAGE'.
append x_events to it_events.
endmethod. "fill_events
"fill_events
method top_of_page.
*- Call Steelcase Standard Header
write 'top_of_page here'.
endmethod. "top_of_page
endclass. "lcl_bill_complete IMPLEMENTATION
start-of-selection.
data: obj type ref to lcl_bill_complete.
create object obj.
call method obj->get_header_data.
call method obj->get_item_data.
call method obj->fill_fieldcat.
call method obj->fill_events.
call method obj->show_data.
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* TOP_OF_PAGE
*----------------------------------------------------------------------*
form top_of_page.
*-To show the top of page
call method obj->top_of_page.
endform. "top_of_page
regards
vijay
07-06-2006 9:30 AM
Hi,
Use the function module 'REUSE_ALV_HIERSEQ_LIST_DISPLAY ' to display the report, this needs header & item internal tables to be passed,
Hope this helps,
Rgds,
07-06-2006 9:53 AM
hi,
go through this program BALVHD01_GROUP, this should solve your problem.
regards,
Manohar.