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: 

hi help in function module

Former Member
0 Kudos

hi,

what are the function modules do we use for the conversion of currency and units.

1) i want to convert currency(US$) to INR.

2) and to convert from one unit to another unit.

before using these function modules what we have to do in bdcs.

regards

vivek

5 REPLIES 5

Vinod_Chandran
Active Contributor
0 Kudos

Hi,

For currency conversion use the function module CONVERT_TO_LOCAL_CURRENCY and for unit conversion UNIT_CONVERSION_SIMPLE.

Cheers

Vinod

Former Member
0 Kudos

Hi,

For units conversion check this'CF_UT_UNIT_CONVERSION'

Currency if you are changing to local it is 'CONVERT_TO_LOCAL_CURRENCY_N'.

check i hope it will help you.

Thanks.

If your issue is solved award points and close thread.

Former Member
0 Kudos

Hi,

Check this sample code,


  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
    EXPORTING
*     CLIENT                  = SY-MANDT
      DATE                    = pdate
      FOREIGN_AMOUNT          = p_amt1
      FOREIGN_CURRENCY        = p_curr1
      LOCAL_CURRENCY          = p_curr2
*     RATE                    = 0
*     TYPE_OF_RATE            = 'M'
*     READ_TCURR              = 'X'
    IMPORTING
      EXCHANGE_RATE           = w_rate
      FOREIGN_FACTOR          = w_fact1
      LOCAL_AMOUNT            = w_amt
      LOCAL_FACTOR            = w_fact2
*     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.
    write: / 'Conversion to loc.curr. failed:',
             p_curr1, '->', p_curr2, 'err.code=', sy-subrc.
  ELSE.
    write: / 'to Loc.curr:', p_amt1 currency p_curr1, p_curr1, '->',
           w_amt currency p_curr2, p_curr2,
           '(', w_rate, ')', w_fact1, w_fact2.
  ENDIF.

http://www.geocities.com/victorav15/sapr3/examples/currconv.txt

Check this

CONVERSION_FACTOR_GET

<b>Measurement unit conversion:</b> Get measurement unit conversion factor Not for Dimensionless Units of Measure

UNIT_CONVERSION_SIMPLE Measurement unit conversion by table T006, with rounding

UNIT_OF_MEASURE_SAP_TO_ISO  

UNIT_OF_MEASURE_ISO_TO_SAP

MATERIAL_UNIT_CONVERSION Material quantity conversion from Base Unit of Measure to Alternative Unit of Measure and vice versa. For Dimensionless Units of Measure (Each, Piece, Box etc.) conversion depends on the given Material (see table MARM). For other Units of Measure (Length, Weigth etc.) conversion can be calculated from the T006 table or via CONVERSION_FACTOR_GET.

CONVERSION_EXIT_CUNIT_INPUT Conversion exit for commercial (3-char) measurement unit INPUT

CONVERSION_EXIT_CUNIT_OUTPUT Conversion exit for commercial (3-char) measurement unit OUTPUT

CONVERSION_EXIT_LUNIT_INPUT Conversion exit for technical (6-char) measurement unit INPUT

CONVERSION_EXIT_LUNIT_OUTPUT Conversion exit for technical (6-char) measurement unit OUTPUT

UNIT_OF_MEASUREMENT_HELP Input help for measurement units of a predefined dimension

http://www.geocities.com/victorav15/sapr3/abapfun.html

0 Kudos

Hi,

Here's another example (almost the same as Judith actually posted):

REPORT Z_CONVERT_CURR .

data: wa_amount(16)      type p.

parameters: p_date       type sy-datum default sy-datum.
parameters: p_amount(16) type p.
parameters: p_local      type TCURR-TCURR.
parameters: p_forei      type TCURR-FCURR.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
  EXPORTING
*   CLIENT                  = SY-MANDT
    date                    = p_date
    foreign_amount          = p_amount
    foreign_currency        = p_forei
    local_currency          = p_local
*   RATE                    = 0
*   TYPE_OF_RATE            = 'M'
*   READ_TCURR              = 'X'
  IMPORTING
*   EXCHANGE_RATE           =
*   FOREIGN_FACTOR          =
    LOCAL_AMOUNT            = wa_amount
*   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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

write: / wa_amount.

Regards,

Ville

Former Member
0 Kudos

Hi,

For Currency Conversion

Before using the below FM go to the transaction <b>OB08</b> and check whether the <b>From</b>(USD in this case) and <b>TO</b>(INR in this case) currency you are passing in the FM exists.

If it is not there it'll throw out an error. You can add your own currency entries and save it.

Data w_val type curr09.

CALL FUNCTION <b>'CONVERT_TO_LOCAL_CURRENCY'</b>

EXPORTING

date = sy-datum

foreign_amount = '100' "your table-field

foreign_currency = 'USD'

local_currency = 'INR'

IMPORTING

local_amount = w_val. "Output

Please reward points if this explanation is useful.

Regards,

Siva

Message was edited by: Sivakumar Muthusamy