Scrol

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

SAP BI Routine Open Order Quantity


Open Order Quantity

CLEAR RESULT.

  IF COMM_STRUCTURE-DENOMINTR EQ COMM_STRUCTURE-NUMERATOR.
    RESULT = COMM_STRUCTURE-OPENORDQTY.
    RETURNCODE = 0.
  ELSE.
    IN    = COMM_STRUCTURE-OPENORDQTY.
    DENOM = COMM_STRUCTURE-DENOMINTR.
    NUMER = COMM_STRUCTURE-NUMERATOR.

    CALL FUNCTION 'UNIT_CONVERSION_WITH_FACTOR'
         EXPORTING
              ADD_CONST        = 0
              DENOMINATOR      = DENOM
              INPUT            = IN
              NUMERATOR        = NUMER
         IMPORTING
              OUTPUT           = OUT
         EXCEPTIONS
              DIVISION_BY_ZERO = 1
              OVERFLOW         = 2
              TYPE_INVALID     = 3
              OTHERS           = 4.

    CASE SY-SUBRC.
      WHEN 0.
        RESULT = OUT.
        RETURNCODE = 0.
      WHEN 1.
        clear MONITOR.
        MONITOR-msgno = '007'.
        MONITOR-msgid = 'SDBW'.
        MONITOR-msgty = c_msgty_e.
        MONITOR-msgv1 = COMM_STRUCTURE-DOC_NUMBER.
        MONITOR-msgv2 = COMM_STRUCTURE-S_ORD_ITEM.
        append MONITOR.
        RETURNCODE = 4.
      WHEN 2.
        clear MONITOR.
        MONITOR-msgno = '008'.
        MONITOR-msgid = 'SDBW'.
        MONITOR-msgty = c_msgty_e.
        MONITOR-msgv1 = COMM_STRUCTURE-DOC_NUMBER.
        MONITOR-msgv2 = COMM_STRUCTURE-S_ORD_ITEM.
        append MONITOR.
        RETURNCODE = 4.
      WHEN OTHERS.
    ENDCASE.
  ENDIF.

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