cancel
Showing results for 
Search instead for 
Did you mean: 

BI Abap Start routine in Transformation - fixed currency calculation

Former Member
0 Kudos

Hi dear Experts

I need your help.

I need to set up in the Start routine a currency conversion with a fixed value. = 1,21

It also has to change the Currency from EUR to CHF when a comp code is there.

Is my coding correct?

thanks in advance for your help

ciao

Manu

    data:
l_t_source_package      type _ty_t_sc_1.

    data:
l_s_source_package      type _ty_s_sc_1.


***********

    loop at source_package

    into
l_s_source_package.

      if
          l_s_source_package-comp_code = 'CH01'
         and' l_s_source_package-currency = 'EUR’.

          l_s_source_package-currency = 'CHF’.

          l_s_source_package-amount = l_s_source_package-amount * 1.21.

        endif.

        modify source_package from l_s_source_package.

     
endif.

    endloop.



* Sortierbare Hilfstabelle anlegen

    l_t_source_package[] = source_package[].

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi

Emanuela Maiaso

by looking at the code.. I think it is fine.. few other simple options..

for Currency change:

instead of writing code you can handle this at transformation level directly..

to do this..

map your source field to target field..

double click on the line attaching these two field and select (routine) to write field level routine..

and just use if else statment that's it..Field level routine is enough to handle this..this will save time and will be less complex and better performance.

for amount: you don't need to write code here.. you can do it at the transformation level. you can write field level routine same as above for currency

or

second option you don't need to handle it in transformation you can handle this directly at Report(query) level before displaying..

Thanks,

Bhupesh

Former Member
0 Kudos

Hi Bhupesh

Thanks for the answer - I was looking at the transformation and there is no target field fpr " 0Currency" . It is the same rule of '0Amount'

If I do that at field level , shall I do the following

SOurce fields -

0currency

0amount

0compcode

Taget Fields

0AMOUNT

Shall I use Routine with Unit?

How can I change the currency there?

I would start the code in this way...

if source_fields -compcode = 'CH01'

How can I check if the currency is correct?

result = source_fields-amout * 1.21

thanks again for your help

ciao

Manu

Former Member
0 Kudos

Manu

yes you can do it on amount field.... the only thing you can avoid start routine or end routine..

and you can just have that in field level routine.. and inside it just write if else ABAP statsmenet which you have wrriten inside routine. this for sure resolve your issue.

Thanks..

0 Kudos

Hi Manu,

You can use Routine with Unit in the transformation routine.

You will get routine with below parameters:

  METHOD compute_XXXXX.

*   IMPORTING

*     request     type rsrequest

*     datapackid  type rsdatapid

*     SOURCE_FIELDS-COMPANY_CODE TYPE XXXXXXX

*     SOURCE_FIELDS-CURRENCY TYPE XXXXXXXX

*     SOURCE_FIELDS-AMOUNT TYPE XXXXXXXX

*    EXPORTING

*      RESULT type _ty_s_TG_1-AMOUNT

*      CURRENCY type _ty_s_TG_1-CURRENCY.

if source_fields -compcode = 'CH01'

result = source_fields-amount * 1.21.

currency= 'CHF'

else.

result = source_fields-amount .

currency= SOURCE_FIELDS-CURRENCY.

endif.

Regards,

Madhu.

Former Member
0 Kudos

Thank you very much guys - you are absolutely great !!

ciao

Manu