Application Development and Automation 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: 
Read only

Attach PDF in mail

Former Member
0 Likes
1,934

Hello,

I have a requirement to attach a pdf file and send it as an attachement to the recipients in the mailing list,

I have got the internal table holding the pdf data using CALL FUNCTION 'ZCONVERT_ABAPSPOOLJOB_2_PDF which is i_pdf,

Now i have not been able to figure out how do i use this table and pass it to the fm

CALL FUNCTION 'SO_DOCUMENT_SEND_API1' . kindly advise.

Thanks in anticipation!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,890

Hi,

As per your requirement, follow the below mentioned steps.

1. Convert internal table data to SPOOL using FM - SLVC_TABLE_PS_TO_SPOOL.

2. Convert this spool to PDF using FM - CONVERT_ABAPSPOOLJOB_2_PDF

3. While sending mail :

a. Convert PDF data to Binary content for mail using QCE1_CONVERT

b. Pass the above binary data in the table CONTENTS_BIN of the FM - SO_DOCUMENT_SEND_API1.

Your internal table will be send as an attachment to your mail.

Hope this helps.

Regards

Shruti

Hi,

As per your requirement, follow the below mentioned steps.

1. Convert internal table data to SPOOL using FM - SLVC_TABLE_PS_TO_SPOOL.

2. Convert this spool to PDF using FM - CONVERT_ABAPSPOOLJOB_2_PDF

3. While sending mail :

a. Convert PDF data to Binary content for mail using QCE1_CONVERT

b. Pass the above binary data in the table CONTENTS_BIN of the FM - SO_DOCUMENT_SEND_API1.

Your internal table will be send as an attachment to your mail.

Hope this helps.

Regards

Shruti

11 REPLIES 11
Read only

Former Member
0 Likes
1,890

Hi,

its regarding report or smartform ?

Read only

Former Member
0 Likes
1,890

Hello,

check the below one it may help u .

Its for report

data : t_packing_list like sopcklsti1 occurs 0 with header line,

t_packing_list like sopcklsti1 occurs 0 with header line,

it_message type standard table of solisti1 initial size 0 with header line,

t_receivers like somlreci1 occurs 0 with header line,

w_doc_data like sodocchgi1,

ld_sender_address like soextreci1-receiver,

ld_sender_address_type like soextreci1-adr_typ,

w_sent_all(1) type c,

call function 'SO_DOCUMENT_SEND_API1'

exporting

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

importing

sent_to_all = w_sent_all

tables

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_receivers

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

For smartforms check this link

http://wiki.sdn.sap.com/wiki/display/Snippets/Smartform%2boutput%2bto%2bPDF%2bformat

Thanks & reagrads,

santhosh

Edited by: santhosh kumar on Jan 7, 2010 10:57 AM

Read only

Former Member
0 Likes
1,891

Hi,

As per your requirement, follow the below mentioned steps.

1. Convert internal table data to SPOOL using FM - SLVC_TABLE_PS_TO_SPOOL.

2. Convert this spool to PDF using FM - CONVERT_ABAPSPOOLJOB_2_PDF

3. While sending mail :

a. Convert PDF data to Binary content for mail using QCE1_CONVERT

b. Pass the above binary data in the table CONTENTS_BIN of the FM - SO_DOCUMENT_SEND_API1.

Your internal table will be send as an attachment to your mail.

Hope this helps.

Regards

Shruti

Read only

0 Likes
1,890

Hi Shruti,

Thanks for the suggestion.

I tried doing it as mentioned by you , i could generate the PDF and attach it in the mail , however when i try to open file in the mail it does not open (says file not in pdf format) any idea what could be the possible shortcoming , how can this be countered?Please advise.

Thanks,

Alok.

Read only

0 Likes
1,890

Hi,

In the function module - SO_NEW_DOCUMENT_ATT_SEND_API1 , you have to create two line items in the table parameter PACKING_LIST.

1. entry for the compressed document (Related to table CONTENTS_TXT) - Pass parameter DOC_TYPE = 'HTM'.

2. entry for Packing as PDF(related to table CONTENTS_BIN) - Pass parameter DOC_TYPE = 'PDF' & TRANSF_BIN = 'X'.

Regards

Shruti

Read only

0 Likes
1,890

Hello Alok,

could you fix your issue in the meantime ? If not, take a look at SMP Notes 1320163 and 1324547. I had the same problem and could solve it.

Kind regards

Andreas

Read only

Former Member
0 Likes
1,890

This message was moderated.

Read only

OttoGold
Active Contributor
0 Likes
1,890

Hello,

first: check this: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf806...

second: you can get more attention under NetWeaver - Adobe forms

Regards, Otto

Read only

Former Member
0 Likes
1,890

Hi Alok,

Change your code accordingly

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'PDF'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Soundarya.

Read only

Former Member
0 Likes
1,890

Hi Alok,

Try out this code,

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'PDF'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Soundarya.

Read only

Former Member
0 Likes
1,890

Hi Alok,

Try out this code,

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'PDF'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Soundarya.