Problem using open dataset

Hi All,
  I am trying to upload flat file data into appl server.but it is uploading some unwanted characters at the end.The code and data is given below.plz let me know the solution.
DATA : file type rlgrap-filename.
data : begin of itab occurs 0,
         rec(500) type c,
       end of itab.
file = '/lz01/fin/in/bop_Checkrecon1.txt'.
clear : itab.
refresh : itab.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'C:\bop3.txt'
   FILETYPE                      = 'ASC'
  HAS_FIELD_SEPARATOR           = ' '
   HEADER_LENGTH                 = 0
   READ_BY_LINE                  = 'X'
  DAT_MODE                      = ' '
  CODEPAGE                      = ' '
  IGNORE_CERR                   = ABAP_TRUE
  REPLACEMENT                   = '#'
  CHECK_BOM                     = ' '
  VIRUS_SCAN_PROFILE            =
IMPORTING
  FILELENGTH                    =
  HEADER                        =
  TABLES
    DATA_TAB                      = itab
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.
open dataset file for input in text mode encoding default.
clear itab.
loop at itab.
   transfer itab-rec to file.
   clear itab.
endloop.
close dataset file.
The exact structure and the data present in the flat file is as follows:
  078041953      0000000001000000052507       0000070000                   R   
  078041953      0000000003000000052507       0000199500                   R   
  078041953      0000000005000000052507       0000530000                   R   
  078041953      0000000007000000052507       0000005000                   R   
  078041953      0000000008000000052507       0000004000                   R   
  078041953      0001000000000000052507       0000058250                   R   
  029005582      0001000000000000052507       0000012300                   R   
  029005582      0001000001000000052507       0009438200                   R   
  030404975      0001000000000000052507       0000056700                   R   
  030404975      0001000001000000052507       0000004500                   R   
  314018577      0001000002000000052507       0000001500                   R   
  314018577      0001000003000000052507       0000435300                   R   
  314018577      0001000007000000052507       0000066600                   R   
Thanks,
Rakesh.

Hello Rakesh
If you display your flat file using an editor (like Notepad) then the file may look ok. However, there may be special characters at the end of every line that are not displayed.
Use the following approach to analyze your flat file:
(1) Start Microsoft Excel
(2) Open your flat file from with Excel. Be careful to choose the right <b>Codepage</b> in the <i>Text Converter Assistent</i>. For example, located in Switzerland I would most like choose Codepage = Windows(ANSI) or  1250 Middle European (Windows)
(3) Scroll to the end of lines and check if there are special characters
Regards
  Uwe

