Saturday, August 29, 2009

Different method of Converting Date in ABAP

Calculate begining of previous to end of previous month

ldate = sy-datum.
ldate+6(2) = '01'.
ldate = ldate - 1.
fdate = ldate.
fdate+6(2) = '01'.

move: fdate to date-low,
ldate to date-high.

append date.

------

I need to convert date from dd.mm.yyyy to yyyymmdd at runtime.

I do not know if there is any function module or not but try following code.

/*************************************************
/**************************************************

data mydate like sy-datum.
data: year(4) type c,
month(2) type c,
date(2) type c.

year = mydate(4).
month = mydate+4(2).
date = mydate+6(2).

write: / year no-gap, month no-gap, date.

/*************************************************
/**************************************************

I am facing one problem with date. Can you suggest me how to save date with some format . for ex: can I save '2004.12.01' in the table with the same format. Right now I am getting output '2...1.2004' but I need output '2004.12.01'.

Date will save in any like yyyymmdd.

Just for display only you can do whatever ever you want.

write:/ gv_date edit mask 'YYYY.MM.DD'.

Thanks for your suggestion..but I think you have not properly understood the problem..Pls don't mind...to make you aware of the problem, I am writing a small coding...

data : date(10) type c value '01122004'.

write :/ date using edit mask '__/__/____'.

output is : 01.12.2004.

but if will pass the value like 01.12.2004 or 01/12/2004 or if change the format i.e 20041201.....then I will get output as 2...1.2004

Pls it would be very helpful if you can kindly devote some time for me.

Have you tried to use CONCATENATE to format the date?

E.g: CONCATENATE: T_0008-BEGDA+6(02)
'/'
T_0008-BEGDA+4(02)
'/'
T_0008-BEGDA(04) INTO T_AUX-DT_ALT.

The result will be 30/12/9999. Just change the IT's for your convenience.

1) Can anyone pls tell me fm to calculate the difference between two dates and return no.of days
as o/p.its very urgent.

2) I want to display all the date calulations, other calculations in one internal table for alv grid display.is it possible.

1. Use the fm 'DAYS_BETWEEN_TWO_DATES'.
2. It is possible. You need to take it in the final internal table which you are going to display.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

goodsites