Skip to Content

Offset Error dump in code

HI guys,

I have a requirement in which when a space is given in string field (text) in table control and enter is pressed, then a special character should appear in place of space. But in another field which is of Simulation it should appear as space i.e. the special character should be converted back to space in simulation field.

Now, I have written the below code and it works fine for the existing records in table. But when i make a new entry and in text field i enter something lets say "abcd" it gives me dump stating some offset error - "subfield accesses with an offset specification that is not smaller than the field length are not permitted."

Can you help me with this.

In code "lws_fzcoprsff" is the work area of table fzcoprsff

"lws_fzcoprsff-text1" is the text field.

DATA : lw_count TYPE i,
lw_char TYPE c.
lw_count = 1.
lw_char = lws_fzcoprsff-text1(1).
IF lws_fzcoprsff-text1 IS NOT INITIAL.
IF lws_fzcoprsff-text1+lw_count(1) EQ '#'.
lws_fzcoprsff-text1+lw_count(1) = space.
ELSEIF lws_fzcoprsff-text1+lw_count(1) EQ lw_char.
lw_count = lw_count + 1.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jan 08, 2013 at 09:17 AM

    Hello Dharmin,

    why do you not use the ABAP statement "REPLACE"?


    REPLACE ALL OCCURRENCES OF '#' IN lws_fzcoprsff WITH space.

    I think, the way, how you use the offset-options is not ideal:

    lw_count(1) makes a string conversion and then takes the first character. When you use this in your context of


    this leads to an error. For using offset, just take the integer-variable without length-operator.

    Kind regards,


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2013 at 11:31 AM

    hi dharmin,

    can you provede some expected result for respective input, so it will be easy to help you


    Add a comment
    10|10000 characters needed characters exceeded

    • HI JO,

      well i tried replace command.. but it didn't work. instead i used this

      LOOP AT int_fzcoprsf INTO ws_zcoprsf WHERE opno = zcoprs-opno AND oopr = zcoprs-oopr AND oprs = zcoprs-oprs.
      lw_count = 1.
      lw_char = ws_zcoprsf-text1(1).
      lw_strlen = STRLEN( ws_zcoprsf-text1 ).
      IF ws_zcoprsf-text1 IS NOT INITIAL.
      WHILE lw_count LT lw_strlen.

      IF ws_zcoprsf-text1+lw_count(1) EQ space.
      ws_zcoprsf-text1+lw_count(1) = '#'.
      ELSEIF ws_zcoprsf-text1+lw_count(1) EQ lw_char.
      lw_count = lw_count + 1.

      MODIFY int_fzcoprsf FROM ws_zcoprsf TRANSPORTING text1 simulation.

      I used while loop.. so its working.

      But am not understanding this behaviour of similar characters.. Moreover only when similar characters are written at first den its showing error.. i.e if "aab cd" if i write like this then it does not show d special charatcer like "aab#cd" instead it shows it as space only.. but if i write anywhere except the first place like "abb cd" then it shows d special char. "abb#cd"..! Wonder why its happening lke this.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.