Uploading PDF-file from unix to SAP internal table

Hi,
i have to write an abap that sends a pdf-file from a unix (SAP server) by mail to some people.
The mailing part is done, but for creating the attachment. I'm reading the pdf-file into an internal table (in a binary way). Then i'm using this int.table to send the mail.
The email is sent with an attachment, but i cannot open the pdf-file because of an error ( file damaged ). So before sending it by mail, i'm downloading the pdf file to my pc by using WS_DOWNLOAD with the same internal table. The download file gives the same error.
If i look at the size :
- originally pdf file 71743 bytes
- resulting pdf file 71665 bytes (281 lines x 255)
The creation of the internal table is as follows :
open dataset g_file for input in binary mode.
  check sy-subrc eq 0.
  do.
*    read dataset g_file MAXIMUM LENGTH 255 into wa_pdf.
    read dataset g_file into wa_pdf.
    if sy-subrc ne 0. exit. endif.
    append wa_pdf_hex to i_pdf.
  enddo.
  close dataset g_file.
where:
types:  tt_pdf  type table of soli,   "raw 255 long
data: i_pdf type tt_pdf,
         wa_pdf like line of i_pdf
Is there a better way to read in the pdf-file ? Any suggestions ?
regards,
Hans
[email protected]

Hello Hans,
this is a little example from a program to send mail with picture. The problem is the same
form p_create_mail tables itab_html.
  data : object_hd_change like sood1 occurs 0 with header line,
         objpara          like selc  occurs 0 with header line,
         receivers        like soos1 occurs 0 with header line,
         packing_list     like soxpl occurs 0 with header line,
         fic_attach       like soli  occurs 0 with header line,
         struct_user_adress like usaddress ,
         v_file(80) type c ,
         v_buff(255) type c ,
         v_num(9) type n,
         v_length type i ,
         v_total_length type i,
         v_len(9) type n.
  move : 'HTM'  to object_hd_change-file_ext ,
         'PIOU' to object_hd_change-objdes.
  append object_hd_change.
* Find email addr for the username.
  loop at s_bname.
    call function 'SUSR_USER_READ'
      exporting
        user_name                  = s_bname-low
      importing
        user_address               = struct_user_adress
      exceptions
        user_name_not_exists       = 1
        internal_error             = 2
        others                     = 3.
    select single smtp_addr
           into receivers-recextnam
           from adr6
           where addrnumber eq struct_user_adress-addrnumber
           and   persnumber eq struct_user_adress-persnumber.
    if sy-subrc eq space.
      move 'U' to receivers-recesc.
      append receivers.
    endif.
  endloop.
* Get the picture.
  move '/sap_interfaces/D27/pzr_00/data/test/logopharma.gif'
       to v_file.
  open dataset v_file for input in binary mode.
  do.
    read dataset v_file into v_buff length v_length.
    v_total_length = v_length + v_total_length.
    move v_buff+0(v_length) to fic_attach-line+0(v_length).
    append fic_attach.
    if sy-subrc ne space.
      exit.
    endif.
  enddo.
  describe table fic_attach lines v_num.
  describe field fic_attach-line length v_len.
  move : 'Logo' to packing_list-objdes ,
         'Logo' to packing_list-objnam ,
         '1'    to packing_list-body_start ,
         'raw'  to packing_list-objtp ,
         'GIF'  to packing_list-file_ext .
  packing_list-body_num = v_num.
  packing_list-objlen   =  v_num * v_len.
  append packing_list.
* Send mail.
  call function 'SO_OBJECT_SEND'
       exporting
           object_hd_change           = object_hd_change
           object_type                = 'RAW'
           owner                      = sy-uname
       tables
           objcont                    = itab_html
           objpara                    = objpara
           receivers                  = receivers
           packing_list               = packing_list
           att_cont                   = fic_attach
       exceptions
           others                     = 01.
endform.                     " P_CREATE_MAIL.
Regards
Frédéric

