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

Attaching PDF document to workflow container using SWC* macros

suresh_kumar53
Participant
0 Likes
2,625

Hello,

I need to attach the quality notification printout (PDF) along with other other details through action box. For this QM06_FM_TASK_SEND_PAPER_ATTACH configured. This function module a pdf as per the configuration with below code.

SWC_CLEAR_CONTAINER CONTAINDER1.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTTITLE' CONTENT_HEADER1.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTNAME' TEXT-201.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTTYPE' 'SCR'.

SWC_SET_TABLE CONTAINER1 'DOCUMENTCONTENT' CONTENT1.

SWC_SET_ELEMENT CONTAINER1 'NO_DIALOG' 'X'.

Now for the same email I need to attach notification printout in the form of PDF. For this I put enhacement point starting of this FM and got OTF data from print program. This OTF data I have tried to attach to email as below.

SWC_CLEAR_CONTAINER CONTAINER1.

SWC_SET_ELEMENT CONTAINER1 'ATTACHMENT' 'MESSAGE1'.

SWC_SET_ELEMENT CONTAINER1 'ATTACHMENTTITLE' 'PRINT'.

SWC_SET_ELEMENT CONTAINER1 'ATTACHEMENTTYPE' 'PDF'.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTSIZE' G_FILESIZE.

SWC_SET_TABLE CONTAINER1 'CONTENT_HEX' BINDATA[].

SWC_SET_TABLE CONTAINER1 'DOCUMENTCONTENT' CONTENT2.

SWC_CALL_METHOD MESSAGE1 'ATTACH' CONTAINER1.

I tried by converting OTF to binary () or PDF . I could able to attach but that PDF is corrupted. Please suggest me. I have attached enhacement code.

Hello,

I need to attach the quality notification printout (PDF) along with other other details through action box. For this QM06_FM_TASK_SEND_PAPER_ATTACH configured. This function module a pdf as per the configuration with below code.

SWC_CLEAR_CONTAINER CONTAINDER1.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTTITLE' CONTENT_HEADER1.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTNAME' TEXT-201.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTTYPE' 'SCR'.

SWC_SET_TABLE CONTAINER1 'DOCUMENTCONTENT' CONTENT1.

SWC_SET_ELEMENT CONTAINER1 'NO_DIALOG' 'X'.

Now for the same email I need to attach notification printout in the form of PDF. For this I put enhacement point starting of this FM and got OTF data from print program. This OTF data I have tried to attach to email as below.

SWC_CLEAR_CONTAINER CONTAINER1.

SWC_SET_ELEMENT CONTAINER1 'ATTACHMENT' 'MESSAGE1'.

SWC_SET_ELEMENT CONTAINER1 'ATTACHMENTTITLE' 'PRINT'.

SWC_SET_ELEMENT CONTAINER1 'ATTACHEMENTTYPE' 'PDF'.

SWC_SET_ELEMENT CONTAINER1 'DOCUMENTSIZE' G_FILESIZE.

SWC_SET_TABLE CONTAINER1 'CONTENT_HEX' BINDATA[].

SWC_SET_TABLE CONTAINER1 'DOCUMENTCONTENT' CONTENT2.

SWC_CALL_METHOD MESSAGE1 'ATTACH' CONTAINER1.

I tried by converting OTF to binary () or PDF . I could able to attach but that PDF is corrupted. Please suggest me. I have attached enhacement code.

8 REPLIES 8
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,115

Suresh

A simple question why did you use GUI_UPLOAD/GUI_DOWNLOAD..? I would request you to search on SCN convert OTF data to binary data etc using CL_BCS class method. You just have to use. Please search for the same

Nabheet

Read only

0 Likes
2,115

Hello Nabheet,

Thanks for quick reply. I have used GUI_UPLOAD/DOWNLOAD to check whether PDF conversion is correct or not. If you see just below this code I have used 'SCMS_XSTRING_TO_BINARY' and passed it to CONTENT_HEX but not worked. Even I used CONVERT_OTF and passed the result to 'DOCUMENTCONTENT' but not worked. I mean I could able to attach but PDF getting corrupted in the email.  If you have please send me sample code for attaching PDF to workflow container.

Regards,

Suresh

Read only

0 Likes
2,115

Okie so downloaded PDF also is corrupt when you open right..? I will suggest you to just search on for OTF to PDF stuff so many documents/links are their.

Read only

0 Likes
2,115

Hello Nabheet,

PDF download on desktop is not corrupted. I can open that.

When I tried to attach coverted binary data or PDF data to these macors then the created email attachement corrupted.

Read only

RemiKaimal
Active Contributor
0 Likes
2,115

Hi,

After analysing your code. In the FM : GUI_DOWNLOAD. Instead of 'BIN', try : 'RAW'.

Hope this should take care of your issue.

Regards,

Remi

Read only

PrabhuPole
Product and Topic Expert
Product and Topic Expert
0 Likes
2,115

Dear All,

I have created an workflow by using swdd and it's working fine. now i need to send pdf with user decission. could you please anybody help me how to send it.

Regards,

Prabhu

Read only

0 Likes
2,115

Hi Prabhu,

First convert the PDF to string format by using function module CONVERT_OTF then get the attachment id with function module 'SAP_WAPI_ATTACHMENT_ADD' by passing the work item id and pdf in string format.

write above steps inside an activity step with import parameter ‘I_WORKITEMID’ and export parameter ‘E_ATTCHID’.

In next activity step with the attachment id generate the object instance of attachment by using method ‘GENERICINSTANTIATE’ of business object ‘SYSTEM’. This instance is of type ‘SOFM’, and in decision step to have the PDF in attachment format pass this instance to container element ‘ATTACHMENTS’ of send mail step.

Regards,

Deb

Read only

PrabhuPole
Product and Topic Expert
Product and Topic Expert
0 Likes
2,115

Hi Deb,

thanks alot  for your quick guidance,

I have completed the workflow without using CONVERT_OTF.

1. I have created adobe form in SFP,

2. created report to display adobe form,

3. Once execute report , an workflow will trigger and mail will go with attachment  to respective manager for approval .

Best Regards,

Prabhu. Pole