Smartform as PDF On Button Click

Hello Everyone,
I need to display a smartform as PDF on click of a button.
I have done the conversion using CONVERT_OTF. And then,
CREATE OBJECT cached_response
EXPORTING add_c_msg = 1.
*Start display PDF
      cached_response->set_header_field( name  = 'content-type'
                                  value = 'application/pdf' ).
some Browsers have caching problems when loading PDF format
      cached_response->set_header_field(
                         name  = 'cache-control'
                         value = 'max-age=0' ).
start PDF viewer either in the Browser or as a separate window
       cached_response->set_header_field(
                           name  = 'content-disposition'
                           value = 'attachment; filename=form.pdf' ).
finally display PDF format in Browser
      l_pdf_len = xstrlen( l_pdf_xstring ).
     cached_response->set_data( data   = l_pdf_xstring
                          length = l_pdf_len ).
DATA: OBJ1 TYPE REF TO CL_BSP_NAVIGATION,
            lr_runtime type ref to cl_bsp_runtime.
CREATE OBJECT OBJ1
  EXPORTING
    RUNTIME = lr_runtime.
call method OBJ1->RESPONSE_COMPLETE .
Is this correct, did I miss anything?
I get a blank screen when I click on the button.
I know this was asked many times , checked those posts but no help.
Looking forward to your input.
Regards,
Mohit Joshi

Mohit,
did you check the smartform itself?
is it complete executed?
can you test it via the FM?
most of the times when the url shows an empty page is that or the SMARTFORM is not executed correctly or the pdf is not opened automatically.
KR,
Micha
have a look at my coding:
     CALL FUNCTION 'SCMS_FTEXT_TO_BINARY'
       EXPORTING
         input_length    = ls_len
         append_to_table = 'X'
       IMPORTING
         output_length   = ls_len
       TABLES
         ftext_tab       = lt_objcont
         binary_tab      = lt_contents
       EXCEPTIONS
         failed          = 1
         OTHERS          = 2.
     lv_file_size = ls_len.
     lv_contenttype = 'text/plain'.                         "#EC NOTEXT
   ELSE.
     lv_file_size = xwa_len.
     lv_contenttype = 'application/pdf'.                    "#EC NOTEXT
     CONCATENATE ls_guid_str '.pdf' INTO lv_filename.
     lv_file_name = lv_filename.
     server->response->append_data(
                         data   = xwa
                         length = xwa_len ).
     CLEAR lt_contents. REFRESH lt_contents.
   ENDIF.
   CONCATENATE 'inline; filename=' lv_filename
     INTO lv_contentdisposition.
   CALL METHOD server->response->set_header_field
     EXPORTING
       name  = 'content-disposition'
       value = lv_contentdisposition.
   CALL METHOD server->response->set_header_field
     EXPORTING
       name  = 'content-type'
       value = lv_contenttype.
   CALL METHOD server->response->set_header_field
     EXPORTING
       name  = 'content-filename'
       value = lv_filename.
  Content Tabelle (Byte Arrays) rausschreiben
   lv_chunksize = 1022.
   LOOP AT lt_contents INTO ls_contents.
     MOVE ls_contents-line TO xwa.
     xwa_len = lv_file_size - ( lv_chunksize * ( sy-tabix - 1 ) ).
     IF xwa_len >= lv_chunksize.
       xwa_len = lv_chunksize.
     ENDIF.
     server->response->append_data( data   = xwa
                         length = xwa_len ).
   ENDLOOP.
  Response beenden
   server->response->delete_header_field(
             name = 'Cache-Control' ).                      "#EC NOTEXT
   server->response->delete_header_field(
             name = 'Expires' ).                            "#EC NOTEXT
Edited by: Micha Van Nijen on May 3, 2011 12:39 PM