Similar Messages

  • Issue with uploading XML file from application server into internal table

    i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module   SMUM_XML_PARSE and the error message is "line   1 col   1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?  
        TYPES: BEGIN OF T_XML,
                 raw(2000) TYPE C,
               END OF T_XML.
    DATA:GW_XML_TAB TYPE  T_XML.
    DATA:  GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
    DATA:GI_STR TYPE STRING.
    data:  GV_XML_STRING TYPE XSTRING.
    DATA: GI_XML_DATA TYPE  TABLE OF SMUM_XMLTB INITIAL SIZE 0.
    data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
        OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF SY-SUBRC NE 0.
          MESSAGE 'File does not exist' TYPE 'E'.
        ELSE.
          DO.
    * Transfer the contents from the file to the work area of the internal table
            READ DATASET LV_FILE1 INTO GW_XML_TAB.
            IF SY-SUBRC EQ 0.
              CONDENSE GW_XML_TAB.
    *       Append the contents of the work area to the internal table
              APPEND GW_XML_TAB TO GI_XML_TAB.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
        ENDIF.
    * Close the file after reading the data
        CLOSE DATASET LV_FILE1.
        IF NOT GI_XML_TAB IS INITIAL.
          CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
        ENDIF.
    * The function module is used to convert string to xstring
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            TEXT   = GI_STR
          IMPORTING
            BUFFER = GV_XML_STRING
          EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
        IF SY-SUBRC <> 0.
          MESSAGE 'Error in the XML file' TYPE 'E'.
        ENDIF.
      ENDIF.
      IF GV_SUBRC = 0.
    * Convert XML to internal table
        CALL FUNCTION 'SMUM_XML_PARSE'
          EXPORTING
            XML_INPUT = GV_XML_STRING
          TABLES
            XML_TABLE = GI_XML_DATA
            RETURN    = GI_RETURN.
      ENDIF.
      READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
      IF SY-SUBRC EQ 0.
        MESSAGE 'Error converting the input XML file' TYPE 'E'.
      ELSE.
        DELETE GI_XML_DATA WHERE TYPE <> 'V'.
        REFRESH GI_RETURN.
      ENDIF.

    Could you please tel me  why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
    Becuase there will be lot of  XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
    what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?>   ??????
    Is there any other way we can do with out removing the lines?

  • Upload XML file from Application Server to Internal Table

    Hi Experts,
       i have xml file in application server and i want to convert to internal table .
       i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
       Here the file is loaded from local(presentation Server) ..
       i want to know how to select file from application layer ..and schedule in background..
       i also tried  FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
       i need to select a xml file from application server and convert into internal table in background.. help me on this..

    Have a look on
    Re: How to convert XML data to different ABAP internal table
    Thanks
    Ravin

  • How to upload pdf file from windows cell phone?

    How to upload pdf file from windows cell phone?

    You can do this in steps.. First use the built in method for uploading a file into the flows files object, Next you would copy the file out to an Oracle built directory on your UNIX box using utl_file.put_raw..
    Here is a link to show you how to upload files in an APEX application [http://download.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm]
    And here is a link to show you how to use utl_file.put_raw.. [http://psoug.org/reference/utl_file.html], item is towards the bottom of the screen..
    Thank you,
    Tony Miller
    Webster, TX

  • Upload a file from unix environment

    hi
    does anybody know which fm to use to upload a file from unix environment?
    anjali

    hi sia,
    try this.
    parameters: p_file like rlgrap-filename obligatory
    default '/usr/sap/upload.xls'.
    types: begin of t_data,
    vbeln like vbap-vbeln,
    posnr like vbap-posnr,
    matnr like vbap-matnr,
    werks like vbap-werks,
    megne like vbap-zmeng,
    end of t_data.
    data: it_data type standard table of t_data,
    wa_data type t_data.
    open dataset p_file for output in text mode encoding default.
    if sy-subrc ne 0.
    write:/ 'Unable to open file:', p_file.
    else.
    do.
    read dataset p_file into wa_data.
    if sy-subrc ne 0.
    exit.
    else.
    append wa_data to it_data.
    endif.
    enddo.
    close dataset p_file.
    endif.
    rgds
    anver

  • Printing of PDF files from Unix and Linux

    Hi
    I am looking for a product (free or commercial) that can print PDF files from Unix (HP-UX, AIX) and Linux system. It must have similar features to the Windows Adobe print driver like setting margins, re-sizing, size to fit, etc.
    Thanks
    Gil

    Hi Gil,
    For HPUX and AIX Adobe Reader 7.0.9 is available for download.
    For Linux and Solaris, the latest version available is Adobe Reader 8.1.2.
    You can download the installers from :
    http://www.adobe.com/products/acrobat/readstep2_allversions.html
    Regards,
    Rishi

  • Uploading excel files from ITS to sap

    Hi all,
    I want to upload excel files from ITS to sap system ECC 6.0 .I am using standalone ITS.Someone please help me find a solution for this.What are the steps involved in it?
    Thanks in advance
    Shinu

    Hi Shinu,
    this seems to be a misunderstanding. The ITS does not have excel files.
    Did you mean to say that you have an application which allows to upload
    files? This application might work using the webgui service of the ITS.
    Try it out!
    best regards
    Tobias

  • Error while reading excel file from application server into internal table.

    Hi experts,
    My requirement is to read an excel file from application server into internal table.
    Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
    Now in my program I have used :
    OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    DO.
    READ DATASET v_filename INTO wa_tab.
    The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
    Error details:
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 445. If this number is 0, the second error case, as
    mentioned above, has occurred.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Characters are always displayed in only a certain codepage. Many
    codepages only define a limited set of characters. If a text from a
    codepage should be converted into another codepage, and if this text
    contains characters that are not defined in one of the two codepages, a
    conversion error occurs.
    Moreover, a conversion error can occur if one of the needed codepages
    '4110' or '4103' is not known to the system.
    If the conversion error occurred at read or write of  screen, the file
    name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
    the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
    Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
    Regards,
    Karthik

    Hi,
    Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    As I think you are uploading the file in BIN format to Application server and trying to open text file.
    Regards,
    Umang Mehta

  • Upload PDF file from SAP Portal and save in SAP

    A file in PDF format needs to be uploaded from SAP Portal and the file is to be saved in SAP. Request for help, how to do the same. What are the FM to be used etc..
    Thanks,

    hi
    Use FM  GUI_UPLOAD with file type as BIN
    there are similar threads...pls refer to them for more details:
    https://www.sdn.sap.com/irj/sdn/profile?userid=3166533
    Upload pdf file to SAP
    PDF File
    reward if helpful
    regards,
    madhu

  • Upload pdf file from frontend to unix server

    Hi all,
    I want to upload a file from frontend to unix server.
    The following coding transfers the file to the unix server. But the file is corrupted.
    Any ideas whats wrong?
    TYPES: BEGIN OF t_data_tab,
             line TYPE x LENGTH 256,
           END OF t_data_tab.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        CHANGING
          file_table = lt_filetable
          rc         = lv_rc.
      READ TABLE lt_filetable INTO p_file INDEX 1.
      lv_filename = p_file.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename = lv_filename
          filetype = 'BIN'
        CHANGING
          data_tab = lt_data_tab
        EXCEPTIONS
          OTHERS   = 4.
      OPEN DATASET p_unix FOR OUTPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        EXIT.
      ELSE.
        LOOP AT lt_data_tab INTO ls_data_tab.
          TRANSFER ls_data_tab TO p_unix.
          IF sy-subrc NE 0.
            CONTINUE.
          ENDIF.
        ENDLOOP.
        CLOSE DATASET p_unix.
      ENDIF.
    regards

    Found solution by myself.
    Upload
    REPORT  z_upload_to_unix.
    TYPES: ESP1_BOOLEAN LIKE BAPISTDTYP-BOOLEAN.
    DATA: i_ftfront TYPE string,
          i_ftappl LIKE  rcgfiletr-ftappl,
          i_flg_overwrite TYPE  esp1_boolean,
          l_flg_open_error TYPE  esp1_boolean,
          l_os_message TYPE  c.
    i_ftfront = '<frontendpath>\test.pdf'.
    i_ftappl = '<unixpath>/test.pdf'.
    CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
      EXPORTING
        i_file_front_end   = i_ftfront
        i_file_appl        = i_ftappl
        i_file_overwrite   = i_flg_overwrite
      IMPORTING
        e_flg_open_error   = l_flg_open_error
        e_os_message       = l_os_message
      EXCEPTIONS
        fe_file_not_exists = 1
        fe_file_read_error = 2
        ap_no_authority    = 3
        ap_file_open_error = 4
        ap_file_exists     = 5
        OTHERS             = 6.
    DOWNLOAD:
    REPORT  z_download_from_unix.
    TYPES: ESP1_BOOLEAN LIKE BAPISTDTYP-BOOLEAN.
    DATA: front TYPE string,
          i_file_appl LIKE rcgfiletr-ftappl,
          i_file_overwrite TYPE  esp1_boolean,
          e_flg_open_error TYPE  esp1_boolean,
          e_os_message TYPE  c.
    i_file_appl = '<unixpath>/test.pdf'.
    front = '<frontendpath>\test.pdf'.
    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
      EXPORTING
        i_file_front_end    = front
        i_file_appl         = i_file_appl
        i_file_overwrite    = i_file_overwrite
      IMPORTING
        e_flg_open_error    = e_flg_open_error
        e_os_message        = e_os_message
      EXCEPTIONS
        fe_file_open_error  = 1
        fe_file_exists      = 2
        fe_file_write_error = 3
        ap_no_authority     = 4
        ap_file_open_error  = 5
        ap_file_empty       = 6
        OTHERS              = 7.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • How can I upload .pdf file from Mac to iPhone or is there an app for that?

    How can I upload a .pdf file from my mac to iPhone 3G?
    Or is there an app that will allow me to that?
    Thanks in advance
    Zia

    The app called "Air Sharing" allows you to do that. Connect to a wifi network, run the program and you can mount your iphone as a drive using Finder. Upload all the PDFs you like, and you can open them from within the Air Sharing app. Also, you can view most image files, most office files, etc.

  • Error while uploading mpp file from OPENPS to SAP PS

    Hi,
    I am trying to upload project .mpp file from OPENPS to SAP PS with following feild:
    ID, Description, Task calander, Start Date, End Date, Object type
    but at the time of uploading it showing error:
    1: E CN194 The stauts could not be created while creating network.
    2. E BS001 No status object is available for wbs #
    3. E CN068 WBS element control area is not same as network control area.
    Kindly sugguest me to resolve all these issue.
    Mukul

    Hi,
    Are you creating new project or updating existing project ? from error it seems to be you are trying to update the existing project you are trying assign the network to WBS which are not having same controlling area and user staus is active.
    Please check your .mpp project data.
    regards,

  • I am trying to upload my PDF file from my IBooks but its only giving me the option to upload from my pictures/gallery. How do I get it to where I can upload PDF files from my iBook or how do I transfer my PDF files to my pics?

    I am trying to upload my PDF file from my iBooks but its only giving me the option to upload from my pictures/gallery. How do I get it so I can upload from my iBooks or move my PDF files to my gallery so I can upload it?

    I'm having the same issue. I saved a PDF from an email into iBooks. I'm on apple applying for a job but the only option the upload button has is from the Photos file. How ironic right? Luckily I'm in Logistics and not an IT specialist applying for this job! Lol. Does anyone know the fix?

  • Download PDF File from Archiv to SAP Application Server

    Hi,
    I need to download the PDF file from an NAST-Dataset (how is stored from the message via SAP ArchivLink) to the SAP Application Server.
    1) At first i read the Archiv-Link data via function module WFMC_GET_ARCHIVE_OBJECT_TYPE
    2) Then i get the Connection-Infos via function module ARCHIV_GET_CONNECTIONS_INT
    3) Now i read the file from archiv as table via function module ARCHIVOBJECT_GET_BYTES
    4) Save to the SAP Appl.Server via:
       - OPEN DATASET ld_dpfad FOR OUTPUT IN BINARY MODE
       - LOOP and TRANSFER lf_archivobject TO ld_dpfad.
       - CLOSE DATASET ld_dpfad.
    In the dialog of NAST-Dataset (Messages) i can open the PDF-File without any errors (display originals). But after the filetransfer to the SAP Appl.Server i get the following errors during the file opening dialog from Adobe Acrobat Reader:
    - the embedded font u201CArialu201D cant to be extract
    - not enough data for the picture
    The reader can display the PDF-File but only without the picture (Logo) and with alternative font.
    The same transfer from archiv and sending as an attachement to the BOR-Object via function module SO_DOCUMENT_INSERT_API1 works very fine and without any errors.
    Can any one please help me to solve this Issue?
    Thanks in Advance,
    Thomas

    Hello Keith,
    Many thanks for your answer.
    In the past i didnu2019t need the BINARCHIVOBJECT-Parameter and so i overlook this option.
    Now, the File looks a little bit different, but only in the STREAM-section.
    During the Fileopen-Dialog i get only one message now - "not enough data for image" and the image will not displayed. The rest seems to be correct.
    The relevant coding is now:
      ld_doc_typ = pf_connections-reserve.
      CALL FUNCTION 'ARCHIVOBJECT_GET_BYTES'
        EXPORTING
          archiv_id                = pf_connections-archiv_id
          archiv_doc_id            = pf_connections-arc_doc_id
          document_type            = ld_doc_typ
          length                   = ld_length1
          offset                   = ld_offset
        IMPORTING
          binlength                = ld_length                        
          offset                   = ld_offset
        TABLES
          binarchivobject          = lt_binarchivobj                  
        EXCEPTIONS
          error_archiv             = 1
          error_communicationtable = 2
          error_kernel             = 3
          OTHERS                   = 4.
    Zieldatei zum Schreiben öffnen
        OPEN DATASET ld_dpfad FOR OUTPUT IN BINARY MODE.
    Inhalte in Zieldatei schreiben
      LOOP AT lt_binarchivobj INTO lf_binarchivobj.
        TRANSFER lf_binarchivobj TO ld_dpfad NO END OF LINE.          
      ENDLOOP.
    Zieldatei schließen
      CLOSE DATASET ld_dpfad.
    Where is the error for the image data?
    Ciao Thomas
    Push up by: Thomas Engler on May 3, 2010 4:54 PM

  • Download file from application server to internal table in background

    hi all,
    i want to download a file from appliaction server into my internal table but in background.
    i had tryed CG3Z and CG3Y t-code but screen that is coming is asking for the parameters, and i want that screen should not appear and file should be saved in the predefined path by me.
    if there any way to do so,
    Points will be rewarded as per the Aswers.
    thaks in advance.

    Hi Sudeep,
       Use this code to get file data from application server.
    REPORT  ZE0232_BDC_APPLSERVER.
    DATA: FILE_PATH TYPE STRING.
    FILE_PATH = 'c:\bdc_mat.prn'.
    DATA: BEGIN OF ITAB OCCURS 0,
                END OF ITAB.
    OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF SY-SUBRC = 0.
    DO.
    READ DATASET FILE_PATH INTO ITAB.
    IF ITAB-RESNO NE SPACE.
       APPEND ITAB.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    ENDIF.
    CLOSE DATASET FILE_PATH.
    LOOP AT ITAB.
    WRITE:/ ITAB.
    ENDLOOP.
    FILE PATH IS  application server path.
    IF USEFULL REWARD

Maybe you are looking for