07-23-2007 10:14 AM
Hi all,
I am having this much of requirement in out put as Top-Of-page.
I did this thing like below given code in classical report.
Now I am dling this in ALV.
Is it possible to get like this out put in ALV.
If, possible meand send the code for below requirement.
ULINE.
New-line no-scrolling.
WRITE:/40 'PLANNER GROUP WISE TAT REPORT'.
uline.
New-line no-scrolling.
WRITE:/39 'FROM:', S_ERDAT-LOW,
58 'TO:' , S_ERDAT-HIGH.
ULINE.
New-line no-scrolling.
WRITE:/ 'UNIT:',p_iwerk.
uline.
case 'X'.
when p_ordno.
New-line no-scrolling.
write 45 'ALL ORDER NUMBERS.'.
WHEN P_PEND.
New-line no-scrolling.
WRITE 45 'CURRENT.'.
WHEN P_BFORD.
New-line no-scrolling.
WRITE 45 'BROUGHT FORWARD ORDERS.'.
WHEN P_COMPL.
New-line no-scrolling.
WRITE 45 'COMPLETED.'.
ENDCASE.
ULINE.
Regards,
sarath
07-23-2007 10:18 AM
Hi
Try like this
tables: ekko.
type-pools: slis.
types: begin of t_ekko,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
statu type ekpo-statu,
aedat type ekpo-aedat,
matnr type ekpo-matnr,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
peinh type ekpo-peinh,
line_color(4) type c, "Used to store row color
end of t_ekko.
data: it_ekko type standard table of t_ekko initial size 0,
wa_ekko type t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
* Data declaration for EVENT and PRINT PARAMETER.
data: gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
* data declaration for sorting.
data : it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
data : i_list_comments type slis_t_listheader.
start-of-selection.
perform data_retrieval.
* perform user_command.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform build_sortcat.
perform display_alv_report.
end-of-selection.
*TOP-OF-PAGE.
* PERFORM top-of-page.
end-of-page.
*&----------------------------------------------------------
*& Form build_fieldcatalog
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
fieldcatalog-do_sum = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " build_fieldcatalog
*&----------------------------------------------------------
*& Form build_layout
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for
*when double
* "click(press f2)*
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " build_layout
*&----------------------------------------------------------
*& Form data_retrieval
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form data_retrieval.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr
peinh from ekpo into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
* Populate color variable with colour properties
* Char 1 = C (This is a color property)
* Char 2 = 3 (Color codes: 1 - 7)
* Char 3 = Intensified on/off ( 1 or 0 )
* Char 4 = Inverse display on/off ( 1 or 0 )
* i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
* Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
* wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " data_retrieval
*&----------------------------------------------------------
*& Form display_alv_report
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_event = gt_events
is_print = gd_prntparams
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_save = 'X'
tables
t_outtab = it_ekko
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.
endform. " DISPLAY_ALV_REPORT
*&----------------------------------------------------------
*& Form user_command
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
*&----------------------------------------------------------
*& Form top-of-page
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
concatenate sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) into wa_header-info."todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header
i_logo = 'GANESH_LOGO'.
endform. " top-of-page
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
when 'ULHAS'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
endcase.
endform.
*---------------------------------------------------------------------*
* FORM set_pf_status *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> RT_EXTAB *
*---------------------------------------------------------------------*
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'ZNEWSTATUS'.
endform.
*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[]
* EXCEPTIONS
* LIST_TYPE_WRONG = 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.
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " build_events
*&---------------------------------------------------------------------*
*& Form build_print_params
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " build_print_params
*---------------------------------------------------------------------*
* FORM END_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form end_of_page.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip. write:/40 'Page:', sy-pagno .
endform.
*---------------------------------------------------------------------*
* FORM END_OF_LIST *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form end_of_list.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip. write:/40 'Page:', sy-pagno .
endform.
*&---------------------------------------------------------------------*
*& Form build_sortcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_sortcat.
wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
append wa_sort to it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'EBELP'.
append wa_sort to it_sortcat.
endform. " build_sortcat
Reward all helpfull answers
Regards
Pavan
07-23-2007 10:18 AM
Hi
Try like this
tables: ekko.
type-pools: slis.
types: begin of t_ekko,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
statu type ekpo-statu,
aedat type ekpo-aedat,
matnr type ekpo-matnr,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
peinh type ekpo-peinh,
line_color(4) type c, "Used to store row color
end of t_ekko.
data: it_ekko type standard table of t_ekko initial size 0,
wa_ekko type t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
* Data declaration for EVENT and PRINT PARAMETER.
data: gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
* data declaration for sorting.
data : it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
data : i_list_comments type slis_t_listheader.
start-of-selection.
perform data_retrieval.
* perform user_command.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform build_sortcat.
perform display_alv_report.
end-of-selection.
*TOP-OF-PAGE.
* PERFORM top-of-page.
end-of-page.
*&----------------------------------------------------------
*& Form build_fieldcatalog
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
fieldcatalog-do_sum = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " build_fieldcatalog
*&----------------------------------------------------------
*& Form build_layout
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for
*when double
* "click(press f2)*
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " build_layout
*&----------------------------------------------------------
*& Form data_retrieval
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form data_retrieval.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr
peinh from ekpo into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
* Populate color variable with colour properties
* Char 1 = C (This is a color property)
* Char 2 = 3 (Color codes: 1 - 7)
* Char 3 = Intensified on/off ( 1 or 0 )
* Char 4 = Inverse display on/off ( 1 or 0 )
* i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
* Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
* wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " data_retrieval
*&----------------------------------------------------------
*& Form display_alv_report
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_event = gt_events
is_print = gd_prntparams
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_save = 'X'
tables
t_outtab = it_ekko
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.
endform. " DISPLAY_ALV_REPORT
*&----------------------------------------------------------
*& Form user_command
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
*&----------------------------------------------------------
*& Form top-of-page
*&----------------------------------------------------------
* text
*-----------------------------------------------------------
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------
form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
concatenate sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) into wa_header-info."todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header
i_logo = 'GANESH_LOGO'.
endform. " top-of-page
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
when 'ULHAS'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
endcase.
endform.
*---------------------------------------------------------------------*
* FORM set_pf_status *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> RT_EXTAB *
*---------------------------------------------------------------------*
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'ZNEWSTATUS'.
endform.
*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[]
* EXCEPTIONS
* LIST_TYPE_WRONG = 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.
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " build_events
*&---------------------------------------------------------------------*
*& Form build_print_params
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " build_print_params
*---------------------------------------------------------------------*
* FORM END_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form end_of_page.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip. write:/40 'Page:', sy-pagno .
endform.
*---------------------------------------------------------------------*
* FORM END_OF_LIST *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form end_of_list.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip. write:/40 'Page:', sy-pagno .
endform.
*&---------------------------------------------------------------------*
*& Form build_sortcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_sortcat.
wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
append wa_sort to it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'EBELP'.
append wa_sort to it_sortcat.
endform. " build_sortcat
Reward all helpfull answers
Regards
Pavan
07-23-2007 10:21 AM
Hi,
it will work fine in classical report but not in ALVS.
First thing there will not be any write statement in ALVS .
and about top of page you should handle using EVENTS.
TOP_OF_PAGE (here underscore not hiphen).
and u have to associate the text to the event and pass it in Function module
REUSE_ALV_COMMENTARY_WRITE
Regards,
Srinivas
07-23-2007 10:31 AM
Hi,
USe this,
To print in top_of_page you can use following code.
FORM top_of_page.
DATA: ls_line TYPE slis_listheader.
CLEAR : ls_line .REFRESH gs_line.
DATA: ws_text(100),
ws_todate(10),
ws_frmdate(10),
id_lines TYPE i,
id_linesc(10) TYPE c,
t_line LIKE ls_line-info.
ls_line-typ = 'H'.
ls_line-info = 'CUSTOMER C-FORM AND E-1 FORM DETAIL'.
APPEND ls_line TO gs_line.
CLEAR ls_line.
DESCRIBE TABLE i_vbrk3 LINES id_lines.
id_linesc = id_lines.
CONCATENATE 'Total No. of Record Selected :- ' id_linesc INTO t_line SEPARATED BY space.
ls_line-typ = 'A'.
ls_line-info = t_line.
APPEND ls_line TO gs_line.
CLEAR: ls_line, t_line.
<b>CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gs_line.
ENDFORM. "top_of_page</b>
Pls reward points.
Regards,
Ameet
07-23-2007 10:43 AM
Hi,
Just chk this link.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm
Regards
Reshma
07-23-2007 11:21 AM
hi,
try this code,
&----
*& Report ZPROGRAM
*&
&----
*&
*&
&----
REPORT ZPROGRAM.
table declaration.
tables : zemployee, zdepartment,zproject.
*type-pools declaration
type-pools : slis , icon.
type specification
types : begin of ty_emp,
empid type zempid,
empname type zempname,
empaddress type zempaddress,
city type zcity,
ponumber type zponumber,
detid type zdeptid,
end of ty_emp.
types : begin of ty_dept,
detid type zdeptid,
deptname type zdeptname,
designation type zdesignation,
projectid type zprojectid,
end of ty_dept.
types : begin of ty_project,
projectid type zprojectid,
technology type ztechnology,
clientname type zclientname,
end of ty_project.
types : begin of ty_final,
empid type zempid,
empname type zempname,
empaddress type zempaddress,
city type zcity,
ponumber type zponumber,
detid type zdeptid,
deptname type zdeptname,
designation type zdesignation,
projectid type zprojectid,
technology type ztechnology,
clientname type zclientname,
average type p decimals 2,
end of ty_final.
table type specification.
types : tt_emp type standard table of ty_emp,
tt_dept type standard table of ty_dept,
tt_project type standard table of ty_project,
tt_final type standard table of ty_final.
work area creation.
data : wa_emp type ty_emp,
wa_dept type ty_dept,
wa_project type ty_project,
wa_final type ty_final.
internal table declaration
data : itab_emp type tt_emp,
itab_dept type tt_dept,
itab_project type tt_project,
itab_final type tt_final.
layout declaration
data : gd_layout type slis_layout_alv.
assigning current program name.
data : gd_repid like sy-repid.
gd_repid = sy-repid.
fieldcatalog declaration.
data : d_fieldcat type slis_t_fieldcat_alv,
d_fieldcat_wa type slis_fieldcat_alv.
header declaration.
data : t_header type slis_t_listheader,
wa_header type slis_listheader,
linecount(10) type c,
line(10) type c.
selection-screen.
selection-screen : begin of block blk1 with frame title text-001.
select-options : s_empid for zemployee-empid.
parameters : p_dname like zdepartment-deptname.
parameters : p_proid like zproject-projectid.
selection-screen : begin of line.
parameters : p_rad1 radiobutton group r1.
selection-screen comment 3(10) text-002.
parameters : p_rad2 radiobutton group r1.
selection-screen comment 16(10) text-003.
selection-screen : end of line.
parameters : chk1 as checkbox.
selection-screen : end of block blk1.
end of selection screen.
start of selection.
select empid empname empaddress city ponumber detid from zemployee into corresponding fields of table itab_emp where empid in s_empid.
if not itab_emp is initial.
select detid deptname designation projectid from zdepartment into corresponding fields of table itab_dept for all entries in itab_emp where detid = itab_emp-detid .
if not itab_dept is initial.
select projectid technology clientname from zproject into corresponding fields of table itab_project for all entries in itab_dept where projectid = itab_dept-projectid.
endif.
endif.
*end of selection.
populating data into itab_final from itab_emp.
loop at itab_emp into wa_emp.
wa_final-empid = wa_emp-empid.
wa_final-empname = wa_emp-empname.
wa_final-empaddress = wa_emp-empaddress.
wa_final-ponumber = wa_emp-ponumber.
wa_final-city = wa_emp-city.
wa_final-detid = wa_emp-detid.
append wa_final to itab_final.
clear wa_final.
endloop.
*populating data into itab_final from itab_dept and itab_project
loop at itab_final into wa_final.
read table itab_dept into wa_dept with key detid = wa_final-detid.
if sy-subrc = 0.
wa_final-deptname = wa_dept-deptname.
wa_final-designation = wa_dept-designation.
wa_final-projectid = wa_dept-projectid.
modify itab_final from wa_final transporting deptname designation projectid .
endif.
read table itab_project into wa_project with key projectid = wa_final-projectid.
if sy-subrc = 0.
wa_final-technology = wa_project-technology.
wa_final-clientname = wa_project-clientname.
modify itab_final from wa_final transporting technology clientname.
endif.
endloop.
if p_rad1 = 'X' or chk1 = 'X'.
d_fieldcat_wa-fieldname = 'EMPID'.
d_fieldcat_wa-seltext_l = 'Employee Id'.
d_fieldcat_wa-emphasize = 'X'.
d_fieldcat_wa-col_pos = 1.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'EMPNAME'.
d_fieldcat_wa-seltext_l = 'Employee Name'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 2.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'EMPADDRESS'.
d_fieldcat_wa-seltext_l = 'Employee Address'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 3.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'CITY'.
d_fieldcat_wa-seltext_l = 'City'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 4.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'PONUMBER'.
d_fieldcat_wa-seltext_l = 'Postal Number'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 5.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'DETID'.
d_fieldcat_wa-seltext_l = 'Department Id'.
d_fieldcat_wa-emphasize = 'X'.
d_fieldcat_wa-col_pos = 6.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'DEPTNAME'.
d_fieldcat_wa-seltext_l = 'Department Name'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 7.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'DESIGNATION'.
d_fieldcat_wa-seltext_l = 'Designation'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 8.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'PROJECTID'.
d_fieldcat_wa-seltext_l = 'Project Id'.
d_fieldcat_wa-emphasize = 'X'.
d_fieldcat_wa-col_pos = 9.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'TECHNOLOGY'.
d_fieldcat_wa-seltext_l = 'technology'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 10.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'CLIENTNAME'.
d_fieldcat_wa-seltext_l = 'Client Name'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 11.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
endif.
if p_rad2 = 'X' or chk1 = 'X'.
refresh itab_emp.
d_fieldcat_wa-fieldname = 'DETID'.
d_fieldcat_wa-seltext_l = 'Department Id'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 6.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'DEPTNAME'.
d_fieldcat_wa-seltext_l = 'Department Name'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 7.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'DESIGNATION'.
d_fieldcat_wa-seltext_l = 'Designation'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 8.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'PROJECTID'.
d_fieldcat_wa-seltext_l = 'Project Id'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 9.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'TECHNOLOGY'.
d_fieldcat_wa-seltext_l = 'technology'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 10.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'CLIENTNAME'.
d_fieldcat_wa-seltext_l = 'Client Name'.
d_fieldcat_wa-emphasize = 'C710'.
d_fieldcat_wa-col_pos = 11.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
endif.
Grid display function module
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = gd_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'EMPLOYEE DETAILS'
I_GRID_SETTINGS =
IS_LAYOUT = gd_layout
IT_FIELDCAT = d_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = itab_final
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.
set pf_status for creating client specified icons.
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'NEWSTATUS'.
endform.
populating data into header using top_of_page
form top_of_page.
wa_header-typ = 'H'.
wa_header-info = 'ALV REPORT'.
append wa_header to t_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Date :'.
Concatenate sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) into wa_header-info.
append wa_header to t_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Time :'.
Concatenate sy-Uzeit(2) '.'
sy-datum+2(2) '.'
sy-datum+4(2) into wa_header-info.
append wa_header to t_header.
clear wa_header.
describe table itab_final lines line.
wa_header-typ = 'A'.
linecount = line.
Concatenate 'Total number of records :' linecount into wa_header-info separated by space.
append wa_header to t_header.
clear wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = t_header
I_LOGO = 'VMCADMIN'
I_END_OF_LIST_GRID =
I_ALV_FORM =
.
endform.
*designing layout.
form gd_layout.
gd_layout-zebra = 'X'.
gd_layout-edit = 'X'.
gd_layout-no_hotspot = ''.
gd_layout-no_colhead = ''.
gd_layout-colwidth_optimize = 'X'.
endform.
REward if useful.
07-23-2007 11:29 AM
HI,
see this code.
REPORT ZBHALV_LIST1.
TABLES:MARA.
SELECT-OPTIONS: MATNR FOR MARA-MATNR.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
MTART LIKE MARA-MTART,
MBRSH LIKE MARA-MBRSH,
END OF ITAB.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
IN MATNR.
TYPE-POOLS SLIS.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVE TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
SORT-UP = 'X'.
SORT-SPOS = 1.
SORT-FIELDNAME = 'ERSDA'.
SORT-tabname = 'MARA'.
APPEND SORT.
SORT-SPOS = 2.
SORT-FIELDNAME = 'MTART'.
SORT-tabname = 'MARA'.
APPEND SORT.
EVE-NAME = 'TOP_OF_PAGE'.
EVE-FORM = 'TOPOFPAGE'.
APPEND EVE.
EVE-NAME = 'TOP_OF_LIST'.
EVE-FORM = 'TOPOFLIST'.
APPEND EVE.
EVE-NAME = 'END_OF_LIST'.
EVE-FORM = 'ENDOFLIST'.
APPEND EVE.
LAYOUT-ZEBRA = 'X'.
LAYOUT-no_hline = 'X'.
LAYOUT-NO_VLINE = 'X'.
LAYOUT-window_titlebar = 'MATERIAL DETAILS'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 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 FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'UCOMM'
I_STRUCTURE_NAME =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = EVE[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 5
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
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 TOPOFPAGE.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
.
ENDFORM.
FORM TOPOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTTOP'.
APPEND HEAD.
<b> CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
.</b>
ENDFORM.
FORM ENDOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTEND'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
.
ENDFORM.
rgds,
bharat.
07-24-2007 6:42 AM