En muchos  empresas  facturan con mas de una moneda ( euros, dolares ). En estos casos cuando tratamos los importes tenemos que tener en cuenta la moneda. Toda sociedad de una empresa tiene especificada una moneda local, que es la moneda por defecto con la que trabaja, viene indicada en la tabla T001-WAERS.
Los factores de cambio entre las monedas salen de la tabla TCURF.
Si tenemos el importe en moneda local y queremos cambiar a otra moneda:
  CALL FUNCTION 'CONVERT_TO_FOREING_CURRENCY'
                     EXPORTING
                           CLIENT                                             = SY-MANDT
             date                                                      = SY-DATUM
              foreign_currency                          = wl_foreing_waers
             local_amount                               = wl_item_data-netpr 
             local_currency                           = wl_item_data-waers
 *                      RATE                    = 0
 *                      TYPE_OF_RATE              = 'M'
 *                       READ_TCURR                              = 'X'
                    IMPORTING
             FOREING_AMOUNT          = wl_foreing_netpr
        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.
Si tenemos el importe una moneda diferente a al local y queremos convertirlo a moneda local:
  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
                     EXPORTING
                           CLIENT                                             = SY-MANDT
             date                                                      = SY-DATUM
             foreign_amount                            = wl_item_data-netpr 
             foreign_currency                        = wl_item_data-waers
                           local_currency                             = wl_waers
 *                      RATE                    = 0
 *                      TYPE_OF_RATE              = 'M'
 *                       READ_TCURR                              = 'X'
                    IMPORTING
                           LOCAL_AMOUNT          = wl_local_netpr
        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. 


 
No hay comentarios:
Publicar un comentario