Problem of # in OPEN DATASET

Hi.
I am uploading a TXT file from FTP .All fields are seperated by comma.
I have windows NT.
I have used following statement to read data.
OPEN DATASET w_physical_name FOR INPUT IN TEXT MODE  ENCODING DEFAULT.
READ DATASET w_physical_name INTO v_text.
My last field in text field is Currency.Value is USD.
However when I take data in V_TEXT my last field value i.e USD gets attached
with # symbol and shows as USD#.
Since system does not recognise this, it throws error.
Can anyone suggest how to avoid this.Or what is the reason?

Hi
should mean the end of a record, so you can try to move all char of a record except the last one:
READ DATASET w_physical_name INTO v_text.
len = strlen( v_text ) - 1.
v_text = v_text(len).
In this case you make sure # is always at the end of every record.
or you have to prevent the program creates the file or the FTP procedure insert # as last character.
Max

Similar Messages

  • PRoblem regarding Submit - Open/Transfer/Close Dataset

    Hello again, I know I keep asking the same topic (regarding datasets) for the past week. Its been a new topic for me. However, I have a program which I am testing that is shown below.
    <b>REPORT ZPROG_COOL7 NO STANDARD PAGE HEADING.
    DATA: ITAB_LIST TYPE STANDARD TABLE OF ABAPLIST WITH HEADER LINE.
    PARAMETERS: PNAME TYPE SYCPROG. (this does nothing yet ...)
    SUBMIT ZPROGRAM EXPORTING LIST TO MEMORY AND RETURN
                        USING SELECTION-SET 'CEDEX'.
    CALL FUNCTION 'LIST_FROM_MEMORY'
         TABLES
              LISTOBJECT = ITAB_LIST
       EXCEPTIONS
            NOT_FOUND  = 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.
    IF SY-SUBRC = 0.
      CALL FUNCTION 'WRITE_LIST'
           TABLES
                LISTOBJECT = ITAB_LIST.
    ENDIF.
    DATA: LD_FILENAME TYPE LOCALFILE.
    DATA: I_MONTH TYPE TABLE OF T247 WITH HEADER LINE.
    DATA: IHTML   TYPE TABLE OF W3HTML  WITH HEADER LINE.
    CALL FUNCTION 'WWW_LIST_TO_HTML'
       EXPORTING
           list_index = sy-lsind
         TABLES
              HTML       = IHTML.
    CLEAR IHTML.
    LD_FILENAME = '
    H******\SAPReport\death.html'.
    OPEN DATASET LD_FILENAME FOR OUTPUT  IN BINARY MODE.
    LOOP AT IHTML.
      TRANSFER IHTML TO LD_FILENAME.
    ENDLOOP.
    CLOSE DATASET LD_FILENAME.
    CLEAR: LD_FILENAME.</b>
    As you can see it is suposed to get a list from a diffrent program, write the list, and then transfer the list into a directory in the SAP application server. This all works fine on foreground but in Background Proccessing the story is diffrent.
    Here is the problem:
    If Iam to send a job in background, the report will generate fine if you view the spool list <b>but there HTML file that is supposed to be saved becomes blank.</b> Is there a way to solve this issue? Thank you all take care, and good day.

    I am concerned that his part does not work in background.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    LISTOBJECT = ITAB_LIST
    * EXCEPTIONS
    * NOT_FOUND = 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.
    IF SY-SUBRC = 0.
    CALL FUNCTION 'WRITE_LIST'
    TABLES
    LISTOBJECT = ITAB_LIST.
    ENDIF.
    DATA: LD_FILENAME TYPE LOCALFILE.
    DATA: I_MONTH TYPE TABLE OF T247 WITH HEADER LINE.
    DATA: IHTML TYPE TABLE OF W3HTML WITH HEADER LINE.
    <b>CALL FUNCTION 'WWW_LIST_TO_HTML'
    * EXPORTING
    * list_index = sy-lsind
    TABLES
    HTML = IHTML.
    CLEAR IHTML.</b>
    LD_FILENAME = '\H******SAPReportdeath.html'.
    OPEN DATASET LD_FILENAME FOR OUTPUT IN BINARY MODE.
    LOOP AT IHTML.
    TRANSFER IHTML TO LD_FILENAME.
    ENDLOOP.
    CLOSE DATASET LD_FILENAME.
    CLEAR: LD_FILENAME.
    I ran across this before and I did find a solution, I'll get back.
    Regards,
    Rich Heilman

  • OPEN Dataset - Peculiar problem

    Hello experts!
    I am facing a peculiar problem with ABAP keyword OPEN DATASET.
    I have a directory to which I am adding new files using OPEN DATASET FOR OUTPUT.. this works perfectly fine in the Consolidation system. But the same thing does'nt work in the Production system! It return SY-SUBRC = 8
    After reading several other posts on SDN and other forums, the following causes were touted.
    1) Path incorrect 
    2) No Authorization
    But upon checking, neither of the wo are possible because the path is maintained properly and the authorizations at OS level are given (R/W) to this folder. Moreover, the user has S_DATASET auth object!!
    Then I read somewhere else that having multiple Application Servers could be a possible cause and that running the code as a background job would be afix.. Is it so?
    Even if it is, the application is in ABAP Web Dynpro and is launched from the portal.. hence launching it as a background job is not an option... Any solutions?????
    Any help on this would be appreciated...
    Thanks in advance, Amith

    Hi,
    Yes this is true that if we are having the multiple application server then this kind of error occures if your specified directory is not mapped on the alll the avaiable sAP application servers.
    I guess when ever you are running your application then system will pick the appkication server based on the present load. Hence if your directory is not mapped in that application server then you wil get this kind of issues,
    so i guess check with you basis team that spctified path is avaiable in all the application server.

  • Problem writing file ANSI to UTF-8. OPEN DATASET FOR OUTPUT IN TEXT MODE

    Hello everybody,
    My report needs  to create a file in ANSI so I am using this sentence: * "OPEN DATASET p_dir_a FOR OUTPUT IN TEXT MODE ENCODING DEFAULT."*  almost all charters in the file are well generating excepting for this two: ( Á ) & ( Í ) because SAP assigns the same code to both characters ( Ã? ) = 'xC3'  which is not correct, the right code should be ( Á ) = 'xC1'  ( Í ) = 'xCD' respectively
    from this string = ( ÁÉÍÓÚáéíóúàèìòùÀÈÌÒÙ ) only those two characters are wrong converted.
    Also I tray to catch a conversion error with this sentence:
              TRY.
                TRANSFER <field> TO p_dir_a NO END OF LINE.
              CATCH cx_sy_conversion_codepage.
                MESSAGE 'error' type 'I'.
            ENDTRY.
    but never enters in it.
    Does anyone know where I can configure SAP to SET this value correctly?
    Thanks for your help.

    was a server problem, not SAP

  • Open dataset in UTF8. Problems between Unicode and non Unicode

    Hello,
    I am currently testing the file transfer between unicode an non unicode systems.
    I transfered some japanese KNA1 data from non unicode system (Mandt,Name1, Name2,City) to a file with this option:
    set local language pi_langu.
      open dataset pe_file in text mode encoding utf-8 for output with byte-order mark.
    Now I want to read the file from a unicode system. The code looks like this:
    open dataset file in text mode encoding utf-8 for input skipping byte-order mark.
    The characters look fine but they are shifted. name1 is correct but now parts of the city characters are in name2....
    If I open the file in a non unicode system with the same coding the data is ok again!
    Is there a problem with spaces between unicode an non-unicode?!

    Hello again,
    after implementing and testing this method, we saw that the conversion is always taken place in the unicode system.
    For examble: we have a char(35) field in mdmp with several japanese signs..as soon as we transfer the data into the file and have a look at it the binary data the field is only 28 chars long. several spaces are missing...now if we open the file in our unicode system using the mentioned class the size is gaining to 35 characters
    on the other hand if we export data from unicode system using this method the size is shrinking from 35 chars to 28 so the mdmp system can interprete the data.
    as soon as all systems are on unicode this method is obselete/wrong because we don't want to cut off/add the spaces..it's not needed anymore..
    the better way would be to create a "real" UTF-8 file in our MDMP system. The question is, is there a method to add somehow the missing spaces in the mdmp system?
    so it works something like thtat:
          OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8 WITH BYTE-ORDER MARK.
    "MDMP (with ECC 6.0 by the way)
    if charsize = 1.
    *add missing spaces to the structure
    *transfer strucutre to file
    *UNICODE
    else.
    *just transfer struc to file -> no conversion needed anymore
    endif.
    I thought mybe somehow this could work with the class CL_ABAP_CONV_OUT_CE. But until now I had no luck...
    Normally I would think that if I'am creating a UTF-8 file this work is done automatically on the transfer command

  • 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

  • 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

  • Problem in file format OPEN DATASET

    Hi all,
       i am upgrading the systemm 4.7 to ECC6.0
      In one of the programs OPEN dataset statement is being used to download the file to unix server, but when i run the same program in ECC6.0 version an try to opn in notepad the same file it is coming in single line (i.e end of line delimiter is being ignored.)
    Hence I tried using WITH WINDOWS LINEFEED addition
    it is displayed correctlyin notepad but when i see thru
    transaction AL11 character'#' is displayed after every end of line also when i take a printout now one extra new line is added
    the delimiter which i have used here is
    C type c value CL_ABAP_CHAR_UTILITIES=>CR_LF
    Can anyone suggest a better method to solve the problem?

    DATA L_MSG1 TYPE STRING.
    CONSTANTS: C_TAB1 TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    *-- Open Dataset
        OPEN DATASET p_aosvr FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          DO.
    *-- Read Dataset and Populate Input file data to Internal Table
            READ DATASET unix_filename INTO L_MSG1.
            IF sy-subrc EQ 0.
              SPLIT L_MSG1 AT C_TAB1 INTO it_final-field1
                        it_final-field2
                        it_final-field3
                        it_final-field4
                        it_final-filed5.
              APPEND it_final.
              CLEAR  it_final.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
        ELSE.
          MESSAGE e000 WITH 'Error while uploading data'(013).
        ENDIF.
    *-- Close Dataset
        CLOSE DATASET p_aosvr.

  • 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

  • File transfer Open dataset CSV file Problem

    Hi Experts,
    I have an issue in transferring Korean characters to a .CSV file using open dataset.
    data : c_file(200) TYPE c value '
    INTERFACES\In\test8.CSV'.
    I have tried
    open dataset  c_file for output LEGACY TEXT MODE CODE PAGE '4103'.
    open dataset  c_file for output    in TEXT MODE ENCODING NON-UNICODE.
    open dataset  c_file for output    in TEXT MODE ENCODING Default.
    Nothing is working.
    But to download to the presentation server the below code is working. How can the same be achieved for uploading the file to application server.
    CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            filename                = 'D:/test123.xls'
            filetype                = 'ASC'
            write_field_separator   = 'X'
            dat_mode                = 'X'
            codepage                = '4103'
            write_bom               = 'X'
          CHANGING
            data_tab                = t_tab
          EXCEPTIONS
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
            not_supported_by_gui    = 22
            error_no_gui            = 23
            OTHERS                  = 24.

    Hi,
    I would recommend to use OPEN DATASET ... ENCODING UTF-8 ...
    If your excel version is unable to open this format, you can convert from 4110 to 4103 with report RSCP_CONVERT_FILE.
    Please also have a look at
    File upload: Special character
    Best regards,
    Nils Buerckel

  • Problem with file in open dataset

    Hi experts ,
    i m  getting output in a standard way . all the fields are displaying in one column .
    this is my code .
      DATA: L_DATA LIKE RLGRAP-FILENAME VALUE '/usr/sap/dev/sys/global/substanc' .
      OPEN DATASET L_DATA FOR OUTPUT IN TEXT MODE ENCODING DEFAULT  .
      IF SY-SUBRC <> 0.
        MESSAGE E208(00) WITH 'Error Opening File'.
      ENDIF.
      LOOP AT I_DOWNLOAD INTO I_WA.
        TRANSFER I_WA-WERKS TO L_DATA.
        TRANSFER I_WA-MATNR TO L_DATA .
        TRANSFER I_WA-MAKTX TO L_DATA.
        TRANSFER I_WA-MEINS TO L_DATA.
        TRANSFER I_WA-PQTY TO L_DATA.
        TRANSFER I_WA-FKLMG1 TO L_DATA.
        TRANSFER I_WA-DQTY TO L_DATA.
        TRANSFER I_WA-DOFORCAST TO L_DATA.
        TRANSFER I_WA-DUFORCAST TO L_DATA.
        TRANSFER I_WA-WAQTY TO L_DATA.
        TRANSFER I_WA-OFORCAST TO L_DATA.
        TRANSFER I_WA-UFORCAST TO L_DATA.
      ENDLOOP.
      CLOSE DATASET L_DATA.
      IF SY-SUBRC <> 0.
        MESSAGE E208(00) WITH 'Error Closing File'.
      ENDIF.
    Thanks,
    Ashish Gupta
    Moderator Message: Basic and Duplicate Post.
    Edited by: kishan P on Dec 10, 2010 3:05 PM

    Hi Sravan,
    Thanks for replay .
    I did the same but  i was getting error message .
    "I_WA" cannot be a table, a reference, a string, or contain any of
    these objects. any of these objects
    This is my internal table and work area definition.
    DATA : I_DOWNLOAD TYPE TABLE OF TY_DOWNLOAD WITH HEADER LINE,
           I_WA TYPE TY_DOWNLOAD.
    Thanks ,
    Ashish Gupta

  • Open DataSet problem

    Hello Expert:
    I wanna download a excel file from unix server
    the file inculde some Chinese Character.
    Program is:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    *& Report  YTEST_17
    REPORT  ytest_17.
    *& Report  ZUPLOADTAB                                                  *
    *& Example of Uploading tab delimited file                             *
    *REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/report/BS_template.xls'.
    *PARAMETERS: p_infile  type string.
    *DATA: ld_file LIKE rlgrap-filename.
    DATA: ld_file TYPE string.
    *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,
          wa_upload    TYPE t_record.
    *String value to data in initially.
    DATA: wa_string(255) TYPE c.
    *constants: con_tab(2) TYPE C 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.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    but a shortdump happened, would u please give some solution
    ShrtText
        You cannot convert the character set.
    &#21457;&#29983;&#20102;&#20160;&#20040;?
        While a text was being converted from code page '4110' to '4102', one of
        the following occurred:
        - an character was discovered that could not be represented in one of
        the two code pages;
        - the system established that this conversion is not supported.
        The running ABAP program, 'YTEST_17' had to be terminated, since the
        conversion could cause incorrect data to be generated.
        683 characters could not be represented (and thus could not converted).
        If 683 = 0, a second or a different error has occurred.
    thank you
    Kevin
    any solution, please..........
    Message was edited by:
            Kevin Gao

    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    *& Report YTEST_17
    REPORT ytest_17.
    *& Report ZUPLOADTAB *
    *& Example of Uploading tab delimited file *
    *REPORT zuploadtab .
    PARAMETERS: p_infile LIKE rlgrap-filename
    OBLIGATORY DEFAULT '/usr/sap/report/BS_template.xls'.
    *PARAMETERS: p_infile type string.
    *DATA: ld_file LIKE rlgrap-filename.
    DATA: ld_file TYPE string.
    *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,
    wa_upload TYPE t_record.
    *String value to data in initially.
    DATA: wa_string(255) TYPE c.
    *constants: con_tab(2) TYPE C 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.
    <b>
    SET LOCALE LANGUAGE 'JA'. “Specify the language .. JA Is for Japanese
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE encoding NON-UNICODE.</b>
    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.

  • Problem in the internal table of open dataset statement

    Hi abapers,
    I am using the open dataset command to download my file at application server into an internal table.
    But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
    The open dataset command does not allow the internal table to have string components.
    Is there any workaround by which i can download all the text components of the file without truncating them .
    Regards,
    Aditya

    try to use field symbols:-
    FORM download_file  .
      DATA: l_file TYPE  rlgrap-filename,
            l_line TYPE string.
      DATA: v_excel_string(1000) TYPE c,
              v_len TYPE i,
              v_zover TYPE i .
      FIELD-SYMBOLS: <f>     TYPE ANY .
      CLEAR wa_fin.
    *--- Seting File path
      CONCATENATE p_cfile v_file sy-datum INTO l_file.
    *--- Open data set
      OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        LOOP AT it_down INTO wa_down.
          CLEAR : v_excel_string, v_zover, v_len.
          DO.
            ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
            IF sy-subrc <> 0.
              EXIT. "exits do loop and process next record in itab
            ENDIF.
            DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
            v_excel_string+v_zover(v_len) = <f> .
            v_zover = v_zover + v_len .
          ENDDO.
          TRANSFER v_excel_string TO l_file.
          CLEAR : v_excel_string,
                  wa_down       ,
                  v_zover       .
        ENDLOOP.
    *--- Close data set
        CLOSE DATASET l_file.
        IF sy-subrc = 0.
    *--- Success Message
         MESSAGE s000(000) WITH text-018.
        ENDIF.
      ELSE.
    *--- Error unable to open file.
        MESSAGE e000(000) WITH text-017.
      ENDIF.
    ENDFORM.                    " DOWNLOAD_FILE
    Thanks ,
    Ruchi Tiwari

  • 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 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

Maybe you are looking for