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

Similar Messages

  • How to download a file from application server to presentation server

    Hi experts,
    I want to download a file from application server to presentaion server, file contaims three fields customer name, customer email id and status..
    help me out i m new into sap.

    Dear Aditya,
    Please check below thread
    http://scn.sap.com/thread/1010164
    it will help you.
    BR
    Atul

  • Download text file from application server to client server.

    Hi all,
    I am facing a format issue while downloading text file from application server to the client machine.
    The issue is that, say I have 6 to 10 lines in my text file in application server. but when i store it on the hard drive,
    it shoes all the data in a single line. Where as i need to download data in same format as in application server.
    Awaiting for your responses.
    Regards,
    Jose

    Hi,
    If we want to upload file data from the application server to the internal table, there is no function module or class static method which we can use, we must wirte the code by ourselves.
    1. For the file data which has no seperator between field columns.
    PARAMETERS p_file  TYPE dxfile-filename.
    START-OF-SELECTION.
    OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
      DO.
        READ DATASET p_file INTO gds_data.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND gds_data TO gdt_data.
      ENDDO.
    CLOSE DATASET p_file.2. For the file data which has tab separator between field columns.
    DATA: gds_field_split type gts_data.
    FIELD-SYMBOLS: <fs_field> TYPE gts_data.
    PARAMETERS p_file  TYPE dxfile-filename.
    START-OF-SELECTION.
    OPEN DATASET prf_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
      DO.
        READ DATASET p_file INTO gds_field.
        SPLIT gds_field  AT cl_abap_char_utilities=>horizontal_tab
             INTO TABLE gdt_field_split.
       LOOP AT gdt_field_split  into gds_field_split.
           gdf_index = gdf_index + 1.
           ASSIGN COMPONENT gdf_index OF STRUCTURE
                 gds_data to <fs_field>.
          IF sy-subrc = 0.
              <fs_field> = gds_field_split.
          ENDIF.
       ENDLOOP.
        APPEND gds_data TO gdt_data.
      ENDDO.
    CLOSE DATASET p_file.
    Thanks & regards,
    ShreeMohan

  • To access pdf files from application server using web.show_document

    Hello!
    If my pdf file is copied in Oracle_home/forms90/java directory.Then using web.show_document i can access the pdf file.But I can't copy all the pdf files in /forms90/java directory.We have lacs of pdf files which I want to keep in my own directory.But my requirement is if my pdf file is in /home2/docs directory in (Linux application server) ie in my own directory where I store all the pdf files.Then web.show_document does not open the pdf file.It says page cannot be displayed.For that I think we have to configure the directory /home2/docs directory as a webserver.From otn I got something like forms90.conf file in application server where we have to set virtual directory mapping etc.If the pdf is in local machine then in orion-web.xml file we have to mention real path and save the file and shutdown oc4j instance and restart it again.I tried it.But it is not working.Can u give me step by step instructions to solve this problem.I found a few links in discussion forum.But is doesn't work out.My pdf file is in /home2/docs directory in Linux application server.Please treat it as urgent.
    Regards
    Jayashree

    Hi Sandeepmsandy,
    There is no available code sample for this scenario. You may write your own.
    Step 1: Get pdf URL from sqlite database. Please refer to the following MSDN blog and see a code sample.
    http://blogs.msdn.com/b/robertgreen/archive/2012/11/13/using-sqlite-in-windows-store-apps.aspx. Note, you need to retarget the project to 8.1 and then get two sqlite packages from NuGet before building this sample.
    Step 2: Use some special classes to get file from serer.
    HttpWebRequest can help download small pdf files. For more information to see
    https://social.msdn.microsoft.com/Forums/windowsapps/en-US/de96a61c-e089-4595-8349-612be5d23ee6/download-file-with-httpwebrequest?forum=winappswithcsharp. It’s easy for use, but if you want to download the larger or many files, it’s recommend to use
    BackgroundTransfer namespace. The classes in this namespace provide a power way to transfer files in the background. See a code sample from MSND.
    https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61.
    Regards,
    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.

  • Download PDF file from APP server!

    Hi!
    Has anyone tried uplaoding and downloding a PDF table from app server as I tried from a normal method by Open dataset, Transfer but it wont work.
    Please provide any inputs.
    Thanks.

    Hi park,
    1. Using open data set, transfer , close etc,
       also it will work.
       ( it will download / upload any kind of file from app server)
    2. Just make sure the
       FULL PATHNAME and the FILENAME
       are mentioned in EXACT CASE
      (small/CAPITAL).
    3. U can check thru transaction AL11, to see the file and path.
    regards,
    amit m.

  • Error while downloading PDF file from FTP Server

    Hi Friends,
    I have sent a PDF file with data to FTP , Then i want to check that uploaded pdf file , whether that is correct or not?
    for that , i have downloaded that file from FTP and i am trying to open the file . but it is giving this problem .
    "There was an error opening the document . The file is damaged and could not be repaired."
    will you suggest me regarding this.
    thanks in advance.
    balaji.T.

    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
              EXPORTING
           SRC_SPOOLID                    = spoolno
                src_spoolid                    = wa_file-rqident
                no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
              IMPORTING
                pdf_bytecount                  = numbytes
                pdf_spoolid                    = pdfspoolid
          OTF_PAGECOUNT                  =
                btc_jobname                    = jobname
                btc_jobcount                   = jobcount
              TABLES
                pdf                            = pdf
              EXCEPTIONS
                err_no_otf_spooljob            = 1
                err_no_spooljob                = 2
                err_no_permission              = 3
                err_conv_not_possible          = 4
                err_bad_dstdevice              = 5
                user_cancelled                 = 6
                err_spoolerror                 = 7
                err_temseerror                 = 8
                err_btcjob_open_failed         = 9
                err_btcjob_submit_failed       = 10
                err_btcjob_close_failed        = 11.
    because of this one PDF internal table is obtained.
           OPEN DATASET L_FILENAME  FOR OUTPUT in text mode  MESSAGE MSG.
      LOOP AT pdf.
        CONCATENATE pdf-tdformat       "Material group
                     pdf-TDLINE       "Basic Material
               INTO ITEXT-TLINE ..
        APPEND ITEXT.
        TRANSFER ITEXT TO L_FILENAME.
      ENDLOOP.

  • How to download a file from application server in webdynpro

    Hi Experts,
                       I am trying to download a file through Web Dynpro file download UI element..The file is stored in application server in binary format ..in my code i am reading the file in binary mode,converting Binary File into Xstring(Using FM SCMS_BINARY_TO_XSTRING) ..getting its Mime type and binding the UI element properties (data with XString, Mime type and file name) with respective context attributes..But the problem is file is getting opened but Junk data is getting displayed on it..Not sure where i am making the mistake.

    Hi Lukas,thanks for the reply..please find the code
    here '/tmp/accenturedocs'  is the folder name on application server,and zdocs_list_tab is the table that contains file URL.File upload is on the BSP page (custom logic to upload the file ) where they are storing local file path in ztable.Same i am extracting in my code to get File URL.
    DATA: i_file TYPE rlgrap-filename .
      DATA:v_path TYPE zlist.
      DATA:i_datatab TYPE STANDARD TABLE OF tbl1024,
           wa_datatab TYPE   tbl1024.
      DATA  file TYPE  string.
      DATA dot_offset TYPE i.
      DATA extension TYPE mimetypes-extension.
      DATA mimetype TYPE mimetypes-type.
      SELECT SINGLE description
        FROM  zdocs_list_tab
        INTO v_path.
      CONCATENATE '/tmp/accenturedocs' v_path INTO i_file.
      FIELD-SYMBOLS <hex_container> TYPE x.
      OPEN DATASET i_file FOR INPUT IN LEGACY BINARY MODE.
      IF sy-subrc NE 0.
        MESSAGE e999(00) WITH 'Error opening file' .
      ENDIF.
      ASSIGN  wa_datatab TO <hex_container> CASTING.
      DO.
        READ DATASET i_file INTO <hex_container>.
        IF sy-subrc = 0.
          APPEND wa_datatab TO i_datatab.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET i_file.
      DATA:l_count TYPE i,
            l_len TYPE i.
      DESCRIBE TABLE i_datatab LINES l_count.
      READ TABLE i_datatab INTO wa_datatab INDEX l_count.
      l_len = XSTRLEN( wa_datatab-line ).
      l_len = l_len + ( l_count - 1 ) * 1022.
    DATA: v_xstring TYPE xstring.
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = l_len
        IMPORTING
          buffer       = v_xstring
        TABLES
          binary_tab   = i_datatab
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
      ENDIF.
    file = i_file.
      " Find out file name extension
      FIND FIRST OCCURRENCE OF REGEX '\.[^\.]+$' IN file MATCH OFFSET
      dot_offset.
      ADD 1 TO dot_offset.
      extension = file+dot_offset.
      " Get mime type
      CALL FUNCTION 'SDOK_MIMETYPE_GET'
        EXPORTING
          extension = extension
        IMPORTING
          mimetype  = mimetype.
    DATA lv_file_content TYPE wd_this->element_context-file_content.
    get element via lead selection
      lo_el_context = wd_context->get_element( ).
    set single attribute
      lo_el_context->set_attribute(
        name =  `FILE_CONTENT`
        value =  v_xstring ).
    same way i am assigning file name and file mime type to context attributes.
    please suggest where is the mistake.

  • Urgent : Download file from Application Server via Process Chain.

    Hi Experts,
    My requirement is to download the file from Application Server to local work station using an ABAP Program .
    I want including the above ABAP program in a process chain to execute  the program daily,
    I tried to use ARCHIVFILE_SERVER_TO_CLIENT and GUI_DOWNLOAD but unfortunately both the above FM doesn't support to run through Process chain.
    Can any one of you help me to send the code which selects a file from application server, downloads to local system and deletes it.
    Thank you very much for spending your precious time in this regard.

    Hi Sailekha,
    Regarding your case ..
    I suggest you to create the program where it run this function: WS_DOWNLOAD.
    After it, the program is run by your process chain.
    Hopefully it can help you a lot.
    Regards,
    Niel.
    thanks for the points you choose to assign.

  • Not able to get file from application server with read dataset

    Hi,
    Firstly i download a file from application server from read data set and then i sent this file as attachment. But problem is that i am able to send .jpg .bmp file but i am not able to send .pdf or .doc file so what can i do for that. ?
    My code is like below...
      DATA : PATH TYPE STRING.
      DATA: E_FILE LIKE RLGRAP-FILENAME.
      CONCATENATE '/tmp/'  NAME_WITH_EXT INTO E_FILE SEPARATED BY SPACE.
      CONDENSE E_FILE NO-GAPS.
      IF EXTENSION = 'TXT'.
        OPEN DATASET E_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH WINDOWS LINEFEED . " MESSAGE MSG.
        IF SY-SUBRC <> 0.
       WRITE: SY-SUBRC, MSG, ' LIKE ', C_FNAME.
        ELSE.
          WHILE SY-SUBRC = 0.
            READ DATASET E_FILE INTO WA_C.
            IF SY-SUBRC <> 0.
              EXIT.
            ENDIF.
            APPEND WA_C TO IT_C.
          ENDWHILE.
          CLOSE DATASET E_FILE.
        ENDIF.
      ELSE.
        OPEN DATASET E_FILE FOR INPUT IN BINARY MODE. " ENCODING DEFAULT. "    INPUT IN  BINARY MODE . " TEXT MODE ENCODING   NON-UNICODE.
        IF SY-SUBRC = 0.
          DO .
            READ DATASET E_FILE INTO GS_PDF_TAB.
            IF SY-SUBRC = 0.
              APPEND GS_PDF_TAB TO GT_PDF_TAB.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
          CLOSE DATASET E_FILE.
        ENDIF.
      ENDIF.
    Regards,
    Gurprit Bhatia

    delete this line DEFAULT WITH WINDOWS LINEFEED  and check this..

  • 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

  • How to delete file from application server(Unix)

    Hi All,
    Using the below code downloading a file from application server(Unix) to client machine. I want to delete the file from application server once it is downloaded to client
    We work on Forms 11.1.1.4.0 and Oracle DB 10g. Client machine are Windows 7.
    BEGIN
      IF webutil_file_transfer.AS_to_Client
      (clientFile => Name_In('global.g_file_name')
      ,serverFile => ls_AppServer_Loc)THEN
      message('Data exported Successfully');
      ELSE
       message('File download from Application Server failed');
      END IF;
    EXCEPTION
      WHEN OTHERS THEN
      message('File download failed: '||SUBSTR(sqlerrm,1,200));
      END;
    I have search for solution on OTN. Few suggested to use HOST.
    Can any one help me how to use Host() built_in to delete the file.
    Thanks,
    Maddy

    Can any one help me how to use Host() built_in to delete the file.
    Host('/bin/rm <complete file path>');

  • Read Tab delimited File from Application server

    Hi Experts,
    I am facing problem while reading file from Application server.
    File in Application server is stored as follows, The below file is a tab delimited file.
    ##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
    i have downloaded this file from Application server using Transaction CG3Y. the Downloaded file is a tab delimited file and i could not see "#' in the file,
    The code is as Below.
    c_split  TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab.
    here i am using IGNORING CONVERSION ERRORS in order to avoid Conversion Error Short Dump.
    OPEN DATASET wa_filename-file FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
          IF sy-subrc = 0.
            WRITE : /,'...Processing file - ', wa_filename-file.   
           DO.
          Read the contents of file
              READ DATASET wa_filename-file INTO wa_file-data.
              IF sy-subrc = 0.
                SPLIT wa_file-data AT c_split INTO wa_adrc_2-kunnr
                                                   wa_adrc_2-title
                                                   wa_adrc_2-name1
                                                   wa_adrc_2-name2
                                                   wa_adrc_2-name3
                                                   wa_adrc_2-name4
                                                   wa_adrc_2-name_co
                                                   wa_adrc_2-city1
                                                   wa_adrc_2-city2
                                                   wa_adrc_2-regiogroup
                                                   wa_adrc_2-post_code1
                                                   wa_adrc_2-post_code2
                                                   wa_adrc_2-po_box
                                                   wa_adrc_2-po_box_loc
                                                   wa_adrc_2-transpzone
                                                   wa_adrc_2-street
                                                   wa_adrc_2-house_num1
                                                   wa_adrc_2-house_num2
                                                   wa_adrc_2-str_suppl1
                                                   wa_adrc_2-str_suppl2
                                                   wa_adrc_2-country
                                                   wa_adrc_2-langu
                                                   wa_adrc_2-region
                                                   wa_adrc_2-sort1
                                                   wa_adrc_2-sort2
                                                   wa_adrc_2-deflt_comm
                                                   wa_adrc_2-tel_number
                                                   wa_adrc_2-tel_extens
                                                   wa_adrc_2-fax_number
                                                   wa_adrc_2-fax_extens
                                                   wa_adrc_2-taxjurcode.
    WA_FILE-DATA is having below values
    ##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
    And this is split by tab delimited and moved to other variables as shown above.
    Please guide me how to read the contents without "#' from the file.
    I have tried all possible ways and unable to get solution.
    Thanks,
    Shrikanth

    Hi ,
    In ECC 6 if all the unicode patches are applied then UTF 16 will defintly work..
    More over i would suggest you to ist replace # with some other  * or , and then try to see in debugging if any further  # appears..
    and no # appears then try to split now.
    if even now the # appears after replace statement then try to find out what exactly is it... wheather it is a horizantal tab etc....
    and then again try to replace it and then split..
    Please follow the process untill all the # are replaced...
    This should work for you..
    Let me know if you further face any issue...
    Regards
    Satish Boguda

  • Error in Reading the file from Application Server

    Hi,
    This Error is regarding one of my interface, the issue is that , the interface reads data from file in bunch suppose 100 records at a time , then processes those records and once finished go for next 100 records .
    Noe the error is that , the process takes place till 500 records correctly but when it went to fetch for next 100 i.e fom 501 to 600 it selects only 501 to 583 .
    this records has been processed successfully but the job finished there only
    but the file contains 788 records
    When the same file has been run in other server it ran successfully without such error .
    Can you please suggest how to resolve the issue

    Hi,
    Try to manually download the file from application server using standard transactions, and than check how many records are you able to download from app. server.
    I guess there might be something wrong with the format of 583rd record, which makes sap assume that the file has come to an end.
    Hope this will help you.
    Regards,
    Vinit...

  • Problem while dowloading the file from Application Server

    Dear Experts,
                 I am facing the Problem while downloading the file from Application server.
    We done the automatic function while saving the invoice, this will create an idoc, and this idoc is written in the Application Server.
    I am running the Transaction AL11 and select the record, and from menu --> List, i am downloading into TXT format.
    But for some segments, the length is long, and so the last 3 to 4 fields values are not appearing in the File. Even though i am unable to view the values in the file before downloading. But i can view in IDOC.
    Please help me to solve this issue.
    Thanks & Regards,
    Srini

    but our user will use the Txn. AL11 and they will download from there
    Educate the user On a serious note, tell him this is not how data from app server should be downloaded. You can ask him to talk to the basis team to provide him access to the app server folder where the file is being stored.
    I can set the Variant and put this in background, But always the file name will be change, Like we use Time stamp in the File name.
    You can't automate this process by scheduling in BG mode. This is because the in BG mode you can't dwld the file to presentation server.
    Hope i'm clear.
    BR,
    Suhas

  • 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

Maybe you are looking for