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: 

time conversion Hey everybody! Iu00B4m writing my diploma thesis in the field o

Former Member
0 Kudos

Hey everybody!

I´m writing my diploma thesis in the field of BW and I have to do a little time conversion.

I hav a date like "22.01.1980" in my source and two destination fields CALYEAR (YYYY) and CALMONTH (MM/YYYY like 01/1980).

What is the easiest way to convert the date with ABAP or is there a predefined function?

Thanks in advance!

Manjula.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

REPORT ztest.

TYPES: BEGIN OF external_month_type,

dd TYPE n LENGTH 2,

p1 TYPE c LENGTH 1,

mm TYPE n LENGTH 2,

p2 TYPE c LENGTH 1,

yyyy TYPE n LENGTH 4,

END OF external_month_type.

TYPES: BEGIN OF calmonth_type,

mm TYPE n LENGTH 2,

sl TYPE c LENGTH 1,

yyyy TYPE n LENGTH 4,

END OF calmonth_type.

DATA: l_input_data TYPE c LENGTH 10,

l_ext_data TYPE external_month_type,

l_calmonth TYPE calmonth_type,

l_calyear TYPE n LENGTH 4.

l_input_data = '22.01.1980'.

l_ext_data = l_input_data.

MOVE-CORRESPONDING l_ext_data TO l_calmonth.

l_calmonth-sl = '/'.

l_calyear = l_ext_data-yyyy.

WRITE: / l_input_data, l_ext_data, l_calmonth, l_calyear.

Reward points if found helpful....

Cheers,

Chandra Sekhar.

2 REPLIES 2

Former Member
0 Kudos

date1 = '22.01.1980'.

dd = date1+0(2).

mm = date1+3(2).

yyyy = date1+6(4).

reward if useful

Former Member
0 Kudos

Hi,

REPORT ztest.

TYPES: BEGIN OF external_month_type,

dd TYPE n LENGTH 2,

p1 TYPE c LENGTH 1,

mm TYPE n LENGTH 2,

p2 TYPE c LENGTH 1,

yyyy TYPE n LENGTH 4,

END OF external_month_type.

TYPES: BEGIN OF calmonth_type,

mm TYPE n LENGTH 2,

sl TYPE c LENGTH 1,

yyyy TYPE n LENGTH 4,

END OF calmonth_type.

DATA: l_input_data TYPE c LENGTH 10,

l_ext_data TYPE external_month_type,

l_calmonth TYPE calmonth_type,

l_calyear TYPE n LENGTH 4.

l_input_data = '22.01.1980'.

l_ext_data = l_input_data.

MOVE-CORRESPONDING l_ext_data TO l_calmonth.

l_calmonth-sl = '/'.

l_calyear = l_ext_data-yyyy.

WRITE: / l_input_data, l_ext_data, l_calmonth, l_calyear.

Reward points if found helpful....

Cheers,

Chandra Sekhar.