PDF file write to application server

Hi All,
I want to write PDF file to application server while downloading 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 )
  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.

Similar Messages

  • Save PDF-file on the application server

    Hello experts,
    I convert my Smartform to a PDF-File. I copied the code from  Suresh Kumar Parvathaneni (REPORT zsuresh_test). At first, thank you Suresh Kumar for that!
    Now, I would like to save the PDF-File on the application server and not local.
    Could you tell me how to do this. Especially, where do I have to put the abap-code in the given code from Suresh Kumar.
    I thank you very much for your help in advance.
    With kind regards.
    gokselin

    Hi,
    You can use the OPEN DATASET statment.
    Probably you must be having an output table which you are downloading to the local machine.You can use the same and loop at it. and if the OPEN dataset returned sy-subrc 0, use the TRANSFER statment.
    Remember the data will be binary for pdf. So you have to open the dataset in binary mode.
    regards,
    Advait

  • Download PDF File to SAP Application Server

    Hi,
    I need to download the PDF file to SAP Application Server. Can any one please help me to Solve this Issue?
    Thanks in Advance,
    Kannan

    You can read and upload the file to the PC:
    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:temptest.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.
    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:temptestn.pdf'
              filetype     = 'BIN'
              bin_filesize = length
         importing
              filelength   = lengthn
         tables
              data_tab     = itab.
    Rob

  • Regarding the uploading the pdf file to the application server

    hi,
    iam getting this error while uploading the pdf file to the applicatioin server.
    "There was an error while trying to parse an image"
    to convert smartform into PDF file we ll use convert_otf FM.
    If see that FM data ll be stored in it_tline structure ok.
    For sending to application server we ll use
    OPEN DATASET p_arch for OUTPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
      LOOP AT it_tline.
      TRANSFER it_tline to p_arch.
      ENDLOOP.
      CLOSE DATASET p_arch.
    Ok
    For getting data from internal table we ll use
    OPEN DATASET p_arch FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS
    do.
      READ DATASET p_arch INTO it_tline.
      if sy-subrc = 0.
        APPEND it_tline.
        ELSE .
          exit.
          endif.
      enddo.
    CLOSE DATASET p_arch.
          LOOP AT it_tline.
        TRANSLATE it_tline USING '~'.
        CONCATENATE wa_buffer it_tline INTO wa_buffer.
      ENDLOOP.
      TRANSLATE wa_buffer USING '~'.
      DO.
        i_record = wa_buffer.
        APPEND i_record.
        SHIFT wa_buffer LEFT BY 255 PLACES.
        IF wa_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    Attachment
      REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
      CLEAR wa_objhead.
      i_objbin[] = i_record[].
    Create Message Body
    Title and Description
      i_objtxt = 'COMMERCIAL INVOICE'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      wa_doc_chng-obj_name   = 'COMMERCIAL INVOICE'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr  = 'COMMERCIAL INVOICE'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size   = v_lines_txt * 255.
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num   = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num   = v_lines_txt.
      i_objpack-doc_type   = 'RAW'.
      APPEND i_objpack.
    Attachment
    (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num   = 0.
      i_objpack-body_start = 1.
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
      READ TABLE i_objbin INDEX v_lines_bin.
      i_objpack-doc_size =  v_lines_bin * 255 .
      i_objpack-body_num  = v_lines_bin.
      i_objpack-doc_type  = 'PDF'.
      i_objpack-obj_name  = 'COMMERCIAL INVOICE'.
      i_objpack-obj_descr = 'COMMERCIAL INVOICE'.
      APPEND i_objpack.
    BREAK-POINT.
      IF it_adr6[] IS NOT INITIAL.
        LOOP AT it_adr6 INTO wa_adr6.
          CLEAR i_reclist.
          i_reclist-receiver = wa_adr6-smtp_addr.
          i_reclist-rec_type = 'U'.
          i_reclist-com_type = 'INT'.
          APPEND i_reclist.
        ENDLOOP.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data = wa_doc_chng
            put_in_outbox = 'X'
          TABLES
            packing_list  = i_objpack
            object_header = wa_objhead
            contents_bin  = i_objbin
            contents_txt  = i_objtxt
            receivers     = i_reclist.
      ENDIF.
    The above error I am getting.
    Please give your suggestions
    Thanks in advance

    U can use this code
    Reward if useful
    REPORT  ZMN_PDF_UPLOAD.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\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.

  • Upload the doc , pdf  file presentation to application server

    When upload file from presentaion to application server other then text
    file data is corruption in wed dynpro application using the UI element
    of UPLOAD. we used the code in custom application when we checked in
    T.Code : 'AL11'. only text file is showing file other then text file
    data is showing as corrupt.
    code:
    elem_sel_opt_1->get_attribute(
    EXPORTING
    name = 'DATASOURCE'
    IMPORTING
    value = gd_data ).
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    EXPORTING
    in_xstring = gd_data
    IMPORTING
    out_string = gd_filedata.
    SPLIT gd_filedata AT cl_abap_char_utilities=>newline INTO TABLE
    ist_data.
    Opening the File
    OPEN DATASET gd_file_appl IN TEXT MODE FOR OUTPUT ENCODING DEFAULT. IF sy-subrc NE 0.
    WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
    EXIT.
    ENDIF.
    Transferring Data
    LOOP AT ist_data INTO wa_data.
    TRANSFER wa_data TO gd_file_appl.
    ENDLOOP.
    Closing the File
    CLOSE DATASET gd_file_appl.
    is it problem with my code. is it problem with UI element.
    for file uploading the prasentation server to appliation.
    we try with binary mode also
    Regards
    Praveen Chetpally.

    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.

  • Open a pdf file located on Application Server from forms 10g

    Dear all,
    I want to open a pdf file which is stored in a folder on Application Server.
    I have the following codes but could not be able to open the file.
    1. host('rundll32 url.dll,FileProtocolHandler C:\REP012.pdf');
    in this code I mentioned the path on local machine which is okey.
    but the question is that how to open the file which is located in a folder on application server?
    the following code don't show and file or error:
    host('rundll32 url.dll,FileProtocolHandler /EMS/MANUALS/ACC001.PDF');
    This is the file on Application Server not on local machine.
    2. web.show_document('//EMS/MANUALS/ACC001.PDF/','_blank');
    This give HTTP 404 NOT FOUND error
    I think the problem is in path, how to mention the path of my Application Server file?
    Regards:
    Muhammad Nadeem

    Hi,
    Did you find a solution to this?
    We are running into the same problem where we need to open a file present on the application server (path /opt/webapps/applications/ISL/)
    When we try this from the local machine it works (path D:/forms) however it does not work while trying to open it from the application server.
    Regards,
    Pooja

  • Unale to print pdf files in oracle application server using oracle forms

    Hi
    We are using oracle developer suite 10g(10.1.2.3.0) in Windows vista. (test environment)
    Oracle application server 10g(10.1.2.3.0) in Hp-UX 11iv3 (production environment)
    We are able to print pdf files in test environment from oracle forms using the below command:
    host('/usr/bin/lp -d p9775hplaser '||'/ashome/output/'||:print_file);
    But while declaring to the live environment it is not working
    host('cat '||:pdf_print_file||' | acroread -toPostScript | /usr/bin/lp -dp9775hplaser');
    but when the above command is put in hp-ux cmd prompt it is workinh"'cat '||:pdf_print_file||' | acroread -toPostScript | /usr/bin/lp -dp9775hplaser'";
    Kind ly tell me whether the problem i with the host command and some other command is available for printing files from forms.

    Here is my guess:
    declare
    AppID PLS_INTEGER;
    begin
    AppID := DDE.App_Begin('acroread -toPostScript '||file name,DDE.APP_MODE_MINIMIZED);
    end;

  • How can I upload a pdf file into the application server?

    Hi,
    I have the otf data, which i have converted into pdf using the funcation module "Convert_otf". Is it possible to upload the pdf file in application server?

    Dear Srishti,
    Use OPEN DATASET in BINARY MODE.
    following link will help you.
    http://scn.sap.com/thread/1480434
    thanks,
    vidyasagar

  • How to check file format in application server?

    Hi guys,
    i have an inbound zip file(which contains PDF files) in the application server .I need to check if the file is in base 64 format or in hexadecimal format.Can any one help me out with the suggestions or with probable solution.
    Regards
    Snehasish

    Thanks for your reply.i am able to get the the zip file data in xstring with following code .
    .now what should be logic to determine that the data in xstring is in base 64 or in hexadecimal format?
    data: lv_zip type xstring.
    OPEN DATASET lc_file FOR INPUT IN binary MODE.
    IF sy-subrc = 0.
    read dataset lc_file into lv_zip.
    endif.
    CLOSE DATASET lc_file.
    Regards
    Snehasish

  • How to see the file at the application server

    HI TO ALL SDNERS ,
                                 THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO.
    Program Name        : ZME11_BDC.
    Title               : PURCHASE INFORMATION RECORD LOAD PROGRAM
    Program Objective   : THIS PROGRAM READS IN THE PURCHASE
                          INFORMATION FILE. IT CREATES A BDC SESSION TO
                          USE TO LOAD THE PURCHASE INFORMATION RECORDS
                          INTO SAP using the ME11 Transaction.
    REPORT  ZME11_BDC no standard page heading MESSAGE-ID ZHNC line-size 55.
                constants declaration
    constants: c_x value 'X',
               c_sess type apqi-groupid value 'zcustomer',
               c_xd01 type tstc-tcode value 'ME11'.
                  DECLARING VARIABLES
    DATA: V_MSG(255),
          V_ERREC TYPE I,"NO OF FAILED RECORDS
          V_LINES."NO OF RECORDS
           FLAG DECLARATIONS
    DATA: FG_DATA_EXIST VALUE 'X',"CHECK FOR DATA
          FG_SESSION_OPEN VALUE ''.
          STRUCTURES AND INTERNAL TABLE DECLARATIONS
    TYPES :BEGIN OF TY_PIR,
             LIFNR TYPE EINA-LIFNR,
             MATNR TYPE EINA-MATNR,
             EKORG TYPE EINE-EKORG,
             WERKS TYPE EINE-WERKS,
             VERKF TYPE EINA-VERKF,"sales person
             TELF1 TYPE EINA-TELF1,"telephone
             URZLA TYPE EINA-URZLA,"country
             REGIO TYPE EINA-REGIO,"region
             APLFZ(5),"plan deleivery time
             EKGRP TYPE EINE-EKGRP,"purchase group
             NORBM(13),
             NETPR(13),
         END OF TY_PIR.
    DATA : IT_PIR TYPE TABLE OF TY_PIR,
           WA_PIR LIKE LINE OF IT_PIR.
    DATA: BEGIN OF IT_BDCDATA.
    INCLUDE STRUCTURE BDCDATA.
    DATA END OF IT_BDCDATA.
    DATA : BEGIN OF IT_BDCMSG.
    INCLUDE STRUCTURE BDCMSGCOLL.
    DATA END OF IT_BDCMSG.
                      SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER : FNAME TYPE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF BLOCK B1.
                           AT SELECTION ON VALUE REQUEST
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = SYST-CPROG
       DYNPRO_NUMBER       = SYST-DYNNR
       FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = FNAME.
                             START OF SELECTION
    START-OF-SELECTION.
    PERFORM F_GET_DATA USING FNAME
                       CHANGING IT_PIR.
    PERFORM F_GENERATE_DATASET USING FNAME
                               CHANGING IT_PIR WA_PIR.
    *&      Form  F_GET_DATA
          text
         -->P_V_FNAME  text
         <--P_IT_PIR  text
    FORM F_GET_DATA  USING    P_FNAME LIKE FNAME
                     CHANGING P_IT_PIR LIKE IT_PIR.
    DATA: LV_FILE TYPE STRING.
    LV_FILE  = FNAME.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = LV_FILE
       FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = P_IT_PIR
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF P_IT_PIR IS INITIAL.
    FG_DATA_EXIST = ''.
    ENDIF.
    ENDFORM.                    " F_GET_DATA
    *&      Form  F_GENERATE_DATASET
          text
         -->P_V_FNAME  text
         <--P_IT_PIR  text
    FORM F_GENERATE_DATASET  USING    P_V_FNAME LIKE FNAME
                             CHANGING P_IT_PIR LIKE IT_PIR
                                      P_WA_PIR LIKE WA_PIR.
    MESSAGE I001(ZHNC).
    *OPENING FILE AT THE APPLICATION SERVER FOR WRITING
    OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC  EQ 0.
    MESSAGE I002(ZHNC).
    LOOP AT P_IT_PIR INTO P_WA_PIR.
    SPLIT P_WA_PIR AT '*' INTO P_WA_PIR-LIFNR
                               P_WA_PIR-MATNR
                               P_WA_PIR-EKORG
                               P_WA_PIR-WERKS
                               P_WA_PIR-VERKF
                               P_WA_PIR-TELF1
                               P_WA_PIR-URZLA
                               P_WA_PIR-REGIO
                               P_WA_PIR-APLFZ
                               P_WA_PIR-EKGRP
                               P_WA_PIR-NORBM.
    *TRANSFER THE FILE FROM INTERNAL TABLE TO APPLICATION SERVER
    MESSAGE I003(ZHNC).
    TRANSFER P_WA_PIR TO FNAME.
    ENDLOOP.
    *CLOSING THE FILE AT THE APPLICATION SERVER
    CLOSE DATASET FNAME.
    ENDIF.

    Hello,
    I made a similar program. You can have a look at it.
    *&      Form  write_to_app_server
          text
    -->  p1        text
    <--  p2        text
    FORM write_to_app_server.
    To get filename
      PERFORM get_filename.
    To write into the application server
      OPEN DATASET g_filename_with_path FOR OUTPUT IN TEXT MODE.
      IF sy-subrc = 0.
        LOOP AT <l_table> INTO <l_line>.
          TRANSFER <l_line> TO g_filename_with_path.
        ENDLOOP.
        CLOSE DATASET g_filename_with_path.
      ELSE.
        CLOSE DATASET g_filename_with_path.
      ENDIF.
    To send mail
      PERFORM send_mail.
    ENDFORM.                    " write_to_app_server
    *&      Form  get_filename
          text
    -->  p1        text
    <--  p2        text
    FORM get_filename.
      DATA : l_log_path TYPE  filepath-pathintern
                          VALUE 'Y28M_DOWNLOADS_BACKGROUND' .
      CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
           EXPORTING
                client                     = sy-mandt
                logical_path               = l_log_path
                operating_system           = sy-opsys
                file_name                  = p_fname
           IMPORTING
                file_name_with_path        = g_filename_with_path
           EXCEPTIONS
                path_not_found             = 1
                missing_parameter          = 2
                operating_system_not_found = 3
                file_system_not_found      = 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.
    ENDFORM.                    " get_filename
    You may find it useful.
    Regards,
    Karuna.

  • File from the Application server

    Hi gurus,
    I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
    Thanks
    Rajeev Gupta

    Hi
    Declare the selection screen with file as parameter so that the user enter the application server file..
    the use the OPEND DATASET  as mentioned in below code and process
    Refer this:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *                     &----
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.
    Regards
    Anji

  • Various ways to place a File in the Application Server.

    Hi all,
       What are the various ways to place a file in the application Server.
          Please classify them as shown below.
          1. Use of ABAP Code.
           2. Without the use of ABAP code.
    Regards

    Hi
    <b>1. Use of ABAP Code.</b>
    by writing code like this
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    *   PROGRAM_NAME        = SYST-REPID
    *   DYNPRO_NUMBER       = SYST-DYNNR
    *   FIELD_NAME          = ' '
       STATIC              = 'X'
    *   MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.
    Here is a pseudo code for what you are looking for-
    OPEN DATASET P_FLPTH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC eq 0.
    LOOP AT LT_TAB INTO LS_TAB.
    TRANSFER LS_TAB TO P_FLPTH.
    ENDLOOP.
    CLOSE DATASET P_FLPTH.
    if sy-batch = 'X'.
    write:/ 'File uploaded successfully'.
    else.
    message sXXX with 'File uploaded successfully'.
    endif.
    Else.
    if sy-batch = 'X'.
    write:/ 'Error in File upload'.
    else.
    message sxxx with 'Error in File upload'.
    endif.
    LEAVE PROGRAM.
    ENDIF.
    <b>2. Without the use of ABAP code.</b>
    CG3Y -
    Appl to Presentation server
    <b>Reward if useful</b>

  • Upload and download of  excel file in the application server in background

    Hi all,
    i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
    i mean i'll schedule the program in background.
    im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
    what method i have to follow ?

    Hi Ankit,
    I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
    In my opinion you have two possibilities:
    1. Convert all files in the CSV format. This file format can be read with open dataset.
    2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
    My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
    Regards
    Dirk

  • File upload to application server

    hi,
        i wanna upload a CSD file into the application server is there any FM to do these.
       while the program is executed i wanna check whether it is being executed in the foreground or background,if the report is executed is executed in the background a CSD file has to be generated.
    its urgent and surely pionts are granted.

    1) if it is one time only then u can make use of transaction CG3Y and CG3Z to download/upload fiel frm or to application server.
    0r
    2) refer this code to donwload/upload file on Aserver
    REPORT  ZGILL_AS    message-id rp                            .
    tables: pa0001,pa0002.
    select-options s_pernr for pa0001-pernr no intervals MODIF ID XYZ.
    parameters: p_dwnld AS CHECKBOX ,
                p_upld AS CHECKBOX  DEFAULT 'X'.
    parameters: P_DSNI(75)                   TYPE C MODIF ID ABG DEFAULT
              '/usr/local/sapdata/amit.dat' LOWER CASE.
    data: begin of itab occurs 0,
          pernr(8),
          sp1(1) value ',',
          werks(4),
          sp2(1) value ',',
          persg(1),
          sp3(1) value ',',
          persk(2),
          end of itab.
    data: s_eof(3).
    start-of-selection.
    if p_upld = 'X'.
    OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.
    PERFORM FETCH_DATA.
    STOP.
    elseif p_dwnld = 'X'.
    OPEN DATASET P_DSNI FOR INPUT IN LEGACY TEXT MODE.
    IF  SY-SUBRC               NE        0.
        MESSAGE E016 WITH
          'Error opening seq. file, RC:' SY-SUBRC.
        EXIT.
      ENDIF.
    CLEAR S_EOF.
    DO.
        PERFORM FETCH_file.
        IF  S_EOF EQ 'YES'. stop. ENDIF.
    ENDDO.
    endif.
    END-OF-SELECTION.
      if itab[] is not initial.
         perform  print_file1 tables itab.
       else.
       write:/ 'No records exists'.
       endif.
    *&      Form  FETCH_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_DATA .
    SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.
    MOVE-CORRESPONDING PA0001 TO ITAB.
    TRANSFER ITAB TO P_DSNI.
    APPEND ITAB.
    ENDSELECT.
    CLOSE DATASET P_DSNI.
    ENDFORM.                    " FETCH_DATA
    *&      Form  FETCH_file
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_file .
    READ DATASET P_DSNI INTO itab.
    append itab.
    clear itab.
    IF  SY-SUBRC               NE        0.
        S_EOF = 'YES'. EXIT.
    ENDIF.
    ENDFORM.                    " FETCH_file
    *&      Form  print_file1
          text
         -->P_ITAB  text
    FORM print_file1  tables P_ITAB structure itab .
    write:/2 'EmpNo',
           14 'Personnel Area',
           34 'Emp Group',
           47 'Emp SubGroup'.
    skip 1.
    loop at p_itab.
    write:2  p_itab-pernr,
          14 p_itab-werks,
          34 p_itab-persg,
          47 p_itab-persk.
    skip 1.
    endloop.
    ENDFORM.                    " print_file1
    3) for ur third requirement make use of sy-batch field.

  • Create a Document with an original file stored on application server

    Hello,
    I start with document managment system : i am able to create new document (CV01N) manually, add a local file and check-in this file.
    Now we need to store file which are stored on the SAP Application Server.
    Firstly, in the GUI of transaction CV01N, i don't know how to browse file on application server. All files i can't attach as original, are files i can access from my computer.
    Is it possible to access also on application server files ?
    Moreover, i have to define function module which have to
    - Create a document (DMS)
    - Attach an orginial file which is stored on application server
    - Check-in the file
    This function module will be called from a web application
    I define this kind of function and run it correctly with a local file (stored on my computer) : i call BAPI "BAPI_DOCUMENT_CREATE2" and "BAPI_DOCUMENT_CHECKIN2"
    But i don't how to do with a file stored on application server. I see also note 504692 and try a program like ZZUZTEST_TEST_CHECKIN which use FM CVAPI_DOC_CHECKIN but it return an error Error uploading  E:\usr\sap\TD1\DVEBMGS00\data\FACTURE.txt" (this path and file exist on application server and is really the file i want to checkin)
    Please could you confirm what i search, is possible or not.
    If possible, could help me with some explanations and guidelines and perhaps a sample ?
    Thank you very much.
    Regards,
    Eric
    The function used
    FUNCTION Z_TEST_CHECKIN.
    Checkin the first original of a document info record *
    from the application server and/or in the background *
      data   : w_host like BAPI_DOC_AUX-HOSTNAME.
      data: lf_line(255).
      data: ls_draw like DRAW,
            ls_message_cvapi like messages,
            lt_files_cvapi type standard table of CVAPI_DOC_FILE,
            lt_files_cvapi_header like CVAPI_DOC_FILE.
      data: lt_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE,
            vo_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE.
      ls_draw-dokar = 'ZFT'.
      ls_Draw-doknr = '0000000000000004500000032'.
      ls_Draw-dokvr = '00'.
      ls_Draw-doktl = '000'.
    Read Originals contained in the document info record
      CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
        EXPORTING
          pf_batchmode    = 'X'
          pf_hostname     = ' '
          pf_dokar        = ls_draw-dokar
          pf_doknr        = ls_draw-doknr
          pf_dokvr        = ls_draw-dokvr
          pf_doktl        = ls_draw-doktl
          pf_active_files = 'X'
        IMPORTING
          psx_draw        = ls_draw
        TABLES
          pt_files        = vo_originals
        EXCEPTIONS
          not_found       = 1
          no_auth         = 2
          error           = 3
          OTHERS          = 4.
      IF sy-subrc <> 0.
        WRITE 'Error returned by CVAPI_DOC_GETDETAIL'.          "#EC NOTEXT
        EXIT.
      ENDIF.
    Check if we can really access the file from the application server
      read table vo_originals index 1.
      open dataset vo_originals-filename for input in text mode ENCODING DEFAULT.
      if not sy-subrc is initial.
        message e500(26) with vo_originals-filename 'not found'.
      endif.
      read dataset vo_originals-filename into lf_line.
      if not sy-subrc is initial.
        message e500(26) with vo_originals-filename 'read error'.
      endif.
      lt_originals             = vo_originals.
      lt_originals-STORAGE_CAT = 'SAP-SYSTEM'.
      append lt_originals.
      w_host = sy-host.
      CALL FUNCTION 'CVAPI_DOC_CHECKIN'
      EXPORTING
      PF_DOKAR = ls_draw-dokar
      PF_DOKNR = ls_draw-doknr
      PF_DOKVR = ls_draw-dokvr
      PF_DOKTL = ls_draw-doktl
    PS_DOC_STATUS =
      PF_FTP_DEST = 'SAPFTPA'
      PF_HTTP_DEST = 'SAPHTTPA'
    *PF_HOSTNAME =  w_host
    PS_API_CONTROL =
    PF_REPLACE = ' '
    PF_CONTENT_PROVIDE = 'SRV'
      IMPORTING
      PSX_MESSAGE = ls_message_cvapi
      TABLES
      PT_FILES_X = lt_originals
    PT_COMP_X =
    PT_CONTENT =
      IF ls_message_cvapi-msg_type CA 'EA'.
        ROLLBACK WORK.
        MESSAGE ID '26' TYPE 'I' NUMBER '000'
        WITH ls_message_cvapi-msg_txt.
      ELSE.
        COMMIT WORK and wait.
      ENDIF.
    ENDFUNCTION.

    This is a bit tricky. I spent lots of hours about this .
    You have to set PF_HOSTNAME with your name of your AS and gives the path to the file on the server.
    You wrote
    *PF_HOSTNAME = w_host
    But beware: if you have more thän one AS you have to fix one AS for upload or you have to find the servers name of the file. A better way can be to share one folder by each AS.
    You also have to decide between HTTP or FTP.
    You wrote:
      PF_FTP_DEST = 'SAPFTPA'
      PF_HTTP_DEST = 'SAPHTTPA'
    You must define only one ! Then you have to check your settings in SM59 about working right.
    Pls rate, if this was helpful.
    Regards,
    Markus

