Skip to Content
author's profile photo Former Member
Former Member

Syntax error with offset

Hi All,

I have the below logic in ECC 6

FORM ysd_sd09_124_clean_up_zzcmw.

DATA: lv_a0 TYPE i VALUE 160.

DATA: lv_trans(2).

FIELD-SYMBOLS: <lf> TYPE c.

ASSIGN lv_a0 TO <lf> CASTING TYPE c.

lv_trans(1) = <lf>+3(1).

TRANSLATE vbkd-zzcmw USING lv_trans.

ZZCMW is a custom field(customer master warranty field).

When I am trying to create a sales order this user exit will trigger and giving dump for the code TRANSLATE vbkd-zzcmw USING lv_trans.

Category ABAP Programming Error

Runtime Errors DATA_OFFSET_TOO_LARGE

Except. CX_SY_RANGE_OUT_OF_BOUNDS

ABAP Program SAPMV45A

Application Component SD-SLS

Date and Time 21.09.2011 10:09:33

Short text

Invalid subfield access: Offset too large

What happened?

Error in the ABAP Application Program

The current ABAP program "SAPMV45A" had to be terminated because it has

come across a statement that unfortunately cannot be executed.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

In the running program "SAPMV45A", the field "<LF>" of the type

"C" and length 2 was to be accessed with the offset 3.

However, subfield accesses with an offset specification that is not

smaller than the field length are not permitted.

But same is wokring in 4.7. I tried to change the declarations but it did not work out. Can you please tell me what would be the difference in both versions?

Regards,

Jyothi CH.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Sep 21, 2011 at 07:41 AM

    Did you activate Unicode during the upgrade, check [Assignments to Field Symbols|http://help.sap.com/saphelp_nw04/helpdata/en/79/c55491b3dc11d5993800508b6b8b11/frameset.htm]

    Assignments to Field Symbols

    Until now the ASSIGN statement made it possible to define addresses past field limits by specifying the offset or length. There was only a runtime error when addressing past the limits of the data segment. Cross-field accesses to the offset/length in an ASSIGN, for example, could be used to edit repeating groups.

    With Unicode, however, problems occur since it is not possible to ensure that cross-field offset or length definitions can be interpreted as bytes or characters in an identical and meaningful manner in both a US and an NUS. For this reason, the ASSIGN statement was enhanced with the RANGE and INCREMENT additions while the CASTING addition now supports all variants of this statement. The RANGE addition is offered for all valid variants of ASSIGN and can be combined with the CASTING addition.

    Try a

    lv_trans = cl_abap_conv_in_ce=>uccp( '00A0' ).

    (UTF-16 to UTF-8 ?)

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2011 at 07:44 AM

    Hi Raymond,

    Tried debugging and changing some lengths of the variables. The value of the FS is #. Does that mean that the Unicode in our current version was not activated as well?

    Thanks!

    Best Regards,

    Benedict

    Edited by: benedict choa on Sep 21, 2011 3:54 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 21, 2011 at 08:55 AM

    Hi Jyothi ,

    In unicode Length of character is 2 bytes . Hence fieldsymbol you declared <lf> is having length 2 .

    and you have specified

    <lf>+3(1) which is more than 2 . Hence this is error .

    so please change your code accordingly .

    <lf>+1(1) .

    ALso you have type casting with c , i.e charater it is taking its value as #

    if you remove type casting it will have value 160 in fieldsymbol varaible , but it will give error while using offset because of integer field assignment .

    regards

    Deepak.

    Edited by: Deepak Dhamat on Sep 21, 2011 10:58 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi ,

      Check this .

      DATA: lv_a0 TYPE i VALUE 260.

      DATA: lv_trans(3) .

      FIELD-SYMBOLS: <gt> .

      ASSIGN lv_a0 TO <gt> .

      lv_trans = <gt>.

      vbkd-BSARK_E = '62' .

      TRANSLATE vbkd-BSARK_E USING lv_trans.

      IT will give output vbkd-BSARK_E = 66

      because it will search for patterns in lv_trans where first value is 2and second is 6 so ,

      in

      TRANSLATE vbkd-BSARK_E USING lv_trans.

      it will search for value 2 from lv_trans in vbkd-BSARK_E and will replace with 6 .

      regards

      Deepak

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2011 at 09:10 AM

    Hi,

    <LF> will always contain # as you have used casting. Even if you remove casting, the statement lv_trans(1) = <lf>3(1) will never give you anything. As <lf> contains 160, <lf>3(1) will contain blanks.

    If you need any value in lv_trans(1), change the offset to either 0(1) / 1(1) / 2(1).

    Try This,

    
    DATA: lv_a0 TYPE c LENGTH 10.
    DATA: lv_trans(2).
    FIELD-SYMBOLS: <lf> TYPE c.
    
    lv_a0 = '160'.
    
    ASSIGN lv_a0 TO <lf>.
    
    lv_trans(1) = <lf>+2(1).
    
    

    Regards,

    Danish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2011 at 11:07 AM

    Hi,

    This questin is answered.

    Add a comment
    10|10000 characters needed characters exceeded

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.