Open all | Close all

Getting the LATEST information!

To ensure you are getting the latest information please vist this page on the new domain for SAP Development


Convert currency value from display to SAP



The following code shows how CURRENCY_AMOUNT_DISPLAY_TO_SAP can be used. You pass it a
Currecny code(WAERS) and the displayed currency value. It will convert the value so that it can be stored
in SAP. Without using this function module the value stored in SAP is not guaranteed to be correct.
                        I.e. 28000 JPY is stored within SAP as 280.

*Data declaration
*------------
* WMTO_S-AMOUNT =  Type DEC :: length 15 :: Deciamls 4
parameter: p_curr   like TCURC-WAERS,     "Display currency
           p_disval like WMTO_S-AMOUNT.  "Internal Amount

data:      gd_intval  like WMTO_S-AMOUNT. "Display Amount


CALL FUNCTION 'CURRENCY_AMOUNT_DISPLAY_TO_SAP'
     EXPORTING
          currency        = p_curr
          amount_display  = p_disval
    IMPORTING
          AMOUNT_INTERNAL = gd_intval
    EXCEPTIONS
          INTERNAL_ERROR  = 1
          OTHERS          = 2
          .
IF sy-subrc <> 0.

* You are now able to store the return value into an SAP table.
ENDIF.


************************************************************************
*Start-of-selection.
START-OF-SELECTION.

write:/(30)  'Value Displayed on screen in SAP:', p_disval,
      /(30)  'Currency:',  p_curr,
      /(30)  'Internal SAP value', gd_intval.