Maybe you are looking for

  • Send existing html file as the message

    Hi I have a small program developed in netbeans that uses ireport and the javadb. The program takes some data from the database and using my ireport jasper file, creates a file in html format. My question is this: Is there a simple way to send this f

  • Regarding Exception in Debug mode.

    Hi All, when i am starting Debugger, it is giving an error like:- Exception occured during creating launch configuration tabd. reason:-No tab group define for launch configuration type com.sap.ide.webdynpro.projecrbrowser..launch.configtype.debug Any

  • Please Apple...we're very tired of "Publish Error" on iWeb

    Over the past two days, we've all grown very tired of "PUBLISH ERROR: Mac account credentials validation failed for account." Is there a reason for the problem you could perhaps share with us? Are you applying all possible resources to correcting the

  • Unable to Use Google Maps

    I have recently upgraded to Mac OSX 10.8.4 and use the latest Safari browser (v6.0.5) all the time.  At some point, since I use iGoogle as my homepage, my maps changed to the Google Maps version now in place.  I am unable to use it, as it never chang

  • Adobe CS4 (64bit) Potoshop, InDesign, Premiere crashes on startup

    I am in need of some major help.  I have a user who only on his profile Adobe Potoshop, InDesign, and Premiere crash on startup.  I've tried most of the basic trouble shooting but still not working.  Any Ideas? Computer Specs: HP z400 Workstation Int