ALV Hierarchy
Here’s the example about how to create report using ALV hierarchy (courtesy of Sigit Rachmanto)
report ytes_hierarchy no standard page heading line-size 255.
*——————standard common includes—————————-*
* common report header and other functions
include yin_list_header.* ALV common functions
include yin_alv_common.*——————standard common includes—ends——————-*
*—————————————————————-*
* Tables *
*———————————————————————-*
tables: aufk, afvc.
type-pools: kkblo, slis, abap.types: begin of header_type.
include structure caufv.
types: chbox(1),
exp(1).
types: end of header_type.types: begin of detail_type,
aufpl like afvc-aufpl,
vornr like afvc-vornr,
werks like afvc-werks,
steus like afvc-steus,
ltxa1 like afvc-ltxa1,
end of detail_type.*———————————————————-*
* Global Internal Table
*———————————————————-*
data:gi_header type standard table of header_type with header line,
gi_detail type standard table of detail_type with header line.*———————————————————-*
* Global Variable *
*———————————————————-*
data: repid like sy-repid value ‘YTES_HIERARCHY’.
data: ok_code like sy-ucomm.*&——————————————————————–*
*& selection-screen -> Selection
*&——————————————————————–*selection-screen begin of block zyhb1 with frame title text-101.
select-options:
so_aufnr for aufk-aufnr no intervals.
selection-screen end of block zyhb1 .*———————————————————————-*
* START-OF-SELECTION.
*———————————————————————-*
start-of-selection.
perform f_collect_data.
perform f_print_data.
perform f_refresh_itab.*———————————————————————-*
* END-OF-SELECTION.
*———————————————————————-*
end-of-selection.*&———————————————————————*
*& Form f_collect_data
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_collect_data.
select * into corresponding fields of table gi_header
from caufv where aufnr in so_aufnr.
select * into corresponding fields of table gi_detail
from afvc for all entries in gi_header where aufpl = gi_header-aufpl.
endform. ” f_collect_data*&———————————————————————*
*& Form f_print_data
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_print_data.
perform f_alv tables gi_header.
endform. ” f_print_data*&———————————————————————*
*& Form f_refresh_intab
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_refresh_itab.
refresh: gi_header, gi_detail.
endform. ” f_refresh_intab*———————————————————————*
* FORM f_alv *
*———————————————————————*
* …….. *
*———————————————————————*
* –> FT_DATA *
*———————————————————————*
form f_alv tables ft_report.perform f_gui_message using ‘Write Data in Progress …’ ”.
perform f_clear_alv_data.
perform f_build_fieldcat.
perform f_build_keyinfo using d_alv_keyinfo.
perform f_build_layout using d_layout.
perform f_build_event tables t_alv_event.d_repid = sy-repid.
call function ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
exporting
i_callback_program = d_repid
i_callback_pf_status_set = ‘F_SET_PF_STATUS’
i_callback_user_command = ‘F_USER_COMMAND’
is_layout = d_layout
it_fieldcat = t_alv_fieldcat[]
it_events = t_alv_event[]
i_tabname_header = ‘GI_HEADER’
i_tabname_item = ‘GI_DETAIL’
is_keyinfo = d_alv_keyinfo
tables
t_outtab_header = gi_header
t_outtab_item = gi_detail
exceptions
program_error = 1
others = 2.
endform. ” f_alv*&———————————————————————*
*& Form f_gui_message
*&———————————————————————*
* text
*———————————————————————-*
* –>fu_text1 text
* –>fu_text2 text
*———————————————————————-*
form f_gui_message using fu_text1 fu_text2.
data: ld_text1(100) type c.concatenate fu_text1 fu_text2 into ld_text1
separated by space.
call function ‘SAPGUI_PROGRESS_INDICATOR’
exporting
percentage = 0
text = ld_text1.
endform. ” f_gui_message*&———————————————————————*
*& Form f_clear_alv_data
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_clear_alv_data.
clear:t_alv_fieldcat,
t_alv_event,
t_events,
t_alv_isort,
t_alv_filter,
t_event_exit,
d_alv_isort,
d_alv_variant,
d_alv_list_scroll,
d_alv_sort_postn,
d_alv_keyinfo,
d_alv_fieldcat,
d_alv_formname,
d_alv_ucomm,
d_alv_print,
d_alv_repid,
d_alv_tabix,
d_alv_subrc,
d_alv_screen_start_column,
d_alv_screen_start_line,
d_alv_screen_end_column,
d_alv_screen_end_line,
d_alv_layout,
d_layout,
d_repid,
d_print.refresh: t_alv_fieldcat,
t_alv_event,
t_events,
t_alv_isort,
t_alv_filter,
t_event_exit.d_repid = sy-repid.
endform. ” f_clear_alv_data*&———————————————————————*
*& Form f_build_fieldcat
*&———————————————————————*
* text
*———————————————————————-*
* –>P_FT_REPORT text
*———————————————————————-*
form f_build_fieldcat .refresh: t_alv_fieldcat.
perform f_fieldcatg using ‘GI_HEADER’:
‘AUFNR’ ‘CAUFV’ ‘AUFNR’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘AUART’ ‘CAUFV’ ‘AUART’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘AUTYP’ ‘CAUFV’ ‘AUTYP’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘AUFPL’ ‘CAUFV’ ‘AUFPL’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”.perform f_fieldcatg using ‘GI_DETAIL’:
‘VORNR’ ‘AFVC’ ‘VORNR’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘WERKS’ ‘AFVC’ ‘WERKS’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘STEUS’ ‘AFVC’ ‘STEUS’ ” ” ” ” ” ” ” ” ” ” ” ” ” ”,
‘LTXA1′ ‘AFVC’ ‘LTXA1′ ” ” ” ” ” ” ” ” ” ” ” ” ” ”.call function ‘REUSE_ALV_FIELDCATALOG_MERGE’
exporting
i_internal_tabname = ‘GI_HEADER’
changing
ct_fieldcat = t_alv_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.call function ‘REUSE_ALV_FIELDCATALOG_MERGE’
exporting
i_internal_tabname = ‘GI_DETAIL’
changing
ct_fieldcat = t_alv_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. ” f_build_fieldcat*&———————————————————————*
*& Form f_build_layout
*&———————————————————————*
* text
*———————————————————————-*
* –>FU_LAYOUT text
*———————————————————————-*
form f_build_layout using fu_layout type slis_layout_alv.
fu_layout-f2code = ‘&IC1′.
fu_layout-zebra = ‘X’.
fu_layout-colwidth_optimize = space.
fu_layout-no_colhead = space.
fu_layout-no_uline_hs = ‘X’.fu_layout-box_fieldname = ‘CHBOX’.
fu_layout-box_tabname = ‘GI_HEADER’.
fu_layout-expand_fieldname = ‘EXP’.
endform. ” f_build_layout*&———————————————————————*
*& Form f_build_sortfield
*&———————————————————————*
* text
*———————————————————————-*
* –>FU_SORT text
*———————————————————————-*
form f_build_sortfield using fu_sort type slis_t_sortinfo_alv.
data: ld_sort type slis_sortinfo_alv.clear ld_sort.
ld_sort-tabname = ‘GI_HEADER’.
ld_sort-fieldname = ‘AUFNR’.
ld_sort-up = ‘X’.
ld_sort-subtot = ‘X’.
append ld_sort to fu_sort.clear ld_sort.
ld_sort-tabname = ‘GI_DETAIL’.
ld_sort-fieldname = ‘VORNR’.
ld_sort-up = ‘X’.
ld_sort-subtot = ‘X’.
append ld_sort to fu_sort.endform. ” f_build_sortfield
*&———————————————————————*
*& Form f_build_event
*&———————————————————————*
* text
*———————————————————————-*
* –> FT_EVENTS
*———————————————————————-*
form f_build_event tables ft_events like t_events.
refresh: ft_events.
clear ft_events.
ft_events-name = slis_ev_top_of_page.
ft_events-form = ‘F_TOP_OF_PAGE’.
append ft_events.
endform. ” f_build_event*&———————————————————————*
*& Form f_build_event_exit
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_build_event_exit.
clear t_event_exit.
t_event_exit-ucomm = ‘&OUP’.
t_event_exit-after = ‘X’.
append t_event_exit.clear t_event_exit.
t_event_exit-ucomm = ‘&ODN’.
t_event_exit-after = ‘X’.
append t_event_exit.
endform. ” f_build_event_exit*&———————————————————————*
*& Form f_fieldcatg
*&———————————————————————*
* text
*———————————————————————-*
form f_fieldcatg using
value(fu_types) value(fu_fname)
value(fu_reftb)
value(fu_refld)
value(fu_noout)
value(fu_outln)
value(fu_fltxt)
value(fu_dosum)
value(fu_hotsp)
value(fu_dec)
value(fu_waers)
value(fu_meins)
value(fu_waers_f)
value(fu_meins_f)
value(fu_checkbox)
* value(fu_fixcolumn)
value(fu_key)
value(fu_icon)
value(fu_input).data: ld_fieldcat type slis_fieldcat_alv.
clear: ld_fieldcat.
ld_fieldcat-tabname = fu_types.
ld_fieldcat-fieldname = fu_fname.
ld_fieldcat-ref_tabname = fu_reftb.
ld_fieldcat-ref_fieldname = fu_refld.
ld_fieldcat-no_out = fu_noout.
ld_fieldcat-outputlen = fu_outln.
ld_fieldcat-seltext_l = fu_fltxt.
ld_fieldcat-seltext_m = fu_fltxt.
ld_fieldcat-seltext_s = fu_fltxt.
ld_fieldcat-reptext_ddic = fu_fltxt.
ld_fieldcat-no_out = fu_noout.
ld_fieldcat-do_sum = fu_dosum.
ld_fieldcat-hotspot = fu_hotsp.
ld_fieldcat-decimals_out = fu_dec.
ld_fieldcat-currency = fu_waers.
ld_fieldcat-quantity = fu_meins.
ld_fieldcat-qfieldname = fu_meins_f.
ld_fieldcat-cfieldname = fu_waers_f.
ld_fieldcat-checkbox = fu_checkbox.
* ld_fieldcat-fix_column = fu_fixcolumn.
ld_fieldcat-key = fu_key.
ld_fieldcat-icon = fu_icon.
ld_fieldcat-input = fu_input.
append ld_fieldcat to t_alv_fieldcat.
clear ld_fieldcat.
endform. ” f_fieldcatg*———————————————————————*
* FORM f_top_of_page *
*———————————————————————*
* …….. *
*———————————————————————*
form f_top_of_page.
uline.
perform fm_hdr_title using sy-title.
perform fm_skip.
uline.
endform. “f_top_of_page*&——————————————————————–*
*& Form f_build_keyinfo
*&——————————————————————–*
* text
*———————————————————————*
* –>FU_KEYINFO text
*———————————————————————*
form f_build_keyinfo using fu_keyinfo type slis_keyinfo_alv .
fu_keyinfo-header01 = ‘AUFPL’.
fu_keyinfo-item01 = ‘AUFPL’.
endform. ” f_build_keyinfo*&——————————————————————–*
*& Form f_set_pf_status
*&——————————————————————–*
* text
*———————————————————————*
*
*———————————————————————*
form f_set_pf_status using rt_extab type slis_t_extab.types: begin of tab_type,
fcode like rsmpe-func,
end of tab_type.data: tab type standard table of tab_type with
non-unique default key initial size 10,
wa_tab type tab_type.clear tab.
sy-lsind = 0.
set pf-status ‘ZSTANDARD’.
endform. ” F_SET_PF_STATUS*———————————————————————*
* FORM f_user_command *
*———————————————————————*
* text
*———————————————————————*
form f_user_command using fu_ucomm like sy-ucomm
fu_selfield type slis_selfield.data: lt_dynpread like dynpread occurs 0 with header line.
move fu_ucomm to ok_code.
case ok_code.
when ‘&IC1′.
perform f_double_clicked_view.
when ‘&ETA’.
perform f_double_clicked_view.
when ‘&F03′ or ‘&F15′ or ‘&F12′.
endcase.move ‘X’ to fu_selfield-refresh.
endform. “f_user_command*&———————————————————————*
*& Form f_double_clicked_view
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
form f_double_clicked_view .
data: rs_selfield type slis_selfield,
l_tabname type kkblo_tabname.get cursor field rs_selfield-sel_tab_field value rs_selfield-value.
split rs_selfield-sel_tab_field at ‘-’ into l_tabname
rs_selfield-fieldname.
endform. ” f_double_clicked_view
INCLUDE yin_list_header
*&——————————————————————-*
*& Include YIN_LIST_HEADER *
*&——————————————————————-*data:
d_hdr_rpt_lines value ‘X’,
d_hdr_selection(50),
d_hdr_rpos type i,
d_hdr_lines type i,
d_hdr_types,
d_hdr_intsf, “Flag for intensified
d_hdr_low(30),
d_hdr_high(30),
d_hdr_atext(80),
d_hdr_lngth type i,
d_hdr_title(999), ” Report title with padding
d_hdr_text1(999), ” User text 1
d_hdr_text2(999), ” User text 2
d_hdr_text3(999). ” User text 3data: d_hdr_begrtime type i,
d_hdr_endrtime type i,
d_hdr_rtime(15) value ‘HH:MM:SS,mm’.*&———————————————————————*
*& Macro m_hdr_show_selection_value
*&———————————————————————*
* Display value of SELECT-OPTIONS
* &1 => cursor position
* &2 => decription
* &3 => internal table from selection screen
* &4 => L = left justified; R = right justified
define m_hdr_show_selection_value.
clear d_hdr_selection.
concatenate &2 ‘%%’ into d_hdr_selection separated by space.
describe table &3 lines d_hdr_lines.
if d_hdr_lines gt 1.
*– More then 1 value for each selection criteria
replace ‘%%’ with ‘Multiple Selection’ into d_hdr_selection.
elseif &3 is initial.
*– Select all
replace ‘%%’ with ‘All’ into d_hdr_selection.
else.
describe field &3-low type d_hdr_types.
write &3-low to d_hdr_low.
write &3-high to d_hdr_high.
*– Specific requirement
if not ( d_hdr_types eq ‘D’ or d_hdr_types ne ‘T’ ).
*—- Don’t delete leading zero for type DATE and TIME.
shift d_hdr_low left deleting leading ‘0′.
shift d_hdr_high left deleting leading ‘0′.
endif.
clear d_hdr_atext.
if &3-sign = ‘I’.
*—- Include range
case &3-option.
*—— Equal
when ‘EQ’. replace ‘%%’ with d_hdr_low into d_hdr_selection.
*—— Between
when ‘BT’. concatenate d_hdr_low ‘to’ d_hdr_high
into d_hdr_atext separated by space.
replace ‘%%’ with d_hdr_atext into d_hdr_selection.
*—— Others ( NE, GT, LT, GE, LE, LIKE )
when others. concatenate &3-option d_hdr_low
into d_hdr_atext separated by space.
replace ‘%%’ with d_hdr_atext into d_hdr_selection.
endcase.
else.
*—- Exclude range
write: ‘NOT’.
case &3-option.
when ‘EQ’. replace ‘%%’ with d_hdr_low into d_hdr_selection.
when ‘BT’. concatenate ‘IN [' d_hdr_low 'to' d_hdr_high ']‘
into d_hdr_atext separated by space.
replace ‘%%’ with d_hdr_atext into d_hdr_selection.
*—— Others ( NE, GT, LT, GE, LE, LIKE )
when others. concatenate &3-option d_hdr_low
into d_hdr_atext separated by space.
replace ‘%%’ with d_hdr_atext into d_hdr_selection.
endcase.
endif.
endif.
d_hdr_lngth = strlen( d_hdr_selection ).
if &4 eq ‘L’ or &4 eq ‘l’.
write at &1(d_hdr_lngth) d_hdr_selection.
else.
d_hdr_rpos = &1 – d_hdr_lngth.
write at d_hdr_rpos(d_hdr_lngth) d_hdr_selection.
endif.
end-of-definition.*&———————————————————————*
*& Form FM_HDR_PAD_TITLE
*&———————————————————————*
* Prepare the variable with the title text spaced correctly
*———————————————————————-*
form fm_hdr_pad_title using v_left_text v_middle_text v_right_text.data:
page_width type i, ” Width of page
middle_length type i, ” Length of title text
left_length type i, ” Length of left text
right_length type i, ” Length of right text
left_start type i, ” Position on line for start of left tex
middle_start type i, ” Position on line for start of middl tex
right_start type i. ” Position on line for start of right tex*— Start with a blank title
clear d_hdr_title.
page_width = sy-linsz – 1.*— Compute space on either side of title allowing vertical border
compute middle_length = strlen( v_middle_text ).
compute left_length = strlen( v_left_text ).
compute right_length = strlen( v_right_text ).compute middle_start = ( sy-linsz – middle_length ) / 2.
*— Allow for vertical lines
left_start = 0.
if d_hdr_rpt_lines = ‘X’.
d_hdr_title(1) = sy-vline.
d_hdr_title+page_width(1) = sy-vline.
left_start = 1.
endif.
right_start = sy-linsz – left_start – right_length – 1.
writesy-vline.
*— Insert texts
if left_length <> 0.
* d_hdr_title+left_start(left_length) = v_left_text.
write at (left_length) v_left_text.
endif.
if middle_length <> 0.
write at middle_start(middle_length) v_middle_text.
* d_hdr_title+middle_start(middle_length) = v_middle_text.
endif.
if right_length <> 0.
write at right_start(26) v_right_text.
* d_hdr_title+right_start(right_length) = v_right_text.
endif.
write at sy-linsz sy-vline.
endform. ” FM_HDR_PAD_TITLE*&———————————————————————*
*& Form F_HDR_END
*&———————————————————————*
* Output End-Of-Report text
*———————————————————————-*
form f_hdr_end.
skip.
write ‘ *** End of Report ***’(999) ” End of report
color col_background.
endform. ” F_HDR_END*&———————————————————————*
*& Form FM_HDR_ULINE
*&———————————————————————*
* Draw underline if flag set
*———————————————————————-*
form fm_hdr_uline.
if d_hdr_rpt_lines = ‘X’.
uline.
endif.
endform. ” FM_HDR_ULINE*&———————————————————————*
*& Form FM_HDR_TITLE
*&———————————————————————*
* Header line with title
*———————————————————————-*
form fm_hdr_title using fu_company.
data:
lv_number(30) value ‘Page : nnnn’,
lv_progname(42) value ‘Program: xx’,
lv_prog(20),
lv_page(10).*— Page number
* lv_page = sy-pagno.
replace ‘nnnn’ with lv_page into lv_number.
if sy-cprog eq sy-repid.
replace ‘xx’ with sy-repid into lv_progname.
else.
concatenate sy-repid ‘(’ sy-cprog ‘)’ into lv_prog.
replace ‘xx’ with lv_prog into lv_progname.
endif.*— Output line
perform fm_hdr_pad_title using fu_company ” lv_page.
endform. ” FM_HDR_TITLE*&———————————————————————*
*& Form FM_HDR_LINE1
*&———————————————————————*
* Client, User text 1, Date and time
*———————————————————————-*
form fm_hdr_line1 using fu_title.
data:
lv_left(30),
lv_datum(10),
lv_right(35).*— left
* replace ‘XXX’ with sy-sysid(3) into lv_left.
* replace ‘YYY’ with sy-mandt into lv_left.*— centre
*— right
write sy-datum to lv_datum.
concatenate ‘Printing date :’ lv_datum into lv_right separated by ‘ ‘.
*— output line
perform fm_hdr_pad_title using lv_left fu_title lv_right.
endform. ” FM_HDR_LINE1*&———————————————————————*
*& Form F_HDR_LINE3
*&———————————————————————*
* User name, text 2, time
*———————————————————————-*
form f_hdr_line3 using fu_title.data:
lv_uzeit(5) value ‘hh:mm’,
lv_uname(30) value ‘Printed by : xx’,
lv_name(10).
*— time
replace ‘hh’ with sy-uzeit(2) into lv_uzeit. ” hour
replace ‘mm’ with sy-uzeit+2(2) into lv_uzeit. ” minute*— user
write sy-uname to lv_name right-justified.
* lv_name = sy-uname.
replace ‘xx’ with lv_name into lv_uname.*— output line
perform fm_hdr_pad_title using lv_uzeit fu_title lv_uname.endform. ” F_HDR_LINE3
*&———————————————————————*
*& Form F_HDR_OPTIONS
*&———————————————————————*
* Select options
*———————————————————————-*
form f_hdr_options.
data: begin of seltab occurs 5.
include structure rsparams.
data: end of seltab.data: rpt like sy-repid.
rpt = sy-repid.call function ‘RS_REFRESH_FROM_SELECTOPTIONS’
exporting
curr_report = rpt
tables
selection_table = seltab
exceptions
not_found = 1
no_report = 2
others = 3.*— Delete unused selection options
loop at seltab.
if seltab-low = space.
delete seltab index sy-tabix.
endif.
endloop.call function ‘RS_LIST_SELECTION_TABLE’
exporting
report = rpt
seltext = ‘X’
newpage = ‘ ‘
tables
sel_tab = seltab
exceptions
sel_tab_empty = 1
others = 2.endform.
*&———————————————————————*
*& Form F_HDR_HEADER
*&———————————————————————*
form f_hdr_header using fu_title.
data: begin of lt_pool occurs 50.
include structure textpool.
data: end of lt_pool.perform fm_hdr_uline.
perform fm_hdr_title using fu_title.
read textpool sy-repid into lt_pool language sy-langu.
read table lt_pool with key ‘R’.
perform fm_hdr_line1 using lt_pool-entry.
perform f_hdr_line3 using space.
perform fm_hdr_uline. ” underline
endform. ” F_HDR_HEADER*&———————————————————————*
*& Form F_HDR_VLINE
*&———————————————————————*
form f_hdr_vline.
write /01 sy-vline.
write at sy-linsz sy-vline.
endform. ” F_HDR_VLINE*&———————————————————————*
*& Form F_HDR_CALC_RUNTIME
*&———————————————————————*
form f_hdr_calc_runtime.
data:
ld_tot_runtime type p decimals 2,
ld_hdr_rtime(5),
ld_trunc type i,
ld_hh(2) type n,
ld_mm(2) type n,
ld_ss(2) type n,
ld_mi(2) type n.skip.
get run time field d_hdr_endrtime.
ld_tot_runtime = ( d_hdr_endrtime – d_hdr_begrtime ) / 1000000.
ld_trunc = trunc( ld_tot_runtime ).
ld_hh = ld_trunc div 3600.
ld_mm = ld_trunc div 60.
ld_ss = ld_trunc mod 60.
ld_mi = ceil( ld_tot_runtime ).
replace ‘HH’ with ld_hh into d_hdr_rtime.
replace ‘MM’ with ld_mm into d_hdr_rtime.
replace ‘SS’ with ld_ss into d_hdr_rtime.
replace ‘mm’ with ld_mi into d_hdr_rtime.
endform. ” F_HDR_CALC_RUNTIME*&———————————————————————*
*& Form F_HDR_END_OF_REPORT
*&———————————————————————*
* Display ‘End of Report’ and run time program
form f_hdr_end_of_report.
if d_hdr_rtime ca sy-abcde.
perform f_hdr_calc_runtime.
endif.
write‘*** End of Report ( Run time =’, d_hdr_rtime, ‘) ***’.
endform. ” F_HDR_END_OF_REPORT*&———————————————————————*
*& Form F_HDR_START_REPORT
*&———————————————————————*
form f_hdr_start_report.
get run time field d_hdr_begrtime.
endform. ” F_HDR_START_REPORT
*&———————————————————————*
*& Form f_hdr_line4
*&———————————————————————*
* text
*———————————————————————-*
* –>P_1608 text
*———————————————————————-*
form f_hdr_line4 using fu_company.
data:
lv_number(30) value ‘Page : nnnn’,
lv_progname(42) value ‘Program: xx’,
lv_prog(20),
lv_page(10).*— Page number
lv_page = sy-pagno.
replace ‘nnnn’ with lv_page into lv_number.
if sy-cprog eq sy-repid.
replace ‘xx’ with sy-repid into lv_progname.
else.
concatenate sy-repid ‘(’ sy-cprog ‘)’ into lv_prog.
replace ‘xx’ with lv_prog into lv_progname.
endif.*— Output line
perform fm_hdr_pad_title using lv_progname fu_company lv_number.
endform. ” F_HDR_LINE4
*&———————————————————————*
*& Form fm_skip
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM fm_skip.
*— Output line
perform fm_hdr_pad_title using ” ” ”.
ENDFORM. ” fm_skip
*&———————————————————————*
*& Form fm_hdr_param1
*&———————————————————————*
* text
*———————————————————————-*
* –>P_FU_TEXT text
*———————————————————————-*
FORM fm_hdr_param1 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.
* replace ‘XXX’ with sy-sysid(3) into lv_left.
* replace ‘YYY’ with sy-mandt into lv_left.*— centre
*— right
write sy-datum to lv_datum.
concatenate ‘Printing date :’ lv_datum into lv_right separated by ‘ ‘.
*— output line
perform fm_hdr_pad_title using lv_left ” lv_right.
ENDFORM. ” fm_hdr_param1
*&———————————————————————*
*& Form fm_hdr_param2
*&———————————————————————*
* text
*———————————————————————-*
* –>P_1609 text
* –>P_1610 text
* –>P_SO_CARID_LOW text
* –>P_SO_CARID_HIGH text
*———————————————————————-*
FORM fm_hdr_param2 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35) value ‘Printed by : xx’,
lv_name(10).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.*— centre
*— right
write sy-uname to lv_name right-justified.
replace ‘xx’ with lv_name into lv_right.*— output line
perform fm_hdr_pad_title using lv_left ” lv_right.ENDFORM. ” fm_hdr_param2
*&———————————————————————*
*& Form fm_hdr_param3
*&———————————————————————*
* text
*———————————————————————-*
* –>P_CODE text
* –>P_TO text
* –>P_LOW text
* –>P_HIGH text
*———————————————————————-*
FORM fm_hdr_param3 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35) value ‘Page : nnnn’,
lv_name(10),
lv_page(10).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.
*— centre*— right
lv_page = sy-pagno.
replace ‘nnnn’ with lv_page into lv_right.*— output line
perform fm_hdr_pad_title using lv_left ” lv_right.ENDFORM. ” fm_hdr_param3
*&———————————————————————*
*& Form fm_hdr_param4
*&———————————————————————*
* text
*———————————————————————-*
* –>P_CODE text
* –>P_TO text
* –>P_LOW text
* –>P_HIGH text
*———————————————————————-*
FORM fm_hdr_param4 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35) value ‘Page : nnnn’,
lv_name(10),
lv_page(10).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.
*— centre*— right
* lv_page = sy-pagno.
* replace ‘nnnn’ with lv_page into lv_right.*— output line
perform fm_hdr_pad_title using lv_left ” ”.ENDFORM. ” fm_hdr_param3
*&———————————————————————*
*& Form fm_hdr_param5
*&———————————————————————*
* text
*———————————————————————-*
* –>P_CODE text
* –>P_TO text
* –>P_LOW text
* –>P_HIGH text
*———————————————————————-*
FORM fm_hdr_param5 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35) value ‘Page : nnnn’,
lv_name(10),
lv_page(10).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.
*— centre*— right
* lv_page = sy-pagno.
* replace ‘nnnn’ with lv_page into lv_right.*— output line
perform fm_hdr_pad_title using lv_left ” ”.ENDFORM. ” fm_hdr_param5
*&———————————————————————*
*& Form fm_hdr_param6
*&———————————————————————*
* text
*———————————————————————-*
* –>P_CODE text
* –>P_TO text
* –>P_LOW text
* –>P_HIGH text
*———————————————————————-*
FORM fm_hdr_param6 USING fu_text1 fu_text2 fu_val01 fu_val02.
data: lv_left(60),
lv_datum(10),
lv_right(35),” value ‘Page : nnnn’,
lv_name(10),
lv_page(10).*— left
if fu_val02 is initial.
concatenate fu_text1 fu_val01 into lv_left separated by ‘ ‘.
else.
concatenate fu_text1 fu_val01 fu_text2 fu_val02 into lv_left
separated by ‘ ‘.
endif.
*— centre*— right
lv_page = sy-pagno.
replace ‘nnnn’ with lv_page into lv_right.*— output line
perform fm_hdr_pad_title using lv_left ” lv_right.ENDFORM. ” fm_hdr_param6
INCLUDE yin_alv_common
*&———————————————————————*
*& Include YIN_ALV_COMMON *
*&———————————————————————*type-pools: slis.
FIELD-SYMBOLS: <fs_table> TYPE table.
data: t_alv_fieldcat type slis_t_fieldcat_alv with header line,
t_alv_event type slis_t_event with header line,
t_events TYPE slis_t_event,
t_alv_isort type slis_t_sortinfo_alv with header line,
t_alv_filter type slis_t_filter_alv with header line,
t_event_exit type slis_t_event_exit with header line,
d_alv_isort type slis_sortinfo_alv,
d_alv_variant type disvariant,
d_alv_list_scroll type slis_list_scroll,
d_alv_sort_postn type i,
d_alv_keyinfo type slis_keyinfo_alv,
d_alv_fieldcat type slis_fieldcat_alv,
d_alv_formname type slis_formname,
d_alv_ucomm type slis_formname,
d_alv_print type slis_print_alv,
d_alv_repid like sy-repid,
d_alv_tabix like sy-tabix,
d_alv_subrc like sy-subrc,
d_alv_screen_start_column type i,
d_alv_screen_start_line type i,
d_alv_screen_end_column type i,
d_alv_screen_end_line type i,
d_alv_layout type slis_layout_alv.data: d_layout TYPE slis_layout_alv,
d_repid LIKE sy-repid,
d_print TYPE slis_print_alv.DATA: gt_list_top_of_page TYPE slis_t_listheader.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
IS_FCAT LIKE LINE OF IT_FCAT.DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.data: begin of gi_FIELDCAT occurs 0.
include structure LVC_S_FCAT.
data: end of gi_FIELDCAT.DATA: NEW_TABLE TYPE REF TO DATA.
DATA: NEW_LINE TYPE REF TO DATA.FIELD-SYMBOLS: <L_TABLE> TYPE standard table, “ANY TABLE,
<L_LINE> TYPE ANY,
<L_FIELD> TYPE ANY,
<L_FIELD2> TYPE ANY.


sy-vline.
buset, katanya blog gue jorok, yours lebih jorok! XD
Good.. wah… makin hebat aja nih..
dah bisa macro excel di ABAP terus dah bisa User Exit terus skrg dah bisa buat report hierarchy.. besok-besok tambah ilmu apa lagi yach?? ditunggu tulisan berikutnya..
Mau gabung jadi contributor article di http://www.sap-interface.com ? klo mau nanti aku bantu upload’in and publish article-nya..
btw, dah minta izin ke Mr. Sigit Rachmanto (yg buat template hierarchy-nya) utk di publish blm??
tp gpp.. aku dukung koq!!
Cahyoo…