cancel
Showing results for 
Search instead for 
Did you mean: 

Purchase Order External Send with email body text

Former Member
0 Kudos

Dear Expert,

I had done the neccessary configurations for sending PO through email to vendor. Currently, an PO attachment can be sent to vendor in PDF format.

However, I would like to add additional information to vendor in email body text, for example vendor memo from PO header text field.

May I know how to do this? I had searched through the forum but so far no solutions found.

Vijaykmm
Explorer
0 Kudos
Hi , i want to know is there any possiblities to send an PO attachment can be sent to vendor in PDF format.if any solution can you send me .

Accepted Solutions (0)

Answers (4)

Answers (4)

julio_vargasmeneses
Discoverer
0 Kudos

This message was moderated.

Former Member
0 Kudos

HI DAVE,

I am just starting my career in sap-abap just 3 months of experience, so dont have much knowledge on it , but my requirement seems to be the same.

when the user creates or changes a purchase order and clicks on save then the pdf needs to be sent. what I am facing is i debugged the program and found the spool request number in sy-msgv1 , and while i am in debugging mode i checked SP01 and found that spool number is yet not shown ( because may be the commit is still not executed on the spool workflow). so i am confused how can i use that spool number just after the ME_PRINT_PO if it is not showing it in spools.

Vijaykmm
Explorer
0 Kudos
Hi ,
Former Member
0 Kudos

Hi Yap ,

For transmitting the texts you may try the following :

Step1 :

Select the o/p type and click on Mail Title and Texts;

Maintain the same against the language required by You.

Step2 :

Double click on ur o/p type .

In the General Data Tab Maintain the below prg and Routine under " Replacement of Text Symbols "

Parameter program: SAPMM07M FORM routine: TEXT_PARAMETER

If you wish to copy the text from Vendor Memo then u need to contact ur ABAPer for the development but i don't think it can be achieved.

Regards

Ramesh Ch

Former Member
0 Kudos

Hi Ramesh,

I had done both steps previously.

For step 2, I get parameter for PO number. I had another requirement is to display the company name in email title. Company code can be retrieved from EKKO-BUKRS. However, I want to display company text from T001-BUTXT. Can this be done? How? I had try to put the parameter as T001-BUTXT but is not working.

For the email body text, may I know which standard program and form routine that I need to refer for customization? Once the customization done, where can I put it in configuration of NACE?

Former Member
0 Kudos

Hi Yap ,

Please maintain the following under the Transaction NACE , after clicking the o/p type :

Double click on ur o/p type .

In the "General Data" Tab Maintain the below prg and Routine under " Replacement of Text Symbols "

Parameter program: SAPMM07M FORM routine: TEXT_WEMAIL_FUELLEN

In the "Mail Tab" Maintain the below prg and Routine under " Replacement of Execution Parameters "

Parameter program: SAPMM07M FORM routine: TEXT_PARAMETER

The text should contain the following format . &T001-BUTXT&

Regards

Ramesh Ch

Former Member
0 Kudos

Hi Ramesh,

Thanks for information. I'll try it out.

I had found [Note 786847 - E-mail purchase order w/ e-mail text and several attachments|https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=786847]

This will involve customization of print program SAPFM06P or the ME_PRINT_PO function module to include additional body text. Do you have any idea on the sample coding?

Former Member
0 Kudos

Hi Yap,

Please do check SAP Note : 191470

Regards

Ramesh Ch

Former Member
0 Kudos

Hi. I have recently done this. I think my method is different to the one SAP are on about in their note, but you can do this yourself without paying them for remote consulting.

First copy the standard print program and before function 'ME_PRINT_PO' is called change L_NAST-NACHA to 1 and clear L_NAST-DIMME.

This will then create a spool instead of an e-mail.

After ME_PRINT_PO is run make sure ENT_RETCO = 0, that means the spool created, then you can get the spool number from SY-MSGV1 or by selecting it from table NAST.

