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: 

Exchange Rates - STEP by STEP

Former Member
0 Kudos

I am doing an exercise using the tables tcurr, tcurc, tcurt.

I am a begginner user in abap and would like to learn step by step how to use parameters to choose the currency code (TCURR-FCURR) to a currency code (TCURR-TCURR) that will be converted (according to the user's choice) and implement the conversion rate.

After displaying a report. Can anyone explain me step by step?

The final report should leave as follows:

Code currency, the name of the currency, code of the currency of exchange, the name of the currency of exchange, rate of exchange.

3 REPLIES 3

Former Member
0 Kudos

I would give you an algorithm which would help you develop this program...

A keyword would be provided for every step, you need to check for syntax & its usage

1) You need to take 2 currencies as input for conversion (From & To Currencies resp.) for which you need to create a screen with these fields for user inputs.

Keyword - PARAMETERS

2) You need to define a structure to hold the data which you would fetch from the tables.

Keyword - DATA

3) You need to fetch data from tables & store it in a structure.

Keyword - SELECT

4) The data you have in the structure should be displayed.

Keyword - WRITE

Try & understand the usage of the 4 keywords & you would be able to write this program.

To find information on a keyword...

Type the keyword on the ABAP Editor (SE38) ,block the keyword & click the Information icon.

Let me know if you need more information...Happy coding

0 Kudos

Hello Jerome.

I am a little confused how.

Can you help me?

The code is this way:

TABLES: tcurc, tcurr, tcurt.

  • Creation of strucutre data to show the final report.

DATE: BEGIN OF e_zcambio OCCURS 0,

Cod_moeda,

Nome_da_moeda,

Nome_da_moeda_de_cambio,

Taxa_de_cambio,

Cod_moeda_de_cambio,

END OF e_zcambio.

Date:

T_tcurt2 like tcurt OCCURS 0 WITH HEADER LINE,

T_tcurt like tcurt OCCURS 0 WITH HEADER LINE,

T_tcurc like tcurc OCCURS 0 WITH HEADER LINE,

T_tcurr like tcurr OCCURS 0 WITH HEADER LINE.

  • Screen Selection of

PARAMETERS:

"Initial currency =

Money like T_TCURR - FCURR,

"Moeda2 = currency to be converted

Moeda2 like t_tcurr - tcurr.

IF t_tcurr [] IS INITIAL.

MESSAGE ID 'SU' TYPE 'I' NUMBER'000 'WITH' Currency Not Found! '.

ENDIF.

IF CURRENCY EQ MOEDA2.

MESSAGE ID 'SU' TYPE 'I' NUMBER'000 'WITH' THE CURRENCY OF ORIGIN AND THE PART FOR Conversion! '.

ENDIF.

  • Subrotinas to be used

START-OF-SELECTION.

PERFORM seleciona_dados.

  • PERFORM formata_dados.

  • PERFORM exibe_relatorio.

FORM seleciona_dados.

ELSE.

ENDIF.

0 Kudos

Some changes to your code:

TABLES: tcurc, tcurr, tcurt. 


* Creation of strucutre data to show the final report. 
DATE: BEGIN OF e_zcambio OCCURS 0, 

Cod_moeda, 
Nome_da_moeda, 
Nome_da_moeda_de_cambio, 
Taxa_de_cambio, 
Cod_moeda_de_cambio, 

END OF e_zcambio. 

Date: 
T_tcurt2 like tcurt OCCURS 0 WITH HEADER LINE, 
T_tcurt like tcurt OCCURS 0 WITH HEADER LINE, 
T_tcurc like tcurc OCCURS 0 WITH HEADER LINE, 
T_tcurr like tcurr OCCURS 0 WITH HEADER LINE. 

* Screen Selection of 

PARAMETERS: 
"Initial currency = 
Money like T_TCURR - FCURR, 

"Moeda2 = currency to be converted 
Moeda2 like t_tcurr - tcurr. 



AT SELECTION-SCREEN.   " << ADDED
IF CURRENCY EQ MOEDA2. 
MESSAGE ID 'SU' TYPE 'I' NUMBER'000 'WITH' THE CURRENCY OF ORIGIN AND THE PART FOR Conversion! '. 
ENDIF. 

* Subrotinas to be used 
START-OF-SELECTION. 
* 
PERFORM seleciona_dados. 
* PERFORM formata_dados. 
* PERFORM exibe_relatorio. 

FORM seleciona_dados. 

ELSE. 

ENDIF. 

* " ADDED
END-OF-SELECTION.
IF t_tcurr [] IS INITIAL. 

MESSAGE ID 'SU' TYPE 'I' NUMBER'000 'WITH' Currency Not Found! '. 
ELSE 
PERFORM WRITE_DATA.


ENDIF.

Regards,

Naimesh Patel