cancel
Showing results for 
Search instead for 
Did you mean: 

How to send PDF document as attachment in the send mail step

Former Member
0 Kudos

Hi,

I want to send a SmartForm converted into PDF format as an attachment to an external user , in the send mail step ...

I am able to convert the smartForm into a PDF and have it stored in my C drive ...

Is there any way to attach this PDF document in my send mail step...

I guess we can use the Attach_Object parameter of the Sendtaskdescription method but I am not able to find how to link my PC document to this Parameter....

Any suggestions for this.....

Its kind of urgent

Accepted Solutions (0)

Answers (3)

Answers (3)

pokrakam
Active Contributor
0 Kudos

Locked.

Please ask new questions in a new thread. That's just [how this forum works|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]!

If another thread such as this one is relevant, include a link to it in your question.

Former Member
0 Kudos

Hi Narsingh,

if you want to create an attachment in a workflow task you need to create a sofm instance for your PDF file.

First, you need to create a method to get an SOFM instance for you PDF file.

Example code:

DATA: attach TYPE swc_object.

DATA:it_objhex TYPE solix_tab.

swc_container l_cont.

DATA folder_id TYPE sofdk.

DATA lt_objcont TYPE STANDARD TABLE OF soli.

DATA ls_objcont TYPE soli.

DATA l_obj_data TYPE sood1.

DATA l_obj_id TYPE soodk.

DATA document_id TYPE sofmk.

DATA lt_objhead TYPE STANDARD TABLE OF soli.

data wa_soli type soli.

data wa_solix type solix.

FIELD-SYMBOLS: <ptr_text> type soli,

<ptr_x> type any,

<ptr_hex> type solix.

define hex_to_cont.

  • &1 Table of structure SOLIX

  • &2 Table of structure SOLI

refresh &2.

loop at &1 into wa_solix.

clear wa_soli.

assign wa_soli to <ptr_hex> casting.

move wa_solix to <ptr_hex>.

append wa_soli to &2.

endloop.

end-of-definition.

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'

EXPORTING

region = 'B'

IMPORTING

folder_id = folder_id

EXCEPTIONS

OTHERS = 1.

*get the PDF file into a table

(CALL FUNCTION 'ZAP_GET_PDF'

EXPORTING

File name: ‘xxx’

TABLES

objhex = it_objhex

EXCEPTIONS

error_image = 1

invalid_url = 2

OTHERS = 3.)

l_obj_data-objnam = 'SOFM'.

l_obj_data-objdes = 'test'.

l_obj_data-file_ext = 'PDF'.

hex_to_cont IT_OBJHEX LT_OBJCONT.

CALL FUNCTION 'SO_OBJECT_INSERT'

EXPORTING

folder_id = folder_id

object_type = 'EXT' "'RAW'

object_hd_change = l_obj_data

IMPORTING

object_id = l_obj_id

TABLES

objhead = lt_objhead

objcont = LT_OBJCONT

EXCEPTIONS

active_user_not_exist = 35

folder_not_exist = 6

object_type_not_exist = 17

owner_not_exist = 22

parameter_error = 23

OTHERS = 1000.

COMMIT WORK.

Data: tb_key(100).

IF sy-subrc = 0.

document_id-foltp = folder_id-foltp.

document_id-folyr = folder_id-folyr.

document_id-folno = folder_id-folno.

document_id-doctp = l_obj_id-objtp.

document_id-docyr = l_obj_id-objyr.

document_id-docno = l_obj_id-objno.

ELSE.

ENDIF.

Concatenate folder_id-foltp folder_id-folyr folder_id-folno

into tb_key.

swc_create_object attach 'SOFM' tb_key.

SWC_SET_ELEMENT CONTAINER 'ZSOFM' attach.

Second, call the method in the workflow in a background task (before sending the mail) and import the SOFM instance in to workflow then attach the SOFM object to the Attachment.

Please disregard the first reply (that is for sending a mail to outlook or groupwise mail etc...).

Hope this helps

Rams.

Former Member
0 Kudos

Hi Rams,

Thank you very much for your quick reply I am trying to create the sofm instance by the method you have suggested but the problem is that I am not getting the function module ZAP_GET_PDF does not exist .

So could you kindly give me the details reagading the implememntation of this function module..

I sincerely appreciate your help

Regards,

Narsingh

Former Member
0 Kudos

Hi Narsingh,

That is a zfunction module you need to create to convert the Smart form into binary table content.

Please see the following link you can get some idea to convert the smart form then use that table content for further process.

Former Member
0 Kudos

Hi

Your code is very useful to me for creating ZSOFM as with super type SOFM.

I'm facing a problem in while binding how i need to assign value in import,export through attachment and your macros for hex_to_cont it_obj lt_cont it showing error what i need to do for this?

Please provide me a step wise details for this.

Advance thanks!

Former Member
0 Kudos

Hi Ram,

I guess your code might help me.But i'm not attaching smartform as PDF.

But i am attaching scanned file which would be a pdf by default while its scanned.

so is there any requirement of that function module zap_get_pdf?

Thanks,

Bhavani

Former Member
0 Kudos

Hi Narsingh,

Use the fucntion module "FM SO_NEW_DOCUMENT_ATT_SEND_API1"

For more details go through the following thread.

Regards,

Rams.