Problem reading DATASET into xstring

Hi,
I am facing a curious problem where I'd appreciate a helping hand: when I read data from a dataset into a variable of fixed-length, everything works fine. When I try to do the same with a variable-length type, nothing is read.
This code works fine:
<i>DATA binarydata(32000) TYPE x,
     alen TYPE i.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
READ DATASET filename INTO binarydata ACTUAL LENGTH alen.</i>
Here alen contains the correct number of bytes read (eg. 19000).
But if I try:
<i>DATA binarydata TYPE xstring,
     alen TYPE i.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
READ DATASET filename INTO binarydata ACTUAL LENGTH alen.
</i>
Here alen is 0.
Can anybody tell me what's wrong here ?
Thanks & Regards
Heiko

Hello Heiko
   If you are using NON-UNICODE system, please try by unselecting the checkbox "Unicode Checks Active" in program attributes.
   While using UNICODE system, need to use as STRING.
Reason:
In UNICODE enabled or when Unicode Checks is active, system can transfer data between structures only when both are of characater format.
In your case, the data is read in text mode i.e character format but trying to move to XSRTING which is sequence of 'X' type characters. Hence resulting in dump.
Just for your info:
<b>The elementary data type STRING is similar to data type C and refers to a variable-length string. Accordingly, the elementary data type XSTRING is similar to data type X and refers to a variable-length byte sequence.</b>
   Hope the above info clarifies you.
Kind Regards
Eswar

