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: 

Customer Invoice Email

Former Member
0 Kudos

Hi,

Can someone help me on how to get the OTF data of the invoice? Is there any Function Module? I searched in SCn, but couldn't find one.

Need to convert the OTF data of the Invoice to PDF and send it as an attachment via email.

I know we have to use 'SO_DOCUMENT_REPOSITORY_MANAGER Function Module for Email attachments.

Please help.

Thanks & Regards,
Sowmya

1 ACCEPTED SOLUTION

arindam_m
Active Contributor
0 Kudos

Hi,

Have you checked the link below. Should help you.

http://wiki.sdn.sap.com/wiki/display/Snippets/Smartform+to+Mail+as+PDF+attachment

What ever it is smartform or SAPScript the idea is to get the OTF convert to PDF and send mail. The wiki should help I think. Also the DUMP POSTING_ILLEGAL_STATEMENT means you are trying to do and activity in a Form where it is not allowed. can you please state the form at the statement that is being disallowed. All these details ate present in the short dump.

Cheers,

Arindam

9 REPLIES 9

FredericGirod
Active Contributor
0 Kudos

Hi Sowmya,

do you use Smartforms or SapScript ?

if you use Smartforms, have a look to my doc : http://scn.sap.com/docs/DOC-42232

regards

Fred

0 Kudos

Hi Frederic,

I use SAPscript.

Thanks & Regards,
Sowmya

Former Member
0 Kudos

Hello Sowmya,

Refer following.

<, link farming removed >>

Thanks

Katrice

Message was edited by: Kesavadas Thekkillath

Former Member
0 Kudos

Hello All,

Thanks for your response.

I'm able to get the OTF data from CLOSE_FORM Function Module.

The ITAB is of type ITCOO whereas the ITAB used in the Funciton Module 'SO_ATTACHMENT_INSERT' is of TYPE SOLI.

I've used the below code for assigning the data and sending as an email attachment:

Loop at itab1.

concatenate itab1-tdprintcom itab1-tdprintpar into w_itab2.

append w_itab2 to itab2."itab2 is of type soli.

endloop.

* the Invoice which is in the OTF format is attached.

CALL FUNCTION 'SO_ATTACHMENT_INSERT'

EXPORTING

object_id = g_objid

attach_type = 'OTF'

object_hd_change = g_hd_dat

owner = sy-uname

TABLES

objcont = itab2

objhead = g_objhead

EXCEPTIONS

active_user_not_exist = 1

object_type_not_exist = 2

operation_no_authorization = 3

owner_not_exist = 4

parameter_error = 5

substitute_not_active = 6

substitute_not_defined = 7

x_error = 8

system_failure = 9

communication_failure = 10

OTHERS = 11.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

FORM f600_send_invoice .

CLEAR : g_method1,

g_receipients.

DATA: p_receiver TYPE so_recname.

SELECT SINGLE adr6~smtp_addr

INTO p_receiver

FROM kna1

INNER JOIN adrc

ON kna1~adrnr = adrc~addrnumber

INNER JOIN adr6

ON adrc~addrnumber = adr6~addrnumber

WHERE kna1~kunnr = nast-parnr

AND adrc~date_to = '99991231'.

IF sy-subrc = 0.

TRANSLATE p_receiver TO UPPER CASE.

ELSE.

MESSAGE 'Error-No email address available in vendor record' TYPE 'E'.

ENDIF.

* The reciepient details are from NAST table and medium is E-MAIL

g_receipients-reclan = nast-tland.

g_receipients-recextnam = p_receiver.

g_receipients-sndex = 'X'.

g_receipients-recesc = 'U'.

APPEND g_receipients.

g_method1 = 'SEND'.

* Using the method 'SEND' as input to the FM

* 'SO_DOCUMENT_REPOSITORY_MANAGER', the receipients will be sent the

* message accordingly based on the transmission medium specified.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = l_g_method1

office_user = sy-uname

TABLES

recipients = l_g_receipients

files = l_g_files

CHANGING

document = l_g_document

header_data = l_g_header.

Using VA01 / VF01, I'm assigning the Output Type with medium - External Send.

In the Business Workplace, I'm getting the Update Termination - "ABAP/4 processor - POSTING_ILLEGAL_STATEMENT".

Can someone help me on how to resolve this Dump?

Thanks & Regards,
Sowmya

0 Kudos

Hi Sowmya,

What is your SAP Version ? (if 7.0 ) check this note is implemented or not .

Note 1007467 - Dump when attaching document.Error POSTING_ILLEGAL_STATEMENT

Regard's

Smruti

0 Kudos

Hi Smruti,

SAP version is 4.7.

And the Note you mentioned is not implemented / applicable.

Thanks & Regards,
Sowmya

Former Member
0 Kudos

hi sowmya,

                   if you send invoice PDF into mail. you can use the this function module.

                  SO_NEW_DOCUMENT_ATT_SEND_API1

after that basis person they can do the mailling config sowmya.


Sudhakargadde
Participant
0 Kudos

Hello Sowmya,

can u please check spool no is generated for the invoice, if then 'CONVERT_ABAPSPOOLJOB_2_PDF'

call this function module then you get the BIN_FILE in exporting parameters then convert the binary format to PDF by calling the function module 'SCMS_XSTRING_TO_BINARY'. then you can pass the Xstring Data to the SO_DOCUMENT_REPOSITORY_MANAGER then after you know what to do.

you need to right this program in a USER-EXIT or a BADI.

most important check the exporting parameter Result in OPEN_FORM function module and see the following screen.

Regards

Ram

arindam_m
Active Contributor
0 Kudos

Hi,

Have you checked the link below. Should help you.

http://wiki.sdn.sap.com/wiki/display/Snippets/Smartform+to+Mail+as+PDF+attachment

What ever it is smartform or SAPScript the idea is to get the OTF convert to PDF and send mail. The wiki should help I think. Also the DUMP POSTING_ILLEGAL_STATEMENT means you are trying to do and activity in a Form where it is not allowed. can you please state the form at the statement that is being disallowed. All these details ate present in the short dump.

Cheers,

Arindam