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: 

Problem In Emailing-Sap Scripts

Former Member
0 Kudos

Hi,

I am Encountering a problem while i am using the FM :SO_NEW_DOCUMENT_ATT_SEND_API1.

The error which Populates is of Exception Type 2.(Document Cannot be Sent)..

My Code Is:

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

EXPORTING

FORMAT_SRC = 'OTF'

FORMAT_DST = 'PDF'

DEVTYPE = 'FILE'

  • FUNCPARA =

LEN_IN = LEN_IN

IMPORTING

LEN_OUT = LEN_OUT

TABLES

CONTENT_IN = OTFDATA2

CONTENT_OUT = PDFDATA

  • EXCEPTIONS

  • ERR_CONV_FAILED = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

objtxt = 'REGARDS-YAMINI.A'.

APPEND objtxt.

doc_chng-obj_name = 'SAP SCRIPT'.

doc_chng-obj_descr = 'SAPSCRIPT OUTPUT'.

DESCRIBE TABLE objtxt LINES tablines.

READ TABLE objtxt INDEX tablines.

doc_chng-doc_size = ( tablines - 1 ) * 255 + STRLEN( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tablines.

objpack-doc_type = 'RAW'.

APPEND objpack.

DESCRIBE TABLE pdfdata LINES tablines.

READ TABLE pdfdata INDEX tablines.

objpack-doc_size = ( tablines - 1 ) * 255 + STRLEN( pdfdata ).

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tablines.

objpack-doc_type = 'PDF'.

objpack-obj_name = 'ATTACH'.

objpack-obj_descr = 'DOCUMENT'.

APPEND objpack.

reclist-receiver = sy-uname.

reclist-rec_type = 'U'.

reclist-express = 'X'.

APPEND reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = objpack

object_header = objhead

contents_bin = pdfdata

contents_txt = objtxt

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = reclist

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

.

IF sy-subrc <> 0.

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

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

ENDIF.

CASE sy-subrc.

WHEN 0.

LOOP AT reclist.

IF reclist-receiver = space.

name = reclist-rec_id.

ELSE.

name = reclist-receiver.

ENDIF.

IF reclist-retrn_code = 0.

WRITE: / name, ': succesfully sent'.

ELSE.

WRITE: / name, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

Which part is Wrong in my code..

Kindly Clarify

Regards

Yamini.A

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Address type U is for internet address, while the address you are providing is SAP USERID. Can you play around with this to see whether it works?

From documentation of the FM

<i>The following entry categories are possible:

SAP use name of the recipient

SAPoffice name of the recipient

Shared distribution list

Fax number in the form of structure SADRFD

Internet address in the form of structure SADRUD

Remote SAP name in the form of structure SADR7D

X.400 address in the form of structure SADR8D

ADR_TYPE

Type of RECEIVER entry.

The following values are permitted:

'B' : SAP user name

' ' : SAPoffice name

'C' : Shared distribution list

'F' : Fax number

'U' : Internet address

'R ' : Remote SAP name

'X' : X.400 address

REC_ID

</i>

cheers,

1 REPLY 1

Former Member
0 Kudos

Hi,

Address type U is for internet address, while the address you are providing is SAP USERID. Can you play around with this to see whether it works?

From documentation of the FM

<i>The following entry categories are possible:

SAP use name of the recipient

SAPoffice name of the recipient

Shared distribution list

Fax number in the form of structure SADRFD

Internet address in the form of structure SADRUD

Remote SAP name in the form of structure SADR7D

X.400 address in the form of structure SADR8D

ADR_TYPE

Type of RECEIVER entry.

The following values are permitted:

'B' : SAP user name

' ' : SAPoffice name

'C' : Shared distribution list

'F' : Fax number

'U' : Internet address

'R ' : Remote SAP name

'X' : X.400 address

REC_ID

</i>

cheers,