‎2009 Feb 19 7:09 AM
Hi.. I am new in abap.
Tell me which function module which splits SY-DATUM into its constituents parts.
‎2009 Feb 19 7:11 AM
Hi,
try this function module.
HR_IN_GET_DATE_COMPONENTS
OR
write : sy-datum+0(4).( gives year )
sy-datum+4(2) (gives month )
sy-datum+6(2) (gives day )
‎2009 Feb 19 7:10 AM
Function modules hampers performance for a program as whole function group is load into program memory at runtime.
So if it is for minimal requirement
Use: offsets.
Data:W_Date type sy-datum value sy-datum,
W_month(2),
W_day(2),
W_year(4).
w_year = w_date+0(4).
w_month = w_date+4(2).
w_day = w_date+6(2).
Regards,
Gurpreet
‎2009 Feb 19 7:11 AM
Hi,
try this function module.
HR_IN_GET_DATE_COMPONENTS
OR
write : sy-datum+0(4).( gives year )
sy-datum+4(2) (gives month )
sy-datum+6(2) (gives day )
‎2009 Feb 19 7:11 AM
Hi Nimish
Welcome to SCN
i usuallu use HR_IN_GET_DATE_COMPONENETS
you do need to use MONTH in the FM even ie u r not goin to use it.
Regards
Sachin
‎2009 Feb 19 7:16 AM
data : date(2) type c,
month(2) type c,
year(4) type c.
date = sy-datum+6(2).
month = sy-datum+4(2).
year = sy-datum+0(4).
‎2009 Feb 19 7:11 AM
.......
SORRY FOR POSTING AGAIN
Edited by: sachin sharma on Feb 19, 2009 12:42 PM
‎2009 Feb 19 7:12 AM
not sure, but you can assign it to a string type variable then do the usual
str_year = str_var+0(4).
str_mon = str_var+4(2).
str_day = str_var+6(2).
regards,
Mon Magllanes
‎2009 Feb 19 7:12 AM
Hi,
You can try this FM
CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
EXPORTING
IDATE = sy-datum
IMPORTING
DAY = lv_day
MONTH = lv_month
YEAR = lv_year
STEXT = lv_stext
LTEXT = lv_ltext
EXCEPTIONS
INPUT_DATE_IS_INITIAL = 1
TEXT_FOR_MONTH_NOT_MAINTAINED = 2
OTHERS = 3.
Thanks
Arun
‎2009 Feb 19 7:15 AM
Hi ,
Better option will be to use offset , as the sy-datum is always of the format YYYYMMDD.
Regards,
Arun
‎2009 Feb 19 7:17 AM
Hi,
I hope you know that using function module to the program includes the whole function group in the program till the program terminates which takes lots of space in the memory and might effect on runtime....
hence its better to use the normal code instead of going for a function module...
to split ituse offsets which would be the best way..
data = sy-datum+6(2).
month = sy-datum+4(2).
year = sy-datum+0(4).ADDITIONAL INFORMATION :
to know more on data validations and leap year check you can go to wiki and type in the respective keywords say data validations and leap year.
Regards,
Siddarth
‎2009 Feb 19 7:18 AM
hi:
Data:
my_date like sy-datum,
year(4),
month(2),
day(2).
year = my_date(4).
month = my_date+4(2).
day = my_date+6(2).
Another way is to use the function module HR_IN_GET_DATE_COMPONENTS
Regards
Shashi
‎2009 Feb 19 7:18 AM
Hi,
Test the following Sample Code.
DATA: date LIKE sy-datum,
day(2),
month(2),
year(4),
stext LIKE t247-ktx,
ltext LIKE t247-ltx,
userdate(10).
date = sy-datum.
CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
EXPORTING
idate = date
IMPORTING
day = day
month = month
year = year
stext = stext
ltext = ltext
userdate = userdate
EXCEPTIONS
input_date_is_initial = 1
text_for_month_not_maintained = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE: / day,/ month,/ year, / stext, / ltext, / userdate.Kind Regards,
Faisal
Edited by: Faisal Altaf on Feb 19, 2009 12:26 PM
‎2009 Feb 19 7:20 AM
DATA: day(10) TYPE c,
month(2) TYPE c,
year(4) TYPE c,
date type sy-datum.
date = sy-datum.
CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
EXPORTING
idate = date
IMPORTING
day = day
month = month
year = year.
WRITE: day, month, year.
‎2009 Feb 19 7:37 AM
‎2009 Feb 19 9:21 AM
Hi
use the function module HR_IN_GET_DATE_COMPONENTS
Regards,
Anki Reddy