Problem with PDF Attachment (from GOS)

Hi Experts,
Below is the code in a ZFM. We are trying to get GOS attachments and the same are to be sent to SAP Inbox through Workitem. When we executed, the attachment is being shown but couldn't be opened.  It's throwing an error as 'The file has been damaged'.
As per my understanding, we are getting PDF file into lt_object_content_l and we are trying to convert that to binary file and send the same to SAP_WAPI_ATTACHMENT_ADD.
FUNCTION ztest_service_atta.
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_WORKITEMID) TYPE  SWW_WIID OPTIONAL
*"     REFERENCE(IV_PERNR) TYPE  PERSNO
*"     REFERENCE(IV_REINR) TYPE  REINR
*"  EXPORTING
*"     REFERENCE(ES_ATT_ID) TYPE  SWR_ATT_ID
*"  EXCEPTIONS
*"      ATTACH_FAILED
  DATA: gs_att_header TYPE swr_att_header.
  DATA: ls_lpor TYPE sibflporb,
  lt_lpor LIKE TABLE OF ls_lpor,
  ls_option TYPE obl_s_relt,
  lt_option TYPE obl_t_relt,
  ls_rol_op TYPE obl_s_rolt,
  lt_rol_op TYPE obl_t_rolt,
  ls_links TYPE obl_s_link,
  lt_links TYPE obl_t_link,
  ls_folder TYPE soodk,
  ls_object TYPE soodk,
  ls_obj_hd TYPE sood2,
  lt_object_content_l TYPE TABLE OF solisti1,
  ls_object_content_l TYPE solisti1,
  lt_obj_cont TYPE TABLE OF soli.
* Work areas
  DATA: lwa_doc_data        LIKE sodocchgi1,
        lwa_document_data   LIKE sofolenti1,
        lv_document_id      TYPE sofolenti1-doc_id,
        lwa_links           LIKE LINE OF lt_links,
        lwa_object          TYPE borident,
        ev_binfile TYPE xstring.
  FIELD-SYMBOLS <p> TYPE x.
  ls_lpor-instid = '000011110000000123'.
  ls_lpor-typeid = 'BUS2089'.
  ls_lpor-catid = 'BO'.
  APPEND ls_lpor TO lt_lpor.
  ls_option-sign = 'I'.
  ls_option-option = 'EQ'.
  ls_option-low = 'ATTA'.
  APPEND ls_option TO lt_option.
  ls_rol_op-sign = 'I'.
  ls_rol_op-option = 'EQ'.
  ls_rol_op-low = 'GOSAPPLOBJ'.
  APPEND ls_rol_op TO lt_rol_op.
  CALL METHOD cl_binary_relation=>read_links
    EXPORTING
      is_object           = ls_lpor
      it_relation_options = lt_option
      it_role_options     = lt_rol_op
    IMPORTING
      et_links            = lt_links.
* Process the attachment list
  LOOP AT lt_links INTO ls_links.
    lv_document_id = ls_links-instid_b.
* Read the data
    CALL FUNCTION 'SO_DOCUMENT_READ_API1'
      EXPORTING
        document_id                = lv_document_id
      IMPORTING
        document_data              = lwa_document_data
      TABLES
        object_content             = lt_object_content_l
      EXCEPTIONS
        document_id_not_exist      = 1
        operation_no_authorization = 2
        x_error                    = 3
        OTHERS                     = 4.
  ENDLOOP.
  LOOP AT lt_object_content_l INTO ls_object_content_l.
    ASSIGN ls_object_content_l TO <p> CASTING.
    CONCATENATE ev_binfile <p> INTO ev_binfile IN BYTE MODE.
  ENDLOOP.
  IF ev_binfile IS NOT INITIAL AND iv_workitemid IS NOT INITIAL.
    gs_att_header-file_type       = 'B'.
    gs_att_header-file_extension  = 'PDF'.
    gs_att_header-language        = 'EN'.
    gs_att_header-file_name       = 'Scanned Atta.PDF'.
    CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
      EXPORTING
        workitem_id = iv_workitemid
        att_header  = gs_att_header
        att_bin     = ev_binfile
        do_commit   = 'X'
      IMPORTING
        att_id      = es_att_id.
    IF es_att_id IS INITIAL.
      RAISE attach_failed.
    ENDIF.
  ENDIF.