Similar Messages

  • Problem reading dates into numbers

    I suspect I am missing something very obvious but I am trying to read a spreadsheet with dates in the first column  into Numbers 3.0.1 in Mavericks. The original file was in xls format and the dates are imported as numbers (e.g. todays date - 31st Dec 2013 appears as 41639). The spreadsheet was created with Libreoffice but the dates are fine if I read the xls file into preview or google docs.  I have tried reformatting the column into date format but nothing happens. Any ideas?

    Check to see if any columns are hidden by opening the contextual menu for any column:

  • Upload read dataset only one line

    hi all
    i have a problem, i want to upload a file from applikation server. When i want to read dataset into a xstring field,
    it read only the first line not all why?
    here is my code
    type-pools dset.
    data lf_filename type string value '/opt/interface/indtrans/d58_sst/integrale/output/PLU.plu'.
    data lf_line type xstring.
    data lf_str_line type string.
    data lf_hex_code type swxmlcont.
    data lt_attr type dset_attributes.
    start-of-selection.
      open dataset lf_filename for input in binary mode.
      do.
        read dataset lf_filename into lf_line.
        if sy-subrc <> 0.
          exit.
        else.
    *      get dataset lf_filename attributes lt_attr.
          append lf_line to lf_hex_code.
        endif.
      enddo.
      close dataset lf_filename.
    thx abap_begin....

    that to be functional, but when i read with the file with cl_gui_frontend_services=>gui_upload with file Typ "BIN"
    CALL METHOD cl_gui_frontend_services=>gui_upload
         EXPORTING
           FILENAME                = l_filename
           FILETYPE                = 'BIN'
    *      HAS_FIELD_SEPARATOR     = SPACE
    *      HEADER_LENGTH           = 0
         IMPORTING
           FILELENGTH              = l_size
    *      HEADER                  =
         CHANGING
           data_tab                = lt_data
         EXCEPTIONS
           FILE_OPEN_ERROR         = c_not_found
           FILE_READ_ERROR         = 3
           INVALID_TYPE            = 4
           NO_BATCH                = 5
           GUI_REFUSE_FILETRANSFER = 7
           others                  = 99.
    i becam a other result then, when i read with
    open dataset lf_filename for input in binary mode.
    why?
    Now i have a idea, i read the file value in text mode and save this in an internal table.
    Then make the loop over table, and convert the value in identical princple such as cl_gui_frontend_services=>gui_upload with the filetype "BIN".
    I dont' know, how you do this?
    thx abap_begin

  • Problem with READ DATASET when reading file from app server

    Hi,
    wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
    OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
                                 ENCODING DEFAULT
                                 WITH SMART LINEFEED.
    DO.
    READ DATASET file_rtf INTO string.
    IF SY-SUBRC = 0.
    EXIT.
    ENDIF.
    ENDDO.
    the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
    Any ideas as to what is causing this problem appreciated, <removed>
    Thanks
    Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...

    Hi Adam,
    The source code in the below link has details about how to read/write to application server.
    [Application server file operartions|http://www.divulgesap.com/blog.php?p=NDk=]
    Please let us know if you have any issues.
    Regards,
    Ravi

  • # problem while reading dataset from application server.

    hi all,
    I uplodaed a  text file which is tab delimeted, to the application server using transaction code cg3z directly. now that file is stored with # in place of tab(space) in application server.
    my broblem is that when i am reading that file using  READ DATASET  its comming with that # symbol also.
    how i split that dataset .
    or if there is any other solution ,like openning file into another mode,
    help me.
    thank uou

    Hi Pawan..
    you can access the Tab character using CL_CHAR_ABAP_UTILITIES=>HORIZONTAL_TAB
    Do like this After READ DATASET.
    DATA : V_RECORD(100).
    DO.
    READ DATASET P_FILE INTO V_RECORD.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    SPLIT V_RECORD INTO FIELD1 FIELD2 SEPARATED BY <b>CL_CHAR_ABAP_UTILITIES=>HORIZONTAL_TAB.</b>
      <<<<further operations here>>>>
    ENDDO.
    reward if Helpful.
    <b></b>

  • Error on line read dataset p_zfile into it_int

    hi while executing this below code..
    open dataset p_zfile for input in text mode ENCODING DEFAULT.
        if sy-subrc = 0.
          v_one = 1.
          do.
            v_no = v_no + 1.
         *read dataset pzfile  into it_record*_ this is giving short dump as below
    code to read file
    end do
    short dump
    the following error is being prompted
    CONVT_CODEPAGE
    CX_SY_CONVERSION_CODEPAGE
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    where
    it_record is type infile_struct,
    and infile_struct is as below
    types: begin of infile_struct,
            data(1150)           type c,
           end of infile_struct.
    and p_zfile is used in fm call file_get_nam
    please suggest this code is working fine in 4.6 c not upgraded to SAP ECC 6.0 this error is occuring in the code
    regarda
    arora

    here is code
    open dataset p_infile for input in text mode ENCODING DEFAULT.
    f sy-subrc = 0.
          v_one = 1.
          do.
            v_no = v_no + 1.
            read dataset p_infile into in_record.        if sy-subrc = 0. here dump is occuring at last record i deleted the last record in the file but again the dump comes on last record only when all records are read and finally when the cursor come to read dataset statement last time
              if v_no <> v_one.
                split in_record at v_tab into wa_record-idno
                                              wa_record-stonumber
                                              wa_record-stolineno
                                              wa_record-sched_line
                                              wa_record-pur_group
                                              wa_record-frmplant
                                              wa_record-frmstglocatin
                                              wa_record-toplant
                                              wa_record-tostglocation
                                              wa_record-material
                                              wa_record-matdesc
                                              wa_record-quantity
                                              wa_record-dockdate
                                              wa_record-splinst1
                                              wa_record-splinst2
                                              wa_record-splinst3
                                              wa_record-splinst4
                                              wa_record-delete
                                              wa_record-block.

  • READ DATASET PROBLEM

    Hi all,
    Using the code to read file data
    DATA : Len type i,
                str_name type string.
    READ DATASET name INTO str_name LENGTH len .
    but it only reads first 155 characters i.e. length is always 155 not more that that but as per requirement wants to read more that 155 charcters.
    Any suggestions welcome,
    Regards,

    READ for Files
    Reads a file.
    Syntax
    READ DATASET <dsn> INTO <f>
    [MAXIMUM LENGTH <maxlen>]
    [ACTUAL LENGTH <len>].
    Reads the contents of the file <dsn> on the application server to the variable <f>. The amount of data can be specified using MAXIMUM LENGTH. The number of bytes transferred can be written to <len> using ACTUAL LENGTH.
    Regards,
    Priya.

  • Problem reading dng files into Photoshop CS6

    Why can't I read dng files from a canon 5dmk2 from ACR8.1 into Photoshop cs6?

    I converted the CR2 files from the Canon5dmk2 into dng using the Adobe DNG converter.
    In Photoshop CS3 I can read these dng files into Adobe Camera Raw and then export them into Photoshop. No problem.
    I have just installed Photoshop CS6. I can read the dng files into Adobe Camera Raw (v8.1) without a problem. However the file is then corrupted when I try to export it into CS6.
    Strangely, I have similar files converted from CR2 to DNG for a Canon 1100D and these read without problem via ACR into both Photoshop CS3 and CS6.
    The problem is that Photoshop CS6 will not read dng files from a Canon 5dmk2.

  • HT4489 I am attempting to import a vcard from my outlook into my icloud contacts. Exporting works fine but I get the error...could not import some contacts becaus ethere was a problem reading the vcard. Any suggestions?

    I am attempting to import a vcard from Outlook 2010 into my iCloud. Exporting to Outlook works fine but I get an error ..could not be imported there was a problem reading the vcard. Any suggestions?

    bmitch3 wrote:
    I am attempting to import a vcard from Outlook 2010 into my iCloud. Exporting to Outlook works fine but I get an error .
    You mean exporting from Outlook surely, what exactly are you you importing to?

  • Problems on reading PCM into digital form

    Hi,
    I'm now on a project doing heart rate detection.
    Due to the project just started, therefore I do not got any device to measure my own heart rate, but I will be making up some PCM(analog) data, and try to read that into digital form and give me results of the heart rate.
    I'm not sure am I on the right track now or not,
    what I'm doing now is trying to convert a ".wav" into bytes array, then it should give me some data, however, I'm not sure how to relate that data into heart rate.
    Please leave me any comment if u think it might help please.
    Thanks,
    till

    I'm not too sure what should be the .wav should be, however, according to this acticle I got it from the web:
    _2.1 Signal acquisition_
    ECG signal frequency content lies between about 0.05Hz and
    500Hz and has amplitude of few mV. The acquisition is provided
    to be performed in three different ways: (i) using direct electrode
    measurements, (ii) using ECG equipment with analogous output;
    and (iii) using ECG equipment with digital output. For the first
    two cases, a sampling rate of 8 kHz is assumed. In the third case,
    the acquired discrete signals are accordingly resampled.
    _2.2 Modulation_
    The bandwidth of the phone’s voice channel is limited to the
    range 300Hz-3300Hz. The signal amplitude at the microphone
    input should not exceed 100mV. Modulation is performed through
    multiplication with carrying sinusoidal signals. Five 500Hz-wide
    channels are packed within the 500Hz-3000Hz band. The
    resulting signal is appropriately refined in amplitude and directed
    to the modulator’s output.
    _2.3 Digitizing, storing and sending_
    The complex signal is band-limited to 3300Hz. Therefore, a
    standard sampling frequency of 8 kHz is used for its digitization.
    A JAVA application performs that and in order to store the signal
    intact, the signal is recorded in a lossless format such as pulsecode
    modulation (PCM). The WAV audio file format implements
    PCM and is used to store the recorded modulated ECG signals.
    Once stored, the signals can be visualized, processed and sent by
    the mobile phone.
    Mobile phone’s firmware is accessible by programming
    languages as C++ and JavaTM. Most mobile phones support
    JavaTM runtime called Kilobyte Virtual Machine (KVM) [6]. This
    language provides the ability to build a GUI application that could
    support all the stages of recording, storing and transmitting of the
    ECG signal. JSR-135 contains libraries of JavaME, which are
    useful for capturing audio from the microphone's port of a mobile
    phone. The above mentioned platform was used to create the
    application software.
    _2.4 Demodulation_
    The procedure of demodulation is performed at the physician’s
    phone, following the reverse track of modulation. A digital band
    pass filter is used to separate the spectra, corresponding to the
    individual ECG signals. The filtered signal was then multiplied by
    the corresponding carrier frequency and filtered with a low pass
    filter, resulting in the original signal. The demodulated signals can
    be stored in separate WAV files in the physician’s phone.
    _2.5 Matlab simulations_
    In order to prove the principal feasibility of the approach, the
    signal acquisition, processing and transmission procedures were
    simulated in MATLAB. Five preliminary recorded ECG signals
    were directly loaded and used. The signals acquisition parameters
    were: 8-bit values, sampling rate of 250Hz and duration – 10S.
    Modulation and demodulation were programmed and performed
    in a numerical way. Modulation was done by multiplication of the
    ECG signals with carrying sinusoidal signals of frequencies
    500Hz, 1000Hz, 1500Hz, 2000Hz, and 2500Hz. The
    demodulation included first separating the spectrum of each
    individual signal with the help of 4-th order 400Hz-wide bandpass
    Butterword filters centered on the corresponding carrying
    frequency. Next the filtered signals were multiplied with the same
    carrier signals and eventually filtered with a low pass 4-th order
    Butterworth filter (fc=200Hz).
    btw, the system need to be implement into Symbian phone at the end,
    but I'm just now testing on the PC atm =)
    according to this article, what kind of wav I should be using ??
    thanks a lot!!!

  • Problem reading .xls file from App Server

    Hi Everyone......
    I hope this might be a common problem but i searched for similar problem......i did'nt find the solution my problem is
    I'm trying to download .xls(excel file data into an internal table using OPEN DATASET FOR INPUT IN TEXT MODE ENCODING DEFUALT and read dataset for reading it).But in the read dataset syntax all stange values like **$#@&&& are getting uploaded???? I dont now why......
    Is it happing because i'm trying to upload .XLS file ???
    My coding is as follows...........
      OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
          IF sy-batch IS INITIAL.
            MESSAGE i001(zz) WITH 'Error opening file for upload'.
            EXIT.
          ELSE.
            MESSAGE s001(zz) WITH 'Error opening file for upload'.
            EXIT.
          ENDIF.
        ENDIF.
    *First Uploading the data into structure
        DO.
          READ DATASET p_file INTO l_wa_tab.   "My internal table work area
          IF sy-subrc = 0.
            APPEND l_wa_tab TO  l_tab.
          ELSE.
            EXIT.
          ENDIF.
          ADD 1 TO count.
        ENDDO.
        CLOSE DATASET p_file.
    Any solution for above problem.........

    Hi,
    Check whether path ur providing to the open data set stmt is correct or not in debugging mode.
    * File upload to internal table from UNIX Directory
        IF NOT p_i1file IS INITIAL AND NOT p_path IS INITIAL.
          CONCATENATE p_path p_i1file INTO v_file.
          CONDENSE v_file.
          OPEN DATASET v_file FOR INPUT IN TEXT MODE MESSAGE v_msg.
          IF sy-subrc EQ 0.
            WRITE:  / 'INPUT FILE CONTAINS NO RECORD :'(010), v_file.
            DO.
              CLEAR tbl_input.
              READ DATASET v_file INTO tbl_input.
              IF sy-subrc NE 0.
                EXIT.
              ELSE.
                APPEND tbl_input.
              ENDIF.
            ENDDO.
    * Close Input File
            CLOSE DATASET v_file.
          ELSE.
            WRITE:/'Error uploading file: '(008),v_file.
            STOP.
          ENDIF.
        ENDIF.
    It should work.check the sy-subrc value and file value in debug mode.
    Thanks
    Parvathi

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

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

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

  • READ DATASET

    Hi Friends,
    I'm getting problem in reading only 100 records from the application server using the READ DATASET statement. The file on the application server may have 8000 records but i wanted to get only 100 records and process them. Then i wanted to get  next 100 records from the file stored on app.server and process and so on.
    After I get the 100 records, I wanted to do further operations such as putting them into a custom table.
    Will the below code work?
    DATA l_item(100) type c.
    *Open the .DAT file for reading
      OPEN DATASET p_file1 FOR INPUT IN TEXT MODE ENCODING UTF-8 MESSAGE
      x_error.
      IF sy-subrc NE 0.
    *An error occured during opening the dataset !
        MESSAGE x_error TYPE 'E'.
        CLEAR x_error.
      ENDIF.
      DO.
    *Read the .DAT file into an internal table
        READ DATASET p_file1 INTO l_item.
        IF sy-subrc EQ 0.
    *split the records into data fields based on delimiter ','
    *then append the current record to an internal table
          SPLIT l_item AT ',' INTO
                                   x_item-inv_item_id
                                   x_item-intl_aa_nbr
                                   x_item-intl_pba_nbr
                                   x_item-intl_ta_nbr
                                   x_item-intl_product_code
                                   x_item-descr254
                                   x_item-intl_stck_id
                                   x_item-awr_disallowed_flg
                                   x_item-returnable_flg
                                   x_item-fulfillment_flg
                                   x_item-refund_only_flg
                                   x_item-prod_returnable_flg
                                   x_item-stock_cat_id.
          APPEND x_item TO i_item.
          CLEAR x_item.
        ELSE.
    *Data was read and the end of the file was reached
          MESSAGE i006.
          EXIT.
        ENDIF.
      ENDDO.

    Hi,
    If you want to process every 100 records once,  you can in ways.
    1.  
    DO.
    *Read the .DAT file into an internal table
        READ DATASET p_file1 INTO l_item.
        IF sy-subrc EQ 0.
    *split the records into data fields based on delimiter ','
    *then append the current record to an internal table
          SPLIT l_item AT ',' INTO
                                   x_item-inv_item_id
                                   x_item-intl_aa_nbr
                                   x_item-intl_pba_nbr
                                   x_item-intl_ta_nbr
                                   x_item-intl_product_code
                                   x_item-descr254
                                   x_item-intl_stck_id
                                   x_item-awr_disallowed_flg
                                   x_item-returnable_flg
                                   x_item-fulfillment_flg
                                   x_item-refund_only_flg
                                   x_item-prod_returnable_flg
                                   x_item-stock_cat_id.
          APPEND x_item TO i_item.
          CLEAR x_item.
          lv_count = lv_count + 1.
         if lv_count = 100.
           perform process 100 records.
            clear: lv_count, x_items.
            refresh x_items.
        endif.
        ELSE.
    *Data was read and the end of the file was reached
          MESSAGE i006.
          EXIT.
        ENDIF.
      ENDDO.
    2.   Download all records into an internal table once.
    then loop internaltable.
    data: lv_count type i,
             lv_count1 type i,
             lv_previous type i.
    lv_count = lv_count  + 1.
    lv_count1 = lv_count1 + 1.
    if lv_count1 < = 100.
    copy 100 records into another internal table2.
    else.
         lv_previous = lv_count - lv_previous.
    if lv_previous = 100.
        process records.
       clear: lv_count1,  internal table2.
       refresh internal table2
    endif.
    endif.
    endloop.
    regards,
    Ganesh

  • Explain why READ DATASET conversion from codepage '4110' to codepage '4102'

    I am unfamiliar with unicode but I am trying to solve a problem in an ABAP program.
    Our code is
    OPEN DATA p_in FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
      READ DATASET p_in INTO i_tab.
    The program gives me the error  'At the conversion of a text from codepage '4110' to codepage '4102'.  The program abends on a line in the file that contains the special character '#'.
    Does this mean that the file I am reading is in codepage '4110' and the internal format of i_tab is codepage '4102'?  If so, how do the codepages get assigned to unix files and internal structures   How can I make the both codepage '4110' or codepage '4102'?  Also, what is the difference between these two codepages?
    thanks.
    Ryan
    My

    Hi,
    Use
    open dataset DSN in text mode for input encoding utf-8.

  • WD ABAP - ALV data into Xstring

    Hello,
      In a WD ABAP application, there is a ALV table and on the ALV tool bar I have a new push button, when it is pressed, I need to extract the ALV data(along with column names) into XSTRING, which is similar to the data that comes into PDF when 'Printversion' button is pressed. Is there any way to do this?
    Thanks.
    Nagendra

    Solved the problem. The requirement was to convert ALV into PDF xstring. The sample code is .
      DATA: lo_interfacecontroller1 TYPE REF TO iwci_salv_wd_table ,
            lo_component            TYPE REF TO cl_salv_wd_c_table,
            lo_result               TYPE REF TO cl_salv_wd_result_data_table,
            lo_pdf                  TYPE REF TO cl_salv_wd_export_pdf,
            lv_pdf_content          TYPE xstring.
      lo_interfacecontroller1 =   wd_this->wd_cpifc_alv( ).
      lo_component ?= lo_interfacecontroller1->get_services( ).
      lo_result = lo_component->r_result_data.
      CREATE OBJECT lo_pdf.
      CLEAR: lv_pdf_content.
    Call the following method to generate the xstring for PDF.
      lo_pdf->execute(
        EXPORTING
           result_data = lo_result
           r_component = lo_component
        IMPORTING
           resultstring = lv_pdf_content ).

Maybe you are looking for

  • Replacement iPod - Still Not Working

    Last week I sent my 30GB to Apple for service (after having it only a month) and I recieved my replacement yesterday, but I'm still having issues. When I first got it home, it hooked up to iTunes and my laptop just fine, but then it stopped transferr

  • How many elements can I insert into a form?

    When creating my form I received a notice that I had reached the maximum number of elements for my form!  I was near the end stages of my design, Ouch!  What can I do?  Is it possible to cut and past sections of my form to create a new form(s) and li

  • I upgraded to IOs5 and now my phone doesn't recognize my contacts in entering calls

    I upgraded my Iphone 4 to IOs5 and now the entering calls are not recognized, it appears only the number but anymore the name of the contact, i think is some easy issue but i can't find it! does it have happened to anyone?? and know how to solve it,

  • Complicated Ipod synching problem

    The most basic part of my problem is that my podcasts don't exist on my ipod. While they may be listed on my computer they do not transfer over, and when I hit the "podcasts" button it's completely blank as if none exist. Please stick with me and hel

  • Call a DLL in background

    Hello fellows, Is that possible to call a DLL ActiveX using OLE Automotion, but in background? It is really important that is in background, because the calls will be through JOBs. Thanks a lot, Marcos Ferreira