Then call function CONVERT_OTFSPOOLJOB_2_PDF using the spool ID, that converts the spool to PDF, then change the linesize with function SX_TABLE_LINE_WIDTH_CHANGE, then call SO_DOCUMENT_SEND_API1 using whatever recipients you want.

On SO_DOCUMENT_SEND_API1 send the PDF in table "CONTENTS_BIN" and whatever text you want in "CONTENTS_TXT"

Populate "PACKING_LIST" with 1 line with the the PDF info and another line with the text info.

Set "COMMIT_WORK" to blank, else you will get a dump when manually repeating the print, there will be a commit work triggered by the PO anyway, so it will work fine.

The good thing about this is that you can also choose the sending e-mail address to be different to the user that is mailing the PO and you can use this to send 1 mail to multiple recipients, or loop round to send many mails. You can also CC or BCC using this.

If you get stuck let me know, I have definitly got this working 100%, it is sending the PO as a PDF to 2 e-mails and copying a 3rd, and also sending some custom text in the e-mail body.

Regards,

Dave.

Edited by: David Barber on Jul 21, 2009 4:20 PM - Added the "1" on the end of SO_DOCUMENT_SEND_API1, missed it off originally

Former Member
0 Kudos

Hi. 1 more thing, you can change the e-mail subject to be anything you like using SO_DOCUMENT_SEND_API1 as well, you are not restricted by what is possible in the config using the text replace.

Regards,

Dave.

Former Member
0 Kudos

Hi Ramesh,

I had tried out the config in transaction NACE but seems like not working. &T001-BUTXT& does not show any value. Besides, &EKKO-EBELN& value is missing.

Best regards,

Yap

Former Member
0 Kudos

Hi David,

Bravo. This is what I was looking for. Could you please explain further?

Is the function 'ME_PRINT_PO' contain send email function SO_DOCUMENT_SEND_API1?

Where should I put the function CONVERT_OTFSPOOLJOB_2_PDF and SO_DOCUMENT_SEND_API1?

There is no EN version documentation for function ME_PRINT_PO. Can you provide some hint in case I need to customize this function?

Best regards,

Yap

Former Member
0 Kudos

Hi. No, you do not need to touch ME_PRINT_PO. You need to put code before and after ME_PRINT_PO in the print program.

Step 1 - Copy the standard print program SAPFM06P to make a Z version, lets call it ZSAPFM06P

Step 2 - Copy include FM06PE02 to make a Z version, lets call that ZFM06PE02.

Step 3 - ZSAPFM06P change the statement "Include FM06PE02" to read "Include ZFM06PE02".

Step 4 - In include ZFM06PE02 you will find a subroutine called "ENTRY_NEU". In this subroutine you will see it first calls ME_READ_PO_FOR_PRINTING then calls ME_PRINT_PO. Before it calls ME_PRINT_PO just put:

l_nast-nacha = 1.

CLEAR l_nast-dimme.

This means that ME_PRINT_PO will not e-mail, it will create a spool request.

Step 5 - Still in ZFM06PE02, after ME_PRINT_PO has been called, add new code. First check that ent_retco EQ 0. If it does not then exit.

Step 6 - Get the spool ID created by ME_PRINT_PO by either moving sy-msgv1 to a variable or select from NAST.

Step 7 - Call function CONVERT_OTFSPOOLJOB_2_PDF using the spool ID from step 6, and put the result from table PDF into an internal table you can use later. ALso store the export variable pdf_bytecount, you will need it later.

Step 8 - Call function SX_TABLE_LINE_WIDTH_CHANGE using the table from step 7 as content_in and put the results from content_out into a new internal table.

Step 9 - Add some text into a internal table of type solisti1, this will be the body text of the e-mail.

Step 10 - Add whatever receivers you want into an internal table of type somlreci1. If you just want it to go to the address that the PO would have gone to anyway, select the e-mail address from ADR6 where the address number = l_doc-xekko-adrnr, that is the data from the PO.

