Generating PDF in Web-Dynpro

Hello,
I have a problem with generating a PDF file with ABAP WebDynpro. I have an ALV and there I read a line. From this line I want to build a smartform which should be converted into PDF. I think my coding works. I have no syntax errors and when I debug the coding, everything looks good. I also get my popup that I want to have. But then I got an error: "File does not begin with '%PDF-'."
I look for this error here in SDN but I could not find a solution. I have also tried to do what is mentioned in note 1042424.
Can anybody helps me?
Regards, Markus

Sebastian, thanks for your help, but I have used the funtions you have written.
I summarize my coding:
call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname                  = 'ZRPM_STECKBRIEF'
    importing
      fm_name                   = fm_name
    exceptions
      no_form                     = 1
      no_function_module    = 2
      others                        = 3.
CALL FUNCTION fm_name
        EXPORTING
          control_parameters =  ls_control_parameters
          is_attributes      =  ls_attributes
          lt_cap             = lt_cap_data
          iv_dateinr         = lv_dateinr
          iv_gate1           = lv_datgate1
          iv_chancen         = lv_chancen
*          IV_RISIKEN         =
*          IV_BEWERTUNG       =
          iv_ziel            = lv_short_texts
          it_fin             = lt_fin_data
          report_reason      = doc_type
        IMPORTING
          job_output_info    = ls_formdata
        TABLES
          it_nutzen          = lt_test3
        EXCEPTIONS
          formatting_error   =  1
          internal_error     =  2
          send_error         =  3
          user_canceled      =  4
          OTHERS             =  5.
lt_otf[] = ls_formdata-otfdata[].
  call function 'SSFCOMP_PDF_PREVIEW'
    exporting
      i_otf                    = lt_otf
    exceptions
      convert_otf_to_pdf_error = 1
      cntl_error               = 2
      others                   = 3.
CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
*        max_linewidth         = 132
      IMPORTING
        bin_filesize          = pdf_size
        bin_file              = pdf_data
      TABLES
        otf                   = lt_otf  
        lines                 = lt_pdf  
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        err_bad_otf           = 4
        OTHERS                = 5.
data:
        node_pdf     type ref to if_wd_context_node,
        elem_pdf     type ref to if_wd_context_element,
        stru_pdf     type        if_componentcontroller=>element_pdf ,
        item_source  like        stru_pdf-source.
* navigate from <CONTEXT> to <PDF> via lead selection
  node_pdf = wd_context->get_child_node( name = if_componentcontroller=>wdctx_changing ).
* get element via lead selection
  elem_pdf = node_pdf->get_element( ).
* set single attribute
  elem_pdf->set_attribute(
    exporting
*      name = `SOURCE`
      name = `PDF`
      value = pdf_data ).

