‎2008 Mar 20 2:45 PM
I have two types of a file structure
TYPES: BEGIN OF ty_est_archivo,
mandt TYPE mandt,
bukrs TYPE bukrs,
gjahr TYPE gjahr,
monat TYPE monat,
xblnr(20),
nacem(16),
ctasc(10),
transact_number TYPE cjtransnumb,
transact_name(30),
mwskz TYPE mwskz,
cbase TYPE BBPRU,
cimpu TYPE BBPRU,
END OF ty_est_archivo.
TYPES: BEGIN OF ty_est_archivo2,
mandt TYPE mandt,
bukrs TYPE bukrs,
gjahr TYPE gjahr,
monat TYPE monat,
xblnr(20),
nacem(16),
ctasc(10),
transact_number TYPE cjtransnumb,
transact_name(30),
mwskz TYPE mwskz,
cbase(13),
cimpu(13),
END OF ty_est_archivo2.
I have to write into a text file, the user asked for no separators so the columns must always be the same size, so using write to... with the first table was impossible, instead I made the TYPE P fields, character type to have a fixed lenght.
The table I_restrc is being filled perfectly, but something wrong happens when I move it to the other structure
DATA l_archivo TYPE string.
DATA: w_archivo TYPE ty_linea_arch,
w_estruct TYPE ty_est_archivo,
w_estruct2 TYPE ty_est_archivo2.
LOOP AT i_restrct INTO w_estruct.
MOVE w_estruct to w_estruct2.
WRITE w_estruct2 TO w_archivo.
APPEND w_archivo TO i_archivo.
ENDLOOP.
The strings cbase and cimpu are not filled, when I move w_estruct to w_estruct2 cimpu is empty and cbase is filled with special characters.
I solved this doing...
LOOP AT i_restrct INTO w_estruct.
MOVE w_estruct to w_estruct2.
MOVE w_estruct-cbase TO w_estruct2-cbase.
MOVE w_estruct-cimpu TO w_estruct2-cimpu.
WRITE w_estruct2-cimpu TO w_estruct2-cimpu RIGHT-JUSTIFIED.
WRITE w_estruct2 TO w_archivo.
APPEND w_archivo TO i_archivo.
ENDLOOP.
When I make an explicit move, the conversion is done.
Is this the way it should be done? Or is some kind of bug?
‎2008 Mar 20 3:14 PM
Try also replacing
MOVE w_estruct to w_estruct2by
MOVE-CORRESPONDING w_estruct to w_estruct2
‎2008 Mar 20 2:51 PM
BBPRU TYPE is a Signed Currency Field, maybe thats the reason we get this problem..
‎2008 Mar 20 3:14 PM
Try also replacing
MOVE w_estruct to w_estruct2by
MOVE-CORRESPONDING w_estruct to w_estruct2
‎2008 Mar 20 3:24 PM
Thanks, I changed the code to
LOOP AT i_restrct INTO w_estruct.
MOVE-CORRESPONDING w_estruct to w_estruct2.
WRITE w_estruct2-cimpu TO w_estruct2-cimpu RIGHT-JUSTIFIED.
WRITE w_estruct2 TO w_archivo.
APPEND w_archivo TO i_archivo.
ENDLOOP.
And is working, I think it's better than nothing.
I also tried
LOOP AT i_restrct INTO w_estruct2.
Also producing the strange characters