Step 11 - Populate an internal table of type sopcklsti1 with data relevant to your PDF table from step 8 and the text table from step 9. You will have to put the size of the PDF from step 7 (pdf_bytecount) on the PDF line and the size of the text will be the number of lines of text * 255.

Step 12 - Add info to a structure of type sodocchgi1. You can add the e-mail title in here, field obj_descr. Also add the size of the PDF and the size of the text from step 12 into doc_size, and give the doc a name in field obj_name. This can be anything, ZPDFPO for example.

Step 13 - Call SO_DOCUMENT_SEND_API1 using the tables from steps 8, 9, 10 and 11 and the structure from step 12. You can amend the sending e-mail also. Set commit_work to space.

Step 14 - That is all you need, but I actually call function RSPO_R_RDELETE_SPOOLREQ to delete the spool request created in step 4, then call NAST_PROTOCOL_UPDATE to add some more messages to the processing log of the PO.

That is all.

Regards,

Dave.

Former Member
0 Kudos

Hi. I am not sure what happened there, I put lots of returns in to space it out, for some reason it has lost them when I saved the post.

Just copy and paste the text into word or something and put a return after each step number.

Regards,

Dave.

Former Member
0 Kudos

Hi David,

After ME_PRINT_PO, I'll need to convert data from spool, do some massaging on the data and finally call function SO_DOCUMENT_SEND_API1. Am I right?

Function SO_DOCUMENT_SEND_API1 is for sending email. May I know how program SAPFM06P works in sending email? Does it call the same function too? At which point of the program?

Many thanks,

Yap

Former Member
0 Kudos

Hi. You are correct.

I am not sure how the standard print program sends the mail, but it is done from the function ME_PRINT_PO.

I don't think it calls SO_DOCUMENT_SEND_API1. You can debug the standard from transaction ME9F. Set a breakpoint in the standard print program then create a PO with an output and set the dispatch time to 3 - send with application own transaction. Then go to ME9F and output the PO, the break point will kick in.

Regards,

Dave.

Former Member
0 Kudos

Hey David,

I implemented your great coding and it worked "neary" fine.

I can maintain the body text of the email and the receivers and I can send the PO as PDF-Attachment.

But unfortunately the receiver can't open the PDF-File but gets the error "The file is damaged or can't be repaired".

Do you have any idee what is wrong in my coding ?

Thanks in advance

Britta

Former Member
0 Kudos

Hi. I had that and with me it was the size of the mail causing it. Check in SOST, is the size of the mail accurate or does it show 0?

If it shows 0 or the wrong size check that you got the sizes right for the PDF and the text in the packlist structure and the overall size right in the header structure when calling SO_DOCUMENT_SEND_API1.

Regards,

Dave.

Former Member
0 Kudos

Hey dave,

thanks a lot for your fast reply - and yes: now it works !!!

So I have a last question and it will be great if you can answer me once again. In a previous message of this Thread you wrote, that: "The good thing about this is that you can also choose the sending e-mail address to be different to the user that is mailing the PO".

How can I change the sending E-mail-Adress in this szenario ? I don't find a structure oder field, which is relevant for this.

Best regards

Britta

Former Member
0 Kudos

Hi. Just use the exporting parameters on SO_DOCUMENT_SEND_API1:

SENDER_ADDRESS = 'mail@address' and SENDER_ADDRESS_TYPE = 'INT'

Regards,

Dave.

Former Member
0 Kudos

Hey Dave,

ah, how stupid I was.

I used SO_NEW_DOCUMENT_ATT_SEND_API1 in my program, which calls SO_DOCUMENT_SEND_API1 but has no own parameter like sender_adress.

Great. Thanks a lot again, your support was very very helpful. !

Best regards

Britta

Former Member
0 Kudos

Hi David

I want to get exactly the same.

But... the point 6 does not work, the FM does not generate any spool number :S

I think the function to send it by mail does not create spool number

Any ideas to get the spool through another method?

Thanks.

Former Member
0 Kudos

Anyone?