‎2007 Mar 20 7:13 AM
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
‎2007 Mar 20 9:50 AM
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.
‎2007 Mar 20 7:20 AM
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
‎2007 Mar 20 7:25 AM
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
‎2007 Mar 20 7:23 AM
‎2007 Mar 20 7:30 AM
hi,
for this there is a function module.u can use that.
/SAPDII/SPP05_CONVERT_DATE.
check it this will be useful.
regards,
bharat.
‎2007 Mar 20 7:35 AM
‎2007 Mar 20 9:50 AM
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.
‎2007 Mar 20 9:58 AM
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>
‎2007 Oct 09 7:30 AM