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 and Date Formatting Urgent !!

Former Member
0 Kudos
80

Hello Gurus,

I want to format Amount in the below manner , I need to put this data in a text file ,

When I read it from SAP , irrespective of whatever format

I need to write the data in the text file in the following format

999999999999.999

if the amount is 12 then

000000000012.000

if the amount is 100 then

000000000100.000

Also , I need a help on date formating

My date will always appear in the text file in the following format

YYYY.MM.DD

so irrespective of whatever user settings on has I need the format to appear in the text file as above.

Please help me Points guaranteed , please try it at your end

and please paste the code.

rgds,

Aryan

4 REPLIES 4

0 Kudos
50

hi, take the amount variable as numeric data type (N).

Former Member
0 Kudos
50

hi

use UNPACK AMOUNT TO TEXT.

for date use SET COUNTRY.

0 Kudos
50

Hi Aryan,

For Amount, try out the below code...it will work fine.

REPORT ZAMT_DAT .

TYPES amt TYPE p DECIMALS 3.

data : v_amt(16) type c ,

v_amt1 type amt value 100,

v_len type i,

v_len1 type c,

p_date(10) type c value '23012008'.

v_amt = v_amt1.

condense v_amt.

v_len = strlen( v_amt ).

v_len = 16 - v_len.

do v_len times.

concatenate '0' v_amt into v_amt.

enddo.

write : v_amt.

For date, set the user settings as below...

system-userprofile->owndata->defaults->dateformat

set it to the 4 th radio button....

it will work fine.

Thanks

0 Kudos
50

Hi!!

check this out if it helps...

REPORT ztestdate.

DATA:lv_day TYPE c LENGTH 2,

lv_month TYPE c LENGTH 2,

lv_year TYPE c LENGTH 4,

lv_string TYPE c LENGTH 10.

*formatting the date into requested type.

lv_day = sy-datum+6(2).

WRITE:/ sy-datum+6(2).

lv_month = sy-datum+4(2).

WRITE:/ sy-datum+4(2).

lv_year = sy-datum(4).

WRITE:/ sy-datum(4).

CONCATENATE lv_year lv_month lv_day INTO lv_string SEPARATED BY '/'.

WRITE:/ lv_string.

Thanks & regards

@mit.