Application Development and Automation 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: 
Read only

Attachment

Former Member
0 Likes
376

Hello Experts,

Please help me for sending attachment on SAP system . How we create attachment in SAP internally or externally as example so00 transaction done.

Thanks In advance.

Ankur Garg.

2 REPLIES 2
Read only

anversha_s
Active Contributor
0 Likes
338

hi,

chk this simple code.

the FM for this is <b>'SO_DOCUMENT_SEND_API1'</b>

REPORT Z895_DOCATTC.

data : wa_doc_data like SODOCCHGI1,

v_lin like Sy-tabix,

v_obj_id like SOFOLENTI1-OBJECT_ID.

data : wa_reciever like SOMLRECI1,

t_reciever like standard table of wa_reciever.

data : wa_pk_list like SOPCKLSTI1,

t_pk_list like standard table of wa_pk_list.

data : wa_con_txt like SOLISTI1,

t_TEMP like standard table of wa_con_txt,

t_con_txt like standard table of wa_con_txt.

wa_con_txt = 'hello'.

append wa_con_txt to t_con_txt.

append wa_con_txt to t_con_txt.

describe table t_con_txt lines v_lin.

read table t_con_txt index v_lin into wa_con_txt.

wa_doc_data-doc_size = ( v_lin - 1 ) * 255 + strlen( wa_con_txt ).

wa_doc_data-OBJ_NAME = 'ATC'.

wa_doc_data-OBJ_DESCR = 'to send an attachment'.

wa_doc_data-OBJ_LANGU = 'E'.

wa_reciever-RECEIVER = ''.

wa_reciever-REC_TYPE = 'B'.

wa_reciever-com_type = 'INT'.

append wa_reciever to t_reciever.

clear wa_pk_list-transf_bin.

wa_pk_list-head_start = 1.

wa_pk_list-head_num = 0.

wa_pk_list-BODY_START = 1.

wa_pk_list-body_num = v_lin.

wa_pk_list-doc_type = 'RAW'.

append wa_pk_list to t_pk_list.

to upload a pdf file

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings'

FILETYPE = 'BIN'

TABLES

DATA_TAB = T_TEMP

.

DESCRIBE TABLE T_TEMP LINES V_LIN.

WA_PK_LIST-TRANSF_BIN = 'X'.

WA_PK_LIST-HEAD_NUM = 0.

WA_PK_LIST-BODY_START = 1.

WA_PK_LIST-BODY_NUM = V_LIN.

WA_PK_LIST-DOC_TYPE = 'PDF'.

WA_PK_LIST-OBJ_NAME = 'ATTACHMENT'.

WA_PK_LIST-OBJ_DESCR = 'Reproduction object 138'.

WA_PK_LIST-DOC_SIZE = V_LIN * 255.

APPEND WA_PK_LIST TO T_PK_LIST..

<b>CALL FUNCTION 'SO_DOCUMENT_SEND_API1'</b>

EXPORTING

DOCUMENT_DATA = wa_doc_data

IMPORTING

NEW_OBJECT_ID = v_obj_id

TABLES

PACKING_LIST = t_pk_list

CONTENTS_BIN = T_TEMP

CONTENTS_TXT = t_con_txt

RECEIVERS = t_reciever

.

rgds

anver

if helepd mark points

Read only

Former Member
0 Likes
338

Check this code it may help u.

FORM send_mail USING p_y16m_rcp_par STRUCTURE y16m_rcp_par.

  • Have a subject for the mail

g_s_document_data-obj_name = text-t02.

g_s_document_data-obj_descr = text-t03.

  • Fill receiver information

g_s_receivers-rec_type = p_y16m_rcp_par-rec_type.

g_s_receivers-rec_id = p_y16m_rcp_par-rec_id.

g_s_receivers-express = 'X'.

APPEND g_s_receivers TO g_t_receivers.

  • Call function to send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = g_s_document_data

document_type = 'RAW'

  • PUT_IN_OUTBOX = ' '

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

  • OBJECT_HEADER =

object_content = g_t_object_content

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = g_t_receivers

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.

ENDFORM. " SEND_MAIL

Regards