Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue downloading excel attachtment

Hi Group ,

Iam using a FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send mail along with a attachment ,where in iam facing a problem in download the attachment which is in xls format ,its giving all the output in a single cell.

can any one help me on this .

Thanks,

vinay .

Tags:
Former Member
Former Member replied

the following code will solve your answer regarding correction in XLS sheet. Just copy paste in se38 and execute it

&----


*& Report ZTEST5

*&

&----


*&

*&

&----


REPORT ZKAILASH.

  • This table requires information about how the data in the

  • tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are

  • to be distributed to the documents and its attachments.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

  • This table must contain the summarized data dependent on each object type.

  • SAPscript objects store information here about forms and styles,

  • for example. Excel list viewer objects store the number of rows and columns

  • amongst other things and PC objects store their original file name.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

data : begin of itobjbin occurs 10 ,

NAME(5),

end of itobjbin .

  • This table must contain the summarized content of the objects identified as binary objects.

*DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJBIN TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: WA_ITOBJBIN LIKE ITOBJBIN .

  • This table must contain the summarized content of the objects identified as ASCII objects.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

  • This table must contain the document recipients.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

  • This structure must contain the attributes of the document to be sent.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

  • Creating the document to be sent

DOC_CHNG-OBJ_NAME = 'OFFER'. " input contains the attributes of the document to be sent

DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'. "input contains title/subject of the document

OBJTXT = 'Reserve price : $250000'. " Text in the mail

APPEND OBJTXT.

OBJTXT = 'A reproduction of the painting to be auctioned'. " Text in the mail

APPEND OBJTXT.

OBJTXT = 'is enclosed as an attachment.'. " Text in the mail

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • Creating the entry for the compressed document

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • Creating the document attachment

  • (Assume the data in OBJBIN are given in BMP format)

ITOBJBIN-NAME = 'ABC'.

APPEND ITOBJBIN.

ITOBJBIN-NAME = 'XYZ'.

APPEND ITOBJBIN.

ITOBJBIN-NAME = 'LMNO'.

APPEND ITOBJBIN.

PERFORM build_xls_data_table .

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'ABC.XLS'. APPEND OBJHEAD.

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'XLS'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'TEST'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK..

  • Entering names in the distribution list

RECLIST-RECEIVER = 'sikha@cadence.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

*RECLIST-RECEIVER = 'DLI-NEUREICH'.

*

*RECLIST-REC_TYPE = 'P'.

*

*APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

WRITE: / 'Result of the send process:'.

LOOP AT RECLIST.

WRITE: / RECLIST-RECEIVER(48), ':'.

IF RECLIST-RETRN_CODE = 0.

WRITE 'sent successfully'.

ELSE.

WRITE 'not sent'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'no authorization to send to the specified number of', 'recipients!'.

WHEN 2.

WRITE: / 'document could not be sent to any of the recipients!'.

WHEN 4.

WRITE: / 'no authorization to send !'.

WHEN OTHERS.

WRITE: / 'error occurred during sending !'.

ENDCASE.

&----


*& Form build_xls_data_table

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_xls_data_table .

CONSTANTS: con_cret TYPE X VALUE '0D', "OK for non Unicode

con_tab TYPE X VALUE '09'. "OK for non Unicode

CONCATENATE 'NAME' ' ' INTO OBJBIN SEPARATED BY con_tab.

CONCATENATE con_cret OBJBIN INTO OBJBIN.

APPEND OBJBIN.

LOOP AT ITOBJBIN .

CONCATENATE ITOBJBIN-NAME ' '

INTO OBJBIN SEPARATED BY con_tab.

CONCATENATE con_cret OBJBIN INTO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

ENDFORM. " build_xls_data_table

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question