Download spool to PDF document on application server

Hi,
I am using function CONVERT_OTFSPOOLJOB_2_PDF to convert a sapscript spool and then downloading the internal table provided to a pdf file on the application server. The sapscript form contains company logos.
After transferring the file from the application server to PC and then opening the pdf document I get the following message:
"There was an error while trying to parse an image."
The PDF doc contains everything except the company logo.
I noticed that this works (i.e. company logo is present in the downloaded file) when I transfer the internal table that contains the PDF contents onto my PC using GUI_DOWNLOAD using mode 'BIN'. However, when I transfer the contents of the same internal
table to a file on the application server using abap statement:
'Open Dataset <filename> FOR OUTPUT IN BINARY MODE'
I get the problem described above.
I noticed that SAP has provided standard program RSTXPDFT4 to convert a spool and download it into a PC file. However is there a similar program that downloads a spool onto the application server? Perhaps there is a 'special' way in downloading PDF documents onto the application server?
I don't this problem with sapscripts that do not have a company logo.
Is there a certain restriction on 'Open Dataset'with transfering logos in PDF documents?
Any help would be greatly appreciated in the form of reward points.
Thanks
Liam

Hi,
We convert some of our spools to pdf and store them on the app server using following high level process.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
       EXPORTING
            src_spoolid = p_spool
            no_dialog   = 'X'
            dst_device  = 'LOCL'
       TABLES
            pdf         = lt_pdf
       EXCEPTIONS
            OTHERS      = 0.
Write PDF file
  CALL FUNCTION 'GUID_CREATE'
       IMPORTING
            ev_guid_32 = l_guid.
  CONCATENATE '/your_path_goes_here/'
              l_guid
              INTO l_filename.
  CONCATENATE l_filename '.pdf' INTO l_filename.
Store
  OPEN DATASET l_filename IN TEXT MODE.
  IF NOT sy-subrc IS INITIAL.   " only write pdf if new
    LOOP AT lt_pdf.
      TRANSFER lt_pdf TO l_filename.
    ENDLOOP.
  ENDIF.
  CLOSE DATASET l_filename.
If it doesn't work, I would 1st try and play with image type. I'm wondering if it's tripping on image conversion. Perhaps revert to 1st principles and try monochrome bitmap and a few variations thereof. I stand by my code above. Definitely works. HTH, Dave