Similar Messages

  • Problem in accessing application server file using open dataset

    Hi All,
    I am trying to access application server file using open dataset command, its working fine for normal path which imention. But when i am giving path of XI server file, its not working. How to access XI server file using open dataset. Please let me know.
    Thanks in advance.
    Regards,
    Vishal

    Hi Vishal,
    You need to verify if the location where you are trying to save the file is in the same server of SAP. In case that the location is in other server you need to map that directy into the same server of SAP.
    You need to point always to a location in the same server of SAP, in order that the open dataset could work.
    Regards,
    Eric

  • Problem in Open dataset in background

    Hi All,
    Iam facing the problem in Open dataset in background. It is working fine in foreground.
    Iam able to read only one line from the application server file in background.
    Please find below the code.
      IF sy-batch = wl_x.
        OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE encoding default. "    
       IF sy-subrc = 0.
          DO.
            READ DATASET pa_sfile INTO wf_string.
            IF sy-subrc <> 0.
              EXIT.
            ELSE.
              SPLIT wf_string AT cl_abap_char_utilities=>horizontal_tab INTO wa_upload-
                       field1 wa_upload-field2 wa_upload-field3
              wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7
             wa_upload-field8   wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13 wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18  wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
              wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28  wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33  wa_upload-field34 wa_upload-field35 wa_upload-field36 .
              APPEND wa_upload TO int_upload.
              CLEAR wa_upload.
            ENDIF.
          ENDDO.
          CLOSE DATASET pa_sfile.
    Thanks in advance.
    Quick suggestions are highly appreciated.
    Best Regards,
    Brahma Reddy

    Thanks for the reply.
    Here is the whole code.
    Here iam submitting one job to the backgrond. But if iam executing it in debugging mode by changing the values of sy-batch( without submitting to background ) at run time, my program is working fine.
    REPORT zvtraffic_carrier_upload
           NO STANDARD PAGE HEADING LINE-SIZE 255
                  MESSAGE-ID zmmx.
    *Data Declarations                                                     *
    TABLES: vtrkh,
            vekp,
            zvship_non_pkgs.
    declaration of data
    DATA:
       wf_filename         LIKE ibipparms-path,  "file with path
       wf_file             LIKE ibipparms-path,        "file
       wf_extsn(3)         TYPE c ,              "file extension
       wf_recnt            TYPE i,
       wf_recok            TYPE i,
    *+001 Begin
       wf_string           TYPE string,
       wf_mess             TYPE string,
       wf_field1       TYPE string,
       wf_field2(30)       TYPE c,
       wf_sum_source_file  TYPE rlgrap-filename ,
       wf_sum_dest_file    TYPE rlgrap-filename ,
      wf_path         LIKE   rlgrap-filename,
       wf_path TYPE salfile-longname
                        VALUE '/usr/sap/nfs/erp/UTL/',
    *+001 End
       wf_complete_file    LIKE pcfile-path.     "total file path
    declaration of counters
    DATA:
       wc_rec(6)          TYPE c,                "total record counter
       wc_success_rec(6)  TYPE c,                "no of rec.having no errors
       wc_error_rec(6)    TYPE c,                "no of rec. having errors
       wc_rec_tot(6)      TYPE c.                "total records
    Constants declarations
    CONSTANTS:
       wl_x(1)         TYPE c VALUE 'X',          "X
       wl_1            TYPE i           VALUE '1',         "Integer value
       wl_e(1)         TYPE c           VALUE 'E',         "Char    value
       wl_mode         TYPE c           VALUE 'N',
       wl_update       TYPE c           VALUE 'S',
       wl_trackno(13)  TYPE c           VALUE 'Tracking No. ',
       wl_tcode(14)    TYPE c           VALUE 'ZVTRAFFICINPUT',
    *+001 Begin:
       wl_id(11)       TYPE c           VALUE 'CARRIERFILE',
       wl_adm(100)     TYPE c           VALUE '[email protected]',
       wl_u(1)         TYPE c VALUE 'U',       " Email through Internet
       wl_int(3)       TYPE c VALUE 'INT',     " Communication method
       wl_urgent(6)    TYPE c VALUE 'Urgent',
       wl_raw(3)       TYPE c VALUE 'RAW',
       wl_descr(48)    TYPE c VALUE 'SAP Alert: Carrier upload',
       wl_file(128)    TYPE c VALUE '/usr/sap/nfs/erp/UTL/carrier.xls',
       wl_jobname LIKE tbtcjob-jobname VALUE 'ZVTRAFFIC_UP',
       wl_variant LIKE raldb-variant VALUE 'VMM01_ZVTRFFIC',
       wl_action  TYPE  zaction VALUE 'MOV', "For moving file to other dir
       wl_i       TYPE  c VALUE 'I',
       wl_cmd(50) TYPE c VALUE '/usr/sap/nfs/erp/UTL/',
       wl_57           TYPE i      VALUE 57,
       wl_m1(2)         TYPE c VALUE 'M1',                      "value M1
       wl_m2(2)         TYPE c VALUE 'M2',                      "value M1
    *+001 End:
       wl_xls(3)       TYPE c           VALUE 'xls',       "Char value
       wl_value(1)     TYPE c           VALUE ','.         "Char value
    *Internal Tables Declarations                                          *
    internal table for holding data from excel file
    *+001 begin
    TYPES : BEGIN OF ty_dir,
             dir(132)  TYPE  c,
            END   OF ty_dir.
    *internal table to get the files in the direactory
    DATA : int_dir      TYPE ty_dir OCCURS 0 WITH HEADER LINE .
    *work area for int_dir
    DATA : wa_int_dir      LIKE LINE OF int_dir.
    DATA: ifiles TYPE TABLE OF  salfldir WITH HEADER LINE.
    *+001 end
    TYPES: BEGIN OF int_upload,
             field1(30)   TYPE c,       "
             field2(30)   TYPE c,       "
             field3(30)   TYPE c,       "
             field4(30)   TYPE c,       "
             field5(30)   TYPE c,       "
             field6(30)   TYPE c,       "
             field7(30)   TYPE c,       "
             field8(30)   TYPE c,       "
             field9(30)   TYPE c,       "
             field10(30)  TYPE c,       "
             field11(30)  TYPE c,       "
             field12(30)  TYPE c,       "
             field13(30)  TYPE c,       "
             field14(30)  TYPE c,       "
             field15(30)  TYPE c,       "
             field16(30)  TYPE c,       "
             field17(30)  TYPE c,       "
             field18(30)  TYPE c,       "
             field19(30)  TYPE c,       "
             field20(30)  TYPE c,       "
             field21(30)  TYPE c,       "
             field22(30)  TYPE c,       "
             field23(30)  TYPE c,       "
             field24(30)  TYPE c,       "
             field25(30)  TYPE c,       "
             field26(30)  TYPE c,       "
             field27(30)  TYPE c,       "
             field28(30)  TYPE c,       "
             field29(30)  TYPE c,       "
             field30(30)  TYPE c,       "
             field31(30)  TYPE c,       "
             field32(30)  TYPE c,       "
             field33(30)  TYPE c,       "
             field34(30)  TYPE c,       "
             field35(30)  TYPE c,       "
             field36(30)  TYPE c,       "
            END OF int_upload.
    DATA: int_upload   TYPE STANDARD TABLE OF int_upload.
    declaring bdc table
    DATA: int_bdcdata LIKE STANDARD TABLE OF bdcdata
          INITIAL SIZE 0 WITH HEADER LINE.
    DATA:   wa_bdcdata LIKE bdcdata.
    DATA:int_messages TYPE
         STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0.
    TYPES: BEGIN OF ty_error_data,
           errtext(500) TYPE c,
           END OF ty_error_data.
    DATA: wa_messages LIKE LINE OF
          int_messages.
    DATA: wa_error_data TYPE
          ty_error_data .
    DATA: int_error_data TYPE
          STANDARD TABLE OF ty_error_data INITIAL SIZE 0.
    *Work Area declarations
    Work area
    DATA:
    wa_upload    LIKE LINE OF int_upload.      "work area for int_upload
    Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : pa_foreg RADIOBUTTON GROUP g1 USER-COMMAND rad DEFAULT 'X', " user command rad,
                 pa_backg RADIOBUTTON GROUP g1 .
    SELECTION-SCREEN: SKIP.
    Input File Location Specification
    SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-002.
    PARAMETERS pa_file LIKE rlgrap-filename
               MODIF ID m1. "OBLIGATORY.     "Input File -001
    SELECTION-SCREEN END OF BLOCK b11.
    *+001 Begin
    SELECTION-SCREEN BEGIN OF BLOCK b12 WITH FRAME TITLE text-006.
    PARAMETERS pa_sfile LIKE rlgrap-filename DEFAULT '/usr/sap/nfs/erp/UTL/carrier2'
               LOWER CASE MODIF ID m2. " server filename
    *PARAMETERS pa_batch AS CHECKBOX DEFAULT ' ' MODIF ID m2.    "Background job
    *+001 End
    SELECTION-SCREEN END OF BLOCK b12.
    SELECTION-SCREEN END OF BLOCK b1.
    Event: INITIALIZATION
    INITIALIZATION.
    clear variables
    refresh internal tables
      REFRESH:int_upload.
    clear Work areas
      CLEAR:  wa_upload.
    A T  S E L E C T I O N - S C R E E N
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.           "-001
    subroutine to display the batch data input file location
      PERFORM f_get_filename.
    *+001 Begin:
    AT SELECTION-SCREEN OUTPUT.
      IF pa_backg = wl_x.
        LOOP AT SCREEN.
          IF screen-group1 = wl_m2.
            screen-invisible = space.
            screen-active = '1'.
            MODIFY SCREEN.
          ELSE.
            IF screen-group1 = wl_m1.
              screen-input = '0'.
              MODIFY SCREEN.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          IF screen-group1 = wl_m2.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_sfile.
    subroutine to display list of files in application server
      PERFORM f_get_server_file.
    *+001 End:
    At Selection-Screen Event: validations check                        *
    AT SELECTION-SCREEN .
    validates the Selection Screen input
      PERFORM f_check_input.
    Event TOP-OF-PAGE
    TOP-OF-PAGE.
    Event: START-OF-SELECTION
    START-OF-SELECTION.
    *+001 Begin :
    get the path for all files from the directory
    PERFORM f_get_path.
    set up background job
      PERFORM f_background_job.
    *+001 End:
    *-001
      CHECK pa_backg EQ ' '.
    *-001
    LOOP AT ifiles.
    clear itab. refresh itab.
       CONCATENATE wf_path ifiles-name INTO pa_sfile.
    upload PC file to internal table int_UPLOAD
      PERFORM f_upload_excel_file.
    reformat data
      PERFORM f_format_data.
    upload formatted data into SAP system
      break breddy.
      PERFORM f_upload_data.
    Event: END-OF-SELECTION
    *END-OF-SELECTION.
    display summary report
      PERFORM f_display_report.
    *+001 Begin
      IF sy-batch = wl_x.
      CONCATENATE '/usr/sap/trans/carrier2' '_'
                  sy-datum '_' sy-uzeit
                  INTO wf_sum_dest_file.
        wf_sum_source_file = '/usr/sap/nfs/erp/UTL/carrier2'.
       wf_sum_dest_file = '/usr/sap/trans/carrier2'.
    ELSE.
       wf_sum_source_file = pa_file.
       wf_sum_dest_file = '/usr/sap/trans/carrier2'.
    To move the processed file to Completed directory
      PERFORM f_move_file_to_other_dir USING
                   wf_sum_source_file
                   wf_sum_dest_file.
      ENDIF.
    *+001 End
      wait up to 60 seconds.
    *&      Form  f_get_filename
          Display the File Location
          Called by:  Main Program (AT SELECTION-SCREEN on VALUE-REQUEST)
          Calls:
    FORM f_get_filename.
      CLEAR wf_filename.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                program_name  = syst-cprog
                dynpro_number = syst-dynnr
               field_name    = wf_fieldname
           IMPORTING
                file_name     = wf_filename.
    If the user press cancel button without selecting file name
    then the file name will be initial and raise the error message
      IF wf_filename IS INITIAL.
        MESSAGE i000 WITH 'No File selected'(012).
        LEAVE LIST-PROCESSING.
      ENDIF.
      pa_file = wf_filename.
    ENDFORM.                    " f_get_filename
    Form: F_CHECK_INPUT                                                **
    Description:
    This subroutine is used to validate the Selection Screen inputs.
    Called By:  ZMISOPPLAN01                                            *
    Calls:      None                                                    *
    FORM f_check_input.
      if pa_foreg eq wl_X.
        if sy-batch ne wl_X.  " IF pa_foreg EQ wl_x.                                      " +001
    check file type
        IF pa_file NS '.xls'.
          MESSAGE e106.
        ENDIF.
      ENDIF.              "+001
      endif.
    *+001 Begin:
    wf_file = pa_sfile.
    EXPORT wf_file TO MEMORY ID wl_id.
    ENDIF.  " Commented by Br
    *+001 Begin
      IF pa_backg EQ wl_x.
        pa_sfile = '/usr/sap/nfs/erp/UTL/carrier2'.
        OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE ENCODING  DEFAULT MESSAGE wf_mess.
        IF sy-subrc NE 0.
          MESSAGE e000(zmmx) WITH 'File not present in path /usr/sap/nfs/erp/UTL'.
          LEAVE LIST-PROCESSING.
          STOP.
        ELSE.
          CLOSE DATASET pa_sfile.
        ENDIF.
    ELSE.
       OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE ENCODING  DEFAULT MESSAGE wf_mess.
       IF sy-subrc NE 0.
         MESSAGE e000(zmmx) WITH 'File not found:' pa_sfile.
         LEAVE LIST-PROCESSING.
         STOP.
       ELSE.
         CLOSE DATASET pa_sfile.
       ENDIF.
      ENDIF.
    *+001 End:
    ENDFORM.                                            "f_check_input
    *&   Form  f_upload_excel_file
       Uploads an excel file from the workstation. The file is loaded  *
       into the internal table specified by int_out_tab.               *
    -->  PA_FILE       The name and path of the excel file to upload  *
    <--  int_UPLOAD    Internal table that that will contain the data *
                        loaded from the excel file.                    *
    FORM f_upload_excel_file.
    *-001
      TYPES truxs_t_text_data(4096) TYPE c OCCURS 0.
      DATA: int_tab_input_data TYPE truxs_t_text_data.
    *+001
      IF sy-batch IS INITIAL.
    *+001
    uploading data into internal table int_upload from excel file
        CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
          EXPORTING
            i_tab_raw_data       = int_tab_input_data[]
            i_filename           = pa_file                      "-001
          TABLES
            i_tab_converted_data = int_upload
          EXCEPTIONS
            conversion_failed    = 1
            OTHERS               = 2.
    problems occur in file uploading
        IF int_upload[] IS INITIAL.
          MESSAGE i000 WITH 'No data uploaded from input file'(005).
          LEAVE LIST-PROCESSING.
        ENDIF.
    *+001
      ENDIF.
    *+001
      IF sy-batch = wl_x.
        OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE encoding default. " ENCODING  DEFAULT MESSAGE wf_mess.
        IF sy-subrc = 0.
          DO.
            READ DATASET pa_sfile INTO wf_string.
            IF sy-subrc <> 0.
              EXIT.
            ELSE.
              SPLIT wf_string AT cl_abap_char_utilities=>horizontal_tab INTO wa_upload-field1 wa_upload-field2 wa_upload-field3
              wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7 wa_upload-field8
              wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13
              wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18
              wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
              wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28
              wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33
              wa_upload-field34 wa_upload-field35 wa_upload-field36 .
              APPEND wa_upload TO int_upload.
              CLEAR wa_upload.
            ENDIF.
          ENDDO.
          CLOSE DATASET pa_sfile.
        ELSE.
          MESSAGE i000(zmmx) WITH 'File not found'.
          LEAVE LIST-PROCESSING.
          STOP.
        ENDIF.
      ENDIF.
    +001
    ENDFORM.                                  "f_upload_excel_file
    *&      Form  f_format_data
          format the data to be uploaded
          Called by:  ZMISOPPLAN01
          Calls: N/A
    FORM f_format_data.
    delete the header lines
      DELETE int_upload WHERE
      field1 CS 'SCAC' OR field1 CS 'Scac' OR field1 CS 'Carrier'.
    delete lines with no carrier info
      DELETE int_upload WHERE
      field1 IS INITIAL OR field2 IS INITIAL.
      SORT int_upload BY field2.
    ENDFORM.                    " f_format_data
    *&      Form  f_upload_data
          Description:upload the data
    FORM f_upload_data.
      DATA: loc_priceperlb LIKE zvship_trk_data-act_per_lb,
            loc_charprice(10) TYPE n,
            loc_size TYPE i,
            loc_pickupdate(10) TYPE c,
            loc_totalwt    LIKE zvship_trk_data-pkg_wgt.
      CHECK NOT int_upload[] IS INITIAL.
      DESCRIBE TABLE int_upload LINES wf_recnt.
      LOOP AT int_upload INTO wa_upload.
        SELECT COUNT(*) FROM zvship_trk_data WHERE trackn = wa_upload-field2.
        IF sy-subrc = 0.
    tracking no. exists in carrier database
          CONCATENATE wl_trackno wa_upload-field2
          ' already exists in carrier tracking database'  INTO
          wa_error_data-errtext. "Error text of int_error_data
          APPEND wa_error_data TO int_error_data.
        ELSE.
          SELECT SINGLE * FROM vtrkh WHERE trackn = wa_upload-field2.
          IF sy-subrc <> 0.
    tracking no. not in tracking database
            CONCATENATE wl_trackno wa_upload-field2
            ' not found in tracking database'  INTO
            wa_error_data-errtext. "Error text of int_error_data
            APPEND wa_error_data TO int_error_data.
          ELSE.
    must have freight charge
            IF wa_upload-field20 IS INITIAL.
              CONCATENATE wl_trackno wa_upload-field2
              ' has no total net charges'  INTO
              wa_error_data-errtext. "Error text of int_error_data
              APPEND wa_error_data TO int_error_data.
              CONTINUE.
            ENDIF.
    must have final delv. date
            IF wa_upload-field25 IS INITIAL.
              CONCATENATE wl_trackno wa_upload-field2
              ' has no final delivery date'  INTO
              wa_error_data-errtext. "Error text of int_error_data
              APPEND wa_error_data TO int_error_data.
              CONTINUE.
            ENDIF.
    all checks ok, build BDC for ZVTRAFFICINPUT
    get total weight and compute price/lb
            IF vtrkh-uevbtyp EQ wl_x.
              SELECT SINGLE  brgew INTO loc_totalwt
              FROM zvship_non_pkgs
                WHERE venum = vtrkh-vbeln.
            ELSE.
              SELECT SINGLE brgew INTO loc_totalwt
              FROM vekp WHERE venum = vtrkh-vbeln.
            ENDIF.
            IF sy-subrc NE 0.
              CONCATENATE wl_trackno wa_upload-field2
              ' has no total weight'  INTO
              wa_error_data-errtext. "Error text of int_error_data
              APPEND wa_error_data TO int_error_data.
              CONTINUE.
            ENDIF.
    price/lb = total net charges / total wt
            loc_priceperlb = wa_upload-field20 / loc_totalwt.
            WRITE loc_priceperlb TO loc_charprice LEFT-JUSTIFIED.
    if no pickup date from VTRKH, use date from file
            IF vtrkh-routeldat IS INITIAL.
              loc_pickupdate = wa_upload-field23.
            ELSE.
              CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
                EXPORTING
                  input  = vtrkh-routeldat
                IMPORTING
                  output = loc_pickupdate.
            ENDIF.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0001',
            ' ' 'BDC_CURSOR' 'VIM_POSITION_INFO',
            ' ' 'BDC_OKCODE' '=AEND'.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0001',
            ' ' 'BDC_CURSOR' 'ZVSHIP_TRK_DATA-EOD_DATE(01)',
            ' ' 'BDC_OKCODE' '=NEWL'.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0002',
            ' ' 'BDC_CURSOR' 'ZVSHIP_TRK_DATA-TRACKN',
            ' ' 'ZVSHIP_TRK_DATA-TRACKN' wa_upload-field2,
            ' ' 'BDC_OKCODE' '/00'.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0002',
            ' ' 'ZVSHIP_TRK_DATA-EOD_DATE' loc_pickupdate,
            ' ' 'ZVSHIP_TRK_DATA-ACT_DATE' wa_upload-field25.
       IF NOT wa_upload-field15 IS INITIAL.
         PERFORM F_SET_BDC_VAL
         USING :
         ' '  'ZVSHIP_TRK_DATA-PKG_WGT' wa_upload-field15.  "Total Wt.
       ENDIF.
            PERFORM f_set_bdc_val
            USING :
            ' ' 'ZVSHIP_TRK_DATA-ACT_FRT' wa_upload-field20,"Total Net charges
            ' ' 'ZVSHIP_TRK_DATA-ACT_SURCH' wa_upload-field18,"Fuel surcharge
            ' ' 'ZVSHIP_TRK_DATA-ACT_ACC' wa_upload-field19,  "Accessorial ch.
            ' ' 'ZVSHIP_TRK_DATA-ACT_TOTAL' wa_upload-field16,"Gross Charges
            ' ' 'ZVSHIP_TRK_DATA-ACT_PER_LB' loc_charprice.  "Price/LB
       IF NOT wa_upload-field13 IS INITIAL.
         PERFORM F_SET_BDC_VAL
         USING :
         ' ' 'ZVSHIP_TRK_DATA-PKG_PAL' wa_upload-field13.  "Pallet count
       ENDIF.
       IF NOT wa_upload-field14 IS INITIAL.
         PERFORM F_SET_BDC_VAL
         USING :
         ' ' 'ZVSHIP_TRK_DATA-PKG_PCS' wa_upload-field14.  "Case count
       ENDIF.
            PERFORM f_set_bdc_val
            USING :
            ' ' 'BDC_OKCODE' '=SAVE'.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0002',
            ' ' 'BDC_OKCODE' '=UEBE'.
            PERFORM f_set_bdc_val
            USING :
            '1' 'SAPLZVSHIP_TRAK' '0001',
            ' ' 'BDC_OKCODE' '=BACK'.
    call transaction ZVTRAFFICINPUT
            PERFORM f_call_zvtrafficinput.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " f_upload_data
          FORM F_SET_BDC_VAL                                            *
    -->  WG_DYNBEGIN                                                   *
    -->  WF_FIELDNAME                                                  *
    -->  WF_FIELDVAL                                                   *
    FORM f_set_bdc_val  USING
          locf_dynbegin
          locf_fieldname
          locf_fieldval.
      CLEAR wa_bdcdata.
      IF locf_dynbegin = wl_1.                                  "'1'.
        wa_bdcdata-program = locf_fieldname.
        wa_bdcdata-dynpro = locf_fieldval.
        wa_bdcdata-dynbegin = wl_x. "'X'.
      ELSE.
        wa_bdcdata-fnam = locf_fieldname.
        wa_bdcdata-fval = locf_fieldval.
      ENDIF.
      APPEND wa_bdcdata TO int_bdcdata.
    ENDFORM.                    "F_SET_BDC_VAL
    *&      Form  F_CALL_ZVTRAFFICINPUT
          text
    -->  p1        text
    <--  p2        text
    FORM f_call_zvtrafficinput .
      DATA: locf_last_rec TYPE sy-index,
            wf_msgstring(128)                TYPE c.
      DATA: loc_mode TYPE c.
      loc_mode = 'N'.      "+001 needs to be changed
      CALL TRANSACTION wl_tcode
        USING int_bdcdata
        MODE 'A'
        MODE wl_mode  "In Backgrnd(N)
          MODE loc_mode
        UPDATE wl_update              "(S)ynchr mode "+001
        MESSAGES INTO int_messages.
    In case there are errors in call transaction
      IF sy-subrc <> 0.
        DESCRIBE TABLE int_messages LINES locf_last_rec.
        READ TABLE int_messages INTO wa_messages
              INDEX locf_last_rec.
        PERFORM f_fill_bdc_error USING wa_upload-field2 wf_msgstring.
      ELSE.
    Keep count of successfully process records
        wf_recok = wf_recok + 1.
        PERFORM f_fill_bdc_success USING wa_upload-field2.
      ENDIF.
      REFRESH: int_bdcdata, int_messages.
    ENDFORM.                    " F_CALL_ZVTRAFFICINPUT
    *&      Form  f_fill_bdc_success
          text
         -->P_WA_UPLOAD_FIELD2  text
    FORM f_fill_bdc_success  USING    p_wa_upload_field2.
      CONCATENATE wl_trackno p_wa_upload_field2 '- Entry added'
      INTO
      wa_error_data-errtext. "Success message
      APPEND wa_error_data TO int_error_data.
    ENDFORM.                    " f_fill_bdc_success
    *&      Form  f_fill_bdc_error
          text
         -->P_WA_UPLOAD_FIELD2  text
         -->P_WF_MSGSTRING  text
    FORM f_fill_bdc_error  USING    p_wa_upload_field2
                                    p_wf_msgstring.
      CONCATENATE wl_trackno p_wa_upload_field2
      '- Error : ' p_wf_msgstring
      INTO
      wa_error_data-errtext. "Error text of int_error_data
      APPEND wa_error_data TO int_error_data.
    ENDFORM.                    " f_fill_bdc_error
    *&      Form  f_display_report
          text
    FORM f_display_report.
    *+001 Begin:
      DATA: reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            doc_chng LIKE sodocchgi1,
            objcont LIKE solisti1 OCCURS 0 WITH HEADER LINE.
      DATA: loc_recnt(4) TYPE c,
            loc_recok(4) TYPE c.
    *+001 End:
        if sy-batch ne wl_x.  "+001
        ULINE /1(175).
        WRITE:/ 'Date/Time: '(006) COLOR COL_HEADING,
                sy-datum DD/MM/YYYY, '/',sy-uzeit,
                40 'Uploading of Carrier Information to ZVTRAFFIC'.
        ULINE /1(175).
        SKIP.
        WRITE:/ 'Following File Has Been Processed'.
             / pa_file.    "-001
        SKIP.
        WRITE:/ 'Number of records read:', wf_recnt.
        WRITE:/ 'Number of records processed successfully:', wf_recok.
        SKIP.
        LOOP AT int_error_data INTO wa_error_data.
          WRITE :/ wa_error_data-errtext.
        ENDLOOP.
    *+001 Begin:
      ELSE.
       IMPORT wf_file FROM MEMORY ID wl_id.
        reclist-receiver = wl_adm.
        reclist-rec_type = wl_u.
        reclist-com_type = wl_int.
        APPEND reclist.
        doc_chng-obj_name = wl_urgent.
        doc_chng-obj_descr = wl_descr.
        CONCATENATE 'Date/Time: ' sy-datum '/' sy-uzeit
                'Uploading of Carrier Information to ZVTRAFFIC'
                INTO objcont SEPARATED BY space.
        APPEND objcont.
    *-001
       CONCATENATE 'Following File Has Been Processed' pa_file
                 INTO objcont SEPARATED BY space.
       APPEND objcont.
    *-001
        loc_recnt = wf_recnt.
        CONCATENATE 'Number of records read:' loc_recnt
          INTO objcont SEPARATED BY space.
        APPEND objcont.
        loc_recok = wf_recok.
        CONCATENATE 'Number of records processed successfully:' loc_recok
          INTO objcont SEPARATED BY space.
        APPEND objcont.
        LOOP AT int_error_data INTO wa_error_data.
          MOVE wa_error_data-errtext TO objcont.
          APPEND objcont.
        ENDLOOP.
        CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
          EXPORTING
            document_type              = wl_raw
            document_data              = doc_chng
            put_in_outbox              = wl_x
            commit_work                = wl_x
          TABLES
            object_content             = objcont
            receivers                  = reclist
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            operation_no_authorization = 4
            OTHERS                     = 99.
        IF sy-subrc EQ 0.
          MESSAGE s205. "email sent
        ELSE.
          MESSAGE i206. "email not sent
        ENDIF.
      ENDIF.
    *+001 End:
    ENDFORM.                    " f_display_report
    *&      Form  f_background_job
          text
    -->  p1        text
    <--  p2        text
    FORM f_background_job .
      DATA: loc_jobcount LIKE btch1150-jobcount.
      IF pa_backg = wl_x.
        CALL FUNCTION 'JOB_OPEN'
          EXPORTING
            jobname          = wl_jobname
            jobclass         = 'A'
          IMPORTING
            jobcount         = loc_jobcount
          EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
        IF sy-subrc <> 0.
          MESSAGE i000(zmmx) WITH 'JOB_OPEN failed.' 'sy-subrc =' sy-subrc.
          LEAVE LIST-PROCESSING.
        ENDIF.
        CALL FUNCTION 'JOB_SUBMIT'
             EXPORTING
               extpgm_param            = pa_file
                  authcknam               = sy-uname
                  jobcount                = loc_jobcount
                  jobname                 = wl_jobname
                  report                  = sy-repid
                  variant                 = wl_variant
             EXCEPTIONS
                  bad_priparams           = 1
                  bad_xpgflags            = 2
                  invalid_jobdata         = 3
                  jobname_missing         = 4
                  job_notex               = 5
                  job_submit_failed       = 6
                  lock_failed             = 7
                  program_missing         = 8
                  prog_abap_and_extpg_set = 9
                  OTHERS                  = 10.
        IF sy-subrc <> 0.
          MESSAGE i000(zmmx) WITH 'JOB_SUMBMIT failed.' 'sy-subrc =' sy-subrc.
          LEAVE LIST-PROCESSING.
        ENDIF.
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount             = loc_jobcount
            jobname              = wl_jobname
            strtimmed            = 'X'
          EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
        IF sy-subrc <> 0.
          MESSAGE i000(zmmx) WITH 'JOB_CLOSE failed.' 'sy-subrc =' sy-subrc.
          LEAVE LIST-PROCESSING.
        ELSE.
          MESSAGE i000(zmmx) DISPLAY LIKE wl_i WITH 'Background job submitted'.
          LEAVE LIST-PROCESSING.
          wait up to 60 seconds.
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f_background_job
    *&      Form  f_get_server_file
          text
    -->  p1        text
    <--  p2        text
    FORM f_get_server_file .
      CLEAR: wf_filename.
    following function module display the list of application file and
    directories in a pop up window
      CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
        IMPORTING
          serverfile       = wf_filename
        EXCEPTIONS
          canceled_by_user = 1
          OTHERS           = 2.
    If the user press cancel button without selecting file name
    then the file name will be initial and raise the error message
      IF wf_filename IS INITIAL.
        MESSAGE i000 WITH 'No File selected'(012).
        LEAVE LIST-PROCESSING.
      ENDIF.
      pa_sfile = wf_filename.
    ENDFORM.                    " f_get_server_file
    *&      Form  f_move_file_to_other_dir
          To move the
    FORM f_move_file_to_other_dir  USING   locf_source_file
                                           locf_dest_file.
      CALL FUNCTION 'Z_FILE_HANDLING_UTILITY'
        EXPORTING
          action                    = wl_action  "VALUE 'mov'
          source_physical_file_name = locf_source_file
          dest_physical_file_name   = locf_dest_file
        EXCEPTIONS
          invalid_action            = 1
          invalid_file_type         = 2
          file_type_missing         = 3
          file_type_not_required    = 4
          source_file_missing       = 5
          source_filename_error     = 6
          destination_not_required  = 7
          destination_missing       = 8
          multiple_file_names       = 9
          file_deletion_error       = 10
          invalid_source_file       = 11
          file_read_error           = 12
          file_write_error          = 13
          file_rename_error         = 14
          file_move_error           = 15
          destination_file_exists   = 16
          OTHERS                    = 17.
      IF sy-subrc <> 0.
        MESSAGE i000(zmmx) WITH 'Error in Moving Process directory to completed Directory'(004).
       LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " f_move_file_to_other_dir
    *&      Form  f_get_path
          text
    -->  p1        text
    <--  p2        text
    FORM f_get_path .
      CALL FUNCTION 'RZL_READ_DIR_LOCAL'
        EXPORTING
          name           = wf_path
        TABLES
          file_tbl       = ifiles
        EXCEPTIONS
          argument_error = 1
          not_found      = 2
          OTHERS         = 3.
      DELETE ifiles WHERE name+0(1) = '.'.
      DELETE ifiles WHERE name+0(1) NE 'w'.
    ENDFORM.                    " f_get_path
    Regards,
    Brahma Reddy

  • Fetch excel file from app. server using open dataset...

    Hello Experts,
    Our functional consultant is asking me if it possible to get an excel file from the
    application server file using OPEN dataset and in background mode? If yes, Please tell me on how to do this.
    Thank you guys and take care!

    Hi Viraylab,
    to download this the procedure:
    you can use the FM 'EXCEL_OLE_STANDARD_DAT ' for this purpose.
    this FM 'EXCEL_OLE_STANDARD_DAT' can be used to start Excel with a new sheet and transfer data from an internal table to the sheet.
    Here are some of the parameters:
    file_name: Name and path of the Excel worksheet file e.g. ?C:TEMPZTEST?
    data_tab: Name of the internal table that should be uploaded to Exvcel
    fieldnames: Internal tabel with column headers
    How to build the field names table:
    data: begin of i_fieldnames occurs 20,
    field(60), end of i_fieldnames.
    i_fieldnames-field = ?This is column 1?. append i_fieldnames-field.
    i_fieldnames-field = ?This is column 2?. append i_fieldnames-field.
    to upload follow this:
    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.
    [/code]Rob
    or Try this function module.
    FILE_READ_AND_CONVERT_SAP_DATA
    pass 'XLS' to I_FILEFORMAT..
    Dont forgot to Reward me points .....All the very best....
    Regards,
    Sreenivasa sarma K.

  • Err with scheduling an abap program using open dataset

    issue: have an abap program which uses "open dataset ... for input ..." to read the file. 
    - with manual ly running it, receive the following message "dataset_not_open".  
    - with scheduling it, receive same message
    attempting to run an abap program as part of a process chain (ie scheduling a background job) in BI.
    the abap performs the following fxns:
    1) read a file on the server
    2) removes delimiter, renames it
    3) rewrites the file onto the server
    initially used ws_upload for reading and ws_download for writing the file. 
    - both fxns worked fine if it is run manually --> but failed as a  background (part of process chain)
    - note 7925 states can't use ws_upload, download for background jobs
    -so switched to "open dataset"
    Any suggestions as to why the "open dataset" does not work is greatly appreciated it.
    B.A.

    Thank you for all responses. here is more info about the err message:
    sy-subrc = 8
    'invalid argument'
    I looked up the invalid argument in note 99155 --> due to "The destination file is no longer available during repeated file access. "   So, the following steps were taken:
    - file was regenerated and
    - file was placed on the server to be read
    have the following code:
    OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE encoding default
                          MESSAGE D_MSG_TEXT.
    also have tried the following:
       OPEN DATASET d1 for input in text mode encoding default.
       open dataset d1 for output in text mode encoding NON-UNICODE..
       open dataset d1 for output in text mode  encoding utf-8.
    none had worked.  system --> status shows no unicode.
    THanks again for any suggestions.

  • How to open a pdf file using OPEN DATASET

    Im trying to convert a pdf into binary format. So im trying to read the contents of the pdf into a XSTRING. Using the FM 'SCMS_XSTRING_TO_BINARY' i can convert the XSTRING to binary format.
    How to open a pdf file using OPEN DATASET and transfer its contents in a XSTRING variable.
    What i've tried is....
    DATA: f_name type string value 'C:\rep_output_pdf.pdf',
          x1 type xstring,
          LT_DATA TYPE STANDARD TABLE OF X255.
    OPEN DATASET f_name FOR input IN BINARY MODE.
    READ DATASET f_name INTO x1.
    CLOSE DATASET f_name.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          BUFFER     = x1
        TABLES
          BINARY_TAB = LT_DATA.
    Im getting a short dump .
    Short text: The file is not open.
    Plz help me out.

    Hello Rajesh,
    You are trying to do use OPEN DATASET with a local file. NOT POSSIBLE
    You have to have the file in the app server to use OPEN DATASET.
    BR,
    Suhas

  • Download file using open dataset

    Hi all,
    I download a .CSV file to sap server using open dataset. I have a column which stores a number with length upto 30 char. I get the output in this format '2.34234E+25' for '23423423423423400000000000' in that particular column.
    Please send your suggestions to solve this issue.
    Rajesh.

    Do you want to use the csv file in Excel or in another application.
    If you display the CSV file created by open dataset using Notepad, you will probably see the 30 digit number.  This is fine for many applications, but not Excel!
    Excel cannot store a 30 digit number internally.  Try entering a 30 digit number into an Excel cell and see what happens - it is converted to scientific format with only 14 decimal places.
    If you need to see the number in Excel, you need to have it displayed as Text and not a number.  There are a few options:
    1. Put a character at the start of the field
    2. Don't use CSV, but use OLE to start Excel and put the data in the cell with text format (complicated I know).
    3. Save as a file with a .txt extension, open in Excel, and in the Text import wizard (step 3)  specify that the column data format is Text
    Michael

  • Transfering the data using OPEN DATASET

    Hi all,
    I am trying to get the data using OPEN DATASET to down load the data and using TRANSFER i am transfering.
    i got strucked while i am downloading.
    Please send coding how to use open dataset and transfer.
    Thanks in advance
    Venkat

    Hi ,
    you can try this code frangment.
    open the file to be created on application server.
      OPEN DATASET app_path FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        MESSAGE e001(zs) .
      ELSE.
    get header data
         PERFORM get_data_header.
    *transfer data to application server file.
        TRANSFER v_header TO app_path.
    get segment data
        PERFORM get_data_segment.
    *transfer data to application server file.
        TRANSFER v_segment TO app_path.
    *clear work areas and local variables.
        PERFORM clear_local.
    get trailer record.
        PERFORM get_data_trailer.
    *transfer data to application server file.
        TRANSFER v_trailer TO app_path.
      ENDIF.
      CLOSE DATASET app_path.
    regards,
    Sumit.

  • Create an Excel File Using OPEN DATASET Command

    Hey, everyone.
    How can I create an Excel file by using OPEN DATASET command ??
    The file is created but the columns are no seperated like thay should.
    I need to seperate the internal table's fields with a comma - How can I do it ?
    Here's my code:
    OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
    IF SY-SUBRC = 0.
       LOOP AT gt_vend_info into gwa_vend_info.
         TRANSFER gwa_vend_info TO filename1.
         IF SY-SUBRC <> 0.
           EXIT.
         ENDIF.
       ENDLOOP.
    ENDIF.
    Thanks in advance.

    Hi Beki,
    REPORT  ZTESTAA.
    TYPE-POOLS:TRUXS.
    DATA: BEGIN OF ITAB OCCURS 0,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          END OF ITAB.
    DATA:
    ITAB1 TYPE TRUXS_T_TEXT_DATA.
    SELECT  VBELN
            POSNR
         UP TO 10 ROWS
         FROM VBAP
         INTO TABLE ITAB.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        I_FIELD_SEPERATOR    = ';'
      TABLES
        I_TAB_SAP_DATA       = ITAB
      CHANGING
        I_TAB_CONVERTED_DATA = ITAB1
      EXCEPTIONS
        CONVERSION_FAILED    = 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.
    OPEN DATASET filename1 FOR OUTPUT IN TEXT MODE.
    IF SY-SUBRC = 0.
    LOOP AT gt_vend_info into gwa_vend_info.
    TRANSFER gwa_vend_info TO filename1.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDLOOP.
    ENDIF.
    the above code give CSV format file, all fields will be separated by ';'
    Regards
    vijay

  • Does we need to Create a file Before using Open dataSet

    Hi Guys,
                Can  any body tell me whether we have to create a File before using Open dataset  for writing files in Application Server.
               Can anybody write a program for EKPO table to store it in application Server using OpendatasSet ?Is there any specific care we have to take for Executing   pgm in Background?
    I wrote the pgm for Foreground using GUI- Download.
    PGM.
          select * into table it_ekpo  from  ekpo .
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename ='c:\EKPO.xls'
    filetype = 'ASC'
    WRITE_FIELD_SEPARATOR = 'X'
    TABLES
    data_tab = it_ekpo
    *fieldnames = l_heading
    EXCEPTIONS
    file_write_error = 1
    no_batch = 2
    gui_refuse_filetransfer = 3 .
                       Plzzzzzzzzz Make the changes for existing Pgm.any help is awarded with points.Its Urgent.
    Thanks,
    Gopi.

    Hi Guys,
                 Thanks for ur immediate response.I am sending the code just confirm me whether is correct r not?
    DATA : wa_EKPO_file   TYPE file_table-filename.
    select * into table it_ekpo  from  ekpo .
      OPEN DATASET wa_EKPO_file FOR OUTPUT         "Write to appl. server
                                          IN TEXT MODE
                                          ENCODING DEFAULT.  "Open dataset Return code
    IF sy-subrc = 0.
    LOOP at IT_EKPO into WA_EKPO.
    TRANSFER wa_ekpo to wa_ekpo_file.
    ENDLOOP.
    ENDIF.
                                             I want write the data into SPREAD Sheet .Can u guys  tell me how to write into Spread Sheet using Open data Set.
    Thanks,
    Gopi.

  • Weird problem in open dataset

    Hi mate,
    I have strange problem with open dataset. I try to download data to server and hit by shortdump telling me that file is not yet opened. I have checked SY-SUBRC (equals zero) after statement open dataset.
    It just happened today, previously i never encounter these problem before.
    Can someone point out me what the problem is? is it because of some delay in opening dataset or system performance issue? Production is running pretty slow in peak hours around 10-13PM.
    Thanks for your input.
    alia

    Hi Alia,
    Please check SAP OSS Note <b>733626</b>. It seems you don't have enough space in application server when the system tries to generate the input file. Perhaps you may need to archive production files.
    <b>Symptom</b>
    Report RCCLBI03 classifies all objects that are contained in an input file. Incorrect records from the input file are written into an error file.
    The report generates a termination with error code DATASET_CANT_OPEN if an object must be really written into the error file.
    <b>Other terms</b>
    Classification, dump
    <b>Reason and Prerequisites</b>
    The check whether the error file can be opened is insufficient. In the standard case this is RCCLBI03.ERROR on the application server.
    <b>Solution</b>
    If the error file cannot be opened, the report now ends with error message LX105 ("Unable to open file &1"). Then the input file is no longer imported.
    Hoep this will help.
    Regards,
    Ferry Lianto

  • Problem in open dataset

    Hi Friends
    Earlier I used FTP option for picking and transferring files, now Instaed of FTP I am going with application server concept.
    while receving, there is no problem between two types.But while transfrring the XML file from SAP to application server it generated some error, the format is not correect like that.But if I pass the same value in foreground its working fine.
    here I am attaching the coding for application server and foreground method
    open dataset filename for output in binary mode.
    *open dataset filename for output in TEXT MODE Encoding UTF-8.
    loop at it_xml.
      transfer it_xml to filename.
    endloop.
      close dataset filename.
    foreground coding
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        bin_filesize = l_xml_size
        filename     = 'C:\Delete_Parked_data.xml'
        filetype     = 'BIN'
      CHANGING
        data_tab     = l_xml_table
      EXCEPTIONS
        OTHERS       = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    I dont know how to convert this binary file into xml format in Application server concept.
    please help me to resolve this.
    Thanks
    Gowrishankar

    HI,
        YOu can use CALL TRANSFORMATION for converting into XML format .
    CALL TRANSFORMATION id SOURCE root = lt_TABLE
                RESULT XML it_xml.
    Then call DATASET
    Regards,
    Seema

  • Unable to create a file in Application Server using OPEN DATASET stattement.

    I am unable to create a file in Application Server using the following statement.
    OPEN DATASET filename FOR OUTPUT
    IN TEXT MODE ENCODING DEFAULT
    MESSAGE msg.
    The message I'm getting is "Permission Denied". I have checked authorisation using SU53 which says "The last authorization check was successful". Please help.

    You can use following code to capture the error.
    TRY.
          OPEN DATASET filename FOR OUTPUT IN BINARY MODE MESSAGE V_MSG.
          CATCH CX_ROOT
          INTO EXCEPTION.
          CALL METHOD O_EXCEPTION ->IF_MESSAGE~GET_TEXT
            RECEIVING
            RESULT = V_MSG.
          MESSAGE v_msg
          TYPE 'E'.
    ENDTRY.
    You can capture error in v_msg.
    Following are the exceptions for the same:
    Exceptions
    Catchable Exceptions
    CX_SY_FILE_OPEN
    Cause: The file is already open.
    Runtime Error: DATASET_REOPEN
      CX_SY_CODEPAGE_CONVERTER_INIT   
    Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT
    CX_SY_CONVERSION_CODEPAGE
    Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE
    CX_SY_FILE_AUTHORITY
    Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
    Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY
      CX_SY_PIPES_NOT_SUPPORTED   
    Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE
    CX_SY_TOO_MANY_FILES
    Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES   Non-Catchable Exceptions   
    Cause: An attempt was made to open a pipe that is already open.
    Runtime Error: DATASET_PIPE_POSITION
    Hope that will help you.
    Please reward if useful.

  • Write internal table to a file on application server using OPEN DATASET

    I have logical file path and XLS file name. I want to write internal table to a XLS or CSV file on application sever. Please give example.

    Hi
    see this program
    EXCEL SHET to INTERNAL table and then to APPLICATION server
    *& Report  ZSD_EXCEL_INT_APP
    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.

  • Problems using "open items" command in ARD

    Hi,
    Having problems while using the "open items" command from ARD. The "Copy" function works well but when trying to open the file I get the message "Failed".
    I suppose I am doing something wrong, any help is appreciated!

    ...  having problems ...
    We don't know what problems you are having

Maybe you are looking for