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: 

Offset related unicode issue : offset at directly table and not field

Former Member
0 Kudos

Hi Experts

I am facing one different kind of issues in Unicode related to OFFSET

Code is some what like this :

bdclm+14 = logtable-logmessage.

here logtable-logmessage is of character type length 400.

and bdclm is a standrd sap structure for Batch input: Log messages.

the error which i get is that "The sum of the offset and length (=628) exceeds the length of the start (=366) of the structure. This is not allowed in Unicode programs. programs. "

i have checked sdn onthis found quite a lot of replies related to offset on field but nothing like this that table+14.

please help

thanks

9 REPLIES 9

Sandeep_Kumar
Advisor
Advisor
0 Kudos

this is because you are directly assigining the literals starting from offset 14 to bdclm but the length of bdclm is only 366.

you can try this by assigning a string less than 366 chars and it should work fine.

0 Kudos

Hi

@Sandeep i did that thing also but it is also not working

@Vivek: so you wana say that we will have to pass each n every field individually by considering offsets from logmessage field?

But if do this it will take lot of time as we have quite a good number of similar error and too with field lengths of 1400 and more

Edited by: sunny singh on Sep 15, 2010 6:09 PM

0 Kudos

yes, in unicode you have to do it. It will work in non unicode system/program. I would prefer to do it using field symbol if I am writing new program (or if I have to pass that string to 2-3 diff structures), one can just hardcode using field names, field length & offset.

Other option is insted of reading in string if possible read into some temp structure & then move-corresponding.

One more point, ur code also will work in unicode if structure has all Char fields.

0 Kudos

you can get some sample solutions in this PDF using Field Symbol & casting

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b02d3594-ae48-2a10-83a7-89d369b70...

Section 9.8

Former Member
0 Kudos

BDCLM is a structure. In nonunicode you can pass a string to a structure & it gets assigned to different fields based on lengths.

This will not be allowed in unicode.

you need to read msg with offsets & assign to each field individualy. From code it looks like +14 is for assigning msg to field 3 & onward.

INDATE DATS 8

INTIME TIMS 6

TCNT NUMC 6

MCNT NUMC 3

TCODE CHAR 20

MODULE CHAR 40

DYNR CHAR 4

MART CHAR 1

MID CHAR 20

MNR CHAR 3

MPARCNT CHAR 1

MPAR CHAR 254

Former Member
0 Kudos

Hi Sunny,

Declare a Filed-Symbol <FS> ,assign the field logtable_logmessage to <FS> ,then assign <FS> to the structure BDCLM.

data:logtable_logmessage(600) type c.

field-symbols:<fs> type C.

logtable_logmessage = 'ggsgjkd'.

assign logtable_logmessage to <fs>.

BDCLM+14(6) = <FS>.

Regards,

Shirisha

Former Member
0 Kudos

Hi Sunny,

You can easily attain this using field symbols..

Declare a Filed-Symbol <L_FS> ,

assign the message table to <L_FS> ,

then Pass the data from <L_FS> to the structure BDCLM by casting it.

Regards,

Imran

0 Kudos

Hi

Thanks for your replies guys but i am still nt able to solve it.

@Shrisha : i tried ur solution but still it gives same unicode errror .

@Imran : Can you pleas elet me know wat do you mean by "casting".

Thanks and waiting

0 Kudos

Check this pdf

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b02d3594-ae48-2a10-83a7-89d369b70...

Section 9.8 has exact solution sample code for ur problem using casting.

Vivek

-


9.8 Assignment Between Structure and Single Field: Container Fields

(1)

Long fields of type C were often used as containers, in which data of different

structures was stored. The assignment between structure and single field could be

used directly for storing and reading the data. In Unicode programs, these

assignments are only allowed if the structure is purely character-type.

Before the conversion to Unicode

data: begin of STRUC,

F1(3) type x,

F2(8) type p,

end of STRUC,

CONTAINER(1000) type c.

u201CStore data in container

CONTAINER = STRUC. Unicode error

u201Dread data from container

STRUC = CONTAINER. Unicode error

Now, C fields can only be used as containers for storing non-purely character-type

structures if the content is only used temporarily within an application server.

Therefore the content of the container field cannot be stored in the database, sent

by RFC, or written to a file1. It is also not possible to access the container field for

the selection of structure components by using offset or length2.

If these prerequisites are met, the writing and reading of data can be converted by

using casts to set field symbols of the type X to the container field and the

structure, and then implementing the assignment between the field symbols. Due

to the assignment, the remaining content of the container is filled with Hex 00

values instead of blank characters. This should not cause any problems if the C

field is only used for data storage.

After the conversion to Unicode

field-symbols: <X_CONTAINER> type x,

<X_STRUC> type x.

assign CONTAINER to <X_CONTAINER> casting.

assign STRUC to <X_STRUC> casting.

u201CStore data in container

<X_CONTAINER> = <X_STRUC>. ok!

u201DRead data from container

<X_STRUC> = <X_CONTAINER>. ok!

Note: The class CL_ABAP_CONTAINER_UTILITIES offers generic solutions to store

structures in containers of type C or STRING. However, when using these classes,

the class wrapping and the generic solution can have a negative effect on the

performance.