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

Date conversion to tcurr-gdatu format.

former_member203480
Participant
0 Kudos
12,411

Hi I have the date field from the file coming as 22-jun-2020 this needs to be updated to table TCURR-GDATU field

pls suggest.

1 ACCEPTED SOLUTION
Read only

ArthurParisius
Contributor
0 Kudos
10,115

You could try FM CONVERSION_EXIT_SDATE_INPUT to convert to a SAP internal YYYYMMDD format and then use one of the other answers given.

You might have to replace '-' with space to get results.

6 REPLIES 6
Read only

minh1995
Explorer
10,115

You need to have a logic to convert it to TCURR-GDATU format
For example: Your date = 22-Jun-2020 => 20200622 (YYYYMMDD)
Then we will have 99999999 - 20200622 = 79799377

And the same if you want to convert TCURR-GDATU to normal date
Example in TCURR we have GDATU = 80029898 => 99999999 - 80029898 = 19970101
Then we have the normal date is 01-Jan-1997

Read only

Sandra_Rossi
Active Contributor
0 Kudos
10,115

I don't think that it's a valid ISO 8601 date format, probably it comes from Excel.

If you process an Excel XLSX file, you should directly read the internal format by using abap2xlsx. Otherwise you'd have to bother with all regional date formats if you work for international users, that would be a never ending story...

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
10,115

To convert date from text, look at oprions of class CL_ABAP_DATFM or build you own logic:

  • SPLIT AT '-', use table T247 for month short names (or FM MONTH_NAMES_GET)

There are statements dedicated to inverted date

CONVERT date odate INTO INVERTED-DATE idate.
CONVERT INVERTED-DATE idate INTO DATE odate.

But first did you consider using

  • Transaction TBEX[n] to load currency exchange rate from Excel file,
  • TransactionTBDM from flat file
  • FM BAPI_EXCHANGERATE_SAVEREPLICA
  • FM VIEW_MAINTENANCE_SINGLE_ENTRY on V_TCURR
Read only

ArthurParisius
Contributor
0 Kudos
10,116

You could try FM CONVERSION_EXIT_SDATE_INPUT to convert to a SAP internal YYYYMMDD format and then use one of the other answers given.

You might have to replace '-' with space to get results.

Read only

0 Kudos
10,115

I did the same way this solved the problem

Read only

10,115
DATA: lv_date TYPE sy-datlo,
      lv_c8   TYPE char8,
      lv_datu TYPE tcurr-gdatu.

lv_date = '20220906'. "Fill lv_date with user-input etc.
lv_c8 = lv_date. "Convert to char8
lv_datu = 99999999 - lv_c8. "To complementary

SELECT SINGLE * FROM tcurr INTO @DATA(ls_tcurr) WHERE gdatu = @lv_datu.

Example!