‎2008 Apr 06 3:36 PM
hello friends,
I am having a syntax error when I make my program unicode check.
I am having error at the loop statement.
DATA : BEGIN OF IT_ATTACH OCCURS 0,
MATNR(20),
TAB1(1) TYPE X VALUE C_09,
MAKTX(40),
TAB2(1) TYPE X VALUE C_09,
LGORT(15),
TAB3(1) TYPE X VALUE C_09,
CHARG(10),
TAB4(1) TYPE X VALUE C_09,
BWTAR(15),
TAB5(1) TYPE X VALUE C_09,
QTY_S(18),
TAB6(1) TYPE X VALUE C_09,
QTY_S_BQ(18),
TAB7(1) TYPE X VALUE C_09,
QTY_W(18),
TAB8(1) TYPE X VALUE C_09,
QTY_W_BQ(18),
TAB9(1) TYPE X VALUE C_09,
UOM(10),
TAB10(1) TYPE X VALUE C_09,
B_UOM(10), " BASE UNIT OF MEASUE
TAB11(1) TYPE X VALUE C_09,
UN_DIFF(18), " DIFF IN UNRESTRICTED QTY
TAB12(1) TYPE X VALUE C_09,
BL_DIFF(18), " DIFF IN BLOCKED QTY
END OF IT_ATTACH.
DATA : BEGIN OF I_CONTENTS_BIN OCCURS 0 .
INCLUDE STRUCTURE SOLISTI1 .
DATA : END OF I_CONTENTS_BIN.
LOOP AT IT_ATTACH.
MOVE IT_ATTACH TO I_CONTENTS_BIN.
APPEND I_CONTENTS_BIN .
ENDLOOP.
the error is
"I_CONTENTS_BIN" and "IT_ATTACH" are not mutually convertible. In Unicode programs, "I_CONTENTS_BIN" must have the same structure layout as "IT_ATTACH", independent of the length of a Unicode character.
Thanks,
Any Suggestions.
Ster
‎2008 Apr 06 5:48 PM
You have defined it_attach as a structure of 25 fields totalling 240 bytes. However, you're trying to move it to a structure of type solisti1, which is just one 255 byte field.
You're going to have to concatenate the fields into the target one by one. I think the tab characters, being defined as type 'X', will cause problems, though.
If you can live without directly storing the tabs in the structure, something like this would work nicely.
REPORT z_assign_itab_from_fieldsymbol.
FIELD-SYMBOLS: <fs> TYPE ANY.
DATA : BEGIN OF it_attach OCCURS 0,
matnr(20),
maktx(40),
lgort(15),
charg(10),
bwtar(15),
qty_s(18),
qty_s_bq(18),
qty_w(18),
qty_w_bq(18),
uom(10),
b_uom(10), " BASE UNIT OF MEASUE
un_diff(18), " DIFF IN UNRESTRICTED QTY
bl_diff(18), " DIFF IN BLOCKED QTY
END OF it_attach.
DATA : BEGIN OF i_contents_bin OCCURS 0 .
INCLUDE STRUCTURE solisti1 .
DATA : END OF i_contents_bin.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE it_attach TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CONCATENATE i_contents_bin <fs> INTO i_contents_bin SEPARATED BY space.
ENDDO.
write i_contents_bin.
‎2008 Apr 06 4:35 PM
hi ster,
the only problem i can think of is that the number of fields in the two tables is not same. this error comes only wen the number of fields are different. Althought this is for unicode, but still the number of fields do matter. Try checking the number of fields. I hope it solvex the problem..
Do reward if helpful and do tell wats the result.
‎2008 Apr 06 5:48 PM
You have defined it_attach as a structure of 25 fields totalling 240 bytes. However, you're trying to move it to a structure of type solisti1, which is just one 255 byte field.
You're going to have to concatenate the fields into the target one by one. I think the tab characters, being defined as type 'X', will cause problems, though.
If you can live without directly storing the tabs in the structure, something like this would work nicely.
REPORT z_assign_itab_from_fieldsymbol.
FIELD-SYMBOLS: <fs> TYPE ANY.
DATA : BEGIN OF it_attach OCCURS 0,
matnr(20),
maktx(40),
lgort(15),
charg(10),
bwtar(15),
qty_s(18),
qty_s_bq(18),
qty_w(18),
qty_w_bq(18),
uom(10),
b_uom(10), " BASE UNIT OF MEASUE
un_diff(18), " DIFF IN UNRESTRICTED QTY
bl_diff(18), " DIFF IN BLOCKED QTY
END OF it_attach.
DATA : BEGIN OF i_contents_bin OCCURS 0 .
INCLUDE STRUCTURE solisti1 .
DATA : END OF i_contents_bin.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE it_attach TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CONCATENATE i_contents_bin <fs> INTO i_contents_bin SEPARATED BY space.
ENDDO.
write i_contents_bin.
‎2008 Apr 06 6:00 PM
Both IT_ATTACH and I_CONTENTS_BIN
are different ,
you will have to move each field and append.
I.E.
MOVE IT_ATTACH-MATNR TO I_CONTENTS_BIN-MATNR .
MOVE IT_ATTACH-MAKTX TO I_CONTENTS_BIN-MAKTX.
.......etc..and so ...
*then
APPEND I_CONTENTS_BIN .
Edited by: Kokwei Wong on Apr 6, 2008 7:02 PM
‎2008 Apr 06 10:43 PM
Hello Ster
You may use the following approach:
DATA: ls_attach LIKE LINE OF it_attach,
ls_content TYPE solisti1.
...
LOOP AT IT_ATTACH INTO ls_attach.
CLEAR: ls_content.
CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
EXPORTING
im_value = ls_attach
IMPORTING
ex_container = ls_content-line.
APPEND ls_content to I_CONTENTS_BIN .
ENDLOOP.
Regards
Uwe