Similar Messages

  • Spool to PDF stored in application server

    Hi Experts,
    Please, please.....I need help.......
    I have a problem with converting spool to PDF. If I download the spool to presentation, the output is fine, BUT when I download it to application server and try to view it in al11, a set of characters comes out and if I try to save it on my local drive from the application server, an error message pops out stating that it could not read the file because it is either not a supported file type or because the file has been damaged. Please help me. I've tried doing everything I can already. I cannot run the convertion of spool file to presentation because it always ends up as run time error, that's why I have no choice but to run it in background. These files will only be viewed by different offices. This files will NOT be sent via email.  Please, please.......help......I'm really, really desperate......Here's what I did with the program....Please tell me where I went wrong.....Help......I've been on it for days and this is really causing a major headache........
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    PARAMETERS: p_file TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
    DATA: gd_buffer TYPE STRING OCCURS 0 WITH HEADER LINE.
    lt_conv LIKE gd_buffer OCCURS 0 WITH HEADER LINE.
    DATA lv_string TYPE string.
    LOOP AT it_pdf_output.
    TRANSLATE it_pdf_output USING '~'.
    CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
    ENDLOOP.
    TRANSLATE gd_buffer USING '~'.
    APPEND gd_buffer.
    DO.
    counter = strlen( gd_buffer ).
    IF counter GE 255.
    lt_conv = gd_buffer(255).
    APPEND lt_conv.
    SHIFT gd_buffer LEFT BY 255 PLACES.
    ELSE.
    lt_conv = gd_buffer(counter).
    APPEND lt_conv.
    EXIT.
    ENDIF.
    ENDDO.
    IF lt_conv[] IS NOT INITIAL.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc EQ 0.
    IF sy-subrc 0.
    MESSAGE e398(00) WITH 'Error creating file' p_file.
    ENDIF.
    LOOP AT lt_conv INTO lv_string.
    TRANSFER lv_string TO p_file.
    ENDLOOP.
    CLOSE DATASET p_file.
    IF sy-subrc EQ 0.
    ELSE.
    MESSAGE e398(00) WITH 'Error closing file' p_file.
    ENDIF.
    ELSE.
    MESSAGE e398(00) WITH 'Error creating file' p_file.
    ENDIF.
    ENDIF.

    Hi,
    maybe a look at Function Module 'CONVERT_ABAPSPOOLJOB_2_PDF' could solve your problem.
    Regards
    Mark-André

  • Spool to PDF output in application server

    Hi Experts,
               I have a problem with converting spool to PDF.  If I download the spool to presentation, the outputs is fine, BUT when I download it to application server and try to view it in al11, a set of characters comes out and if I try to save it on my local drive, an error message pops out stating that it could not read the file because it is either not a supported file type or because the file has been damaged.  Please help me.  I've tried doing everything I can already.  I cannot run the convertion of spool file to presentation because it always ends up as run time error, that's why I have no choice but to run it in background.  These files needs to be distributed to all branch offices.  Please, please.......help......I'm desperate......

    Hi Nikhil,
            I'm sorry....but I'm still stucked.  If I try to view the pdf output in AL11 this characters are still displayed "&#9552;&#17478;&#11569;&#11827;&#3338;&#9698;&#58319;&#54029;&#2610;‰&#8303;&#25194;&#3338;&#12119;&#26990;&#16750;&#29545;&#17774;&#25455;&#25705;&#28263;&#3338;&#25966;&#25711;&#25194;&#3338;&#13088;&#12320;&#28514;&#27149;&#2620;&#15373;&#2597;&#17509;&#30324;&#31088;&#25888;&#20559;&#21332;&#12832;†&#8262;&#28526;&#29728;&#17231;&#21842;&#18757;&#21024;&#8302;&#28530;&#28001;&#27680;&#19553;&#28263;&#8261;&#19981;&#2607;&#21625;&#28773;&#8239;&#18031;&#28276;&#3338;&#12115;&#30050;&#29817;&#28773;&#8239;&#21625;&#28773;&#12557;&#2607;&#16993;&#29541;&#18031;&#28276;&#8239;&#17263;&#30066;&#26981;&#29197;&#2607;&#20065;&#28005;&#8239;&#17968;", and when the basis transferred it to the local folder the same error came out that the file could not be read either it is corrupted or file type is not supported.  Please.....I've been on it for hours and can't seem to get the problem.  Here's what I did with the program....Please tell me where I went wrong.....Help......
    PARAMETERS: p_file TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
    DATA: gd_buffer TYPE STRING OCCURS 0 WITH HEADER LINE.
               lt_conv   LIKE gd_buffer OCCURS 0 WITH HEADER LINE.
    DATA lv_string TYPE string.
            LOOP AT it_pdf_output.
              TRANSLATE it_pdf_output USING '~'.
              CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
            ENDLOOP.
            TRANSLATE gd_buffer USING '~'.
            APPEND gd_buffer.
            DO.
              counter = strlen( gd_buffer ).
              IF counter GE 255.
                lt_conv = gd_buffer(255).
                APPEND lt_conv.
                SHIFT gd_buffer LEFT BY 255 PLACES.
              ELSE.
                lt_conv = gd_buffer(counter).
                APPEND lt_conv.
                EXIT.
              ENDIF.
            ENDDO.
            IF lt_conv[] IS NOT INITIAL.
              OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
              IF sy-subrc EQ 0.
                IF sy-subrc <> 0.
                  MESSAGE e398(00) WITH 'Error creating file' p_file.
                ENDIF.
                LOOP AT lt_conv INTO lv_string.
                  TRANSFER lv_string TO p_file.
                ENDLOOP.
                CLOSE DATASET p_file.
                IF sy-subrc EQ 0.
                ELSE.
                  MESSAGE e398(00) WITH 'Error closing file' p_file.
                ENDIF.
              ELSE.
                MESSAGE e398(00) WITH 'Error creating file' p_file.
              ENDIF.
            ENDIF.

  • Issue with Uploading OTF converted PDF file on application server...

    Hello Gurus,
    I want to download otf converted pdf data on application server. I am using following but it does not work ?
    data: i_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
            wa_pdf_tab like tline,
    CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          FORMAT                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          BIN_FILESIZE          = w_bin_filesize
        TABLES
          OTF                   = I_OTFDATA
          LINES                 = i_pdf_tab
        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.
      concatenate './' 'ARCH_' SY-DATUM '_' SY-UZEIT INTO FILENAME.
      OPEN DATASET FILENAME FOR output in text mode encoding default.
      loop at i_pdf_tab INTO wa_pdf_tab.
        TRANSFER wa_pdf_tab TO FILENAME .
      ENDLOOP.
    CLOSE DATASET FILENAME.
    After this I am using CG3Y to downlaod the file created on application server to front end with "Transfer format data" as BIN.
    But it dos not work. 
    Please hlep.
    Regards,
    Rajesh.

    Instead of CG3Y use this code.
    DATA : p_sour TYPE string VALUE '\\usr\sap\trans\tmp\test.pdf',
           p_dest TYPE string VALUE 'c:\test.pdf'.
    CALL METHOD cl_gui_frontend_services=>file_copy
      EXPORTING
        SOURCE               = p_sour
        destination          = p_dest
        overwrite            = SPACE

  • Read PDF Formatted Spool and write PDF File to Application Server

    Hi Experts,
    After ECC 6.0, HR-W2 and W2C Form Spools are getting generated in PDF format.
    We have a requirement wherein we want to read the PDF Spool Programatically and write the PDF file to Application server (Using OPEN DATASET and CLOSE DATASET)
    PARAMETERS : p_spono LIKE tsp01-rqident.
    DATA: pdf_data type FPCONTENT.
    types: lt_pdf_table(1000) type x.
    data:  l_pdf_data type standard table of lt_pdf_table,
           l_pdf_line type lt_pdf_table,
           l_offset type i,
           l_len type i,
           p_file(100) VALUE '\sapout\DVH\pdf2.pdf'.
    *Read the spool content
    CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
        EXPORTING
             i_spoolid = p_spono
             i_partnum = '1'
        IMPORTING
               e_pdf = pdf_data
    *         e_pdf_file = file
        EXCEPTIONS
             ads_error = 1
             usage_error = 2
             system_error = 3
             internal_error = 4
        OTHERS = 5.
    * Modify the spool  contents to prepare internal table
      l_len = xstrlen( pdf_data ).
      while l_len >= 1000.
        l_pdf_line = pdf_data+l_offset(1000).
        append l_pdf_line to l_pdf_data.
        add 1000 to l_offset.
        subtract 1000 from l_len.
      endwhile.
      if l_len > 0.
        l_pdf_line = pdf_data+l_offset(l_len).
        append l_pdf_line to l_pdf_data.
      endif.
    * GUI DOWNLOAD Works Fine
    * Now pdf contents is ready , lets store in local PC
    *CALL FUNCTION 'GUI_DOWNLOAD'
    *  EXPORTING
    *   filename                        = 'C:\Documents and Settings\Desktop\shital.pdf'
    *   filetype                        = 'BIN'
    *  TABLES
    *    data_tab                        = l_pdf_data.
    OPEN DATASET p_file FOR OUTPUT IN BINARY MODE.
    IF sy-subrc <> 0.
      MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
              ' Error opening file:'(Z03) p_file.
    ENDIF.
    LOOP AT l_pdf_data INTO l_pdf_line.
      TRANSFER l_pdf_line TO p_file.
    ENDLOOP.
    CLOSE DATASET p_file.
    IF sy-subrc <> 0.
      MESSAGE ID '00' TYPE 'E' NUMBER '398' WITH 'sy-subrc:' sy-subrc
              ' Error closing file:'(Z04) p_file.
    ENDIF.
    Currently as you can see I have commented out GUI_DOWNLOAD Function Module, But it works perfect when I try to Download file to Local Desktop.
    But when I try to pass the same Contents to Application server file and then try to open it by downloading file then it opens BLANK pdf file.
    As per requirements I should be able to write the file correctly on Application server and If I dowload it from there it should open PDF file correctly.
    Let me know if you require further details about the issue.
    Regards
    Shital
    Edited by: shital phadake on Apr 8, 2009 9:39 PM

    Thanks Selçuk for your reply and taking time for understanding the Issue,
    I went thru Functionality of the program you suggested but dont think it matches my requirement.
    Regards
    Shital

  • Write PDF file into application server.

    Hi Gurus,
    I have created a smartform and converted into PDF using function module as given below. Now I want to write this generated PDF file into application server. I am not generating any spool request too. How can I proceed from here?  Pls advice..
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
        IMPORTING
          bin_filesize                 = lv_bin_filesize
        TABLES
          otf                              = ls_job_output_info-otfdata
          doctab_archive         = lt_docs
          lines                           = lt_lines
        EXCEPTIONS
          err_conv_not_possible  = 1
          err_otf_mc_noendmarker = 2
          OTHERS                 = 3.
    Thanks..
    Saj

    transfer all the data from ur itabs to one final itab declared as follow
    DATA: BEGIN OF final_itab OCCURS 0,
                     document  TYPE string,
               END OF final_itab.
    then finally,
    OPEN DATASET 'yourfile.pdf' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      len = strlen( final_itab-DOCUMENT ).
      TRANSFER final_itab-DOCUMENT  TO 'yourfile.pdf'  LENGTH len.
    CLOSE DATASET 'yourfile.pdf'.
    This ends the coding mate.
    Enjoy it n have a good day.
    Cheers

  • PDF write to application server

    Hi All,
    I want to write PDF string to application server its writing but in this manner
    %PDF-1.6#%####
    108 0 obj#<</First 17/Length 108/Filter/FlateDecode/N 3/Type/ObjStm>>stream
    xڲT0P04Q07W05#2,#ll##K#J*#R#C####Sbq#[^##GjNYjIfr##SN##kr~Jf#~xf#c^q&##Ҧ##agG#a####X###T##XR### ##b#
    Please let me know where i am doing wrong.
    Please see below my code .
    (the scenario is when i download the pdf file i want to write the same file in to app server, there user changes the data and he will do upload )
      call function fm_name
        exporting
          /1bcdwb/docparams  = fp_docparams "
          ls_header          = ls_waste
          lt_item            = gt_rkpf
          aufnr              = lv_aufnr
        importing
          /1bcdwb/formoutput = fp_formoutput
        exceptions
          usage_error        = 1
          system_error       = 2
          internal_error     = 3
          others             = 4.
    concatenate 'D:\temp\PROCESSORDER_' ls_waste-rsnum   '.PDF' into lv_file.
        pr_file = lv_file.
      open dataset pr_file for output in binary mode."text mode encoding  NON-UNICODE.
      if sy-subrc <> 0.
        exit.
      endif.
      transfer fp_formoutput-pdf  to pr_file.
      close dataset pr_file.
      clear :fp_formoutput-pdf,lv_file.
    Please any one help me thanks,
    Thanks,
    Kumar

    You can't tranfer the whole PDF data with just one transfer statement, instead you have to loop that table and transfer the data to the file until you reach the last row.
      open dataset pr_file for output in binary mode."text mode encoding  NON-UNICODE.
      if sy-subrc  0.
        exit.
      endif.
      loop at fp_formoutput-pdf  *****************
        transfer fp_formoutput-pdf  to pr_file.
      endloop.
      close dataset pr_file.
      clear :fp_formoutput-pdf,lv_file.

  • Retrieving PDF form from Application server

    hi all,
    i am saving a pdf form in application server and when the user wants the same file then i want to retrive that file from application and show the user and it should not be saved to presentation server only he should see it.
    iam able to save it to presentation layer using gui_download but my requirement is not to save it show only display the form.
    Thanks in advance,
    Sree
    helpful answers will be surely rewarded points

    Hi,
    1st solution - use DOI (desktop office integration). This way you can open Adobe, Microsoft, and others application documents directly in the SAP windows. See SAP document how to do it. It's not a little work, but it should fulfill your requirements.
    2nd solution - share the folder with the PDF documents and then with shell command (start
    server\folder\xxxxxx.pdf) at the front end access it and start the associated application at the frontend. I don't recommend this one, sharing folders at the appl.server is a security threat...
    You know about the points and useful answers...

  • Saving PDF file into application server

    Dear all,
    My requirement is retrieving a PDF file from application server and modifying the document and saving it back to the application server through BSP application.
    I've retrieved the data from the application server and displayed it in the frame of BSP layout and modified the same (adding signature). We got stuck in saving back the signed document into the application server.
    Can anyone guide me in saving back the modified document or how to get the modified file content through BSP.
    Regards
    Srini

    Hi Friend,
    Hope these  links will help you ,
    File Upload in BSP Applications and store in Application server
    Re: How to Upload .TXT, BITMAP, .PDF files into a Data base Table.
    Re: sapscript - pdf
    With Regards,
    SHARMILA BRINDHA.M

  • Cannot download an Apple pdf document.

    I have been trying to download an Apple pdf document (about HDV capture) but my screen goes dead when I try. I used another computer and tried there and got a page that my "server" does not have permission. What's going on? How do I get "permission." And I don't have a server, I have only stand-alone computers.
    Barry

    http://manuals.info.apple.com/en/DVDStudio_Pro_4.0_lbnz.pdf
    Well, that's the link, only I just now tried it again and this time it downloaded the document. So the problem is solved but I don't know why it was there in the first place. Thanks for the response.
    Barry

  • Move pdf file into application server

    Hi ABAP Gurus,
    i want your valuable help in solving my problem.
       i tried to create PDF file in application server and its creating as
    PDF file in Application server..but i am unable to see the content in text ,
    instead it is displaying in binary content...but when i tried to create
    in presentation server i am able to see it as text in PDF file....
    Can u please let me know whats wrong in my work and how to create a PDF file
    in Application server with text content
    with regards,
    Gowri.

    Hi Gowri,
    Check this example....
    report ztest.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '/usr/sap/xfr/FIS/testpdf',
    length like sy-tabix,
    lengthn like sy-tabix.
    call function 'GUI_UPLOAD'
    exporting
    filename = 'c:\temp\test.pdf'
    filetype = 'BIN'
    importing
    filelength = length
    tables
    data_tab = itab.
    open dataset dsn for output in binary mode.
    loop at itab.
    transfer itab-field to dsn.
    endloop.
    close dataset dsn.
    clear itab.
    refresh itab.
    *- To crosscheck if it went well
    open dataset dsn for input in binary mode.
    do.
    read dataset dsn into itab-field.
    if sy-subrc = 0.
    append itab.
    else.
    exit.
    endif.
    enddo.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = 'c:\temp\testn.pdf'
    filetype = 'BIN'
    bin_filesize = length
    importing
    filelength = lengthn
    tables
    data_tab = itab.
    Or
    Use the TCode
    CG3Z or CG3Y
    for downloading to Application Server.
    Thanks,
    Reward If helpful.

  • Download all files from a specific application server directory to Local pc

    Hi Experts,
    I have a requirement of downloading all the files from an application server directory to a local pc.
    I know how to download a single file from an application server at a time provided the file name is known.
    But my requirement is to download all the files in that particulary directory, because I dont know how many files were created in that directory and what are their names.
    Please kindly provide the solution.
    Thanks,
    Kalikonda.

    Nelson,
    Here is the function module that I have used to get all the application server files.
    appl_dir_name is the path of the directory  i.e. '/outbound/PD1/Applnserverfiles/'
    it_appl_srv_fls is the internal table where all the files gets stored in.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       EXPORTING
         dir_name                     = appl_dir_name
      FILE_MASK                    = ' '
    IMPORTING
      DIR_NAME                     =
      FILE_COUNTER                 =
      ERROR_COUNTER                =
       TABLES
         dir_list                     = it_appl_srv_fls
    EXCEPTIONS
      invalid_eps_subdir           = 1
      sapgparam_failed             = 2
      build_directory_failed       = 3
      no_authorization             = 4
      read_directory_failed        = 5
      too_many_read_errors         = 6
      empty_directory_list         = 7
      OTHERS                       = 8
      IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    hope this solves your problem.
    Thanks,
    kalikonda.

  • Downloading and Opening pdf documents

    I cannot either download or open pdf documents.
    I am receiving this error message: instruction at 0x6c61e referenced memory at oxoooooooo.  the memory could not be read.
    This is causing google.com to not respond.

    Hi Jerseyjoe1933,
    This seems to be an error with the OS.
    Please refer : http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/the-instruction-at- 0x01764b69-referenced-memory-at/e2df405a-a3e5-4bfc-8721-5aa7929cc5c7
    When was the las time it worked fine.
    What is the Acrobat / Reader version you are using and on which OS?

  • Download PDF file from Application Server in BSP

    Hello,
    We have a requirement on which we want to download a PDF file stored in Application server using BSP application. I have used function module  ARCHIVFILE_SERVER_TO_CLIENT but this FM will help only if i want to download file from GUI it won't work in BSP application.
    Further i have used class CL_BSP_UTILITY and download method to download file from application server but it is not working in desired manner.
    I am attaching my code for your reference:
    DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON ,
               EVENT TYPE REF TO IF_HTMLB_DATA.
    DATA: LS_HOURS LIKE LINE OF GT_HOURS.
    DATA STR TYPE STRING.
    DATA: OUTPUT TYPE STRING ,
              L_XSTRING TYPE XSTRING ,
               APP_TYPE TYPE STRING. 
    EVENT = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
    DATA PHY_NAME_OUT     TYPE SAPB-SAPPFAD.
    IF EVENT IS NOT INITIAL AND EVENT->EVENT_NAME = HTMLB_EVENTS=>BUTTON .
      BUTTON_EVENT ?= EVENT .
      CASE EVENT->EVENT_SERVER_NAME.
        WHEN 'test' .
          IF GT_HOURS IS NOT INITIAL.
            PHY_NAME_OUT = '/usr/sap/put/form16//01000200_2007.PDF'.
          OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING DEFAULT.
            IF SY-SUBRC IS INITIAL.
              DO.
                READ DATASET PHY_NAME_OUT INTO STR.
                IF SY-SUBRC IS INITIAL.
                CONCATENATE
                    OUTPUT
                    str
                    cl_abap_char_utilities=>cr_lf
    INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
                ELSE.
                  EXIT.
                ENDIF.
              ENDDO.
            ENDIF.
    *LOOP AT gt_hours INTO ls_hours.
    *CONCATENATE
    *OUTPUT
    *ls_hours-hour
    *cl_abap_char_utilities=>cr_lf
    *INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
    *ENDLOOP.
            APP_TYPE = 'APPLICATION/PDF;charset=utf-16le'.
            CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
              EXPORTING
                TEXT     = OUTPUT
                MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
              IMPORTING
                BUFFER   = L_XSTRING.
            CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
            L_XSTRING
            INTO L_XSTRING IN BYTE MODE.
            CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
            EXPORTING
            OBJECT_S = L_XSTRING
            CONTENT_TYPE = APP_TYPE
            CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
            RESPONSE = _M_RESPONSE
            NAVIGATION = NAVIGATION.
          ENDIF.
      ENDCASE.
    ENDIF.
    From this code i am able to download PDF file but it is not opening in local machine.
    If any other way to download file then please suggest.
    waiting for ur reply.
    Regards,
    Gagan

    Hi,
    you do the file reading wrong:
    have a look at:
    Local declarations.
      data:
        components          type stringtab,
        component           type string,
        path                type text255,
        file                type text255,
        line_length         type i,
       filecontent_binary type sdokcntbin,
        rows                type sytabix,
        content             type sdokcntbin,
        exception           type ref to cx_sy_file_access_error,
        exception_tmf       type ref to cx_sy_too_many_files ,
        block_size          type i value 1022,
        length              type i.
      field-symbols:
        <hex_container>     type x.
      constants:
        c_dms_blk_size      type i value 2550.
      clear file_size.
      try.
          open dataset file_name  for input in binary mode message message.
        catch cx_sy_file_open  into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when '41825AD355C3005E000000000A1551B1'. raise open_error.
            when '47E8B03AECE5BA07E10000000A114829'. raise already_open.
            when others.
          endcase.
        catch cx_sy_file_authority into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when 'A70BB8396F051547E10000000A11447B'. raise authority_error.
            when others.
          endcase.
        catch cx_sy_too_many_files into exception_tmf.
          case exception_tmf->textid.
            when '8708B73915F6B645E10000000A11447B'. raise too_many_files.
            when others.
          endcase.
      endtry.
      do.
        try.
            read dataset file_name into filecontent_binary-line.
            if sy-subrc <> 0.
              add  line_length to file_size.
              append filecontent_binary to file_content_binary.
              exit.
            else.
              add  line_length to file_size.
              append filecontent_binary to file_content_binary.
            endif.
          catch cx_sy_file_open_mode into exception.
            case exception->textid.
              when '9207B73915F6B645E10000000A11447B'. raise cx_sy_file_open_mode.
              when '9807B73915F6B645E10000000A11447B'. raise read_only.
              when '9E07B73915F6B645E10000000A11447B'. raise not_open.
              when '409D273A2D824360E10000000A11447B'. raise incompatible_mode.
              when others.
            endcase.
        endtry.
      enddo.
      try.
          close dataset file_name.
        catch cx_sy_file_close into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when 'C10BB8396F051547E10000000A11447B'. raise close_error.
            when others.
          endcase.
        catch cx_sy_file_access_error into exception.
          case exception->textid.
            when '4182174D03030063000000000A1551B1'. raise access_error.
            when others.
          endcase.
      endtry.
    Get file size.
      split file_name at '/' into table components.
      describe table components lines sy-tfill.
      read table components into component index sy-tfill.
      path = file_name.
      replace component in path with ''.
      file = component.
      call function '/EUH/MMS_GET_FILE_SIZE'
        exporting
          dir_name  = path
          file_name = file
        importing
          file_size = file_size.
    and function /euh/mms_get_file_size.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(DIR_NAME) TYPE  TEXT255
    *"     VALUE(FILE_NAME) TYPE  TEXT255
    *"  EXPORTING
    *"     VALUE(FILE_SIZE) TYPE  SDOK_FSIZE
    *"  EXCEPTIONS
    *"      NO_AUTHORITY
    *"      ACTIVITY_UNKNOWN
    *"      NOT_A_DIRECTORY
    *"      NO_MEDIA_IN_DRIVE
    *"      TOO_MANY_ERRORS
    *"      TOO_MANY_FILES
    *"      BRACKET_ERROR_IN_FILENAME
    *"      NO_SUCH_PARAMETER
      types: begin of files,
               line like ocs_file,
             end of files.
      data: file type files,
         f_subrc like sy-subrc value 0,
         errno(3)    type c,
         errmsg(40)  type c,
         pos                        type i,
         len                        type i,
         parameter(120)             type c,
         help1(120)                 type c,
         help2(120)                 type c,
         error_counter              type i.
      data:
        dir_list  like  ocs_file occurs 0 with header line.
    CASE sy-subrc.
       WHEN 1. f_subrc = 64.
       WHEN 2. f_subrc = 65.
       WHEN 0.
      search dir_name for 'SY-HOST'.    "Is SY-HOST used in directory name?
      if sy-subrc = 0.
        pos = sy-fdpos + 7.
        move dir_name(sy-fdpos) to help1.
        move dir_name+pos to help2.
        concatenate help1 sy-host help2 into dir_name.
      endif.
      do 12 times.                                 " To avoid endless loop
        if dir_name cs '$('.           " Replace parameter by their value
          pos = sy-fdpos + 2.
          if dir_name cs ')'.
            len = sy-fdpos - pos.
            if len le 0.
              f_subrc = 4. exit.
            else.
              parameter = dir_name+pos(len).
              call 'C_SAPGPARAM' id 'NAME'  field parameter
                               id 'VALUE' field parameter.
              if sy-subrc = 0.
                len = pos + len + 1.
                pos = pos - 2.
                if pos > 0.
                  move dir_name(pos) to help1.
                else.
                  help1 = ''.
                endif.
                pos = strlen( dir_name ).
                if pos > len.
                  move dir_name+len to help2.
                else.
                  help2 = ''.
                endif.
                concatenate help1 parameter help2 into dir_name.
              else.
                f_subrc = 8. exit.
              endif.
            endif.
          else.
            exit.
          endif.
        else.
          exit.
        endif.
      enddo.
      shift dir_name right deleting trailing '/\ '.
      shift dir_name left deleting leading space.
      call 'C_DIR_READ_FINISH'                      " this is from RSWATCH0
            id 'ERRNO'  field errno
            id 'ERRMSG' field errmsg.
      call 'C_DIR_READ_START'
            id 'DIR'    field dir_name
            id 'FILE'   field file_name
            id 'ERRNO'  field errno
            id 'ERRMSG' field errmsg.
      case sy-subrc.
        when 1.
          case errno.
            when 2 or 20.  f_subrc = f_subrc + 66.
            when ' '. f_subrc = f_subrc + 67.
          endcase.
        when 0.
          clear error_counter.
          do.
            clear file.
            clear dir_list.
            call 'C_DIR_READ_NEXT'
                id 'TYPE'   field file-line-type
                id 'NAME'   field file-line-name
                id 'LEN'    field file-line-len
                id 'OWNER'  field file-line-owner
                id 'MTIME'  field file-line-mtime
                id 'MODE'   field file-line-acc_mode
                id 'ERRNO'  field errno
                id 'ERRMSG' field errmsg.   "sy-subrc = 3 is e.g. if return
            if sy-subrc = 0 or sy-subrc = 3."data do not fit into variables
              perform p6_to_date_time_tz(rstr0400) using
                    file-line-mtime
                    file-line-mod_time
                    file-line-mod_date.
              file_size = file-line-len.
              dir_list = file-line.
              append dir_list.
            elseif sy-subrc = 1.                 " nothing (more) found
              exit.
            else.
              if error_counter > 50.
                call 'C_DIR_READ_FINISH'
                    id 'ERRNO'  field errno
                    id 'ERRMSG' field errmsg.
                pos =  f_subrc mod 2.
                if pos = 0. f_subrc = f_subrc + 1. endif.
                exit.
              endif.
              add 1 to error_counter.
            endif.
            if sy-index > 1000.
              pos =  f_subrc mod 4.
              if pos = 0. f_subrc = f_subrc + 2. endif.
              exit.
            endif.
          enddo.
          call 'C_DIR_READ_FINISH'
               id 'ERRNO'  field errno
               id 'ERRMSG' field errmsg.
          if sy-opsys(3) = 'Win' and not ( file_name cs '*' ).
            describe table dir_list lines len.
            if len = 0.
              help1 = file_name.
              translate help1 to upper case.
              translate help1 using
                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
              call 'C_DIR_READ_START'
                    id 'DIR'    field dir_name
                    id 'FILE'   field help1.
              if sy-subrc = 0.
                clear error_counter.
                do.
                  clear file.
                  clear dir_list.
                  call 'C_DIR_READ_NEXT'
                      id 'TYPE'   field file-line-type
                      id 'NAME'   field file-line-name
                      id 'LEN'    field file-line-len
                      id 'OWNER'  field file-line-owner
                      id 'MTIME'  field file-line-mtime
                      id 'MODE'   field file-line-acc_mode
                      id 'ERRNO'  field errno
                      id 'ERRMSG' field errmsg.
                  if sy-subrc = 0 or sy-subrc = 3.
                    help2 = file_name.
                    translate help2 to upper case.
                    help1 = file-line-name.
                    translate help1 to upper case.
                    if help1 = help2.
                      perform p6_to_date_time_tz(rstr0400) using
                         file-line-mtime
                         file-line-mod_time
                         file-line-mod_date.
                      dir_list = file-line.
                      append dir_list.
                    endif.
                  elseif sy-subrc = 1.
                    exit.
                  else.
                    if error_counter > 50.
                      call 'C_DIR_READ_FINISH'
                          id 'ERRNO'  field errno
                          id 'ERRMSG' field errmsg.
                      pos =  f_subrc mod 2.
                      if pos = 0. f_subrc = f_subrc + 1. endif.
                      exit.
                    endif.
                    add 1 to error_counter.
                  endif.
                  if sy-index > 1000.
                    pos =  f_subrc mod 4.
                    if pos = 0. f_subrc = f_subrc + 2. endif.
                    exit.
                  endif.
                enddo.
                call 'C_DIR_READ_FINISH'
                     id 'ERRNO'  field errno
                     id 'ERRMSG' field errmsg.
              endif.
            endif.
          endif.
      endcase.
    ENDCASE.
    CASE f_subrc.
       WHEN 1 OR 3.             RAISE too_many_errors.
       WHEN 2.                  RAISE too_many_files.
       WHEN 4 OR 5 OR 6 OR 7 OR 70 OR 71.
         RAISE bracket_error_in_filename.
       WHEN 8 OR 9 OR 10 OR 11 OR 74 OR 75.
         RAISE no_such_parameter.
       WHEN 64.                 RAISE no_authority.
       WHEN 65.                 RAISE activity_unknown.
       WHEN 66.                 RAISE not_a_directory.
       WHEN 67.                 RAISE no_media_in_drive.
    ENDCASE.
    endfunction.
    Now you will be able to get the filesize and the file in SDOK format sdokbin.
    Okay.
    You have to build an request and push the content to the user like:
      call method server->response->set_header_field( name = 'Content-Type' value = value ).
      describe field file_content_binary-line length line_length in byte mode.
      bytes_rest = file-size.
      loop at file_content_binaries assigning <file_content_binary>.
        move <file_content_binary>-line to data.
        if bytes_rest <= 0. "mismatch between line values and size
          exit.
        endif.
        if bytes_rest >= line_length.
          call method server->response->append_data( data = data
            length = line_length ).
        else.
          call method server->response->append_data( data = data
            length = bytes_rest ).
        endif.
        bytes_rest = bytes_rest - line_length.
      endloop.
    This will work.
    You can set the header fields like you want. Have also a look at sicf node contentserver
    and its handler: CL_HTTP_EXT_CSIF

  • Download the pdf document from sap server

    Hi,
    I uploaded the pdf document as MIME type in mime browser.  I have a requirement to open this document when I click on the button.  How could we achieve this ?  I appreciate your help.

    1.You could use offline intractive form to display PDF.
    2. use
      cl_wd_runtime_services=>attach_file_to_response(
        i_filename  = file_name
        i_content   = lv_content
        i_mime_type = mime_type
        i_in_new_window = abap_true
        i_inplace       = abap_false ).

Maybe you are looking for

  • How do i get my itunes account to link to my clash of clans game

    how do i get my itunes account to link to my clash of clans game

  • Carrier update and no longer synching to Exchange

    I had my email and contacts synching great with my office exchange server since the first day I got my phone over a year ago. However - since the carrier update I can not longer connect and download/push exchange email and all of my contacts are wipe

  • Open in Organizer

    Hello Is there a way to open in the Organizer, or in a particular collection.  I've looked through the open parameters document, but no luck there.  I'm working on a large project, and I like the Organizer interface, which I have the project set up i

  • Crosstab scrollbars

    When including a crosstab in an RTF for use by BI Publisher, is there any way to include scrollbars on that crosstab, so that it doesn't split itself into multiple sections going down the page? (For example, TIME going across the page - scrollable le

  • Enterprise service ECC_INDIVIDUALMATERIALIDQR

    hi i am new to SOA. I want to test the above standard service. i went to SOAMANAGER tcode and in webservice administration i have found out this service. i have clicked on "Apply selection" and then in "cinfigurations" tab there are no service and en