Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

send OO AVL report to internet email address

Hi all,

Please help me out on this problem.

I have a report that is using OO AVL and now my boss wants to receive the report's output in his Outlook. I have read a lot of posts in here and follow their instructions but none works for me. I put complete source code in here:

*&----


*& Report ZHRRPT0003

&----


*& Purpose: email HR all recent changes to designated managers

&----


*& Author: David Nguyen. *

*& Date: 05/22/2006 *

*& SAP System: R/3 Enterprise 620 *

&----


*& Modification: *

*& Date Userid Description

*&

&----


report zhrrpt0003.

tables: pa0001,"HR Master Record

t501t. "Employee Group Names

data: begin of t_list occurs 0,

pernr like pa0001-pernr,

ename like pa0001-ename,

aedtm like pa0001-aedtm,

begda like pa0001-begda,

uname like pa0001-uname,

persg like pa0001-persg,

ptext like t501t-ptext,

orgeh like pa0001-orgeh,

orgtx like t527x-orgtx,

kostl like pa0001-kostl,

ktext like cskt-ktext,

burks like pa0001-bukrs,

werks like pa0001-werks,

persk like pa0001-persk,

vdsk1 like pa0001-vdsk1,

btrtl like pa0001-btrtl,

abkrs like pa0001-abkrs,

plans like pa0001-plans,

stell like pa0001-stell,

sachz like pa0001-sachz,

sname like pa0001-sname,

otype like pa0001-otype,

sbmod like pa0001-sbmod,

kokrs like pa0001-kokrs,

end of t_list.

data: wa_list like line of t_list,

g_repid like sy-repid,

save_ok type sy-ucomm, " command field

ok_code type sy-ucomm. " command field

*-- Global data definitions for ALV

data c_save type c value 'A'.

  • Structure to hold Variants

data gs_variant like disvariant.

*--- ALV Grid instance reference

data gr_alvgrid type ref to cl_gui_alv_grid .

*--- Name of the custom control added on the screen

data gc_custom_control_name type scrfname value 'CC_ALV' .

*--- Custom container instance reference

data gr_ccontainer type ref to cl_gui_custom_container .

*--- Field catalog table

data gt_fieldcat type lvc_t_fcat .

*--- Layout structure

data gs_layout type lvc_s_layo.

select-options: s_aedtm for pa0001-aedtm.

parameters: p_endda like pa0001-endda NO-DISPLAY.

************************************************************************

  • INITIALIZATION *

************************************************************************

initialization.

s_aedtm-low = sy-datum - 1.

append s_aedtm.

p_endda = '99991231'.

start-of-selection.

perform selection.

end-of-selection.

clear gs_variant.

g_repid = sy-repid.

gs_variant-report = g_repid.

call screen 200.

  • Subroutines

*----


  • Selection

*

*----


form selection.

data temp_wa_list like line of t_list.

data temp_index type I.

select pa0001~pernr pa0001~ename pa0001~aedtm pa0001~begda

pa0001~uname pa0001~persg t501t~ptext pa0001~orgeh

t527x~orgtx pa0001~kostl cskt~ktext pa0001~bukrs

pa0001~werks pa0001~persk pa0001~vdsk1 pa0001~btrtl

pa0001~abkrs pa0001~plans pa0001~stell pa0001~sachz

pa0001~sname pa0001~otype pa0001~sbmod pa0001~kokrs

into table t_list

from pa0001 inner join t501t on pa0001~persg = t501t~persg

inner join t527x on pa0001~orgeh = t527x~orgeh

inner join cskt on pa0001~kostl = cskt~kostl

where pa0001~aedtm in s_aedtm

and pa0001~endda <= p_endda

and pa0001~kostl ne ''

order by pa0001~ename pa0001~begda.

clear temp_wa_list.

loop at t_list into wa_list.

if wa_list-pernr <> temp_wa_list-pernr.

temp_wa_list = wa_list.

if wa_list-persg = 'A'.

select * from pa0001

where pa0001~pernr = wa_list-pernr

and pa0001~aedtm < wa_list-aedtm

and pa0001~persg = 'A'

order by pa0001~aedtm.

endselect.

if pa0001-kostl = wa_list-kostl.

delete t_list index sy-tabix.

clear temp_wa_list.

endif.

endif.

else.

clear temp_index.

temp_index = sy-tabix - 1.

delete t_list index temp_index .

endif.

endloop.

endform. " END OF SELECTION

************************************************************************

  • Display ALV

  • *

************************************************************************

form display_alv.

if gr_alvgrid is initial .

*----Creating custom container instance

create object gr_ccontainer

exporting

container_name = gc_custom_control_name

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6 .

if sy-subrc <> 0.

  • --Exception handling

endif.

  • ----Creating ALV Grid instance

