Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Send ALV Grid output as PDF attachment to external mail id?

vsubbakrishna
Participant
0 Kudos
967

Hi all,

I need to execute this report in background and <b>email the output as PDF</b> attachment to desired mail id's.

Need ur help on this....

Subba

&----


*& Report Z_ALV_PO *

*& *

&----


*& *

*& *

&----


REPORT ZALV_PO .

TABLES:EKKO.

TYPE-POOLS: slis.

*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: BEGIN OF I_FINAL OCCURS 10,

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

LIFNR LIKE EKKO-LIFNR,

AEDAT LIKE EKKO-AEDAT,

STATU LIKE EKKO-STATU,

END OF I_FINAL.

SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN,

S_AEDAT FOR EKKO-AEDAT.

START-OF-SELECTION.

SELECT

EBELN

BUKRS

LIFNR

AEDAT

STATU

FROM EKKO

INTO TABLE I_FINAL

WHERE EBELN IN S_EBELN

AND AEDAT IN S_AEDAT.

*build alv field catalog

perform bulid_field_catalog.

*display alv

perform display_alv_report.

&----


*& Form bulid_field_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bulid_field_catalog .

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'PUR DOC#'.

fieldcatalog-col_pos = 1.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'C310'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'BUKRS'.

fieldcatalog-seltext_m = 'COMP CODE'.

fieldcatalog-outputlen = 4.

fieldcatalog-col_pos = 2.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'LIFNR'.

fieldcatalog-seltext_m = 'VENDOR'.

fieldcatalog-outputlen = 10.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'PO DATE'.

fieldcatalog-outputlen = 8.

fieldcatalog-col_pos = 4.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'STATUS'.

fieldcatalog-outputlen = 6.

fieldcatalog-col_pos = 5.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDFORM. " bulid_field_catalog

&----


*& Form display_alv_report

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_report .

gd_repid = sy-repid.

CALL FUNCTION <b>'REUSE_ALV_GRID_DISPLAY'</b>

EXPORTING

I_CALLBACK_PROGRAM = gd_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = gd_layout

IT_FIELDCAT = fieldcatalog[]

I_SAVE = 'X'

TABLES

T_OUTTAB = I_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.

ENDFORM. " display_alv_report

1 ACCEPTED SOLUTION

Former Member
0 Kudos
123

you cannot use GRID in background, instead use LIST DISPLAY

if sy-batch eq 'X'.

  • use LIST

else.

*use GRID

endif.

8 REPLIES 8

Former Member
0 Kudos
124

you cannot use GRID in background, instead use LIST DISPLAY

if sy-batch eq 'X'.

  • use LIST

else.

*use GRID

endif.

0 Kudos
123

ACTUALLY I AM NOT EXECUTING IN BACKGROUND...I need to run it in background and mail the output as PDF attachment

Subba

Former Member
0 Kudos
123

Hi,

refer to the link below:

http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm

Hope this helps.

Reward if helpful.

Regards,

Sipra

0 Kudos
123

thanks all.....it s working on one SAP system but not on the other one....i don't know why?

vsubbakrishna
Participant
0 Kudos
123

thanks all...

0 Kudos
123

Hi ,

Can you please give me the solution which u did to get perfect format of pdf mail attachment of a grid report output.

thanks in advance

very urgent

0 Kudos
123

instead of reuse_alv_grid_display

use "reuse_alv_list_display"

reuse_alv_grid_display is not working in background processing.