Application Development and Automation 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: 
Read only

CONVERT INVERTED-DATE

Former Member
0 Likes
8,742

Hi Experts,

can anybody explain below example..

DATA: odate TYPE d VALUE '19955011',

idate LIKE odate.

CONVERT DATE odate INTO INVERTED-DATE idate.

CONVERT INVERTED-DATE idate INTO DATE odate.

Thanks in advance..

shobha henry

1 ACCEPTED SOLUTION
Read only

former_member784222
Active Participant
0 Likes
3,710

Hi,

Convert date routine is mainly used in case you are querying date field in a currency table example TCURR.

Assume an internal table containing following dates:

18.3.2006

17.3.2006

19.3.2006.

If we sort the internal table by date ascending, then the sequence would be:

17.3.2006, 18.3.2006 and 19.3.2006.

Now in another internal table have another internal table with actual date and converted date. Convert the actual date into inverted date and populate into the second field.

Now if you give a sort ascending by the converted date field the sequence will be:

19.3.2006, 18.3.2006 and 17.3.2006. This means the latest(youngest) gets on top.

This will be very useful when querying currency table to find latest exchange rates / exchange rate between a given period.

TABLES: tcurr.

PARAMETERS: p_date LIKE sy-datum.

DATA: c_date LIKE sy-datum.

SELECT SINGLE ukurs INTO tcurr-ukurs FROM tcurr WHERE

kurst = '1001' AND

fcurr = 'DEM' AND

tcurr = 'USD' AND

gdatu = p_date.

WRITE:/ tcurr-ukurs.

CONVERT DATE p_date INTO INVERTED-DATE c_date.

SELECT SINGLE ukurs INTO tcurr-ukurs FROM tcurr WHERE

kurst = '1001' AND

fcurr = 'DEM' AND

tcurr = 'USD' AND

gdatu = c_date.

WRITE:/ tcurr-ukurs.

Put a breakpoint after convert statement and see for yourself.

Thanks and regards,

S. Chandra Mouli.

8 REPLIES 8
Read only

Former Member
0 Likes
3,710

hai

DATA: time_stamp TYPE timestamp,

dat TYPE d,

tim TYPE t,

tz TYPE ttzz-tzone.

tz = 'BRAZIL'.

dat = '20030309'.

tim = '013000'.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME 'X'

INTO TIME STAMP time_stamp TIME ZONE tz.

WRITE: / time_stamp.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME ' '

INTO TIME STAMP time_stamp TIME ZONE tz.

WRITE: / time_stamp.

**Please reward suitable points***

With Regards

Navin Khedikar

Read only

0 Likes
3,710

Hi Naveen,

Thanks for your immeadiate reply..i want to know what is CONVERT DATE INTO INVERTED -DATE and CONVERT INVERTED - DATE INTO DATE..plase explain in detail if you can..

Thanks in advance..

Shobha Hanry

Read only

Former Member
0 Likes
3,710

Hi Shobha,

Please check Mrutyunjaya's reply in the link,

Best Regards.

    • Reward points if it is useful.

Read only

Former Member
0 Likes
3,710

hi,

for this there is a function module.u can use that.

/SAPDII/SPP05_CONVERT_DATE.

check it this will be useful.

regards,

bharat.

Read only

Former Member
0 Likes
3,710

Hi,

Message was edited by:

shweta soni

Read only

former_member784222
Active Participant
0 Likes
3,711

Hi,

Convert date routine is mainly used in case you are querying date field in a currency table example TCURR.

Assume an internal table containing following dates:

18.3.2006

17.3.2006

19.3.2006.

If we sort the internal table by date ascending, then the sequence would be:

17.3.2006, 18.3.2006 and 19.3.2006.

Now in another internal table have another internal table with actual date and converted date. Convert the actual date into inverted date and populate into the second field.

Now if you give a sort ascending by the converted date field the sequence will be:

19.3.2006, 18.3.2006 and 17.3.2006. This means the latest(youngest) gets on top.

This will be very useful when querying currency table to find latest exchange rates / exchange rate between a given period.

TABLES: tcurr.

PARAMETERS: p_date LIKE sy-datum.

DATA: c_date LIKE sy-datum.

SELECT SINGLE ukurs INTO tcurr-ukurs FROM tcurr WHERE

kurst = '1001' AND

fcurr = 'DEM' AND

tcurr = 'USD' AND

gdatu = p_date.

WRITE:/ tcurr-ukurs.

CONVERT DATE p_date INTO INVERTED-DATE c_date.

SELECT SINGLE ukurs INTO tcurr-ukurs FROM tcurr WHERE

kurst = '1001' AND

fcurr = 'DEM' AND

tcurr = 'USD' AND

gdatu = c_date.

WRITE:/ tcurr-ukurs.

Put a breakpoint after convert statement and see for yourself.

Thanks and regards,

S. Chandra Mouli.

Read only

Former Member
0 Likes
3,710

In the table TCURR the field GDATU will be stored in inverted format , so Convert that to normal format we use the below syntax

<b>CONVERT DATE odate INTO INVERTED-DATE idate.

CONVERT INVERTED-DATE idate INTO DATE odate.</b>

Read only

Former Member
0 Likes
3,710

Good answer........keep it up