10-06-2005 5:12 AM
Hello
I was hoping someone could help me with this Unicode problem.
In the non-unicode system we have the following ABAP:
FIELD-SYMBOLS: <RECORD_STRUCTURE>.
DATA: P_IT_RAW(1000).
F_RECORD_TYPE = HDR.
ASSIGN (F_RECORD_TYPE) TO <RECORD_STRUCTURE>
P_IT_RAW = <RECORD_STRUCTURE>. <== Unicode runtime error
Basically the structure of HDR is all different types of fields, such as CHAR, DATS, INT4, NUMC etc
Whats the recommend way to copy "CHAR, DATS, INT4, NUMC" fields in and out of character structures in a Unicode system.
This is the code that fails when we try to copy a character field over a field that contains CHAR, DATS, INT4, NUMC
<RECORD_STRUCTURE> = P_IT_RAW. <== Unicode runtime error
Thanks in advance
Peter
PS: To replace the:
P_IT_RAW = <RECORD_STRUCTURE>.
I have been using the follow code:
data: f_compcnt TYPE i,
f_comptype(1) TYPE c,
f_field_len type i,
f_total_write_len type i,
f_temp_str(1000) type c,
f_compcnt2 TYPE i,
f_comptype2(1) TYPE c.
field-symbols : <comp> TYPE ANY.
clear: f_field_len.
f_total_write_len = 0.
DESCRIBE FIELD <RECORD_STRUCTURE> TYPE f_comptype COMPONENTS f_compcnt.
DO f_compcnt TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE <RECORD_STRUCTURE> TO <comp>.
P_IT_RAW+f_total_write_len = <comp>.
describe field <comp> output-length f_field_len.
f_total_write_len = f_total_write_len + f_field_len.
ENDDO.
But how do I get data back out of the P_IT_RAW field into a structured field?
10-06-2005 5:17 AM
either do casting or use different variables for receiving different type of variable from field symbol
regards
10-06-2005 5:17 AM
either do casting or use different variables for receiving different type of variable from field symbol
regards
10-06-2005 5:23 AM
or you could simply switch off the uni-code check in the program attributes ....
10-06-2005 5:25 AM
Hi Peter,
You can only solve this issue by definining only char fields in HDR . You can define INT4 fields with char fields of same name with length equal to output length.
You can fill INT4 ( defined as CHAR) field using Write To . DATS/ NUMC are char fields so should not be an issue .
Cheers
10-10-2005 10:05 PM
Thanks for all your help.
We did manage to find a suitable solution and here it is...
Replace the following code:
P_IT_RAW = <RECORD_STRUCTURE>. <==Unicode error
with:
field-symbols: <G_FROM_STRUCT> type x.
field-symbols: <G_TO_STRUCT> type x.
assign <RECORD_STRUCTURE> to <G_FROM_STRUCT> casting.
assign P_IT_RAW to <G_TO_STRUCT> casting.
<G_TO_STRUCT> = <G_FROM_STRUCT>.
Works great
10-11-2005 3:27 AM