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: 

Date conversion to tcurr-gdatu format.

former_member203480
Participant
0 Kudos

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

ArthurParisius
Contributor
0 Kudos

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

minh1995
Explorer

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

Sandra_Rossi
Active Contributor
0 Kudos

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...

raymond_giuseppi
Active Contributor
0 Kudos

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

ArthurParisius
Contributor
0 Kudos

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.

0 Kudos

I did the same way this solved the problem

0 Kudos
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!