Net Value in Statistics Currency
DATA: VALUE LIKE COMM_STRUCTURE-NETVAL_INV.
DATA: US_RATE_TYPE LIKE COMM_STRUCTURE-RATE_TYPE.
CLEAR RESULT.
IF COMM_STRUCTURE-BILL_RULE CA '45'.
RETURNCODE = 4.
EXIT.
ENDIF.
IF NOT COMM_STRUCTURE-NETVAL_INV IS INITIAL AND
COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
US_RATE_TYPE = COMM_STRUCTURE-RATE_TYPE.
IF US_RATE_TYPE EQ SPACE.
US_RATE_TYPE = 'M'.
ENDIF.
ENDIF.
IF COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
CALL FUNCTION 'CONVERT_TO_STAT_CURRENCY'
EXPORTING
DATE = COMM_STRUCTURE-ST_UP_DTE
DOCUMENT_AMOUNT = COMM_STRUCTURE-NETVAL_INV
DOCUMENT_CURRENCY = COMM_STRUCTURE-DOC_CURRCY
LOCAL_CURRENCY = COMM_STRUCTURE-LOC_CURRCY
STAT_CURRENCY = COMM_STRUCTURE-STAT_CURR
LOCAL_RATE = COMM_STRUCTURE-EXRATE_ACC
STAT_RATE = COMM_STRUCTURE-EXCHG_STAT
LOCAL_TYPE_OF_RATE = US_RATE_TYPE
STAT_TYPE_OF_RATE = US_RATE_TYPE
IMPORTING
STATISTICAL_AMOUNT = VALUE
EXCEPTIONS
LOCAL_RATE_NOT_FOUND = 1
STAT_RATE_NOT_FOUND = 2.
CASE SY-SUBRC.
WHEN 0.
RESULT = VALUE.
RETURNCODE = 0.
WHEN 1.
CLEAR MONITOR.
MONITOR-msgno = '005'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-LOC_CURRCY.
append MONITOR.
RETURNCODE = 4.
WHEN 2.
CLEAR MONITOR.
MONITOR-msgno = '006'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-STAT_CURR.
append MONITOR.
RETURNCODE = 4.
ENDCASE.
ELSE.
RESULT = COMM_STRUCTURE-NETVAL_INV.
ENDIF.
IF COMM_STRUCTURE-DOC_CATEG CA DEB_CRED.
RESULT = RESULT * ( -1 ).
ENDIF.