SAP ABAP - Multiple Header ALV List
REPORT ZALV_LIST_MULTIHEADER NO STANDARD PAGE HEADING.
TYPE-POOLS: slis.
DATA :t_fieldcat TYPE slis_t_fieldcat_alv,
w_fieldcat TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv,
t_sort TYPE slis_t_sortinfo_alv,
t_event TYPE slis_t_event WITH HEADER LINE,
d_repid LIKE sy-repid,
d_layout TYPE slis_layout_alv,
key TYPE slis_keyinfo_alv.
TYPES : BEGIN OF ty_data,
store(50),
price TYPE dmbtr,
quantity TYPE p,
total TYPE dmbtr, "(10) TYPE p DECIMALS 2,
price2 TYPE dmbtr,
quantity2 TYPE p,
total2 TYPE dmbtr, "(10) TYPE p DECIMALS 2,
curr TYPE waers,
END OF ty_data.
DATA : t_data TYPE ty_data OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
PERFORM f_process_data.
PERFORM f_write_data.
*&---------------------------------------------------------------------*
*& Form F_PROCESS_DATA
*&---------------------------------------------------------------------*
FORM f_process_data .
*fill data t_data
t_data-store = 'Ayam Kampung'.
t_data-quantity = 30.
t_data-price = 50000.
t_data-total = t_data-quantity * t_data-price.
t_data-quantity2 = 525.
t_data-price2 = 55000.
t_data-total2 = t_data-quantity2 * t_data-price2.
t_data-curr = 'IDR'.
APPEND t_data.
t_data-store = 'Ayam Boiler'.
t_data-quantity = 10.
t_data-price = 50000.
t_data-total = t_data-quantity * t_data-price.
t_data-quantity2 = 55.
t_data-price2 = 55000.
t_data-total2 = t_data-quantity2 * t_data-price2.
t_data-curr = 'IDR'.
APPEND t_data.
ENDFORM. " F_PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form F_WRITE_DATA
*&---------------------------------------------------------------------*
FORM f_write_data .
PERFORM field_catalog.
PERFORM build_layout.
PERFORM build_event.
d_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = d_repid
is_layout = d_layout
i_bypassing_buffer = 'X'
it_fieldcat = t_fieldcat
i_default = 'X'
i_save = 'A'
it_events = t_event[]
it_sort = t_sort
TABLES
t_outtab = t_data[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " F_WRITE_DATA
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM field_catalog .
PERFORM f_fieldcats USING :
'STORE' 'STORE' '50' '' '' '' '' '',
'QUANTITY' 'QUANTITY' '15' '' '' '' '' '',
'PRICE' 'PRICE' '15' '' 'CURR' '' '' '',
'TOTAL' 'TOTAL' '20' '' 'CURR' '' '' '',
'QUANTITY2' 'QUANTITY2' '15' '' '' '' '' '',
'PRICE2' 'PRICE2' '15' '' 'CURR' '' '' '',
'TOTAL2' 'TOTAL2' '20' '' 'CURR' '' '' ''.
ENDFORM. " FIELD_CATALOG
*&---------------------------------------------------------------------*
*& Form F_FIELDCATS
*&---------------------------------------------------------------------*
FORM f_fieldcats USING fu_fname
fu_text
fu_len
fu_sum
fu_curr
fu_spot
fu_out
fu_sign.
DATA : lt_fieldcat TYPE slis_fieldcat_alv.
lt_fieldcat-fieldname = fu_fname. "field name
lt_fieldcat-seltext_l = lt_fieldcat-seltext_m = "text
lt_fieldcat-seltext_s = fu_text.
lt_fieldcat-reptext_ddic = fu_text.
lt_fieldcat-outputlen = fu_len. "text length
lt_fieldcat-do_sum = fu_sum. "summing
lt_fieldcat-cfieldname = fu_curr. "currency
lt_fieldcat-hotspot = fu_spot.
lt_fieldcat-no_out = fu_out.
lt_fieldcat-no_sign = fu_sign.
APPEND lt_fieldcat TO t_fieldcat.
CLEAR: lt_fieldcat.
ENDFORM. " F_FIELDCATS
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
FORM build_layout .
d_layout-colwidth_optimize = ''.
d_layout-zebra = 'X'.
d_layout-no_colhead = 'X'. "space.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form BUILD_EVENT
*&---------------------------------------------------------------------*
FORM build_event .
t_event-form = 'TOP_PAGE'.
t_event-name = 'TOP_OF_PAGE'.
APPEND t_event.
ENDFORM. " BUILD_EVENT
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
FORM top_page.
ULINE (295) .
FORMAT COLOR 1 .
WRITE: / sy-vline, (48) '' CENTERED,
sy-vline, (50) 'Current Period' CENTERED,
sy-vline, (50) 'Ytd Period' CENTERED,
sy-vline.
* ULINE (295) .
WRITE: / sy-vline, (48) ' ' CENTERED,
sy-vline, (13) 'Quantity' CENTERED,
sy-vline, (13) 'per Unit' CENTERED,
sy-vline, (18) 'Total' CENTERED,
sy-vline, (13) 'Quantity' CENTERED,
sy-vline, (13) 'per Unit' CENTERED,
sy-vline, (18) 'Total' CENTERED,
sy-vline.
* ULINE (295) .
FORMAT COLOR OFF.
ENDFORM. "top_of_page
TYPE-POOLS: slis.
DATA :t_fieldcat TYPE slis_t_fieldcat_alv,
w_fieldcat TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv,
t_sort TYPE slis_t_sortinfo_alv,
t_event TYPE slis_t_event WITH HEADER LINE,
d_repid LIKE sy-repid,
d_layout TYPE slis_layout_alv,
key TYPE slis_keyinfo_alv.
TYPES : BEGIN OF ty_data,
store(50),
price TYPE dmbtr,
quantity TYPE p,
total TYPE dmbtr, "(10) TYPE p DECIMALS 2,
price2 TYPE dmbtr,
quantity2 TYPE p,
total2 TYPE dmbtr, "(10) TYPE p DECIMALS 2,
curr TYPE waers,
END OF ty_data.
DATA : t_data TYPE ty_data OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
PERFORM f_process_data.
PERFORM f_write_data.
*&---------------------------------------------------------------------*
*& Form F_PROCESS_DATA
*&---------------------------------------------------------------------*
FORM f_process_data .
*fill data t_data
t_data-store = 'Ayam Kampung'.
t_data-quantity = 30.
t_data-price = 50000.
t_data-total = t_data-quantity * t_data-price.
t_data-quantity2 = 525.
t_data-price2 = 55000.
t_data-total2 = t_data-quantity2 * t_data-price2.
t_data-curr = 'IDR'.
APPEND t_data.
t_data-store = 'Ayam Boiler'.
t_data-quantity = 10.
t_data-price = 50000.
t_data-total = t_data-quantity * t_data-price.
t_data-quantity2 = 55.
t_data-price2 = 55000.
t_data-total2 = t_data-quantity2 * t_data-price2.
t_data-curr = 'IDR'.
APPEND t_data.
ENDFORM. " F_PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form F_WRITE_DATA
*&---------------------------------------------------------------------*
FORM f_write_data .
PERFORM field_catalog.
PERFORM build_layout.
PERFORM build_event.
d_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = d_repid
is_layout = d_layout
i_bypassing_buffer = 'X'
it_fieldcat = t_fieldcat
i_default = 'X'
i_save = 'A'
it_events = t_event[]
it_sort = t_sort
TABLES
t_outtab = t_data[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " F_WRITE_DATA
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM field_catalog .
PERFORM f_fieldcats USING :
'STORE' 'STORE' '50' '' '' '' '' '',
'QUANTITY' 'QUANTITY' '15' '' '' '' '' '',
'PRICE' 'PRICE' '15' '' 'CURR' '' '' '',
'TOTAL' 'TOTAL' '20' '' 'CURR' '' '' '',
'QUANTITY2' 'QUANTITY2' '15' '' '' '' '' '',
'PRICE2' 'PRICE2' '15' '' 'CURR' '' '' '',
'TOTAL2' 'TOTAL2' '20' '' 'CURR' '' '' ''.
ENDFORM. " FIELD_CATALOG
*&---------------------------------------------------------------------*
*& Form F_FIELDCATS
*&---------------------------------------------------------------------*
FORM f_fieldcats USING fu_fname
fu_text
fu_len
fu_sum
fu_curr
fu_spot
fu_out
fu_sign.
DATA : lt_fieldcat TYPE slis_fieldcat_alv.
lt_fieldcat-fieldname = fu_fname. "field name
lt_fieldcat-seltext_l = lt_fieldcat-seltext_m = "text
lt_fieldcat-seltext_s = fu_text.
lt_fieldcat-reptext_ddic = fu_text.
lt_fieldcat-outputlen = fu_len. "text length
lt_fieldcat-do_sum = fu_sum. "summing
lt_fieldcat-cfieldname = fu_curr. "currency
lt_fieldcat-hotspot = fu_spot.
lt_fieldcat-no_out = fu_out.
lt_fieldcat-no_sign = fu_sign.
APPEND lt_fieldcat TO t_fieldcat.
CLEAR: lt_fieldcat.
ENDFORM. " F_FIELDCATS
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
FORM build_layout .
d_layout-colwidth_optimize = ''.
d_layout-zebra = 'X'.
d_layout-no_colhead = 'X'. "space.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form BUILD_EVENT
*&---------------------------------------------------------------------*
FORM build_event .
t_event-form = 'TOP_PAGE'.
t_event-name = 'TOP_OF_PAGE'.
APPEND t_event.
ENDFORM. " BUILD_EVENT
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
FORM top_page.
ULINE (295) .
FORMAT COLOR 1 .
WRITE: / sy-vline, (48) '' CENTERED,
sy-vline, (50) 'Current Period' CENTERED,
sy-vline, (50) 'Ytd Period' CENTERED,
sy-vline.
* ULINE (295) .
WRITE: / sy-vline, (48) ' ' CENTERED,
sy-vline, (13) 'Quantity' CENTERED,
sy-vline, (13) 'per Unit' CENTERED,
sy-vline, (18) 'Total' CENTERED,
sy-vline, (13) 'Quantity' CENTERED,
sy-vline, (13) 'per Unit' CENTERED,
sy-vline, (18) 'Total' CENTERED,
sy-vline.
* ULINE (295) .
FORMAT COLOR OFF.
ENDFORM. "top_of_page
Comments
Post a Comment