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: 

Calculation of the average exchange rate on tcurr table

Former Member
0 Kudos

Hello guys,

( I am new to the forums. If i posted my concerns on the wrong section, kindly move it to the correct one)

I would like to ask assistance on calculation of the average exchange rate on a tcurr table per month on below keys:

KURST,FCURR,TCURR and TCURR

Normally, tcurr table only contains monthend data but there are some scenarios that there are entries on the middle of the month.

The main requirement was to store the tcur data on a DSO and add a key fig for the average data. We create a datasource using table view.

Also, the GDATU is on number format so i need to convert it first to calday format ( i did not use the FM)

So first, i determined the available months on the start routine:

N= 1.

LOOP AT SOURCE_PACKAGE

  ASSIGNING <SOURCE_FIELDS>.

       W_DIFF = '99999999' - <SOURCE_FIELDS>-GDATU.

       TRANSLATE W_DIFF(5) USING ' 0'.

       CONDENSE W_DIFF NO-GAPS.    "YYYYMMDD

       W_OUT = W_DIFF.

      W_MONTH = W_OUT(6).

      READ TABLE T_MONTH

        INTO E_MONTH

        INDEX N.

         MOVE W_MONTH TO E_MONTH-CALMONTH.

        APPEND E_MONTH TO T_MONTH.

N = N + 1.

  ENDLOOP.

i now have the list of available months on table t_month

the next thing i can think of is to get all of the entries on the source package per month, setup a counter, add all of the exchange rate then divide by the counter. But i am having a hard time coding this.

 

Also, i think i should put some codes on the end routine to populate the average key fig on the dso.

Any help would be appreciated.

Thanks!

Gervy

4 REPLIES 4

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi,

You can achieve this using collect statement.

Arivazhagan S

0 Kudos

Hello Arivazhagan ,

thank you so much for your reply. can you show me how to code it?

i am a having a hard time keeping the records with the same key. the conversion of GDATU to corresponding month also added complexity.

Thanks!

Gervy

0 Kudos

Hi,

Please use following function modules for GDATU.

CONVERSION_EXIT_INVDT_INPUT

CONVERSION_EXIT_INVDT_INPUT

Now you can able to write function easily.

Arivazhagan S

0 Kudos

Hi,

I was able to create now an internal table below structure:

KEY FIELDSDATA FIELD
KURSTFCURRTCURRCALMONTHUKURS
1001EURPHP201301100
1001EURPHP201301300
3000SGDUSD201302400
3000SGDUSD201302800
4000PHPUSD201303500

how can i end up with

KEY FIELDDATA
KURSTFCURRTCURRCALMONTHAVERAGE
1001EURPHP201301200
3000SGDUSD201302600
4000PHPUSD201303500

Thanks!