2008 Apr 14 1:50 PM
Hi Experts,
I have a question related to the Unicode System...
Here is a piece of code writeen in non-unicode...
data:
begin of struct1,
x1(1) type x,
end of struct1.
data:
begin of struct2,
c1(10) type c,
end of struct2.
struct1-x1 = '1C'.
struct2-c1 = struct1.
*struct2-c1 = struct1. this type of assigment is not allowed in Unicode.
So how can i assign this in unicode System...
it's ugrent ..
Thanks for the help in advance.
2008 Apr 14 1:53 PM
data:
begin of struct1,
x1(1) type x,
end of struct1.
data:
begin of struct2,
c1(10) type c,
end of struct2.
struct1-x1 = '1C'.
struct2-c1 = struct1-X1.
2008 Apr 14 1:53 PM
data:
begin of struct1,
x1(1) type x,
end of struct1.
data:
begin of struct2,
c1(10) type c,
end of struct2.
struct1-x1 = '1C'.
struct2-c1 = struct1-X1.
2008 Apr 14 4:00 PM
Hi PBS,
Thanks for ur time , but my problem is not yet solved.
when i try to assign struct1 = struct2-x1.
then the values are internally getting changed, that can be seen in debugging mode.
for my code it's something like this...
Debug Mode:
In non-unicode :
struct1-x1 = C1
struct1 = C1
struct2-c1 = 1C202020202020202020.
In unicode :
struct1-x1 = C1
struct2-c1 = 31432020202020202020.
how i can get the same value what there in non-unicode
in unicode.
Regards
Syed Abdul Adil
2008 Apr 14 4:09 PM
Hi,
In Unicode environment while moving values between variables, the variables of same type. For this you need to do try lile this way
report zaRs
no standard page heading
line-size 255.
begin of struct1,
x1(1) type x,
end of struct1.
data: xcontent type xstring,
content type string,
conv type ref to cl_abap_conv_in_ce,
len type i.
struct1-x1 = '1C'.
xcontent = struct1-x1.
conv = cl_abap_conv_in_ce=>create( input = xcontent ).
conv->read( importing data = content len = len ).
struct2-c1 = content.
a®
2008 Apr 14 8:44 PM
Hi,
Thanks for the post it was realy helpful,
on the similar issue i have one more question .
In non-uncode system:
data:
begin of struct,
x1(1) type x,
end of struct.
data:
c1 type c value 'C'.
struct1 = c1.
In unicode system
struct1 = c1 is not allowed.
If i assign struct1-x1 = c1, intenally the values value are getting changed that can be seen in debug mode .
so how can i assign this in unicode system with out the values to be changed ...
please reply
Regards
Syed Abdul Adil.
2008 Apr 14 1:58 PM
Hi,
Unlike in Non-Unicode systems, we can not move data from one structure to other directly in Unicode enabled systems. We have to explicitly move field by field.
Non-Unicode system:
<WA_FINAL> = <WA_IN>. " Is ValidUnicode System:
<WA_FINAL> = <WA_IN>. " Not ValidUse as:
<WA_FINAL>-FLD1 = <WA_IN>-FLD1.
<WA_FINAL>-FLD2 = <WA_IN>-FLDn.
...Below extract from Unicode document can help you understand conversions:
Conversion between flat structures
To check whether conversion is permitted at all, the Unicode fragment view of
the structures is set up initially by combining character and byte type groups
and alignment gaps as well as any other components. If the type and length of
the fragments of the source structure are identical in the length of the shorter
structure, conversion is permitted. Assignment is allowed subject to the
fulfillment of the following conditions:
1. The fragments of both structures up to the second-last fragment of the
shorter structure are identical.
12
2. The last fragment of the shorter structure is a character or byte type group.
3. The corresponding fragment of the longer structure is a character or byte
type group with a greater length.If the target structure is longer than the source structure, the character-type
components of the remaining length are filled with blank characters. All other
components of the remaining length are filled with the type-adequate initial
value, and alignment gaps are filled with zero bytes. Since longer structures
were previously filled with blanks by default, using initial values for noncharacter-
type component types is incompatible. This incompatible change is,
however, rather an error correction. For reasons of compatibility, charactertype
components are not filled with initial values.
BEGIN OF struc1, BEGIN OF struc2,
a(1) TYPE C, a(1) TYPE C,
x(1) TYPE X, b(1) TYPE C,
END OF struc1. END OF struc2.The assignment struc1 = struc2 is not allowed under Unicode since struc1-x in
contrast to struc2-b occupies only one byte.
BEGIN OF struc3, BEGIN OF struc4,
a(2) TYPE C, a(8) TYPE C,
n(6) TYPE N, i TYPE I,
i TYPE I, f TYPE F,
END OF struc3. END OF struc4.The assignment struc3 = struc4 is allowed since the fragment views of the
character-type fields and the integer are identical.
BEGIN OF struc5, BEGIN OF struc6,
a(1) TYPE X, a(1) TYPE X,
b(1) TYPE X, BEGIN OF STRUC3,
c(1) TYPE C, b(1) TYPE X,
END OF struc5. c(1) TYPE C,
END OF struc3,
END OF struc6.struc5 = struc6 is again not permitted since the fragment views of both
structures are not identical due to the alignment gaps before struc3 and struc3-
c.
BEGIN OF struc7, BEGIN OF struc8,
p(8) TYPE P, p(8) TYPE P,
c(1) TYPE C, c(5) TYPE C,
END OF struc7. o(8) TYPE P,
END OF struc8.The assignment struc7 = struc8 works since the Unicode fragment views are
identical with regard to the length of structure struc1.
For deep structures, the operand types must be compatible as usual. As an
enhancement measure, we slightly generalized the convertibility in case of
object references and table components.
Conversion between structures and single fields
The following rules apply for converting a structure into a single field and vice
versa:
1. If a structure is purely character-type, it is treated like a C field during
conversion.
2. If the single field is of type C, but only part of the structure is charactertype,
conversion is only possible if the structure begins with a character13
type structure and if this structure is at least as long as the single field.
Conversion now takes place between the first character-type group of the
structure and the single field. If the structure is the target field, the
character type sections of the remainder are filled with blanks, and all other
components are filled with the type-adequate initial value.
3. Conversion is not permitted if the structure is not purely character-type and
if the single field is not of type C.As with the assignment between structures, filling non-character-type
components with the initial value is incompatible.
<REMOVED BY MODERATOR>
raam
Edited by: Alvaro Tejada Galindo on Apr 14, 2008 11:23 AM