SAP ABAP:獲取匯率的完整實現之一

leniz發表於2011-07-21
 
經常用到,好不容易做了一個完整的。
 
data: cw_rate like bapi1093_0.
data: s_c_factor type p decimals 3,
      t_c_factor type p decimals 3,.
data:  s_waerk type waerk,
       t_waerk type waerk,
       curdate type rscalday,"add by Robin 2010.08.07
       l_rate type p decimals 4.
*1. 獲取匯率資訊
    call function 'BAPI_EXCHANGERATE_GETDETAIL'
      exporting
        rate_type  = 'M'
        from_curr  =  s_waerk
        to_currncy =  t_waerk
        date       =  curdate
      importing
        exch_rate  = cw_rate.
*2. 獲取轉換因子
    call function 'CURRENCY_CONVERTING_FACTOR'
      exporting
        currency = s-waerk
      importing
        factor   = s_c_factor.
    call function 'CURRENCY_CONVERTING_FACTOR'
      exporting
        currency = t-waerk
      importing
        factor   = t_c_factor.
      l_rate = cw_rate-exch_rate * ( cw_rate-to_factor / cw_rate-from_factor )
                * ( s_c_factor / t_c_factor ) .

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/554557/viewspace-702753/,如需轉載,請註明出處,否則將追究法律責任。

相關文章