ENDFUNCTION.
Can somebody please tell me if I went somewhere wrong. What I feel is, it's because of the PDF file being 255 chars. As I have got the PDF file but not OTF, how can I convert that ot be of 132 chars. Whatever, is the problem due to this reason only?
Can somebody please tell me where I have gone wrong. Your help is highly appreciable.
Thanks

Solved. Instead of converting object_content, I got contents_hex also and converted that as below:
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
      EXPORTING
        document_id                = lv_document_id
      IMPORTING
        document_data              = lwa_document_data
      TABLES
        object_content             = lt_object_content_l
        contents_hex               = lt_hex_cont
      EXCEPTIONS
        document_id_not_exist      = 1
        operation_no_authorization = 2
        x_error                    = 3
        OTHERS                     = 4.
  LOOP AT lt_hex_cont INTO ls_hex_cont.
    ASSIGN ls_hex_cont TO <p> CASTING.
    CONCATENATE ev_binfile <p> INTO ev_binfile IN BYTE MODE.
  ENDLOOP.

Similar Messages

  • Problem with PDF attach

    Hi, my problem es this, I use de FM 'CONVERT_OTFSPOOLJOB_2_PDF' to convert a spool to PDF document, it work ok.
    Then I convert th PDF doc from 132 to 255 char, and the end I send the PDF with FM 'SO_OBJECT_SEND' 
    The mail is sending correctly but when a try to open the PDF attached occurs an error "Error (14)" or "Format Error"
    Anyone?
    Thanks in advance.

    Instead of using the function module 'SO_OBJECT_SEND' try to use 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
    For more information: check  Abhishek Suppal's response in this [thread|PDF attachment in mail;.

  • Resolution problem with pdf presentation from CS4 in Bridge

    I have CS4 and am consistently having problems creating multipage pdf files using Bridge; though they are created using 300 dpi files in Photoshop CS4 the resulting multipage pdfs from Bridge are not print quality. I never had a problem with this before Bridge was required to create pdf presentations. The files used to create the presentation in Bridge are either psd or Photoshop pdf at 300 dpi. I am completely self-taught in Photoshop and my skill level is moderate at best, but I am not finding anything to help me so far in searching google and forums. Does anyone have any info to point me in the right direction? thanks-

    Have you applied all the updates for photoshop cs4 including this one:
    win:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4228
    mac:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4229

  • Printing problem with PDF graphs from preview

    Whenever I print PDF files from preview or from safari, some graphs print incorrectly, although they are displayed correctly on the screen.  This only happens with black and white figures and either a negative image with the black and white are reversed is printed or the background of the graphic just prints as a black box.  Colour elements are unaffected.  This doesn't happen when printing the same files using Adobe Reader or Adobe Professional.  Any suggestions for tweaking this, or am I going to have to start using the Adobe plugins instead?

    Please try it on Adobe Reader version 10.1.0 ,  Please note that this forum is for Adobe Reader on android and not for PDF Viewer.
    -vaibhav

  • Big problem with PDF export from CS4

    Create a document with facing pages. Then place a rectangle or any other object on the master through the whole spread. Place the text or any other object on the master over the first rectangle on the both pages. Now, when exporting pdf, the text on the left pages is disappeared becaouse it covered by the copy of the rectangle. The variation of the problem is when using any tansparencies, then they become "less transparent" on the left pages because of this strange dublicating.
    There is an archive in attachment that contains indd and pdf files with this problem.

    Thanks, it works, but bug is still bug. In some cases it's impossible to do this, for example my recent case: it was text with huge outer glow on master pages. Outer glow from right page dublicates to the left and covered left text, and there's no way to move effect to another layer separately. The solution was to detach these texts from masters, but it's also unhandy solution.
    It's hard to detect such cases unless it happen with big elements.

  • Urgent text shifting problem with pdf creation from indesign

    I have eps files placed in indesign and when some pages of my document are exported as pdf for press, the text moves slightly, like 1/16" or less, but enough to cause problems.  I'm using the original Indesign CS and eps files saved out of Illustrator 10.  Yup, old.....I know, but it's what I have to work with right now.  Some files are working fine but others are don't and they were all created/saved/exported the same, as far as I can tell.  Here's a small sample.  All the street name text is shifted down and to the left from the actually street.  Occurring with text on path as well as straight text.  Any ideas greatly appreciated.

    You might also try exporting to .idml form CS5 (see Remove minor corruption by exporting). We've had other reports of similar beahvior when working with legacy files, and exporting to .inx from the original version may work even better.

  • Problem with pdf files from ABBYY FineReader 11

    I am using htc desire with Android 2.2 with latest update for PDF Viewer.
    Recently I scaned book on FineReader 11 with recognition and save it on pdf format with setting to show page pictuire above recognized text. On desktop this file opening normaly, but on PDF Viewer for Android Version 1.00.1045 on my Android device it opening very very slowly and the following pages don't want to open at all. At the same time other pdf files downloaded from Net is opening normaly.
    What is the matter of problem, on perfomance (1 Ghz), RAM capacity (512)?
    How can I improve pdf files that I can read it on Android? Its imperative to have page picture above (with recognized text above its working very fast).

    Please try it on Adobe Reader version 10.1.0 ,  Please note that this forum is for Adobe Reader on android and not for PDF Viewer.
    -vaibhav

  • Resolution problem with pdf presentation from CS6 in Bridge.

    I'm having exactly the same problem as this guy but on CS6 http://forums.adobe.com/message/4352008.
    "I am consistently having problems creating multipage pdf files using Bridge; though they are created using 300 dpi files in Photoshop CS6 the resulting multipage pdfs from Bridge are not print quality."
    I couldnt find any updates for Bridge CS6. Can anyone help please?
    If Adobe wants us to use Bridge for generating pdf's it'd better be working correctly
    Thanks

    What are the PDF settings? What system are you using? Which version of Acrobat is on the system?
    Mylenium

  • Problem with .PDF files from .html files at pagebreaks

    I am using DW CS5.  When I make a .pdf from the .html file it is not handling the images with captions correctly, or even consistently, at the bottom of the .pdf page.
    Here is the Link to the .html code:
    http://www.schembs.com/0_PDF_PAGE_PROBLEM.htm
    and to the .css, if you need it:
    http://www.schembs.com/0_PDF_files/2011_ZachBuch_No_Lines.css
    The test page repeats the same image with caption several times. 
    See at the bottom of page 1. There is not enough space for Image #3 so it correctly puts it at the top of page 2.  However it puts the caption for Image #3 in the vertical position as if there were no page break and Image #3 were positioned just below the caption for Image #2.  Here is a screenshot of the bottom of page 1:
    It then places image #4 below the caption for Image #3, which results in Image #4 being on top of Image #3.
    At the bottom of page 2 there is not space for Image #6 so it puts it at the top of page 3.  It properly places the caption below Image #6 and properly places Image #7.  Here is the bottom of page 2;
    At the bottom of page 3 there is not space for all the lines of the caption, so it puts the last line of the caption for Image #8 at the top of page 4.  This is o.k.  Here is the bottom of page 3:
    I can live with it breaking up the caption (not ideal) but not with the caption overwriting the image or images overwriting images. 
    Thanks very much for your ideas on how to fix this.
    jds zigzag

    Hello Jim,
    in my IE 8 your website looks great, I don't see any overlaps. To show you what I did, here you can follow and check my proceeding by using my (German) "Adobe Acrobat 9 Pro".
    Step 1:
    Step 2:
    Step 3:
    Step 4:
    I'm sure that you can understand the used German terms, if not, bitte frage mich nachher noch einmal.
    Good luck! (German: Glück auf!)
    Hans-Günter
    P.S.
    Would you say where in one of these countless "St. Alban's" did you find these "Fratzensteine"?

  • Problem with PDF attachment - need to send as "application/pdf" - Urgent!

    I have code to email a created PDF but when the email is received the attachment is being removed by some kind of SMTPO firewall (I assume at my ISP). It says that attachment type "application/octet" with that file extension (.pdf) is not allowed. How do I set the mime type of the attachment to be "application/pdf"?
    My code I use is similar to this at the moment:-
    // Part one is the text
    BodyPart bodyPart = new MimeBodyPart();
    bodyPart.setText("Some text");
    multipart.addBodyPart(bodyPart);
    // Part two is the attachment
    bodyPart = new MimeBodyPart();
    DataSource sourceFile = new FileDataSource(FileName);
    bodyPart.setDataHandler(new DataHandler(sourceFile));
    bodyPart.setFileName("FileName.pdf");
    multipart.addBodyPart(bodyPart);
    message.setContent(multipart);Any help would be greatly apprecieated as I need to fix asap!!!

    i tried like this,but it will giving error like this
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
                        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/pdf
    my code is :
    MimeBodyPart pdfpart=new MimeBodyPart();
    pdfpart.setContent(message,"application/pdf");
    pdfpart.addHeaderLine("Content-Type: application/pdf; charset=\"iso-8859-1\"");
    pdfpart.addHeaderLine("Content-Transfer-Encoding: quoted-printable");
    Multipart mp2=new MimeMultipart();
    for( int i = 0; i < m_attachments.length; i++ )
    // attachments= str+"/"+attachments[i];
    MimeBodyPart messageBodyPart = new MimeBodyPart();
    DataSource fileDataSource =new FileDataSource(m_attachments[i]);
    InputStream fi = fileDataSource.getInputStream();
    DataSource fileDataSource1 = new ByteArrayDataSource(fi, "application/pdf");
    messageBodyPart.setDataHandler(new DataHandler(fileDataSource1));
    // messageBodyPart.setFileName(attachments[i]);
    messageBodyPart.setFileName(m_attachments[i].getName());
    mp2.addBodyPart(messageBodyPart);

  • Problem with PDF generation from Interactive Report

    Greetings,
    I created an interactive report and chose CSV and PDF download options. I am able to create CSV but when I try to download a PDF it says that that acrobat reader cannot open the created pdf file. I am not sure what I should do to make it work. Please help.
    -Vatsa

    Hey there,
    That happened to me when I had an & sign in the page title name. If you have some weird symbols in the page title, try changing them. Then it will work.
    PS
    Make sure in the title name and page name there are no weird symbols.
    Mike
    Message was edited by:
    weezy f

  • Problem with PDF vie from coldfusiom

    Hi,
    I am using the following code to display pdf files which I
    have in a seperate folder.
    <cfoutput>
    <select id="airportid" name="AirportDropDown"
    onChange="foo(this);" style="font:8pt monospace;
    font-weight:500;">
    <option value=""
    selected>                 Select
    Individual
    Airport                 </option>
    <cfloop query="AirportID">
    <option
    value="#AirportID.FAAIdentifier#,#AirportID.System_Plan#,#AirportID.Pavement_Report#,#Air portID.CityName#,#AirportID.FacilityName#,#AirportID.FAA5010_Reports#,#AirportID.CIP_Repor ts#,#AirportID.HCIP_Reports#">#AirportID.FAAIdentifier# - #AirportID.CityName# - #AirportI D.FacilityName#</option>
    </cfloop>
    </select>
    </cfoutput>
    When i click the respective link...the URL is as follows
    http://aviation-web1/Aviation/PDF/CrystalReports/5010_47A.pdf#page=1&view=fit
    when i right click on this screen i see the following code
    generated..
    <option
    value="PIM,../PDF/System_Plans/PIM_SysPlan.pdf,../PDF/Pavement_Reports/PIM_PaveStudy.pdf, PINE
    MOUNTAIN,HARRIS
    COUNTY,../PDF/CrystalReports/5010_PIM.pdf#page=1&view=fit,../PDF/CrystalReports/CIP_PIM.p df#page=1&view=fit,../PDF/CrystalReports/HCIP_PIM.pdf#page=1&view=fit">PIM - PINE
    MOUNTAIN - HARRIS COUNTY</option>
    I am not sure where
    Text
    view=fit in the above code is declared. When I click the
    link in IE6 it is working fine and in IE7 due to this view = fit
    ..is is not working
    Do please suggest me..

    Please try it on Adobe Reader version 10.1.0 ,  Please note that this forum is for Adobe Reader on android and not for PDF Viewer.
    -vaibhav

  • Trouble with PDF Export from ID CS6

    I am having the following problem with PDF exported from an ID CS6 document. I have a couple of pages where a b&w photograph is partly covered by a non-wrapping text frame and in that text frame there is blue text. In ID it looks like this:
    It also looks like this in the exported PDF in Apple Preview.app and for most of these pages they also look good in Acrobat Pro. But two are giving me trouble. They look like this:
    and sadly, they also look that way when Ingram tries to use them. I export using the typical print format PDF/X-1a:2001
    I have a minimal ID document that shows the problem with 3 such pages, one with the problem.

    Select one of the troublesome objects and open the attributes panel as well as the effects panel.
    Give us a screenshot.

  • Anyone experiencing problems with pdfs with Mountain Lion?

    When I try to open pdfs downloaded from the internet via Safari to the Mountain Lion desktop I get this message:
    "There was an error opening this document. The file is damaged and could not be repaired."
    I have encountered this problem with pdfs downloaded from several sources.
    When I open pdfs received in email messages there is no probem.
    Can anyone advise please?

    I had been having a similar problem on Lion with Safari pdf files despite downloading the latest Adobe Reader XI.
    I would constantly get the same messages - There was an error opening this document. The file is damaged and could not be repaired. And I would get a blank page when I tried to print the pdf if I tried printing from the Safari web page using File - Print from the top toolbar on my laptop.
    Then I came across the grey Safari lozenge with action icons.
    This allowed me, without downloading the pdf, to print the pdf file direct from the Safari page by using the Print icon on the grey lozenge that appears centrally three quarters down the screen.
    Then I discovered that if I save the pdf using the Save icon from this same grey lozenge on the Safari page I can open and print this pdf version from my desktop.
    I've tested it with a couple of different pdf files and these methods work using the grey lozenge icons but the same pdfs files don't work using File - Save As on the Tool Bar.

  • A problem with copying text from english pdf to a word file

    i have a problem with copying text from english pdf to a word file. the english text of pdf turns to be unknown signs when i copy them to word file .
    i illustrated what i mean in the picture i attached . note that i have adobe acrobat reader 9 . so please help cause i need to copy text to translate it .

    Is this an e-book? Does it allow for copying? It is possible that the pdf file is a scan of a book?

Maybe you are looking for

  • After checkin the timestamp of dInDate is not correct

    Hi, I use UCM 10g and have a problem with the metadata field dInDate and other fields that contain the time. The scenario is like this 1. I click on 'New-Check In' in the UCM Administration gui 2. I enter type, security group, title and other values

  • Crackling audio on my iMac.

    I'm running the latest version of OSX and ever since the update I'm getting crackles every now and again on the audio. Regardless of which program it's running. It isn't a hardware issue as I have windows installed on another partition and it's fine.

  • How to download flash video with firefox only?

    I leaned that I can download flash video clips using only firefox browser without using 3 rd party software,so when a video starts playing I select tools- page info -media, then I should select the video file and save it,I am looking for a file with

  • How to back up a Windows partition created in Boot Camp in Lion.

    Hello. I have Lion installed and I already had Windows 7 installed aswell. I used boot camp. Boot Camp booted Win. 7 just fine. Then, yesterday, I tried to boot into Win. 7 and all that apeared was a Black screen with a dash in the upper left hand co

  • URLConnection in applet

    I'm having an applet communication problem... here is the scenario: A user can click on an area on the applet. This initiates a URLConnection to the server. The server sends back a response and the applet deals with it. Sometimes, if a user clicks on