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: 

internal table to field symbol!!

Former Member
0 Kudos

Hi

i have an internal table which i want to assign to field symbol and pass it to CONVERT_TO_LOCAL_CURRENCY so that the amount can get converted...

what should be the syntax...

my code


  FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE ,
                 <fs_wa>  TYPE t_konv,
                 <fs_field>  TYPE ANY.
  DATA: wa_konv TYPE t_konv.
  ASSIGN i_konv[] TO <fs_table>.
  ASSIGN wa_konv TO <fs_wa>.
  LOOP AT <fs_table> ASSIGNING  <fs_wa>.
    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
      EXPORTING
*        date             = <fs_wa>-bedat
        foreign_amount   = <fs_wa>-waers
        foreign_currency = <fs_wa>-kbetr
        local_currency   = p_curr
      IMPORTING
        local_amount     = <fs_wa>-kbetr
      EXCEPTIONS
        no_rate_found    = 1
        overflow         = 2
        no_factors_found = 3
        no_spread_found  = 4
        OTHERS           = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

  ENDLOOP.

points for sure..

Regards

Gunjan

4 REPLIES 4

Former Member
0 Kudos

any pointers?

Former Member
0 Kudos

HI

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'       EXPORTING        
 client            = sy-mandt         
 date              = p_date        
 foreign_amount    = p_input        
 foreign_currency  = p_currency        
 local_currency    = 'USD'
* RATE              = 0
*        TYPE_OF_RATE      = 'M'
*        READ_TCURR        = 'X'      
IMPORTING
*        exchange_rate     =
*        FOREIGN_FACTOR    =         
local_amount      = p_output
*        LOCAL_FACTOR      =
*        EXCHANGE_RATEX    =
*        FIXED_RATE        =
*        DERIVED_RATE_TYPE =     
 EXCEPTIONS         
no_rate_found     = 1   
overflow          = 2
no_factors_found  = 3         
no_spread_found   = 4         
derived_2_times   = 5         
OTHERS            = 6.  
IF sy-subrc <> 0.    
p_output = 0.  
ENDIF.

<b>report</b>

DATA: gd_fcurr TYPE tcurr-fcurr,
      gd_tcurr TYPE tcurr-tcurr,
      gd_date  TYPE sy-datum,
      gd_value TYPE i.
 
gd_fcurr = 'EUR'.
gd_tcurr = 'GBP'.
gd_date  = sy-datum.
gd_value = 10.
 
PERFORM currency_conversion USING gd_fcurr
                                  gd_tcurr
                                  gd_date
                         CHANGING gd_value.
 
 
 
* Convert value to Currency value 
*&---------------------------------------------------------------------*
*&      Form  currency_conversion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GD_FCURR  text
*      -->P_GD_TCURR  text
*      -->P_GD_DATE   text
*      <--P_GD_VALUE  text
*----------------------------------------------------------------------*
FORM currency_conversion  USING    p_fcurr
                                   p_tcurr
                                   p_date
                          CHANGING p_value.
 
  DATA: t_er        TYPE tcurr-ukurs,
        t_ff        TYPE tcurr-ffact,
        t_lf        TYPE tcurr-tfact,
        t_vfd       TYPE datum,
        ld_erate(12)   TYPE c.
 
  CALL FUNCTION 'READ_EXCHANGE_RATE'
    EXPORTING
*       CLIENT                  = SY-MANDT
      date                    = p_date
      foreign_currency        = p_fcurr
      local_currency          = p_tcurr
      TYPE_OF_RATE            = 'M'
*       EXACT_DATE              = ' '
   IMPORTING
      exchange_rate           = t_er
      foreign_factor          = t_ff
      local_factor            = t_lf
      valid_from_date         = t_vfd
*       DERIVED_RATE_TYPE       =
*       FIXED_RATE              =
*       OLDEST_RATE_FROM        =
   EXCEPTIONS
     no_rate_found           = 1
     no_factors_found        = 2
     no_spread_found         = 3
     derived_2_times         = 4
     overflow                = 5
     zero_rate               = 6
     OTHERS                  = 7
            .
  IF sy-subrc EQ 0.
    ld_erate = t_er / ( t_ff / t_lf ).
    p_value = p_value * ld_erate.
  ENDIF.
ENDFORM.                    " currency_conversion 

Check this out

http://www.sapdevelopment.co.uk/country/country_curr.htm

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

Former Member
0 Kudos

Hi

Where's the problem?

Your code seems to be ok, the only problem is the field-symbol <fs_table> is type any so you make sure the table you assign is of the same type of KONV.

Max

Former Member
0 Kudos

<b>Hi ... Gunjan ... here is your code i corrected it was working utilise it i have used your Field -symbols also </b> .


REPORT  zsiva_test .

DATA itab TYPE TABLE OF  konv.
DATA wa2 LIKE LINE OF itab.
DATA: p_curr TYPE tcurr-fcurr.

FIELD-SYMBOLS <fs_wa> TYPE konv.
ASSIGN wa2 TO <fs_wa> CASTING.

LOOP AT itab ASSIGNING  <fs_wa>.
    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
      EXPORTING
*        date             = <fs_wa>-bedat
        foreign_amount   = <fs_wa>-waers
        foreign_currency = <fs_wa>-kbetr
        local_currency   = p_curr
      IMPORTING
        local_amount     = <fs_wa>-kbetr
      EXCEPTIONS
        no_rate_found    = 1
        overflow         = 2
        no_factors_found = 3
        no_spread_found  = 4
        OTHERS           = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

  ENDLOOP.

reward points if it is usefull...

Girish