Application Development 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: 

justification of number field in output file

Former Member
0 Kudos
86

I created a abap program to write a file to my C drive. I have to create this file with the fields in certain columns and the numeric fileds are causing me problems. is there a way to left-justify the numeric values so that they all end in the same column. this way I can control the spacing of the rest of the fields. I have checked the forum and can not find anything on this. I have also did the F1 on the DATA field so see some help but there is no explaination for it.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
52

Hi Timothy,

One way would be to move all the fields into internal table with the same fields but defined as characters in your program & then move those fields to a file in C drive.

3 REPLIES 3

Former Member
0 Kudos
53

Hi Timothy,

One way would be to move all the fields into internal table with the same fields but defined as characters in your program & then move those fields to a file in C drive.

0 Kudos
52

Just like this Tim, notice here I'm using the same example program, not the SHIFT statements, this will force the FLD2 field to push the numbers to the right of the field, hence lining them up.



report zrich_0001.


data: begin of itab occurs 0,
      fld1(10) type c,
      fld2(20) type c,
      fld3(10) type c,
      end of itab.


itab-fld1 = 'A'.
itab-fld2 = '100.00'.
shift itab-fld2 right deleting trailing space.
itab-fld3 = 'C'.
append itab.

itab-fld1 = 'D'.
itab-fld2 = '1000.00'.
shift itab-fld2 right deleting trailing space.
itab-fld3 = 'F'.
append itab.

itab-fld1 = 'G'.
itab-fld2 = '10000.00'.
shift itab-fld2 right deleting trailing space.
itab-fld3 = 'I'.
append itab.

call function 'GUI_DOWNLOAD'
     exporting
          filename = 'C:test.txt'
     tables
          data_tab = itab.

Regards,

Rich Heilman

Former Member
0 Kudos
52

HI,

By specifying an offset <o> and a length (<l>) directly after the field name <f>, you can address the part of the field starting at position <o>1 with length <l> as though it were an independent data object

ex: <b>/(40) f1 left-justified,</b>

if you use like this, then the starting position will be same for all the fileds.

Thanks

Sudheer