Similar Messages

  • Dynamically generate PDF with web dynpro

    Is it possible to generate a PDF in web dynpro abap without using the interactive form UI element ? In other words just take the data in my context and convert that into a xstring pdf using a predefined template and interface?

    Hi
    Do tell your solution for others to benefit
    Regards
    Yuval

  • Prerequisites to generate PDF in web dynpro

    hi Web dynpro Gurus,
    I am trying to create a web dynpro application, which uses two BAPIs, The first BAPI output results in some data which I am displaying in a table format.
    Now among the data retrieved from the first BAPI is INVOICE number.
    Now on clicking the invoice number, the second BAPI should be called and that would result in the PDF file.
    So please help me in this issue.
    Thanks and regards
    kris

    Hi,
    For WD4A the information about PDF is here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2c/241a427ff6db2ce10000000a1550b0/frameset.htm
    And for WD4J here's the information with all the relevant links inside:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/60/6fc10c6748479392101e09c9e8d33a/frameset.htm
    Regards, Heidi

  • Generating PDF in Web-Dynpro   - empty window popup

    Hi Expertise,
       I notice that in FM Y_GLXX_WD_JAVA_PDF has calls CONVERT_OTF. It returns different value bin_file in 4.6 & ecc6. In Ecc6 there wasnt return  PDF header %PDF 1.3 - ......... but 4.6 had returns. It cause the portal site will prompt out empty windows instead of prompt out PDF screen.
    Any ideas, which FM should i use to replace CONVERT_OTF or other solutions??
    Regards,
    azel
    Edited by: azel aziz on Sep 4, 2008 4:33 AM

    For your information, i am currrently developing in Webdynpro Java. But, i don't think that is the case because the Java code will convert the Binary String to Bytes. The problem is why the BAPI returning different BIN_FILE values from two different system (ECC6.0 & 4.6C)?
    After the execution, the BAPI will return the PDF value as String
    [http://inakimi.multiply.com/photos/album/48/webdynpro#1]
    And this is the code in WD Java converting the String to Bytes:
         IWDCachedWebResource resource;
         wdThis.setData();
         String line = wdContext.currentOutputElement().getBin_File();     byte[] pdfContent = line.getBytes();     
         try{          
              resource = WDWebResource.getWebResource(pdfContent,   WDWebResourceType.PDF);
              IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getURL(), "PDF File");
              window.setWindowPosition(5, 5);       
              window.setWindowSize(600, 600);       
              window.show();
         }catch(Exception e){
    Edited by: azel aziz on Sep 5, 2008 3:25 AM

  • How to display smartform as PDF in web dynpro java

    Hi,
    Where can I find sample program to display smartform as PDF in web dynpro java.
    Thanks.
    Regards,
    Henry

    1. Create a smart form in the R/3 side
    2. Now create a function module with the corresponding export parameter:
    3. Make sure that the function module is marked remote enabled. 
    4. In NWDS  create an Adaptive RFC model which points to the FM created in R/3 under the webdynpro application
    5. Now create an application and view inside it to display the PDF and Insert a frame inside the view
    6. Create a  value node and an attribute say url of type string inside that node and bind it to the source
    7. In the doInit() method place the following code
    >    ZTest_Pdf_1_Input input = new ZTest_Pdf_Input();
    >    wdContext.nodeZTest_Pdf_Input().bind(input);      
    >    try {                       
    >            wdContext.currentZTest_Pdf_InputElement().modelObject().execute();
    >            }
    >  catch (Exception e) {
    >                        e.printStackTrace();
    >            }          
    >  wdContext.currentInternalElement().setUrl(convert(wdContext.currentOutputElement().getBin_File()));       
    Inside that view create a method to convert the string to url so that it can be passed as a string to the setUrl method of the currentContextElement() , say convet(byte[] doc_content) which return a string.
    Inside that methos write the following code,
    >         String url = "";
    >           WDWebResourceType webResType = WDWebResourceType.PDF;
    >            IWDWebResource webResource = WDWebResource.getWebResource(doc_content, webResType);
    >            try {
    >                        url = webResource.getURL();
    >            }
    >  catch (Exception e) {
    >                        e.printStackTrace();
    >            }          
    >            return url;
    Hope It will be helpful
    Regards,
    Sam Charles J.

  • Generate Adobe Interactiveform pdf using Web Dynpro Java API.

    I created pdf form by using standard "InteractiveFormElement" and it is displaying correctly in browser.
    Now there is a requirement to provide url link to the same pdf that is displayed with InteractiveFormElement. To generate pdf, I was doing something the below.
    //Copied  XDP file from the srcconfigurationcomponents<package><file>.xdp
    //to srcmimiescomponents<package><file>.xdp
    try {
         templateUrl = WDURLGenerator.getWebResourceURL(
                                   wdComponentAPI.getDeployableObjectPart(),
                          "CompView_InteractiveForm.xdp");
    } catch (WDURLException e) {               
    IWDPDFDocumentCreationContext pdfContext =
       WDPDFDocumentFactory.getDocumentHandler().getDocumentCreationContext(); 
    pdfContext.setData(
       WDInteractiveFormHelper.getContextDataAsStream(wdContext.nodeDataNode()));
    pdfContext.setTemplate(templateUrl);          
    IWDPDFDocument pdf = null;
    try {
         pdf = pdfContext.execute();               
    } catch (WDPDFDocumentRenderException e) {
                   wdComponentAPI.getMessageManager().reportException(
    "pdfContext.execute() " + e.getLocalizedMessage(), false);
    IWDPDFDocument.execute() is raising exeception "Template used in PDF render
    operation is invalid or cannot be found". template url is indeed correct. I checked by
    assigning to that url to linkToUrl Element and opening the xdp file.
    Please help me to identify the issue. Thank you.

    Hi Ajay,
    Use  getResourcePath instead of getWebResourceURL
    templateUrl = WDURLGenerator.getResourcePath(
                                   wdComponentAPI.getDeployableObjectPart(),
                          "CompView_InteractiveForm.xdp");
    Thanks
    Ram

  • Print a PDF from Web Dynpro

    Hi all gurus.
    I developed a Web Dynpro application to let the users create their own sales orders.
    Now I need to let them print the orders when they need to. Searching on the documentation I have, I've never found anything about crating a pdf print from the WD Application.
    There must be a way, because I managed to do that even with the very old ITS (the one in which you had to write HTML code...) but i cannot find how.
    Can anyone help me please? Even a tutorial would be very appreciated.
    Thank you in advance...

    >
    horatiusx wrote:
    > Hi all gurus.
    >
    > I developed a Web Dynpro application to let the users create their own sales orders.
    >
    > Now I need to let them print the orders when they need to. Searching on the documentation I have, I've never found anything about crating a pdf print from the WD Application.
    >
    > There must be a way, because I managed to do that even with the very old ITS (the one in which you had to write HTML code...) but i cannot find how.
    >
    > Can anyone help me please? Even a tutorial would be very appreciated.
    >
    > Thank you in advance...
    You need a Smartform, SAPScript, or AdobeForm to be defined for your output.  Define an action/method for print, then pass the data to your Form.  SmartForms are not bad, as SmartForms generate a Function Module, and are easy to call.
    Call the SmartForm Function with PDF output = 'X' (parameter within Output Control I think).  Then pass the PDF_DATA[] table (type = TAB_SOLIX) to a new window output .
    Don't have the code in front of me, but have done it several times.  
    Adobe Forms is another good option, but you need Adobe Server, and generally I have found ADOBE to be SLOOOOOWWWWW.  I think Steve Jobs might have been on to something with ADOBE -- just my opinion.
    And of course, it can be done with SAPSCript, but I would need a whole blog on how to do that.....

  • Mass upload & Download of PDFs in Web Dynpro ABAP

    Hi All,
    Is it possible to download multiple PDF's at one go ? for example if you have a Table UI control where each row has one clickable link that generates a PDF using WebDynpro ABAP Application, we want to enable multiselect property of Table UI and provide Mass Download Button control on click of which all selected rows should generate PDF and then get dowloaded to a specific location on machine (c:/). or if there is any other alternative possible ?similarly for Mass Upload we wish to multi select PDFs and upload them to R/3 at one go ?
    please let me know if such thing is possible ? if yes is it a good option to have ? as we have users who have to upload these PDF one by one and they wish if they could simply select all PDFs at one go and click Mass upload..Note that there are some validation that we perform once we upload PDF before posting PDF data to backend.
    your help & comments would be Highly Appreciated !!
    Thanks
    Asif

    >
    Maged Ishak wrote:
    > Hi Thomas,
    >
    > could you give me an example how can i download multiple objects without multiple prompts with the class CL_ABAP_ZIP. I use a Web Dynpro for ABAP and I have for Example many word file and i want to download all file in one ZIP-File.
    > thanks in advance
    > mishak
    You simply use the CL_ABAP_ZIP class to combine the multiple binary strings of the word files together.
      data izip type ref to cl_abap_zip.
      data zip_xstring type xstring.
      create object izip.
      loop at ifiles assigning <Wa_file>.
      izip->add( name = <wa_file>-filename
                  content = <wa_file>-filecontent ).
      endloop.
      zip_xstring = izip->save( ).

  • Print Version PDF in Web Dynpro ABAP Developements

    Hi!
    But when we push the print button, it works but doesn't generate the pdf document correctly.
    alvexport.pdf   1 bytes_   the size of the document isn't correct because there is not content inside.
    Best Regards.

    >
    Gabriel Rodriguez Jimenez wrote:
    > I put this direction to verify de ADS
    >
    > http://maep7java.miquel.es/AdobeDocumentServices/Config?style=rpc
    >
    > making a rpc test "works"
    >
    >
    > The test conection in sm59 ADS works
    >
    >
    >  Also check to see if any of the sample AdobeForms WDA applications are working. <-- where I can check this?
    >
    >
    > Thanks
    The connection test in SM59 only does a basic PING to the web service endpoint. Often it will show OK, when in fact the ADS is not setup correctly.  That is why there are some test applications that do more. 
    For proper testing of your setup see OSS Note 944221.  But basically run the ABAP programs FP_PDF_TEST_00 and FP_CHECK_DESTINATION_SERVICE.  You can also try running the web dynpro components WDR_TEST_ADOBE and WDR_TEST_ADOBE_PDF_ONLY

  • Smartform as PDF in Web Dynpro for ABAP

    Hello Experts,
    I have developed one Web Dynpro application in which i am trying to show PDF converting from smart from on button click.
    I am seeing blank screen when i try to display PDF? But when i check i debugging data passed successfully to context element.
    PDF source property mapped to review context element.
    I used below code to show PDF in view method:
    call function 'SSF_FUNCTION_MODULE_NAME'
    call function lv_fm_name
    call function 'SSFCOMP_PDF_PREVIEW'
    call function 'CONVERT_OTF'
    elem_pdf->set_attribute(
       exporting
             name = `SOURCE`
              value = data ).
    Thanks
    Rajesh Yadla

    Looks quite alright, but since you only have provided a few function modules, there is 'no' way of telling what is going wrong. I can however give you a link and compare your coding with the one from the tutorial:
    [How to display a smartform as PDF in WD4A|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0de1eb8-0b98-2910-7996-8a3c2fcf6785]

  • After SP upgrade, pdf in web dynpro could not display dollar symbol

    Dear Experts,
          We have updated the following support packages:
         SAP_BASIS 14-18
         SAP_ABA 14-18
         PI_BASIS 14-18
         SAP_BW 15-20
         SAP_AP 12-15
         EA-HR 23-61
         SAP-HR 23-61
         E-RECRUITMENT 18
         After that, Some webdynpro for abap which used PDF report has some errors, which dollar could not be displayed, which indicates some kind of error 'o'.
         We check that the pattern is of this column is from old version :num{$zzz,zzz,zz9.99} to num{($z,zzz,zz9.99)} . How could we deal with this ? And where could I find the related influence of the SP upgrade of adobe and web dynpro?
    Thanks & Best Regards,
    Derek

    Chris,
    You may be right. Also it requires some configuration in SAP KPro ( document class etc).
    Please see SAP [Help |http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCSRVBDS/BDS_STRUCTURE.pdf]on Business Document Services.
    At page 64 of this document under topic 'Display Documents' 'Feature it says. "If it is not possible to display the document in place, an appropriate viewer that is available on the
    PC is started and the document is displayed u201Cout placeu201C

  • How to display pdf in Web Dynpro Page

    Hi Experts,
    I need to display the pdf file in web dynpro page. I am using  Web dynpro 7.1(CE), in that no ui element like Iframe. With Iframe we can display the pdf file in web Dynpro page in 7.0.
    But My problem is how display pdf with out using Iframe.
    Please any one tell how to display with any other UI elements.
    Regards,
    Sunil.

    Hi sunil..
    chk this link..
    <u><b>Pdf</b></u>
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0401535-f81c-2a10-0192-ffd41e8e8d59
    <u><b>Adobe</b></u>
    /people/achim.hauck/blog/2005/02/04/my-struggles-with-the-adobe-document-services-in-was640
    <u><b>Configuration</b></u>
    http://help.sap.com/saphelp_nw70/helpdata/en/43/8a1a8ece230c8ce10000000a11466f/content.htm
    <u><b>Adobe Document services</b></u>
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9e4e9afb-0701-0010-f8a8-b8cd093662c2
    <u><b>Configuring Guided procedure of Interactive Forms</b></u>
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b9ea34c2-0701-0010-e2a2-d8e9cd6d85dc
    <u><b>Forum Discussions abt Adobe Document Services</b></u>
    Re: Configuring the Destination URL for the Adobe Document Services
    Hop will this helpful for u..
    Regards,
    GS

  • Display archive doc as pdf from web dynpro?

    Hi All,
    We have a situation where we want to display archived pdf's from a web dynpro.  I have put an interactive form ui element on my view and bound this to an attribute of type xstring on the context.
    When I run it, i get an error message saying that file does not begin with '%PDF-'.  I've tried putting this on the front of the string but i didn't work either.
    So can anyone tell me the process for displaying archived pdf's from a web dynpro.
    Many thanks in advance,
    Liz.

    This is the code necessary to get it to work:
    get optical archive id of pdf to display
        select single * from toahr into ls_toahr
          where sap_object = 'PREL'
            and OBJECT_ID  = lv_obj_id
            and ar_object  = ls_zhr_paylsip-zhr_doc_type.
        lv_archiv_id  = 'H1'.
        lv_document_type = ls_toahr-ar_object.
        lv_archiv_doc_id = ls_toahr-arc_doc_id.
        lv_signature = 'X'.
        lv_compid = 'data'.
        free lt_binarchivobject.
        call function 'ARCHIVOBJECT_GET_TABLE'
          exporting
            archiv_id                      = lv_archiv_id
            document_type                  = lv_document_type
            archiv_doc_id                  = lv_archiv_doc_id
      ALL_COMPONENTS                 =
           signature                      = lv_signature
           compid                         = lv_compid
         importing
           length                         = lv_length
           binlength                      = lv_binlength
         tables
           archivobject                   = lt_archivobject
           binarchivobject                = lt_binarchivobject
         exceptions
           error_archiv                   = 1
           error_communicationtable       = 2
           error_kernel                   = 3
           others                         = 4.
        if lt_archivobject[] is not initial.
          describe table lt_archivobject lines lv_rowcount.
          lv_rowcount = lv_rowcount * 1024.
          call function 'SCMS_BINARY_TO_XSTRING'
            exporting
              input_length = lv_rowcount
              first_line   = 1
              last_line    = lv_rowcount
            importing
              buffer       = lv_xstring
          tables
            binary_tab   = lt_binarchivobject
          exceptions
            failed       = 1.
        endif.
    Where yo bind lv_xstring to the the pdfSource via the context

  • Error while generating PDF ( BEx Web Analyzer )

    Hi,
    Is there any limit to the number of pages we can print using ADS? We always get
    " Error while generating PDF" Error when we try to print reports with more than 500 lines.
    Thanks
    Niveda

    Great. It worked.
    Points assigned.
    Niveda

  • Generating a PDF in Web Dynpro without using InteractiveForms

    Hello All,
      I have been following this tutorial <a href="http://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20working%20with%20the%20pdf%20document%20object%20-%2032.htm">http://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20working%20with%20the%20pdf%20document%20object%20-%2032.htm</a> from SDN and is currently stuck.
    <u><b>What I'll like to achieve</b></u>
    1) User logs on to the system and a table displaying a list of items for approval appears.
    2) the user is then able to select a row item from the table and click on 'approve'. In doing so, my application should generate a pdf form in the background and attach it as an email attachment and sent that email to an appointed vendor.
    <b><u>Problem</u></b>
    As there is no InteractiveForm involved, I do believe I will need to provide the template (.xdp) so that the PDF can be generated. In the tutorial, it suggests doing this (I modified it a little to reflect my own path name):
    InputStream templateSourceInputStream =     getClass().getClassLoader().getResourceAsStream("d:
    usr
    sap
    pdf
    PDF
    XBCRPDFPreviewView_InteractiveForm1.xdp");
    However, I am given a NullPointerException when I attempt to do that. Does anyone has any idea what may have caused the error ? Thank you.
    from
    Kwok Wei

    Hi Kwok Wei ,
    According to the convention the any file can be placed in the src/mimes/Components/<component package + component name>/folder of your webdynpro project along with other generated files of your application.
    After this you just need to pass the filename to the getResourcestream() method,it automatically picks up the file from the folder.
    Regards
    Aarthi Mathivanan
    Message was edited by: aarthi mathivanan

Maybe you are looking for