Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax error with offset

Former Member
0 Kudos

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.

7 REPLIES 7

raymond_giuseppi
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Replace your code (substring of pointer is not a good idea in unicode system) with a

lv_trans = cl_abap_conv_in_ce=>uccp( '00A0' ).
REPLACE ALL OCCURRENCES OF lv_trans IN vbkd-zzcmw WITH space.

Regards,

Raymond

NB: For information, '00A0' is the unicode value of "non-breaking space" (NBSP) and the program try to translate those to simple space characters. (ref [Non-breaking space|http://en.wikipedia.org/wiki/Non-breaking_space])

deepak_dhamat
Active Contributor
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

This questin is answered.