Application Development and Automation 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: 
Read only

Move or write to not doing conversion routine

Former Member
0 Likes
643

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?

1 ACCEPTED SOLUTION
Read only

former_member194797
Active Contributor
0 Likes
548

Try also replacing

MOVE w_estruct to w_estruct2

by

MOVE-CORRESPONDING w_estruct to w_estruct2

3 REPLIES 3
Read only

rahulkavuri
Active Contributor
0 Likes
548

BBPRU TYPE is a Signed Currency Field, maybe thats the reason we get this problem..

Read only

former_member194797
Active Contributor
0 Likes
549

Try also replacing

MOVE w_estruct to w_estruct2

by

MOVE-CORRESPONDING w_estruct to w_estruct2

Read only

0 Likes
548

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