Download File from DMS into WD ABAP gives junk data

Hi Experts ,
I want to achieve following functionality in WD ABAP.
User should be able to upload and download any file ( in any fromat ) , to / form document management server.
Since user can upload / download any file so I am using a file download UI , which would open any file in a new window.
I have searched about this in SDN ([ link |https://wiki.sdn.sap.com/wiki/display/Snippets/WDA%20Retrieve%20Data%20from%20DMS%20server]) and I have created a FM which gives me Xstring corresponding to the file in the DMS system.
then I pass this Xstring data to my context 'DATACONTENT' which is bound to file download UI (data property). But When I execute this application I am getting junk data in the new window. Please correct me where I am making a mistake.
following is the code in FM which in turn passes v_xstring ( of type xstring ) to WD ABAP . Then I bind this value to context
'DATACONTENT'.
wd_context->set_attribute( name = 'DATACONTENT' value = V_XSTRING ).
FUNCTION ZTESTING_EP.
""Local Interface:
*"  IMPORTING
*"     VALUE(DOCUMENTTYPE) LIKE  BAPI_DOC_AUX-DOCTYPE DEFAULT 'IVF'
*"     VALUE(DOCUMENTNUMBER) LIKE  BAPI_DOC_AUX-DOCNUMBER DEFAULT 1
*"     VALUE(DOCUMENTPART) LIKE  BAPI_DOC_AUX-DOCPART DEFAULT 000
*"     VALUE(DOCUMENTVERSION) LIKE  BAPI_DOC_AUX-DOCVERSION DEFAULT 00
*"  EXPORTING
*"     VALUE(C) LIKE  BAPIEMPLB-RETURN
*"     VALUE(V_XSTRING) TYPE  XSTRING
*"     VALUE(RETURN) TYPE  BAPIRET2
data: ls_docfiles type bapi_doc_files2,
       ls_dms type dms_doc_files,
       lt_docfiles type standard table of bapi_doc_files2.
select single * from dms_doc_files
   into ls_dms
   where "Retrieve file
MOVE '0000000000000000000000001' to DOCUMENTNUMBER .
MOVE '000' to DOCUMENTPART .
MOVE '00' to DOCUMENTVERSION .
if sy-subrc = 0.
    ls_docfiles-documenttype = DOCUMENTTYPE.
    ls_docfiles-documentnumber = DOCUMENTNUMBER .
    ls_docfiles-documentpart = DOCUMENTPART .
    ls_docfiles-documentversion = DOCUMENTVERSION.
endif.
  call function 'BAPI_DOCUMENT_CHECKOUTVIEW2'
    exporting
      documenttype              = ls_docfiles-documenttype
      documentnumber            = ls_docfiles-documentnumber
      documentpart              = ls_docfiles-documentpart
      documentversion           = ls_docfiles-documentversion
      documentfile              = ls_docfiles
     getstructure              = '1'
     getcomponents             = 'X'
     getheader                 = 'X'
     pf_ftp_dest               = 'SAPFTPA'
     IMPORTING
     return                    = return
   tables
     documentfiles             = lt_docfiles.
MOVE return to return.
  data: i_bin type standard table of sdokcntbin,
        i_info type standard table of scms_acinf,
        v_info type scms_acinf,
        v_id type sdok_phid,
        v_cat type sdok_stcat.
  if sy-subrc = 0.
    loop at lt_docfiles into ls_docfiles.
      v_id = ls_docfiles-docfile.
      v_cat = ls_docfiles-storagecategory.
      call function 'SCMS_DOC_READ'
        exporting
          stor_cat                = v_cat
          doc_id                  = v_id
          phio_id                      =  ls_docfiles-file_id
       tables
         access_info                 = i_info
         content_bin                 = i_bin
       exceptions
         bad_storage_type            = 1
         bad_request                 = 2
         unauthorized                = 3
         comp_not_found              = 4
         not_found                   = 5
         forbidden                   = 6
         conflict                    = 7
         internal_server_error       = 8
         error_http                  = 9
         error_signature             = 10
         error_config                = 11
         error_format                = 12
         error_parameter             = 13
         error                       = 14
         others                      = 15
    endloop.
    if sy-subrc <> 0.
    else.
     data: v_xstring type xstring.
      read table i_info into v_info index 1.
      call function 'SCMS_BINARY_TO_XSTRING'
        exporting
          input_length       = v_info-comp_size
       importing
         buffer             = v_xstring
        tables
          binary_tab         = i_bin
       exceptions
         failed             = 1
         others             = 2
      if sy-subrc <> 0.
      endif.
    endif.
  endif.
ENDFUNCTION.
Thanks in advance
Abhay

Hi Abhay,
I have used the belwo method to achive the same:
1) Call funtion 'CVAPI_DOC_GETDETAIL' to get the document details.This function module returns PT_FILES tables parameter
2) Loop at PT_FILES and call the 'CV120_GET_MIME_TYPE' funtion by passing DAPPL of PT_FILES to get the mime type.
3)call function 'CVAPI_DOC_CHECKOUTVIEW' by passing PT_FILES values form above retrived to the function module in this step
4)Loop at the content and convert to XSTRING using SCMS_XSTRING_TO_BINARY
After getting the XSTRING,MIMETYPE use ATTACH_FILE_FOR_RESPONSE method of CL_WD_RUNTIME_SERVICES to download the file
Sample Code:
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
      EXPORTING
        pf_dokar     = ls_draw-dokar
        pf_doknr     = iv_documentnumber
        pf_dokvr     = ls_draw-dokvr
        pf_doktl     = ls_draw-doktl
        pf_read_drat = abap_true
      IMPORTING
        psx_draw     = ls_draw
      TABLES
        pt_drat      = et_drat
        pt_files     = et_files
      EXCEPTIONS
        not_found    = 1
        no_auth      = 2
        error        = 3
        OTHERS       = 4.
  ENDIF.
  IF et_files IS NOT INITIAL.
    LOOP AT et_files INTO ls_files.
      CALL FUNCTION 'CV120_GET_MIME_TYPE'
       EXPORTING
         pf_dappl           = ls_files-dappl
