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: 

sending excel at attachments

Former Member
0 Kudos

Hi ,

i'm sending an excel file as attachment using SO_NEW_DOCUMENT_ATT_SEND_API1 function module.

the contents of the excel file are put in internal table CONTENTS_BIN. this internal table has a data type of only 255 characters. so some fields on the excel file are getting cut. is there anyway to avoid this problem.

Regards,

Vijay

8 REPLIES 8

Former Member
0 Kudos

hi Vijay,

Is there any way that you can increase the internal table size for more than 255 character if so do that ...

Former Member
0 Kudos

Hello,

U can try like this.

DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

TABLES

packing_list = objpack

object_header = objhead

contents_bin = objbin

  • contents_txt = objtxt

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

If useful reward points.

Regards,

Vasanth

0 Kudos

hi vasanth, what have u done in this code to address the 255 length issue.

Regards,

Vijay

0 Kudos

Hi Vijay,

DO like this.

DESCRIBE TABLE objbin LINES tab_lines.

READ TABLE objbin INDEX tab_lines.

doc_chng-doc_size = tab_lines * 255 + STRLEN( objbin ).

If useful reward points.

Rgerads,

Vasanth

0 Kudos

no vasanth,

but u see the OBJBIN will still have LINE data type of 255 characters only. so I can only fill that much data into it. I need to find a way to increase the length of this data type, or any other way to accomodate more than 255 characters in a single line in OBJBIN internal table.

Regards,

Vijay

0 Kudos

Hello Vijay,

I am sendign the whole code of the sending porcess.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = l_f_filename

filetype = 'BIN'

TABLES

data_tab = objbin

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

OTHERS = 11. "#EC *

IF sy-subrc <> 0.

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

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

ENDIF.

  • Creation of the document to be sent

doc_chng-obj_name = text-016.

doc_chng-obj_descr = text-017. "Title

DESCRIBE TABLE objbin LINES tab_lines.

READ TABLE objbin INDEX tab_lines.

doc_chng-doc_size = tab_lines * 255 + STRLEN( objbin ).

objhead = l_f_filename. APPEND objhead.

  • Creation of 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 = text-018.

objpack-obj_descr = text-019.

objpack-doc_size = tab_lines * 255.

APPEND objpack.

  • Completing the recipient list

LOOP AT s_email.

reclist-receiver = s_email-low.

reclist-rec_type = 'U'.

reclist-com_type = 'INT'.

APPEND reclist.

ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

TABLES

packing_list = objpack

object_header = objhead

contents_bin = objbin

  • contents_txt = objtxt

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.

COMMIT WORK AND WAIT.

  • Start the send process

SUBMIT rsconn01

WITH mode = 'INT'

WITH output = ' '

AND RETURN.

ENDIF.

ENDFORM. " DISPATCH_EMAIL

Regards,

Vasanth

0 Kudos

hi vijay,

report zpsendmailexternal .

  • 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.

*CREATION OF INTERNAL TABLE

data : begin of itobjbin occurs 10 ,

vbeln type vbrp-vbeln,

matnr type vbrp-matnr,

werks type vbrp-werks,

fktyp like vbrk-fktyp,

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.

data : v_fktyp like vbrk-fktyp.

  • 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 = 'EMAIL WITH EXCEL DOWNLOAD'. "input contains

*title/subject of the document

*BODY OF THE MAIL

objtxt = 'Hi'.

append objtxt .

objtxt = 'Test for excel download'.

append objtxt.

objtxt = 'Below is the attachment with Billing Document Details'.

append objtxt.

objtxt = 'Regards'.

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)

select vbeln matnr werks

from vbrp into table itobjbin

up to 10 rows

where werks ge '1000'.

loop at itobjbin.

select single fktyp into v_fktyp from vbrk where vbeln = itobjbin-vbeln.

move v_fktyp to itobjbin-fktyp.

modify itobjbin.

endloop.

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 = 'XLS'.

objpack-doc_size = tab_lines * 255.

append objpack..

  • Entering names in the distribution list

reclist-receiver = 'dev02'.

reclist-rec_type = 'b'.

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 .

data: con_cret like cl_abap_char_utilities=>cr_lf."OK for non Unicode

*con_tab TYPE C VALUE '09'. "OK for non Unicode

data:con_tab like cl_abap_char_utilities=>newline.

concatenate 'Billing Document' 'Material Number' 'Plant' 'Billing

category' ' ' into objbin separated by con_tab.

concatenate con_cret objbin into objbin.

append objbin.

loop at itobjbin .

concatenate itobjbin-vbeln itobjbin-matnr itobjbin-werks itobjbin-fktyp'

'

into objbin separated by con_tab.

concatenate con_cret objbin into objbin.

append objbin.

endloop.

endform.

hope this helps,

do reward if it helps,

priya.

Former Member
0 Kudos

Hai Vijay

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DOC_CHNG-OBJ_NAME = 'TEST'.

DOC_CHNG-OBJ_DESCR = 'Test-Dokument fur API1 Test'(001).

OBJTXT = 'Mindestgebot : $250000'.

APPEND OBJTXT.

OBJTXT = 'Eine Abbildung des zur Versteigerung stehenden Bildes'.

APPEND OBJTXT.

OBJTXT = 'wurde als Anlage beigefugt.'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

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

  • * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT

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.

  • * ERSTELLEN DER ANLAGE FUR DAS DOKUMENT

OBJBIN = '\O/ '. APPEND OBJBIN.

OBJBIN = ' '. APPEND OBJBIN.

OBJBIN = ' / \ '. APPEND OBJBIN.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.

  • * Erstellen des Eintrags zur komprimierten Anlage

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'TXT'.

OBJPACK-OBJ_NAME = 'ANLAGE'.

OBJPACK-OBJ_DESCR = 'Abbildung Objekt 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

  • * Fullen der Empfangerliste

RECLIST-RECEIVER = SY-UNAME.

RECLIST-REC_TYPE = 'B'.

APPEND RECLIST.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = '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.

Regards

Sreeni