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: 

To Convert TCURR-GDATU to normal date format

Former Member
0 Kudos

Hi All,

In TCURR table GDATU (Date As of Which the Exchange Rate Is Effective) field is in inverted date format. I want to convert it to normal date format and use it in an BI end routine.

Can you please check the code below and let me know if there are any errors.

TABLES: TCURR.

DATA: tcurr_tab TYPE TABLE OF tcurr.

FIELD-SYMBOLS

<tcurr_wa> TYPE tcurr.

SELECT gdatu FROM tcurr INTO TABLE tcurr_tab.

SORT tcurr_tab BY gdatu.

LOOP AT tcurr_tab ASSIGNING <tcurr_wa>.

CONVERT INVERTED-DATE <tcurr_wa>-gdatu

INTO DATE <tcurr_wa>-gdatu.

ENDLOOP.

Thanks,

Sri Arun Prian

1 ACCEPTED SOLUTION

former_member188685
Active Contributor

one more correction

REPORT  ZTEST.

TABLES: TCURR.

DATA: tcurr_tab TYPE TABLE OF tcurr.
data: date_normal type sy-datum.
FIELD-SYMBOLS
<tcurr_wa> TYPE tcurr.

SELECT gdatu FROM tcurr INTO corresponding fields of

TABLE tcurr_tab.

SORT tcurr_tab BY gdatu.

LOOP AT tcurr_tab ASSIGNING <tcurr_wa>.
break-point.
CONVERT INVERTED-DATE <tcurr_wa>-gdatu
INTO DATE date_normal.  "you need to move that to normal date field
write:/ date_normal.      "you need to take a normal date field

ENDLOOP.

5 REPLIES 5

Former Member
0 Kudos

Hi

u can use FM available for changing date formats

Regards

Sachin

Former Member
0 Kudos

Hi,

Use FM CONVERT_DATE_TO_EXTERNAL as follows,

Data : date_out(10) type c,
       date_in type d.

date_in = '20081017'.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
 EXPORTING
   DATE_INTERNAL                  = date_in
 IMPORTING
   DATE_EXTERNAL                  = date_out
 EXCEPTIONS
   DATE_INTERNAL_IS_INVALID       = 1
   OTHERS                         = 2.

Remember that you cannot store external format back to your date variable as it is 10 characters long while date is only 8 characters long.

Regards

Karthik D

former_member188685
Active Contributor
0 Kudos

as i told you yesterday, the statement is obsolete. just keep in mind. apart from that there is a correction to your code.

SELECT gdatu FROM tcurr 
INTO corresponding fields of  "add this
TABLE tcurr_tab.

former_member188685
Active Contributor

one more correction

REPORT  ZTEST.

TABLES: TCURR.

DATA: tcurr_tab TYPE TABLE OF tcurr.
data: date_normal type sy-datum.
FIELD-SYMBOLS
<tcurr_wa> TYPE tcurr.

SELECT gdatu FROM tcurr INTO corresponding fields of

TABLE tcurr_tab.

SORT tcurr_tab BY gdatu.

LOOP AT tcurr_tab ASSIGNING <tcurr_wa>.
break-point.
CONVERT INVERTED-DATE <tcurr_wa>-gdatu
INTO DATE date_normal.  "you need to move that to normal date field
write:/ date_normal.      "you need to take a normal date field

ENDLOOP.

0 Kudos

Hi Vijay,

Thanks for your help.

Thanks,

Sri Arun Prian