Skip to Content
avatar image
Former Member

READ DATASET

I am reading the file using READ DATASET. I get an error on the 4th MOVE, MOVE gv_row+36(40) TO wa_qualitydata-char_descr.

The current program "ZFS1052IN" tried to access a part of a string using

offset and length.

However, the sum of the offset (36) and length (40) specifications

was greater than the length of the string (64).

This is not allowed.

Any ideas how to solve this?

Thanks

TYPES: BEGIN OF t_qualitydata,
         matnr(18)      TYPE C,
         charg(10)      TYPE C,
         verwmerkm(8)   TYPE C,
         char_descr(40) TYPE C,
         kurztext(40)   TYPE C,
         mean_value(22) TYPE C,
       END OF t_qualitydata.
DATA: i_qualitydata  TYPE STANDARD TABLE OF t_qualitydata,
      wa_qualitydata TYPE t_qualitydata.

DATA: gv_row TYPE string.

OPEN DATASET c_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
  READ DATASET c_file INTO gv_row.
  IF sy-subrc = 0.

    MOVE gv_row+0(18)   TO wa_qualitydata-matnr.
    MOVE gv_row+18(10)  TO wa_qualitydata-charg.
    MOVE gv_row+28(8)   TO wa_qualitydata-verwmerkm.
<b>    MOVE gv_row+36(40)  TO wa_qualitydata-char_descr.</b>

    APPEND wa_qualitydata TO i_qualitydata.

  ELSE.
    EXIT.
  ENDIF.                   "IF sy-subrc = 0.
ENDDO.

CLOSE DATASET gv_row.

HYC26138450      AC7812345 50000700SPECIFIC GRAVITY @ 15.6 C                                                                       1.0600
HYC26138450      AC7812345 50000751BLOT  (PASS)                            Clean
HYC26138450      AC7812345 50000757CLARITY  (CLEAR)                        Slight Haze Pass
HYC26138450      AC7812345 50000761COLOR  3.0 typical                      L 0.5
HYC26138450      AC7812345 50000731VISCOSITY @ 40 C, CST                                                                            69.00
HYC26138450      AC7812345 50000725VISCOSITY @ 100 C, CST                                                                           8.300
HYC26138450      AC7812345 50000429WATER                                                                                0.300
HYC26138450      AC7812345 50000770COPPER STRIP  2C max.                   1A
HYC26138450      AC7812345 50000286NITROGEN                                                                                0.900
HYC26138450      AC7812345 50000322PHOSPHORUS                                                                                1.600
HYC26138450      AC7812345 50000401SULFUR                                                                                30.000
HYC26138450      AC7812345 50000745APPEARANCE  (PASS)                      Tan
HYC26138450      AC7812345 50000264MINERAL OIL                                                                                1.900
HYC26138450      AC7812345 50000398SULFATED ASH                                                                                0.850
HYC26138450      AC7812345 50000469BASE NUMBER                                                                                90.000
HYC26138450      AC7812345 50000524FLASH POINT, C, PMCC                                                                              63.0
HYC26138450      AC7812345 50000531FOAM TEST, SEQ II, STABILITY
HYC26138450      AC7812345 50000530FOAM TEST, SEQ II, TENDENCY
HYC26138450      AC7812345 50000793H2S HEAD AFTER STG  (NEGATIVE)          Negative
HYC26138450      AC7812345 50000778INFRARED EVALUATION  (PASS)             FC-1 Fail Category 1
HYC26138450      AC7812345 50000569LBS PER GAL @ 15.6 C                                                                             8.880
HYC26138450      AC7812345 50000782ODOR AFTER STORAGE  (STRONG)            Strong
HYC26138450      AC7812345 50000617POUR POINT, C                                                                                -24.0
HYC26138450      AC7812345 50000713SPECIFIC GRAVITY FACTOR                                                                      0.0007200

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 20, 2007 at 07:14 PM

    Hi,

    change gv_row from string to char say length 250.

    Thanks,

    Deepak.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 07:14 PM

    I changed gv_row to

    data: gv_row(256) type c.

    and it worked. strange!!

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 20, 2007 at 07:19 PM

    Hi Megan, if you want to keep gv_row as a string, you may want to give this a try.

    
        move gv_row+0(18)   to wa_qualitydata-matnr.
        move gv_row+18(10)  to wa_qualitydata-charg.
        move gv_row+28(8)   to wa_qualitydata-verwmerkm.
    
        data: len type i.
        data: char type i.
        len = strlen( gv_row ).
        if len > 76.
          move gv_row+36(40)  to wa_qualitydata-char_descr.
        else.
          char = len - 36.
          move gv_row+36(char)  to wa_qualitydata-char_descr.
        endif.
    
        append wa_qualitydata to i_qualitydata.
    
    

    Regards,

    RIch Heilman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 07:36 PM

    Thanks Rich. i have decided to stick to type c length 256. I have been trying to look for your book, its not available on amazon. Where can I get it from?

    Add comment
    10|10000 characters needed characters exceeded