*       PF_FILE            =
       IMPORTING
         pfx_mimetype       = lv_mimetype.
      CLEAR lt_files_checkout.
      CLEAR lt_content.
      ls_files_checkout-description = ls_files-description.
      ls_files_checkout-lo_objid = ls_files-lo_objid.
      ls_files_checkout-ph_objid = ls_files-ph_objid.
      APPEND ls_files_checkout TO lt_files_checkout.
      CALL FUNCTION 'CVAPI_DOC_CHECKOUTVIEW'
        EXPORTING
          pf_dokar                 = ls_draw-dokar
          pf_doknr                 = iv_documentnumber
          pf_dokvr                 = ls_draw-dokvr
          pf_doktl                 = ls_draw-doktl
         pf_content_provide       = gc_content_provide
*         PS_API_CONTROL           =
*         PF_STD_URL               = 'X'
       IMPORTING
         psx_message              = ls_message
         psx_draw                 = ls_draw
       TABLES
         pt_files                 = lt_files_checkout
*         PTX_COMPONENTS           =
         ptx_content              = lt_content.
      IF ls_message CA gc_error_a.
        ev_fail = abap_true.
      ELSE.
        CLEAR lt_xdata.
        CLEAR ls_bindata.
*Data into String
        LOOP AT lt_content INTO ls_content.
          lv_size = ls_content-orln.
          ls_xdata-line = ls_content-orblk.
          APPEND ls_xdata TO lt_xdata.
        ENDLOOP.
* --  Convert XData to Xstring
        CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
          EXPORTING
            input_length = lv_size
          IMPORTING
            buffer       = ls_bindata
          TABLES
            binary_tab   = lt_xdata
          EXCEPTIONS
            failed       = 1
            OTHERS       = 2.
        IF sy-subrc NE 0.
          ev_fail = abap_true.
        ELSE.
          ls_file_list-filename = ls_files-description.
          ls_file_list-mimetype = lv_mimetype.
          ls_file_list-content = ls_bindata.
          ls_file_list-application_id = ls_files-lo_objid.
          ls_file_list-file_id = ls_files-ph_objid.
          APPEND ls_file_list TO et_file_list.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
Regards,
Madhu

