Skip to Content
author's profile photo Former Member
Former Member

How to upload file from desktop or C drive and send as attachments

Hello Experts,

Please tell me

How to upload jpg or gif or drawing files from desktop or any drive and store into R/3 by the same time I have to send mail as a attachment.

I heard that FM

SO_NEW_DOCUMENT_ATT_SEND_API1 is only to send as a attachment what ever the data is present in the internal table only.

please help me on that.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 12:31 PM

    Hi

    To upload files to the application server you can use CG3Z trxn, many others also are available like ws_upload/gui_upload et.al. Also as you have quoted the FM can be used to send files. There would be numerous FM's which would cater your requirement, just browse thru the forum.

    Rgds,

    Narendra.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 12:36 PM

    Hi,

    To upload images use tcode SE78

    To send image as mail refer link

    http://www.sap-basis-abap.com/abap021.htm

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 12:38 PM

    Hi Balaji.

    use FM GUI_UPLOAD.

    *    CALL FUNCTION 'WS_UPLOAD'
    *         EXPORTING
    *              codepage            = 'IBM'
    *              filename            = file
    *              filetype            = 'DAT'
    *              headlen             = space
    *              line_exit           = space
    *              trunclen            = space
    *              user_form           = space
    *              user_prog           = space
    *         TABLES
    *              data_tab            = data_tab
    *         EXCEPTIONS
    *              conversion_error    = 1
    *              file_open_error     = 2
    *              file_read_error     = 3
    *              invalid_table_width = 4
    *              invalid_type        = 5
    *              no_batch            = 6
    *              unknown_error       = 7.
    DATA : lv_filename type STRING.
    lv_filename = file.
    CONSTANTS: LV_FILETYPE TYPE CHAR10 VALUE 'ASC'.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = lv_filename
        FILETYPE                      = 'DAT'
        CODEPAGE                      = 'IBM'
      TABLES
        DATA_TAB                      = data_tab
      EXCEPTIONS
        FILE_OPEN_ERROR               = 1
        FILE_READ_ERROR               = 2
        NO_BATCH                      = 3
        GUI_REFUSE_FILETRANSFER       = 4
        INVALID_TYPE                  = 5
        NO_AUTHORITY                  = 6
        UNKNOWN_ERROR                 = 7
        BAD_DATA_FORMAT               = 8
        HEADER_NOT_ALLOWED            = 9
        SEPARATOR_NOT_ALLOWED         = 10
        HEADER_TOO_LONG               = 11
        UNKNOWN_DP_ERROR              = 12
        ACCESS_DENIED                 = 13
        DP_OUT_OF_MEMORY              = 14
        DISK_FULL                     = 15		
        DP_TIMEOUT                    = 16		
        OTHERS                        = 17.		
    file = lv_filename.		
    

    ws_upload is obsolete in ECC6.

    Thanks and Regards,

    Syf

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I m using this code its having attachment but I m not able to open the file. Please help me

      I m using gui_upload to upload the file

      PROGRAM ZTEST

      no standard page heading line-size 255.

      DATA: xfile TYPE string.

      data : t_IW51 LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

      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.

      DATA: TAB_LINES LIKE SY-TABIX.

      data : email type table of BAPIADSMTP.

      PARAMETERS : file LIKE rlgrap-filename OBLIGATORY.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.

      CLEAR file.

      CALL FUNCTION 'F4_FILENAME'

      IMPORTING

      file_name = file.

      xfile = file.

      START-OF-SELECTION.

      CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

      filename = xfile

      filetype = 'ASC'

      has_field_separator = 'X'

      TABLES

      data_tab = t_IW51.

      • Creation of the document to be sent

      • File Name

      DOC_CHNG-OBJ_NAME = 'SENDFILE'.

      • Mail Subject

      DOC_CHNG-OBJ_DESCR = 'Send External Mail'.

      • Mail Contents

      OBJTXT = 'Minimum bid : $250000'.

      APPEND OBJTXT.

      OBJTXT = 'A representation of the pictures up for auction'.

      APPEND OBJTXT.

      OBJTXT = 'was included as attachment.'.

      APPEND OBJTXT.

      DESCRIBE TABLE OBJTXT LINES TAB_LINES.

      READ TABLE OBJTXT INDEX TAB_LINES.

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

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

      • Creation of the document attachment

      • (Assume that the data in OBJBIN is in BMP format)

      *OBJBIN = ' \O/ '. APPEND OBJBIN.

      *OBJBIN = ' | '. APPEND OBJBIN.

      *OBJBIN = ' / \ '. APPEND OBJBIN.

      OBJBIN[] = t_IW51[].

      DESCRIBE TABLE OBJBIN LINES TAB_LINES.

      OBJHEAD = 'PICTURE.PDF'.

      APPEND OBJHEAD.

      OBJBIN[] = t_IW51[].

      • 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 = 'PDF'.

      OBJPACK-OBJ_NAME = 'PICTURE'.

      OBJPACK-OBJ_DESCR = 'Representation of object 138'.

      OBJPACK-DOC_SIZE = TAB_LINES * 255.

      APPEND OBJPACK.

      • Completing the recipient list

      RECLIST-RECEIVER = 'email_id have to enter here'.

      RECLIST-REC_TYPE = 'U'.

      APPEND RECLIST.

      RECLIST-RECEIVER = 'ENTEG01'.

      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 'The document was sent'.

      ELSE.

      WRITE 'The document could not be sent'.

      ENDIF.

      ENDLOOP.

      WHEN 1.

      WRITE: / 'No authorization for sending to the specified number',

      'of recipients'.

      WHEN 2.

      WRITE: / 'Document could not be sent to any recipient'.

      WHEN 4.

      WRITE: / 'No send authorization'.

      WHEN OTHERS.

      WRITE: / 'Error occurred while sending'.

      ENDCASE.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.