create object gr_alvgrid

exporting

i_parent = gr_ccontainer

exceptions

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5 .

if sy-subrc <> 0.

  • --Exception handling

endif.

  • ----Preparing field catalog.

perform prepare_field_catalog changing gt_fieldcat .

  • ----Preparing layout structure

perform prepare_layout changing gs_layout .

  • ----Here will be additional preparations

*--e.g. initial sorting criteria, initial filtering criteria, excluding

  • --functions

call method gr_alvgrid->set_table_for_first_display

exporting

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

is_variant = gs_variant

i_save = c_save

  • I_DEFAULT = 'X'

is_layout = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

changing

it_outtab = t_list[]

it_fieldcatalog = gt_fieldcat

  • IT_SORT =

  • IT_FILTER =

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4 .

if sy-subrc <> 0.

  • --Exception handling

endif.

else .

call method gr_alvgrid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

exceptions

finished = 1

others = 2 .

if sy-subrc <> 0.

  • --Exception handling

endif.

endif .

endform. "END OF DISPLAY_ALV

************************************************************************

  • PREPARE_FIELD_CATALOG

  • *

************************************************************************

form prepare_field_catalog changing gt_fieldcat type lvc_t_fcat.

data ls_fcat type lvc_s_fcat .

ls_fcat-fieldname = 'PERNR'.

ls_fcat-ref_field = 'PERNR'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'ENAME'.

ls_fcat-ref_field = 'ENAME'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'AEDTM'.

ls_fcat-ref_field = 'AEDTM'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'BEGDA'.

ls_fcat-ref_field = 'BEGDA'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'UNAME'.

ls_fcat-ref_field = 'UNAME'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'PERSG'.

ls_fcat-ref_field = 'PERSG'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'PTEXT'.

ls_fcat-ref_field = 'PTEXT'.

ls_fcat-ref_table = 'T501T'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'ORGEH'.

ls_fcat-ref_field = 'ORGEH'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'ORGTX'.

ls_fcat-ref_field = 'ORGTX'.

ls_fcat-ref_table = 'T527X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'KOSTL'.

ls_fcat-ref_field = 'KOSTL'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'KTEXT'.

ls_fcat-ref_field = 'KTEXT'.

ls_fcat-ref_table = 'CSKT'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

  • Fields not display in default.

clear ls_fcat.

ls_fcat-fieldname = 'BUKRS'.

ls_fcat-ref_field = 'BURKS'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'WERKS'.

ls_fcat-ref_field = 'WERKS'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'PERSK'.

ls_fcat-ref_field = 'PERSK'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'VDSK1'.

ls_fcat-ref_field = 'VDSK1'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'BTRTL'.

ls_fcat-ref_field = 'BTRTL'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'ABKRS'.

ls_fcat-ref_field = 'ABKRS'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'PLANS'.

ls_fcat-ref_field = 'PLANS'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'STELL'.

ls_fcat-ref_field = 'STELL'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'SACHZ'.

ls_fcat-ref_field = 'SACHZ'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'SNAME'.

ls_fcat-ref_field = 'SNAME'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'OTYPE'.

ls_fcat-ref_field = 'OTYPE'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'SBMOD'.

ls_fcat-ref_field = 'SBMOD'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

clear ls_fcat.

ls_fcat-fieldname = 'KOKRS'.

ls_fcat-ref_field = 'KOKRS'.

ls_fcat-ref_table = 'PA0001'.

ls_fcat-no_out = 'X'.

ls_fcat-colddictxt = 'M'.

ls_fcat-selddictxt = 'L'.

append ls_fcat to gt_fieldcat.

endform. "END OF PREPARE_FIELD_CATALOG

************************************************************************

  • PREPARE_LAYOUT

  • *

************************************************************************

form prepare_layout changing gs_layout type lvc_s_layo.

gs_layout-cwidth_opt = 'X'.

  • GS_LAYOUT-stylefname = 'CELLSTYLES'. PUSHBUTTON

endform. "END OF PREPARE_LAYOUT

&----


*& Module status_0200 OUTPUT

&----


  • text

----


module status_0200 output.

set pf-status 'SCREEN_0200'.

set titlebar 'SCREEN_0200'.

perform display_alv.

endmodule. " status_0200 OUTPUT

&----


*& Module user_command_0200 INPUT

&----


module user_command_0200 input.

save_ok = ok_code.

clear ok_code.

case save_ok.

when 'BACK'.

call method gr_ccontainer->free.

leave to screen 0.

when 'CANCEL'.

call method gr_ccontainer->free.

leave to screen 0.

when 'EXIT'.

leave program.

endcase.

endmodule. " user_command_0200 INPUT

I will reward points and really appreciate your helps.

Tags:
Not what you were looking for? View more on this topic or Ask a question