SAP汇率转换函数[BAPI_EXCHANGERATE_GETDETAIL]

BAPI_EXCHANGERATE_GETDETAIL 用法:

tables : tcurr .

data :  g_waers  type   tcurr-UKURS  .

data :  exr   type BAPI1093_0 ,
           exr2 type BAPI1093_0 .

"定义一个宏
define ZWAERS .
  clear: exr , exr2 .
  CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
    EXPORTING
      RATE_TYPE          =  'M'
      FROM_CURR         =  &1
      TO_CURRNCY       =  &2
      DATE                    =  sy-datum
   IMPORTING
     EXCH_RATE          = exr
*     RETURN           =
            .
  CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
    EXPORTING
      RATE_TYPE         =  'M'
      FROM_CURR        =  &2
      TO_CURRNCY      =  &1
      DATE                   =  sy-datum
   IMPORTING
     EXCH_RATE         = exr2
*     RETURN           =
            .
   if exr-valid_from >= exr2-valid_from .
      &3 = exr-EXCH_RATE .            "如果日期為 0 ,則rate為0
   else.
      &3 = 1 / exr2-EXCH_RATE .      "exr2肯定不為0
   endif.
 end-of-definition .

"调用宏

 ZWAERS  原货币  目标货币   g_waers .

你可能感兴趣的:(Exchanger)