Scrol

SAP Trainings contact sap.sreeram@gmail.com or 091-9916083157, 001-210-399-8414

SAP BI Routine Subtotal 5 from Pricing Procedure in Statistics Currency


Subtotal 5 from Pricing Procedure in Statistics Currency
DATA: VALUE LIKE COMM_STRUCTURE-SUBTOTAL_5.
  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-SUBTOTAL_5 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-SUBTOTAL_5
              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-SUBTOTAL_5.
  ENDIF.

  IF COMM_STRUCTURE-DOC_CATEG CA DEB_CRED.
    RESULT = RESULT * ( -1 ).
  ENDIF.