Similar Messages

  • About "Upload and download files from ADF into blob type colum."

    hi
    Using JDeveloper 10.1.3.3.0 I have tried the example available for download from this blog post by Jakub Pawlowski:
    "Upload and download files from ADF into blob type colum."
    at http://kuba.zilp.pl/?id=1
    First a thank you to Jakub for this interesting example.
    I have a question about a PDF file that I uploaded using the example.
    The file has a size of 10445518 bytes.
    After I upload that file, the blob column has a value with a size of 10445516 bytes, 2 bytes less.
    SQL> select file_name, dbms_lob.getlength(stored_file) from blob_table;
    FILE_NAME
    DBMS_LOB.GETLENGTH(STORED_FILE)
    ADF-DeveloperGuide-4GL-B25947_01.pdf
                           10445516If I download that file using the example, it has the same size as the blob value, 10445516 bytes.
    If I open the downloaded file, using Adobe Reader 8.1.1, it first shows this message:
    "The file is damaged but is being repaired."
    After that, there is not problem using the PDF file in Adobe Reader.
    I have tried this with both Internet Explorer 6 and Firefox 2.0.0.11.
    I have also tried this with other (smaller) files, and those upload and download correctly.
    question:
    Why are those 2 bytes lost during upload?
    many thanks
    Jan Vervecken

    Hi!
    I can only post you my code that works for me and as I said I had same problems but can't remember what solved them. My code:
      public void fileUploaded(ValueChangeEvent event)
        FacesContext fc = FacesContext.getCurrentInstance();
        UploadedFile file = (UploadedFile) event.getNewValue();
        if (file != null && file.getLength() > 0)
          // here I have some messages written and a call to the method on AM to save the uploaded file to the DB
      private BlobDomain newBlobDomainForInputStream(InputStream in)
        throws SQLException, IOException
        BlobDomain loBlob = new BlobDomain();
        OutputStream out = loBlob.getBinaryOutputStream();
        writeInputStreamToWriter(in, out);
        in.close();
        out.close();
        return loBlob;
      private static void writeInputStreamToWriter(InputStream in,
                                                   OutputStream out)
        throws IOException
        byte[] buffer = new byte[8192];
        int charsRead = 0;
        while ((charsRead = in.read(buffer, 0, 8192)) != -1)
          out.write(buffer, 0, charsRead);
       * Launch the upload - see fileUploaded() for actual upload handling.
       * @return null navigation event - we stay on this page
      public String UploadButton_action()
        if (this.getMyInputFile().getValue() == null)
          FacesContext context = FacesContext.getCurrentInstance();
          FacesMessage message =
            new FacesMessage(FacesMessage.SEVERITY_WARN, JSFUtils.getStringFromBundle("fileupload.emptyfielderror"),
                             null);
          context.addMessage(this.getMyInputFile().getId(), message);
        return null;
       * Setter for inputFile UI Component.
       * @param inputFile inputFile UI component
      public void setMyInputFile(CoreInputFile inputFile)
        this.myInputFile = inputFile;
       * Getter for inputFile UI Component.
       * @return inputFile UI component
      public CoreInputFile getMyInputFile()
        return myInputFile;
      }fileUploaded is a valueChangeListener on inputFile and UploadButton_action is as the name says the action for upload button.
    Hope this helps. If not, than your problem is probably not the same as mine was, although the message about file corrupted was the same.
    Next thing you can check in this case is if your file exceeds max file upload size. I don't know the exact default value, but if the file is too long I think this upload logic will upload only a part of the file and save it to the DB which can also lead to the same file corrupted error.
    You can set the max upload value in web.xml like this:
    <context-param>
    <!-- Maximum memory per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
    <!-- Use 5000K -->
    <param-value>5120000</param-value>
    </context-param>
    <context-param>
    <!-- Maximum disk space per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
    <!-- Use 10,000K -->
    <param-value>15360000</param-value>
    </context-param>

  • Download file from AL11 into CSV to load MD into BPC

    Hi All
    I have an issue in downloading file from AL11 which is in the form of CSV.
    1) I have exported the masterdata for Costcenter using a Open hub.
    2) The file is residing at the app server AL11 in the form of CSV.
    3) I want to down load the file into CSV and upload that file into BPC NW for my costcenter diemension.
    When i am downloading the file from AL11 , the total records are merged into one row, i cannot download same as it is available in AL11.
    I have followed the HOW TO GUIED : HOW TO AUTOMATE MD LOADING IN BPC nw.
    I m unable to get the file properly on to my PC.
    could you please help me .
    AK

    You should open your file in AL11, then clicking 'List' then 'Save' you'll be able to download your file. There will be some header lines indeed.
    You'd better use an open hub with your local client as destination if you need the file.

  • Merge the Attachment Files from DMS into smart forms

    Hi Gurus,
    I have a requirement of merging documents and printing it on a smart form.
    I need to read the active files of SAP DMS. It could be DOC or PDF or Image.
    I will have a smart form with some data to be printed related to the document(may be 2 pages).
    Once after printing the data, I need to print the contents of the file in the smart form. (ie) 3rd, 4th and 5th pages.
    then i need to convert the entire smartform into PDF and load it back to DMS.
    Example :
    if I have 3 different files
    1. Word document, which has a Graphical representation of the component
    2. PDF, which has a Graphical representation of the component
    3. Image fileBMP or GIF or JPEG, which has a Graphical representation of the component.
    I have used BAPI_DOCUMENT_GETDETAIL2 to read the active document, and the function SCMS_DOC_READ to get the contents of the file in Binary format
    I couldnu2019t merge the contents of the documents
    Please let me know if there is any solution with in SAP to do this. We are restricted to smartforms only.

    hi Naveen,
      Checkout the link..,
      http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/creating xml forms 6.0
        it provides step-by-step guide to ur problem..
        hope it helps..,
    regards,
    Vinoth

  • Upload and download files from ADF into blob type colum

    i have a question about Kuba's example ( http://kuba.zilp.pl/?id=1# )
    after you have upload the word documents, and when u click on the downoad button that document is open... i want to know if it is possibile that afer you have download the document, you make some changes on it and then to save these changes on the database? any idea if this can be done? Thanks in advance :)

    If you download the entire application from that link, the create.sql file is included in the \DBModel\model\zilp\testcase\dbmodel folder
    It's a rather complicated matter in my opinion. Download the app, open it in JDev and use debug-mode to go through it step by step, so you can try to understand everything that happens.
    Good luck :)

  • File download from DMS into Webdynpro for ABAP application

    I need to download the file from DMS content server on the PC and with my application on clicking of file name, file needs to be displayed.
    To achieve the downloading part I tried BAPI_DOCUMENT_CHECKOUTVIEW2, but it is not working.
    If I pass the parameters
    PF_HTTP_DEST              = 'SAPHTTPA'
    PF_FTP_DEST               = 'SAPFTPA', then it returns error message saying file can not be saved.
    If I don't pass above parameters then it gives me 'RFC_START_PROGRAM' error.
    How to download the file from DMS in WebDynpro and read/display the content?
    Please help.
    Thanks, in advance.

    Hi,
    I had the same problem, but found a solution. All I changed was the hostname to 'DEFAULT'
    Use the code below:
    DATA: lt_drao TYPE TABLE OF drao,
             wa_drao TYPE drao,
             wa_bin TYPE x LENGTH 2550,
             lt_bin LIKE TABLE OF wa_bin,
             file_data TYPE xstring,
             v_line TYPE i,
             size TYPE i.
       CALL FUNCTION 'CVAPI_DOC_CHECKOUTVIEW_DIALOG'
         EXPORTING
           pf_dokar                 = ls_input-dokar
           pf_doknr                 = ls_input-doknr
           pf_dokvr                 = ls_input-dokvr
           pf_doktl                 = ls_input-doktl
    *     PF_FTP_DEST              = 'SAPFTPA'
    *     PF_HTTP_DEST             = ' '
          pf_hostname              = 'DEFAULT'
          pf_content_provide       = 'TBL'
    *     PS_API_CONTROL           =
    *   IMPORTING
    *     PSX_MESSAGE              =
    *     PSX_FILE                 =
    *     PSX_DRAW                 =
        TABLES
          ptx_content              = lt_drao.
       LOOP AT lt_drao INTO wa_drao.
         wa_bin = wa_drao-orblk.
         APPEND wa_bin TO lt_bin.
       ENDLOOP.
       DESCRIBE TABLE lt_drao LINES v_line.
       size = 2550 * v_line.
       CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
         EXPORTING
           input_length       = size
    *     FIRST_LINE         = 0
    *     LAST_LINE          = 0
        IMPORTING
          buffer             = file_data
         TABLES
           binary_tab         = lt_bin
    *   EXCEPTIONS
    *     FAILED             = 1
    *     OTHERS             = 2
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.
    CALL METHOD cl_wd_runtime_services=>attach_file_to_response
         EXPORTING
           i_filename      = 'abc.pdf'
           i_content       = file_data
           i_mime_type     = 'application/pdf'
    *     i_in_new_window = ABAP_FALSE
    *     i_inplace       =  ABAP_FALSE

  • DMS - Download File from CV03n

    Hi guys!
    Is there some function or BAPI, that can I make donwload file from cv03n and move to another server or save file content in internal table?
    I need develop the abap program that download file from cv03n and put in another unix adress, that is possible?
    thanks
    Felipe Martin

    Hi,
    if you have the document data (number, type, ....) you can use the report DMS_KPRO_READ. This report will list all originals of this document info record and with the small green download button you can easily download the file to your desired directory.
    Best regards,
    Christoph

  • I cannot open a file from LR5 into CC2014 unless it is a smart object. also will not save back to LR at all it gives me an error message "Line: 1 -   photoshop.notifyLightroomDocClosed ('lightroom-2.0', 'B53AFA39-A49B-4709-A9BD-0B6467C175C3', 'Macintosh H

    I cannot open a file from lightroom into CC2014 unless I open it as a smart object. CC opens, just will not display my image. i am given an error code when I save an image, and can only save to my desktop or other locations, not automatically back into my lightroom.
    I am using LR5 latest update, as well as CC2014
    Below is the error message:
    Line: 1 ->  photoshop.notifyLightroomDocClosed ('lightroom-2.0', 'B53AFA39-A49B-4709-A9BD-0B6467C175C3', 'Macintosh HD:Users:BPexposures:Desktop:_DSC5962 as Smart Object-1.psd');

    I was also having this issue, and I did some more searching and found this answer in the Adobe forums: Re: Photos from Lightroom 5 to Photoshop CC (2014) and back.... The issue appears to be caused by having not updated Lightroom to the latest version prior to having CC2014 installed (wow that's stupid). The trick seems to be to uninstall Photoshop CC2014 and to then reinstall it after having upgraded to Lightroom 5.5.

  • How to download files from Application Server of Unix o.s to local director

    Hi All,
    I am trying to download files from Apllication server of Unix operating Systems to local file in excel sheet format using a z-program.but whenever I am trying to use OPEN dataset ........
    it is showing sy-subrc = 8.
    Can I have any clew please.
    Thanks in advance,
    Regards,
    AMEER.

    Hi Sreekanth,
    Thanks a lot for quick reply.I have to download that files from z-program only. I am giving you my code below.
    *& Report  ZTRAK_DOWNLOAD                                         *
    REPORT  ZTRAK_DOWNLOAD  MESSAGE-ID ZCT                   .
    SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD WITH FRAME TITLE TEXT1.
      PARAMETERS :
           SERDIR LIKE RLGRAP-FILENAME DEFAULT '/usr/trak',
           LOCDIR LIKE RLGRAP-FILENAME DEFAULT 'C:\Trak'.
    SELECTION-SCREEN END OF BLOCK DOWNLOAD .
    SELECTION-SCREEN BEGIN OF BLOCK INFO2 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT2.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT3.
    SELECTION-SCREEN END OF BLOCK INFO2 .
    SELECTION-SCREEN BEGIN OF BLOCK INFO3 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT4.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT5.
            SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT6.
           SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT7.
           SELECTION-SCREEN SKIP 2.
           SELECTION-SCREEN COMMENT 1(79) TEXT8.
    SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT9.
    SELECTION-SCREEN END OF BLOCK INFO3.
    *- Internal Table to output data in Excel
    DATA: BEGIN OF tab_excel OCCURS 0,
            col1(50),
            col2(132),
            col3(255),
            col4(100),
            col5(100),
            col6(50),
            COL7(60),
            col8(30),
            col9(30),
            col10(30),
            col11(20),
            col12(15),
            col13(15),
          END OF tab_excel.
    DATA: FILE LIKE RLGRAP-FILENAME .
    DATA: W_DATASET(80).
    INITIALIZATION.
      TEXT1  = 'Download Reports'.
      TEXT2 = 'The Program downloads the reports generated by Trak'.
      TEXT3 = 'Utility from Server to Local PC.'.
      TEXT4 = 'Check the following before executing the Program.'.
      TEXT5 = '     1. A valid Server path is provided.'.
      TEXT6 = '     2. A valid Local PC path is provided.'.
      TEXT7 = '     3. Local PC has 10 MB free space.'.
      TEXT8 = 'The report can be executed in the forground.'.
    TEXT9 =
    'The report should be executed after execution of Transaction TRAK'.
    AT SELECTION-SCREEN.
    IF SERDIR EQ ''.
    MESSAGE E001(ZCT).
    ENDIF.
    IF LOCDIR EQ ''.
    MESSAGE E002(ZCT).
    ENDIF.
    START-OF-SELECTION.
    Download ABAP Development Summary Report
    FILE =  '\ABAP_Report_Developments.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAP_Report_Developments.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download BDC Development Report
    FILE =  '\BDC_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/BDC_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Development Summary Report
    FILE = '\Developments_Summary_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Developments_Summary_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Enhancement Development Report
    FILE =  '\Enhancement_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Enhancement_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download field exit Development Report
    FILE =  '\Field_Exit_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Field_Exit_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Frequency & Purpose Report
    FILE =  '\Frequency_And_Purpose_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Frequency_And_Purpose_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Group Developments Report
    FILE =  '\FunctionGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Module Developments Report
    FILE = '\FunctionModule_Developments_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionModule_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    FILE =  '\Include_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Include_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download UserGroup Developments Report
    FILE =  '\UserGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Modified_Standard_SAP_Objects_Report
    FILE = '\Modified_Standard_SAP_Objects_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Modified_Standard_SAP_Objects_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    *FILE =  '\Include_Developments_Report.XLS'.
    *CONCATENATE LOCDIR FILE INTO FILE.
    *W_DATASET = '/Include_Developments_Report.dat'.
    *CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    *PERFORM INIT.
    Download SAP Script Developments Report
    FILE =  '\SAP_Scipt_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/SAP_Scipt_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Transaction Developments Report
    FILE =  '\Transaction_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Transaction_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download User Exits Developments Report
    FILE =  '\UserExits_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserExits_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download ABAP Query Developments Report
    FILE =  '\ABAPQuery_Developments_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAPQuery_Developments_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Functional Area Developments Report
    FILE =  '\FunctionalArea_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionalArea_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    MESSAGE S003(ZCT) WITH LOCDIR.
    END-OF-SELECTION.
    This routine checks whether file exists if yes downloads it to
    the Local PC
    FORM INIT.
    OPEN DATASET W_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
       IF SY-SUBRC <> 0.
          EXIT.
       ENDIF.
       READ DATASET W_DATASET INTO  tab_excel.
       APPEND tab_excel.
       CLEAR tab_excel.
    ENDDO.
         PERFORM DOWNLOAD_FILE.
    ENDFORM.
    This routine downloads the data in an XL format on local PC
    FORM Download_File .
      CALL FUNCTION 'WS_DOWNLOAD'
                EXPORTING
                     FILENAME                = FILE
                     FILETYPE                = 'DAT'
                TABLES
                     DATA_TAB                = tab_excel
                EXCEPTIONS
                     FILE_OPEN_ERROR         = 1
                     FILE_WRITE_ERROR        = 2
                     INVALID_FILESIZE        = 3
                     INVALID_TYPE            = 4
                     NO_BATCH                = 5
                     UNKNOWN_ERROR           = 6
                     INVALID_TABLE_WIDTH     = 7
                     GUI_REFUSE_FILETRANSFER = 8
                     CUSTOMER_ERROR          = 9
                     OTHERS                  = 10.
        IF sy-subrc <> 0.
         message ''.       " Error in file transfer
        ELSE.
          CLEAR TAB_EXCEL.
          REFRESH TAB_EXCEL.
          FILE = ''.
          W_DATASET = ''.
        ENDIF.
    ENDFORM.
    I have created those files in Application Server running in another z-program in background mode.Then I am trying to download those files using above the program.I am creating those trak/Trak files manually and I can able to see those files in A.S level.But when downloading the same files I am facing the problem.
    regards,
    Ameer

  • Error in PDF Conversion while downloading file from application server

    Hi,
    I am facing a problem in which i have to download file from application server which is a PDF file (output of SAP Script). I am downloading this file using following code in BSP technology:
    * event handler for data retrieval
    EMPCD = REQUEST->GET_FORM_FIELD( 'emp' ).
    MONTH = REQUEST->GET_FORM_FIELD( 'mn' ).
    YEAR  = REQUEST->GET_FORM_FIELD( 'yr' ).
    W_IND = 'N' .
    DATA : wa_zform16 type  zform16.
    DATA : file_path type string.
    DATA : l_pdf_len type string.
    DATA STR TYPE STRING.
    DATA: OUTPUT    TYPE STRING ,
          L_XSTRING TYPE XSTRING ,
          APP_TYPE  TYPE STRING.
    DATA: PDF_TABLE TYPE  RCL_BAG_TLINE.
    DATA PHY_NAME_OUT     TYPE SAPB-SAPPFAD.
    concatenate '/usr/sap/put/form16/' EMPCD '_' YEAR '.PDF'  into file_path
    *PHY_NAME_OUT = '/usr/sap/put/form16/01000200_2007.PDF'.
    PHY_NAME_OUT = file_path.
    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.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      APP_TYPE = 'APPLICATION/PDF'.
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          TEXT     = OUTPUT
                MIMETYPE = 'APPLICATION/PDF'
    *            MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
        IMPORTING
          BUFFER   = L_XSTRING.
      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.
    Result of this code is : there is a pop up asking to open or save pdf format and process is complete, but i have problem in downloaded file.
    At the time of creation i have put BMP image for signature in PDF file and it is working fine but when i upload that file in Application server and then download it with above used code it save the PDF file but when i open that file so whereever i have used signature that page gives error and could not display that scanned signature.
    Can anyone please help me in this regard.
    or is there any possibility from which i can download that file just like File transfer from BSP.
    Keep in mind that i am using BSP technology so all GUI based function module to download file are not working.
    waiting for your reply.....
    Regards,
    Gagan

    Hi Raja,
    I have standard sap form for TDS Certificate on which i have include an BMP image for digital signature and download that script into pdf format.While i download that PDF looks ok but it is not working in BSP.
    Regards,
    Gagan

  • [HELP] Download file from FTP server

    hi,
    I want to write a java program that can download and upload files from ftp server. Currently I only manage to upload a file to ftp server but i cant download file from ftp server. Here is the source code that only allow user to upload file. Anyone can give me some guidelines so that my program can download and also upload file? thx.
    import java.io.*;
    import java.net.*;
    public class FTPUpload {
    private static final int CTRLPORT = 21;
    private static Socket ctrlSocket;
    private static PrintWriter ctrlOutput;
    private static BufferedReader ctrlInput;
    private static byte[] localHostAddress;
    public final static String DIR = "C:\\zip\\";
    public static void main(String[] args) {
    try {
    String host = "192.168.1.1";
    String loginName = "testuser";
    String password = "password";
    String dirName = "/home/testuser";
    String fileName = "hello.zip";
    ctrlSocket = new Socket(host, CTRLPORT);
    localHostAddress = ctrlSocket.getLocalAddress().getAddress();
    ctrlOutput = new PrintWriter(ctrlSocket.getOutputStream());
    ctrlInput = new BufferedReader(new InputStreamReader(ctrlSocket.getInputStream()));
    ctrlOutput.println("USER " + loginName);
    ctrlOutput.flush();
    ctrlOutput.println("PASS " + password);
    ctrlOutput.flush();
    ctrlOutput.println("CWD " + dirName);
    ctrlOutput.flush();
    ctrlOutput.println("TYPE I");
    ctrlOutput.flush();
    FileInputStream fis = new FileInputStream(DIR + fileName);
    Socket dataSocket = dataConnection("STOR " + fileName);
    OutputStream outstr = dataSocket.getOutputStream();
    int n;
    byte[] buff = new byte[1024];
    while ((n = fis.read(buff)) > 0) {
    outstr.write(buff,0,n);
    dataSocket.close();
    fis.close();
    ctrlOutput.close();
    ctrlInput.close();
    ctrlSocket.close();
    }catch (Exception e) {
    e.printStackTrace();
    private static Socket dataConnection(String ctrlcmd)
    throws IOException,UnknownHostException {
    String cmd = "PORT ";
    ServerSocket serverDataSocket = new ServerSocket(0,1);
    for (int i=0;i<4;i++) {
    cmd = cmd + (localHostAddress[i] & 0xff) + ",";
    cmd = cmd + (((serverDataSocket.getLocalPort())/256) & 0xff)
    + ","
    + (serverDataSocket.getLocalPort() & 0xff);
    ctrlOutput.println(cmd);
    ctrlOutput.flush();
    ctrlOutput.println(ctrlcmd);
    ctrlOutput.flush();
    Socket dataSocket = serverDataSocket.accept();
    serverDataSocket.close();
    return dataSocket;
    }

    Or just use a java.net.URL("ftp://...) ..., get its input stream, and away you go ...

  • Uploading and downloading files from a web app (Urgent!!)

    Hi everyone:
    I'm developing an application in PL/SQL to upload and download files from an HTML webpage. I congured the document table and the parameters necessary in the DAD of my application.
    when I upload the file using my webpage that file info is automatically uploaded to the doc table. This is as far as I have gotten.
    I need to do the following:
    - Place the uploaded file into a column in another table in my database as part of a text message (think of it as an email message), and delete the file from the doc table (as this is thought to be a temp table that holds the file when uploaded from my webpage)
    - Retreive the file so that it can be downloaded from another web page.
    The file can be a PDF, WORD DOC, etc...
    I now that I can do this with InterMedia but I haven't figured out how :(
    Can anyone please point me to an example or some documentation that can guide me through the process.
    DB VERSION: 8.1.7
    IAS VERSION: 1.0.2.2
    Thanks,
    Carlos Abarca

    The idea was for you to look at the code and get an idea of how to access the BLOB in the document table. IF you look at the procedure
    insert_new_photo( new_description IN VARCHAR2,
    new_location IN VARCHAR,
    new_photo IN VARCHAR2 )
    It shows how to access the blob that is stored in the document table. You can then copy this blob to your own table using the DBMS_LOB package.
    Hope this helps,
    Larry

  • How to download file from application server

    Hi Experts,
                  I developed report and execute in background mode. for this i used Open dataset transfer and close dataset . i got the requried output . But in this case user want downloaded file on presentation server so can anyone tell me How to download file from application server?
    i know it is possible through Tcode CG3Y. but i want code in program.

    This code will download a file to your Client package by package, so it will also work for huge files.
    *& Report  ZBI_DOWNLOAD_APPSERVER_FILE
    REPORT  zbi_download_appserver_file.
    PARAMETERS: lv_as_fn TYPE sapb-sappfad
    DEFAULT '/usr/sap/WBP/DVEBMGS00/work/ZBSPL_R01.CSV'.
    PARAMETERS: lv_cl_fn TYPE string
    DEFAULT 'C:\Users\atsvioli\Desktop\Budget Backups\ZBSPL_R01.CSV'.
    START-OF-SELECTION.
      CONSTANTS blocksize TYPE i VALUE 524287.
      CONSTANTS packagesize TYPE i VALUE 8.
      TYPES ty_datablock(blocksize) TYPE x.
      DATA lv_fil TYPE epsf-epsfilnam.
      DATA lv_dir TYPE epsf-epsdirnam.
      DATA ls_data TYPE ty_datablock.
      DATA lt_data TYPE STANDARD TABLE OF ty_datablock.
      DATA lv_block_len TYPE i.
      DATA lv_package_len TYPE i.
      DATA lv_subrc TYPE sy-subrc.
      DATA lv_msgv1 LIKE sy-msgv1.
      DATA lv_processed_so_far TYPE p.
      DATA lv_append TYPE c.
      DATA lv_status TYPE string.
      DATA lv_filesize TYPE p.
      DATA lv_percent TYPE i.
      "Determine size
      SPLIT lv_as_fn AT '/' INTO lv_dir lv_fil.
      CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
          file_name      = lv_fil
          dir_name       = lv_dir
        IMPORTING
          file_size_long = lv_filesize.
      "Open the file on application server
      OPEN DATASET lv_as_fn FOR INPUT IN BINARY MODE MESSAGE lv_msgv1.
      IF sy-subrc <> 0.
        MESSAGE e048(cms) WITH lv_as_fn lv_msgv1 RAISING file_read_error.
        EXIT.
      ENDIF.
      lv_processed_so_far = 0.
      DO.
        REFRESH lt_data.
        lv_package_len = 0.
        DO packagesize TIMES.
          CLEAR ls_data.
          CLEAR lv_block_len.
          READ DATASET lv_as_fn INTO ls_data MAXIMUM LENGTH blocksize LENGTH lv_block_len.
          lv_subrc = sy-subrc.
          IF lv_block_len > 0.
            lv_package_len = lv_package_len + lv_block_len.
            APPEND ls_data TO lt_data.
          ENDIF.
          "End of file
          IF lv_subrc <> 0.
            EXIT.
          ENDIF.
        ENDDO.
        IF lv_package_len > 0.
          "Put file to client
          IF lv_processed_so_far = 0.
            lv_append = ' '.
          ELSE.
            lv_append = 'X'.
          ENDIF.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              bin_filesize         = lv_package_len
              filename             = lv_cl_fn
              filetype             = 'BIN'
              append               = lv_append
              show_transfer_status = abap_false
            TABLES
              data_tab             = lt_data.
          lv_processed_so_far = lv_processed_so_far + lv_package_len.
          "Status display
          lv_percent = lv_processed_so_far * 100 / lv_filesize.
          lv_status = |{ lv_percent }% - { lv_processed_so_far } bytes downloaded of { lv_filesize }|.
          CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
            EXPORTING          "percentage = lv_percent - will make it fash
              text = lv_status.
        ENDIF.
        "End of file
        IF lv_subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      "Close the file on application server
      CLOSE DATASET lv_as_fn.

  • How do I move a downloaded file (from YouTube) to GarageBand so as to separate video from audio, then send audio to iTunes?

    How do I move a downloaded file (from You Tube) to Garagband - so as to separate video from audio (which I will send to iTunes)

    Create a new GarageBand "Movie" project, then import your movie into GarageBand, by dragging it from the "Movies" tab of the Media Browser into the Timeline. GarageBand will split the movie into a video channel and an audio channel. Delete the video/movie channel and use the "Share" menu to send the audio channel to iTunes (assuming you have iLife '11 GarageBand)
    Regards
    Léonie

  • Download file from UNIX to EXCEL problem

    Hi,
    I am trying to download file from UNIX server to excel file, there is one column which is messing up and that is number 100000000000000002 (18 in length) it is writing as 1E+17, funny thing is when I click on that cell it is showing as
    100000000000000000.
    I am using GUI_DOWNLOAD to download to excel, below is the output excel format, I am talking about 4th value from left
    GUID    leg_reg     lic_type     lic_num     ex_lic_num     vali_from     valid_to     created_by
    3E633B85C05E6F28E100     EAR     ENC     1E+17     ENC     20030305     20930305     VANRIJ
    below is the program I am using to download the output from UNIX to excel
    FORM get_data_file.
      OPEN DATASET p_unxfil FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        DO.
          READ DATASET p_unxfil INTO input_file_tab-line_string.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          APPEND input_file_tab.
          CLEAR  input_file_tab.
        ENDDO.
      ELSE.
        PERFORM write_message USING 'ZZ' 'E' '000'
          'Unable to find file' p_unxfil
          '  Press Enter key to exit.' ''.
      ENDIF.
      CLOSE DATASET p_unxfil.
      DESCRIBE TABLE input_file_tab LINES record_cnt.
    ENDFORM.                    " get_data_file
    FORM create_pc_file.
      DATA: l_file TYPE string.
      MOVE p_pcfile TO l_file.
    Save the file
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
        TABLES
          data_tab                = input_file_tab
        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 NE 0.
        WRITE: / 'Error creating pc file', p_pcfile.
        EXIT.
    endif.
    I will assure of points.
    Thanks for your help
    Sarath

    It is not the problem of your program. This happens becuase of the "nature" of the excel. You need to retain the text property of that column.
    Try like this:
    1. Download the file in .txt
    2. Open Excel .. blank sheet
    3. Now, click on Open. Select your .txt file
    4. One pop up will come ..."Text Import Wizard"
    5. Select the fixed width or Delimited ... Press Next ...
    6. Select appropriate delimitors or fixed length .. press Next
    7. Select your coulumn (which has the problem), Select the "Text" radiobutton on the upper-right corner and finish.
    Regards,
    Naimesh Patel

Maybe you are looking for

  • How to get class name of a object in run time, from its accessible context.

    Hi, I need to get the class name of a java object in run-time, given the AccessibleContext of that object. I gone through the AccessibleContext api documentation. but there is not way to get the class name for a java object using its AccessibleContex

  • Why is my Illustrator cs6 not opening files.

    I'm having a issue with Illustrator not opening files (eps or ai) either from the server or my desktop, opening original from Indesign, double clicking a file or from the menu 'open file'. I have to end up quitting Illustrator, then open the file fro

  • How to get image properties in PDF using javascript

    Hi How to get the image(all the images) properties in PDF using javascript? Thanks in Advance

  • Load-Balancers strange behaviour.

    Hi Gurus, I have a kind of a strange behaviour of our our CSS11150 Load-Balancers configured in Active-Standby mode. These LBs monitor the servers and the latters report UP and Down state from the Standby unit while they are always UP from teh Active

  • Error encountered when Adding an Item style Flex in Search criteria

    Hi All, I am trying to add an Item style Flex in the Searchable region(search criteria region) ,then I have encountered an error saying Program error. Please inform your support representative that the descriptive flexfield in the application could n