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: 

Amount should be left justified

Former Member
0 Kudos

Hi Abapers,

I'm downloading some data to .CSV file in presentation server. I have amount field as part of my file.

When data is downloaded to file, amount value is right justified. But then user is requesting to remove spaces on left side of the value. I have moved the amount value to char field but still my purpose is not solved.

Is it possible to achieve this? Please help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

There are several solutions, they depend on which format u need:

- WRITE <AMOUNT> TO <FILE> LEFT-JUSTIFIED

Or u can use MOVE:

MOVE <AMOUNT> TO <CHAR_VAR>.

CONDENSE <CHAR_VAR>.

MOVE <CHAR_VAR> TO <FILE>.

Max

10 REPLIES 10

Former Member
0 Kudos

HI,

After moving the amount field to Char varaible. And then use the CONDENSE statement on it.

CONDENSE <Char Varaible>.

Former Member
0 Kudos

Hi there,

after you moved it to the char field.

use condense <variable> no-gaps.

regards

Former Member
0 Kudos

Hi

There are several solutions, they depend on which format u need:

- WRITE <AMOUNT> TO <FILE> LEFT-JUSTIFIED

Or u can use MOVE:

MOVE <AMOUNT> TO <CHAR_VAR>.

CONDENSE <CHAR_VAR>.

MOVE <CHAR_VAR> TO <FILE>.

Max

0 Kudos

After moving the amount value to char field, i have used condense before populating the char value into workarea and appending to table. data is saved as right justified in file. Please suggest

l_pay_rate = wa_out-wage_amount.

condense l_pay_rate no-gaps.

CONCATENATE

l_empno

wa_out-vorna

wa_out-nachn

wa_out-labor_level1

wa_out-company

wa_out-kostl

wa_out-orgeh

wa_out-orig_hire_date

wa_out-gbdat

l_pay_rate

INTO wa_out_new-line SEPARATED BY c_sep_comma.

APPEND wa_out_new TO p_tb_out_new.

*--Download data to Presentation Server

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_file

filetype = c_filetype

append = c_x

TABLES

data_tab = tb_out_new

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

0 Kudos

Hi Prem,

I guess you are opening the CSV file in EXCEL, which by default takes the number into right justified format. My suggestion would be to change the format into TEXT in EXCEL after opening the file using FORMAT CELLS option.

Regards

Khanna

0 Kudos

Hi

I've tried your code and it worked fine.

Probably the problem is when the file is open by excel: u should check the file by NOTEPAD or WORDPAD in order to understand how the file is downloaded.

Max

0 Kudos

Thanks Khanna and Max for your replies.

Yes i'm opening the file in Excel which is displaying the amount as right justified. So the only way to remove spaces on left of amount is either to change the format to text or to view it in word or text right?

0 Kudos

Hi

Yes you're right.

If the user need to open the file by excel, he has to change the properties of the numeric cells: they have to become TEXT.

Max

0 Kudos

Hi Premraj,

As also said by others to make your amount field left justified in your excel you have to use the FORMAT CELL option of your excel file and make the NUMBER CATEGORY as TEXT.

With luck,

Pritam.

Former Member
0 Kudos

Hi,

Moved the amount value to string field and check.

Regards

Md.MahaboobKhan