Similar Messages

  • Need to print a pdf on button click

    Hi,
    I need to do something similiar to what the code is doing below, except I need to create a button that when clicked will print a pdf. Not sure if it is better(easier) to add the pdf to my library and print that way or just upload the pdf to the server and print that.
    anyway here is the code I have sofar. Not sure exavtly what I need to change/modify.
    package com.wiley.as3bible.printing {
        import flash.display.Sprite;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import flash.events.Event;
        import flash.printing.PrintJob;
        import flash.display.SimpleButton;
        public class Printing extends Sprite {
            private var _printableContent:Sprite;
            private var _textField:TextField;
            private var _loader:URLLoader;
            public function Printing() {
                //Load the text from a text file
                _loader = new URLLoader();
                _loader.load(new URLRequest("http://www.rightactionscript.com/samplefiles/lorem_ipsum.txt"));
                _loader.addEventListener(Event.COMPLETE, completeHandler);
                //Create a multiline text field that autosizes.
                _textField = new TextField();
                _textField.width = 400;
                _textField.multiline = true;
                _textField.wordWrap = true;
                _textField.autoSize = TextFieldAutoSize.LEFT;
                //Create a sprite container for the text field,
                //and add the text field to it.
                _printableContent = new Sprite();
                addChild(_printableContent);
                _printableContent.addChild(_textField);
            //When the text loads add it to the text field and  then print the text
            private function completeHandler(event:Event):void {
                _textField.text = _loader.data;
                var printJob:PrintJob = new PrintJob();
                if (printJob.start()) {
                    printJob.addPage(_printableContent);
                    printJob.send();
    I know the button code should be something like:
    Printbtn.addEventListener(MouseEvent.CLICK,startPrint);
    thanks in advance for any help.

    I see what you are saying. I think I am going about this the wrong way. Really all I need is to upload the pdf to the server, since it is already created, and then in AS3 create a link that will be clickable and will download the pdf, in which case they can just print the download. I know how to do this in HTML, but not AS. Basically, it needs to be the equivalent of <a href="PathtoPDF_File">Click to download file</a>.
    also I have a message window already coded, and within this message window is where I need to add the link:
    package exam {
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        //this class is used to create a "pop-up" window to ask users to confirm they want to exit (after clicking
        //exit exam button), and then to report back on how the submission went, and offer to resend if necessary
        public class MessageWindow extends Sprite {
            //VARIABLES
            private var feedback:TextField;
            private var confirm:YesBtn;
            private var quit:CancelBtn;
            private var resend:ResendBtn;
            public function MessageWindow (type:String, unanswered:Number=0, score:Number=0) {
                var bg:Shape = new Shape();
                bg.graphics.beginFill(0xffffff,1);
                bg.graphics.lineStyle(3,0x6fc9f4);
                bg.graphics.lineTo(400,0);
                bg.graphics.lineTo(400,250);
                bg.graphics.lineTo(0,250);
                bg.graphics.lineTo(0,0);
                bg.graphics.endFill();
                addChild(bg);
                var format:TextFormat = new TextFormat();
                format.font = "Verdana";
                format.size = "22";
                format.bold = false;
                format.color = 0x464646;
                feedback = new TextField();
                feedback.width = 300;
                feedback.x = 50;
                feedback.y = 15;
                feedback.wordWrap = true;
                feedback.autoSize = TextFieldAutoSize.LEFT;
                feedback.mouseEnabled = false;
                if (type == "confirm") {
                    feedback.text = "Are you sure you want to exit the exam?";
                    if (unanswered > 0) {
                        feedback.appendText("  You still have "+unanswered+" unanswered questions.");
                    feedback.setTextFormat(format);
                    addChild(feedback);
                    quit = new CancelBtn();
                    quit.setType("cancel");
                    quit.x = 25;
                    quit.y = this.height - (quit.height + 15);
                    addChild(quit);
                    confirm = new YesBtn();
                    confirm.setType("confirm");
                    confirm.y = quit.y;
                    confirm.x = this.width - (confirm.width + 25);
                    addChild(confirm);
                }else if (type == "success") {
                    feedback.text = "Congrats on finishing the exam!\r\nYour score is "+Math.round(score*100)+"%\r\nYou may now close the exam window.";
                    feedback.setTextFormat(format);
                    addChild(feedback);
                }else {
                    if (type == "databaseError") {
                        feedback.text = "Errors occured while saving your data.  Please retry.";
                    }else if (type == "networkError") {
                        feedback.text = "Could not contact the server.  Please make sure you are connected to the internet and try again.";
                    feedback.setTextFormat(format);
                    addChild(feedback);
                    resend = new ResendBtn();
                    resend.setType("resend");
                    resend.x = 200-(resend.width/2);
                    resend.y = this.height - (resend.height + 15);
                    addChild(resend);
    in the else if(type =="success") part in the feedback.text ="" is where I need the link to go.

  • Submit PDF via Button Click into Email

    event.target.submitForm({cURL:"mailto:[email protected]" + "?subject=" + subjectext + "&body=" + bodytext + "&cc=" + ccemail address ,cSubmitAs:"PDF",cCharset:"utf-8"});
    cURL:"mailto:"
    can also write cURL:"mailto:" + variable   (i.e.= field containing email address)
    "?subject" = not sure what this means. Seems to be some sort of signal the subject is coming next
    subjectext = variable containing text you want for the subject of the email
    "&body" = not sure what this means. Seems to be some sort of signal the body text is coming next.
    subjectext = variable containing text you want for the body of the email i.e. var bodytext = "\n" + "\n" + "Thank you for........"
    "&cc=" not sure what this means. Seems to be some sort of signal the carbon copy email address is coming next.
    ccemail address = variable containing email address you want to send the email to as a cc
    cSubmitAs:"PDF" = option to send as differing formats
    cCharset:"utf-8" = unsure
    From the Book:
    Creating Dynamic Forms with Adobe® LiveCycle® Designer
    For this to work, one of the following must be true:
    Your form fillers must have Acrobat.
    Your form must be Reader extended.
    // put the code in the click event of a regular button var mail; var address = email.rawValue; //email is a text field var sub = subject.rawValue;  mail = "mailto: " + address + "?subject=" + sub; event.target.submitForm({ cURL: mail, bEmpty: true, cSubmitAs: "PDF", cCharset: "utf-8" });
    The submitForm function takes the following four parameters.
    The email address and subject
    A Boolean true to imply that all fields are posted
    The attachment file format (XML, XDP, or PDF)
    The character encoding
    Hope this helps the next person searching for this info.

    Thank you.  I finally got it to work!
    Sarah T. Love
    Grants & Contracts Director
    California Pacific Medical Center Research Institute
    475 Brannan Street, Suite 220
    San Francisco, CA   94107
    415-601-2555 cell phone
    415-600-1702 phone
    415-600-1681 fax
    Website:  http://www.cpmc.org/professionals/research/grants/index.html

  • Download pdf with button click??

    hi again guys,
    i have a pdf in my public_html and a button on my site that links to a PDF but when i click the button it opens the PDF in a browser window,
    is there a way to  save directly to the desktop?
    without opening in a browser window or zipping the file?
    thanks Mr A

    I believe you'll need to use the FileReference class, and its download method.

  • How to print PDF report by clicking a button

    Hi,
    I'm using oracle 10g developer suite. i've developed a form clicking a button calling a PDF report. But i do not want to show PDF report. i want to auto print PDF report by clicking a button.
    Plz help me.

    Just follow the Oracle reports 10g output directly to printer and you will able to print directly
    Hope this helps
    Hamid
    If response is helpful or correct mark it.

  • Download the PDF Form as a attachment when button click in BSP application

    Hi All,
    I have scenario, when button click in the BSP application PDF Form want to download in the IE (like one window open with Open,Save and cancel button).
    I have written this code:
    data: pdf type fpformoutput-pdf.
    < Logic for populate value to pdf field ....
    .>
    response->set_header_field(
                         name  = 'cache-control'
                         value = 'max-age=0' ).
      response->set_header_field(
                         name  = 'content-disposition'
                         value = 'attachment; filename=webforms.pdf' ).
      response->set_data( data   = pdf ).
    Once button is clicked pop up is opened and closed automatically because of browser or adobe reader issue.
    How can I resolve this problem ?
    In the IE i need to change any settings ?
    IE version = 7.0
    Adobe reader = 9.0
    I have tried in the same code with IE = 6.0 and adobe reader 8.1.2 its getting download the pdf form working fine.
    The same think i want in IE 7.0 and adobe reader 9.0, what needs to be done ?
    Regards,
    Boopathi M

    Hello Ravi,
    Best would be to bind the dataSource of the InteractiveForm ui element to the parent node containing the table's data. Then specify a name of a template to be created in the templateSource and hit <enter>. Some popups later, the system will have created a template from the structure of the context. All you need to do now is to drag&drop the data structure inside the template designer to the template itself. This will result in a table. Save, activate and return the Web Dynpro view. Don't forget to unbind the pdfSource and enjoy.
    Best regards,
    Thomas

  • How to open an pdf report On click of some command button in adf

    Hi,
    I have to generate some pdf report or some pdf document on click of some command button .Could any one please tell me how to achieve this.
    suggestion would be appreciated,
    Regards
    Vinay kumar

    So what you're saying is the PDF already exists on your web server, and all you want to do is navigate in the browser from your ADF application to the PDF, yes? If that's correct, let's assume you're PDF exists at:
    http://www.acme.com/someCustomPath/myFantasticReport.pdf
    Consider the <af:goButton> or <af:goLink> controls, which include the destination attribute. As such you'd do something like this:
    <af:goButton destination="http://www.acme.com/someCustomPath/myFantasticReport.pdf"/>As you can see the "go" controls are for navigating to resources not inside your ADF application, while the "command" controls are reserved for navigation among resources in your application.
    In order to generate the destination URL, just replace the destination attribute with an EL expression that retrieves it's value from a backing bean:
    <af:goButton destination="#{myBean.giveMeTheUrl}"/>Regards,
    CM.

  • How to generate barcode on button click event in PDF using adobe livecycle?

    I already created form in PDF file which is validate completely .But , I required generate a barcode of all field of form using custom script on button click event.
    Please give me right way for doing it .
    Thanks in Advance,
    Jaydeep Solanki.

    Hi vijay,
    What project are you doing? Is it Asp.Net project? If so, you'll need to post it in the dedicated ASP.Net Forum
    http://forums.asp.net  for more efficient responses, where you can contact ASP.NET experts.
    Have a nice day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Opening new window on button click from pdf without loosing session

    Hi,
    In my Java web applicaion on click of a link, we are opening a new window in which we are displaying a pdf. There are 5 buttons on this pdf.
    On clicking of this button again we are opening a application link in new window. But in this window we are not gettting our session, which is there in first two window.
    For opening new window from pdf button click we are using
    var dynamicUrl3 = myappurl;
    app.launchURL(dynamicUrl, true); 
    How can i open new window with the same sesion from the pdf button.
    Please help for the same.
    Thanks,
    Abhijit Mohite.

    Yes, with target="_blank" in a link or a form.Thanks for ur valuable suggestion. I changed the button to link.
    Its working fine now without JavaScript.
    Now i got another requirement. When user select some items and press a button in the new popup window, the window must close on button click and the parent window must refresh. This must also be done without using JavaScript.
    Is this possible? Please give me an idea to do this.
    Thanks.

  • Error while saving a smartform in pdf with action profile in service order

    Hi experts,
    I have a problem in saving a smartform which is converted in pdf.
    WHat i m doing is.
    The action profile is configured with new Z class and Z method. CL_DOC_PROCESSING_CRM_ORDER and CRM_SRVORDER_EXEC_SMART_FORM.
    But when i click the button in the Order, i m able to save the pdf in local drive, but an error is coming in the Order page(at the bottom) "Action could not be executed successfully".
    The action has been setup with "Printonly" and "Smartforms print" in customization.
    I have a dount whether, this action Printonly is only to print the smartform ??? Or can we use just to save the smartform in pdf.
    But when i remove the pdf conversion and save dialog and try to print it directly, Its printing the smartform. No errors are coming.
    But guys, please help me on this. I have tried all the tricks i know.
    I just want to save a smartform in pdf with action profile configured.
    Thanks in advance.
    <REMOVED BY MODERATOR>
    KK
    Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:26 PM

    Hi;
    Did you checked
    Queries Error With FRM-92101 In Many NLS Forms [ID 443922.1] << seems similar error like yours
    Forms FRM-92050, FRM-92100, FRM-92101, FRM-92102 Reference Guide [ID 444690.1]
    If its not help please enable trace
    How To Perform System Tracing For All Forms Runtime Processes? [ID 400144.1]
    Regard
    Helios

  • Error in SmartForm to PDF while Saving with Preview option.

    Hi,
    I have created a report to convert Smartform to PDF.
    I want the user to Preview data, if user is interested, then they can save the file.
    When user clicks the Back button in SmartForm Print Preview, user can select the path of PDF file to save the data.
    My code works fine, if Preview is disabled.
    In the sub-routine createpdffile, I am getting error while creating PDF file.
    The program works fine, if I disable the preview option i.e. if I uncomment
    cparam-getotf = 'X'.
    How can I have the both options in my report?
    1)     Preview SmartForm.
    2)     Save the SmartForm as PDF.
    Regards,
    Vikas
    DATA:
      cparam TYPE ssfctrlop,
      outop TYPE ssfcompop,
    *  fm_name TYPE rs38l_fnam,
    *  my_tabix TYPE sy-tabix,
      file_size TYPE i,
      bin_filesize TYPE i,
      s_filename TYPE string.
    DATA:
      tab_otf_data TYPE ssfcrescl,
    *  tab_otf_data TYPE itcoo OCCURS 0 WITH HEADER LINE,
      pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
      tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
      it_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE.
    *  it_docs  TYPE STANDARD TABLE OF docs.
    START-OF-SELECTION.
      PERFORM fetchdata.
    ***************** suppressing the dialog box****************************
      outop-tddest = 'LP01'.
      cparam-no_dialog = 'X'.
      cparam-preview = 'X'.
    *  cparam-getotf = 'X'.
    END-OF-SELECTION.
      PERFORM callsmartform.
      tab_otf_final[] = tab_otf_data-otfdata[].
      PERFORM createpdffile.
      PERFORM getfilename.
      PERFORM savepdffile.
    *&      Form  FetchData
    FORM fetchdata .
      SELECT * FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_ekpo
      WHERE ebeln >  '4500009071' AND ebeln  < '4500009073' .
    ENDFORM.                    " FetchData
    *&      Form  CallSmartForm
    FORM callsmartform .
      CALL FUNCTION '/1BCDWB/SF00000234'
      EXPORTING
      control_parameters         =  cparam
        output_options             = outop
        user_settings              = space
      IMPORTING
        job_output_info            = tab_otf_data
      TABLES
           t_ekpo                     = it_ekpo
    * EXCEPTIONS
      IF sy-subrc <> 0.
        MESSAGE  'Error in Calling Smart Form ' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " CallSmartForm
    *&      Form  CreatePDFFile
    *       text
    FORM createpdffile .
    ****removing the initial and final markers from the OTF data**********
    *  DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
    *  READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
    *  my_tabix = sy-tabix + 1.
    ******** appending the modified OTF table to the final OTF table****
    * INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix
    ************ converting OTF data into pdf data**************************
      CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
      format = 'PDF'
      max_linewidth = 132
      IMPORTING
      bin_filesize = bin_filesize
    * BIN_FILE =
      TABLES
      otf = tab_otf_final
      lines = pdf_tab
      EXCEPTIONS
      OTHERS = 5
      IF sy-subrc <> 0.
        MESSAGE  'Error in Creating PDF File ' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " CreatePDFFile
    *&      Form  SavePDFFile
    FORM savepdffile .
      CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      bin_filesize = bin_filesize
      filename = s_filename
      filetype = 'BIN'
      IMPORTING
      filelength = file_size
      TABLES
      data_tab = pdf_tab
      EXCEPTIONS
      OTHERS = 22
      IF sy-subrc <> 0.
        MESSAGE  'Error in Saving PDF File ' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " SavePDFFile
    *&      Form  GetFileName
    FORM getfilename .
      DATA:
        v_name                  TYPE string,
        v_path                  TYPE string,
        v_fullpath              TYPE string,
        v_filter                TYPE string,
        v_uact                  TYPE i,
        v_guiobj                TYPE REF TO cl_gui_frontend_services.
    *    v_filename              TYPE string.
      CONCATENATE 'smrt' '.pdf' INTO v_name.
      CREATE OBJECT v_guiobj.
      CALL METHOD v_guiobj->file_save_dialog
        EXPORTING
          default_extension = 'pdf'
          default_file_name = v_name
          file_filter       = v_filter
        CHANGING
          filename          = v_name
          path              = v_path
          fullpath          = v_fullpath
          user_action       = v_uact.
      IF v_uact = v_guiobj->action_cancel.
        EXIT.
      ENDIF.
      MOVE v_fullpath TO s_filename.
    ENDFORM.                    " GetFileName

    I think the excerpt and link below is the why, but the page talks about server code and not javascript.  I guessing that this is why blank pages work, but not wiki pages.  Can anyone verify this?
    The following are general rules for using server-side code on a site page.
    If the page is uncustomized, server-side code is supported on the page.
    If the page is customized, server-side code does not run, and the page does not render. This includes the code-behind for the page itself.
    http://msdn.microsoft.com/en-us/library/office/aa979592(v=office.14).aspx

  • Unable to print directly from vf03 txn after converting  smartform into PDF

    Dear All,
    I have converted ond smartform into pdf.now when i am trying to print one document using vf03 transaction whatever button i click(ex-print preview/print) it is asking to save the pdf as local file. but i want to print that document as pdf directly from vf03 without saving it into local file.
    I am giving you the code below:-
    (all modification done by me are in BOLD)
         Print of a invoice by SAPscript SMART FORMS               *
    REPORT zrlb_invoice5.
    declaration of data
    INCLUDE zrlb_invoice_data_declare5.
    *INCLUDE ZRLB_INVOICE_DATA_DECLARE.
    *INCLUDE rlb_invoice_data_declare.
    definition of forms
    INCLUDE zrlb_invoice_form015.
    *INCLUDE ZRLB_INVOICE_FORM01.
    *INCLUDE rlb_invoice_form01.
    INCLUDE zrlb_print_forms5.
    *INCLUDE ZRLB_PRINT_FORMS.
    *INCLUDE rlb_print_forms.
    START-OF-SELECTION.
          FORM ENTRY
    FORM entry USING return_code us_screen.
      DATA: lf_retcode TYPE sy-subrc.
      CLEAR retcode.
      xscreen = us_screen.
      PERFORM processing USING us_screen
                         CHANGING lf_retcode.
      IF lf_retcode NE 0.
        return_code = 1.
      ELSE.
        return_code = 0.
      ENDIF.
    ENDFORM.                    "ENTRY
          FORM PROCESSING                                               *
    FORM processing USING proc_screen
                    CHANGING cf_retcode.
      DATA: lv_medium LIKE tnapr-nacha.
      DATA: lwa_print_data_to_read TYPE lbbil_print_data_to_read.
      DATA: lwa_bil_invoice TYPE lbbil_invoice.
      DATA: lf_fm_name            TYPE rs38l_fnam.
      DATA: lwa_control_param      TYPE ssfctrlop.
      DATA: lwa_composer_param     TYPE ssfcompop.
      DATA: lwa_recipient          TYPE swotobjid.
      DATA: lwa_sender             TYPE swotobjid.
      DATA: lf_formname           TYPE tdsfname.
      DATA: lwa_addr_key           LIKE addr_key.
      DATA: ls_dlv-land           LIKE vbrk-land1.
      DATA:lv_job_output_info      TYPE ssfcrescl,
             lv_document_output_info TYPE ssfcrespd,
             lv_job_output_options   TYPE ssfcresop,
             lv_bin_filesize          TYPE i,
             gt_docs  TYPE STANDARD TABLE OF docs,
             gt_lines TYPE STANDARD TABLE OF tline,
             gt_otf TYPE TABLE OF itcoo, " OTF Structure
             lv_name                  TYPE string VALUE 'INVOICE',
             lv_guiobj                TYPE REF TO cl_gui_frontend_services,
             lv_path                  TYPE string  VALUE 'D:\',
             lv_fullpath              TYPE string VALUE 'D:\INVOICE',
             lv_filter                TYPE string,
             lv_uact                  TYPE i,
             lv_filename              TYPE string,
    ++lv_fm_name               TYPE rs38l_fnam.         +*****************************************
    SmartForm from customizing table TNAPR
      lf_formname = tnapr-sform.
      lv_medium = tnapr-nacha.
    determine print data
      PERFORM set_print_data_to_read USING    lf_formname
                                     CHANGING lwa_print_data_to_read
                                     cf_retcode.
      IF cf_retcode EQ 0.
    select print data
        PERFORM get_data USING    lwa_print_data_to_read
                         CHANGING lwa_addr_key
                                  ls_dlv-land
                                  lwa_bil_invoice
                                  cf_retcode.
      ENDIF.
      IF cf_retcode EQ 0.
        PERFORM set_print_param USING    lwa_addr_key
                                         ls_dlv-land
                                CHANGING lwa_control_param
                                         lwa_composer_param
                                         lwa_recipient
                                         lwa_sender
                                         cf_retcode.
      ENDIF.
      IF cf_retcode EQ 0.
    determine smartform function module for invoice
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
             EXPORTING  formname           = lf_formname
                    variant            = ' '
                    direct_call        = ' '
             IMPORTING  fm_name            = lf_fm_name
             EXCEPTIONS no_form            = 1
                        no_function_module = 2
                        OTHERS             = 3.
        IF sy-subrc NE 0.
      error handling
          cf_retcode = sy-subrc.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
      IF cf_retcode EQ 0.
        PERFORM check_repeat.
        IF lwa_composer_param-tdcopies EQ 0.
          nast_anzal = 1.
        ELSE.
          nast_anzal = lwa_composer_param-tdcopies.
        ENDIF.
        lwa_composer_param-tdcopies = 1.
        DO nast_anzal TIMES.
    In case of repetition only one time archiving
          IF sy-index GT 1 AND nast-tdarmod EQ 3.
            nast_tdarmod = nast-tdarmod.
            nast-tdarmod = 1.
            lwa_composer_param-tdarmod = 1.
          ENDIF.
          IF sy-index NE 1 AND repeat IS INITIAL.
            repeat = 'X'.
          ENDIF.
    call smartform invoice
         CALL FUNCTION lf_fm_name
              EXPORTING
                         archive_index        = toa_dara
                         archive_parameters   = arc_params
                         control_parameters   = ls_control_param
                    mail_appl_obj        =
                         mail_recipient       = ls_recipient
                         mail_sender          = ls_sender
                         output_options       = ls_composer_param
                         user_settings        = space
                         is_bil_invoice       = ls_bil_invoice
                         is_nast              = nast
                         is_repeat            = repeat
         importing  document_output_info =
                    job_output_info      =
                    job_output_options   =
              EXCEPTIONS formatting_error     = 1
                         internal_error       = 2
                         send_error           = 3
                         user_canceled        = 4
                         OTHERS               = 5.
          lwa_control_param-getotf = 'X'.
          lwa_control_param-no_dialog = 'X'.
          lwa_control_param-device = 'PRINTER'.
          CALL FUNCTION lf_fm_name
            EXPORTING
             archive_index              = toa_dara
    Begin of Changes 24/10/2007*
      ARCHIVE_INDEX_TAB          =*
            ARCHIVE_PARAMETERS         = arc_params*
             control_parameters         = lwa_control_param
      MAIL_APPL_OBJ              =*
            MAIL_RECIPIENT             = lwa_recipient*
            MAIL_SENDER                = lwa_sender*
    *End of changes 04/12/2007
             output_options             = lwa_composer_param
             user_settings              = 'X'
              is_bil_invoice             = lwa_bil_invoice
              is_nast                    = nast
              is_repeat                  = repeat
              iv_medium                  = lv_medium
    Begin OF Changes 04/12/2007*
    IMPORTING
       document_output_info       = lv_document_output_info
       job_output_info            = lv_job_output_info
       *job_output_options         = lv_job_output_options     *
    End Of Changes 04/12/2007*
    EXCEPTIONS
       formatting_error           = 1
       internal_error             = 2
       send_error                 = 3
       user_canceled              = 4
       OTHERS                     = 5.
         CALL FUNCTION lf_fm_name
           EXPORTING
            ARCHIVE_INDEX              = toa_dara
      ARCHIVE_INDEX_TAB          =
            ARCHIVE_PARAMETERS         = arc_params
            CONTROL_PARAMETERS         = lWA_control_param
      MAIL_APPL_OBJ              =
            MAIL_RECIPIENT             = lwa_recipient
            MAIL_SENDER                = lwa_sender
            OUTPUT_OPTIONS             = lwa_composer_param
            USER_SETTINGS              = space
             IS_BIL_INVOICE             = LWA_BIL_INVOICE
             IS_NAST                    = nast
             IS_REPEAT                  = repeat
             IV_MEDIUM                  = lv_medium
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
          gt_otf[] = lv_job_output_info-otfdata[].
                  CALL FUNCTION 'CONVERT_OTF'
             EXPORTING
               FORMAT                      = 'PDF'
               MAX_LINEWIDTH               = 132
            ARCHIVE_INDEX               = ' '*
            COPYNUMBER                  = 0*
            ASCII_BIDI_VIS2LOG          = ' '*
             IMPORTING
               BIN_FILESIZE                = lv_bin_filesize
            BIN_FILE                    =*
              TABLES
                otf                         = gt_otf
                lines                       = gt_lines
          EXCEPTIONS*
            ERR_MAX_LINEWIDTH           = 1*
            ERR_FORMAT                  = 2*
            ERR_CONV_NOT_POSSIBLE       = 3*
            ERR_BAD_OTF                 = 4*
            OTHERS                      = 5*
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
            ENDIF.
    *.......................GET THE FILE NAME TO STORE.........
            CONCATENATE 'smrt' '.pdf' INTO lv_name.
          CREATE OBJECT lv_guiobj.
          CALL METHOD lv_guiobj->file_save_dialog
            EXPORTING
              default_extension = 'pdf'
              default_file_name = lv_name
              file_filter       = lv_filter
            CHANGING
              filename          = lv_name
              path              = lv_path
              fullpath          = lv_fullpath.
       user_action       = lv_uact.*
          IF lv_uact = lv_guiobj->action_cancel.
            EXIT.
          ENDIF.*
         MOVE lv_fullpath TO lv_filename.
           CALL METHOD cl_gui_frontend_services=>gui_download
             EXPORTING
              BIN_FILESIZE              =  lv_bin_filesize
               filename                  =  lv_fullpath
               FILETYPE                  = 'BIN'
       APPEND                    = SPACE
       WRITE_FIELD_SEPARATOR     = SPACE
       HEADER                    = '00'
       TRUNC_TRAILING_BLANKS     = SPACE
       WRITE_LF                  = 'X'
       COL_SELECT                = SPACE
       COL_SELECT_MASK           = SPACE
       DAT_MODE                  = SPACE
       CONFIRM_OVERWRITE         = SPACE
       NO_AUTH_CHECK             = SPACE
       CODEPAGE                  = SPACE
       IGNORE_CERR               = ABAP_TRUE
       REPLACEMENT               = '#'
       WRITE_BOM                 = SPACE
       TRUNC_TRAILING_BLANKS_EOL = 'X'
    IMPORTING
       FILELENGTH                =
             changing
               data_tab                  =   gt_lines.
    EXCEPTIONS
       FILE_WRITE_ERROR          = 1
       NO_BATCH                  = 2
       GUI_REFUSE_FILETRANSFER   = 3
       INVALID_TYPE              = 4
       NO_AUTHORITY              = 5
       UNKNOWN_ERROR             = 6
       HEADER_NOT_ALLOWED        = 7
       SEPARATOR_NOT_ALLOWED     = 8
       FILESIZE_NOT_ALLOWED      = 9
       HEADER_TOO_LONG           = 10
       DP_ERROR_CREATE           = 11
       DP_ERROR_SEND             = 12
       DP_ERROR_WRITE            = 13
       UNKNOWN_DP_ERROR          = 14
       ACCESS_DENIED             = 15
       DP_OUT_OF_MEMORY          = 16
       DISK_FULL                 = 17
       DP_TIMEOUT                = 18
       FILE_NOT_FOUND            = 19
       DATAPROVIDER_EXCEPTION    = 20
       CONTROL_FLUSH_ERROR       = 21
       NOT_SUPPORTED_BY_GUI      = 22
       ERROR_NO_GUI              = 23
       others                    = 24
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
            ENDIF.
          Else.
           IF sy-subrc NE 0.*
      error handling
              cf_retcode = sy-subrc.
              PERFORM protocol_update.
    get SmartForm protocoll and store it in the NAST protocoll
              PERFORM add_smfrm_prot.
            ENDIF.
          ENDDO.
          lwa_composer_param-tdcopies = nast_anzal.
          IF NOT nast_tdarmod IS INITIAL.
            nast-tdarmod = nast_tdarmod.
            CLEAR nast_tdarmod.
          ENDIF.
        ENDIF.
    get SmartForm protocoll and store it in the NAST protocoll
    PERFORM ADD_SMFRM_PROT.
      ENDFORM.                    "PROCESSING
    kindly give me a sloution.

    Hi,
    Check for the print mode in the print options and set it as 3- print and archive .
    Regards,
    Ram

  • 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]

  • Smartforms print PDF to a folder

    Hello,
    I call the function:
    CALL function FM_NAME
        exporting
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
       ARCHIVE_PARAMETERS         = space
        CONTROL_PARAMETERS         = I_CTRL
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
        output_options             = i_print
        USER_SETTINGS              = SPACE
          form                     = form
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
      TABLES
          form1                      = form1
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
    to print a smartform, but i want print the smartform in pdf to a folder without appear the screen that i have click in print button or preview button.
    Anyone could help me.
    Thanks and Regards
    Eduardo Paiva

    Check this code
        lS_CONTROL_PARAM-NO_DIALOG   = 'X'.
        lS_CONTROL_PARAM-GETOTF      = 'X'.
          CALL FUNCTION lf_fm_name
               EXPORTING
                   control_parameters   = ls_control_param
                  output_options       = ls_composer_param
                  user_settings        = space
                 is_bil_invoice       = ls_bil_invoice
                   is_nast              = nast
                 is_repeat            = repeat
          importing
                     job_output_info      =  r_ssfcrescl
               EXCEPTIONS formatting_error     = 1
                          internal_error       = 2
                          send_error           = 3
                          user_canceled        = 4
                          OTHERS               = 5.
          IF sy-subrc <> 0.
      error handling
            cf_retcode = sy-subrc.
            PERFORM protocol_update.
    get SmartForm protocoll and store it in the NAST protocoll
            PERFORM add_smfrm_prot.
          ELSE.
            i_otfdata = r_ssfcrescl-otfdata.
            CALL FUNCTION 'CONVERT_OTF_2_PDF'
            EXPORTING
              USE_OTF_MC_CMD               = 'X'
              ARCHIVE_INDEX                =
             IMPORTING
               BIN_FILESIZE                 =  v_filesize
              TABLES
                otf                          = i_otfdata
                doctab_archive               = i_doc_archive
                lines                        = i_lines
            EXCEPTIONS
              ERR_CONV_NOT_POSSIBLE        = 1
              ERR_OTF_MC_NOENDMARKER       = 2
              OTHERS                       = 3
            IF sy-subrc <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
           DATA:
            w_string type string.
           LOOP AT i_lines.
             translate i_lines USING ' ~'.
             concatenate w_string i_lines INTO w_string.
           ENDLOOP.
            translate w_striNg USING '~ '.
            v_filename = 'C:\INVOICE.PDF'.
            CALL FUNCTION 'GUI_DOWNLOAD'
              EXPORTING
               BIN_FILESIZE                    =  v_filesize
                filename                        = v_filename
                FILETYPE                        = 'BIN'
              APPEND                          = ' '
              WRITE_FIELD_SEPARATOR           = ' '
              HEADER                          = '00'
              TRUNC_TRAILING_BLANKS           = ' '
              WRITE_LF                        = 'X'
              COL_SELECT                      = ' '
              COL_SELECT_MASK                 = ' '
              DAT_MODE                        = ' '
              CONFIRM_OVERWRITE               = ' '
              NO_AUTH_CHECK                   = ' '
              CODEPAGE                        = ' '
              IGNORE_CERR                     = ABAP_TRUE
              REPLACEMENT                     = '#'
              WRITE_BOM                       = ' '
              TRUNC_TRAILING_BLANKS_EOL       = 'X'
              WK1_N_FORMAT                    = ' '
              WK1_N_SIZE                      = ' '
              WK1_T_FORMAT                    = ' '
              WK1_T_SIZE                      = ' '
            IMPORTING
              FILELENGTH                      =
              tables
                data_tab                        = i_lines
              FIELDNAMES                      =
             EXCEPTIONS
               FILE_WRITE_ERROR                = 1
               NO_BATCH                        = 2
               GUI_REFUSE_FILETRANSFER         = 3
               INVALID_TYPE                    = 4
               NO_AUTHORITY                    = 5
               UNKNOWN_ERROR                   = 6
               HEADER_NOT_ALLOWED              = 7
               SEPARATOR_NOT_ALLOWED           = 8
               FILESIZE_NOT_ALLOWED            = 9
               HEADER_TOO_LONG                 = 10
               DP_ERROR_CREATE                 = 11
               DP_ERROR_SEND                   = 12
               DP_ERROR_WRITE                  = 13
               UNKNOWN_DP_ERROR                = 14
               ACCESS_DENIED                   = 15
               DP_OUT_OF_MEMORY                = 16
               DISK_FULL                       = 17
               DP_TIMEOUT                      = 18
               FILE_NOT_FOUND                  = 19
               DATAPROVIDER_EXCEPTION          = 20
               CONTROL_FLUSH_ERROR             = 21
               OTHERS                          = 22
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
          ENDIF.

  • Open PDF report on clicking a URL link

    Hello,
    I have a requirement to open a PDF report when clicking on a URL.
    Example : Open a Purchase Order PDF report when clicked on a URL from a different web based system (non APEX). I was able to open APEX pages from the web pages but i am not sure how to open a PDF report. I will have to pass PO number in the URL.
    I would really appreciate it If anyone can give me some direction. I have created PDF reports within APEX and called from within other Pages in APEX but not outside of APEX.

    Sorry I really didn't mean to be stupid ;)
    below is my requirement. We use oracle ebs and we use forms version. Our requirement is to open various PDF reports by clicking a buttons/menu in different forms with in Oracle apps forms. We have APEX developer who can create PDF reports in APEX easily but the technology on ebs side is complex to develop simple PDF in the way users want. So we were thinking if we create a PDF report in APEX..and call the apex report from ebs. Is this possible? Inow we can call other APEX web pages from EBS.

Maybe you are looking for