Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
1
Indexable
   SUBROUTINE COUNT.SMCUSTORDER
   ************************************************************
   ** Created by JCRI on 08/08/2023 in SMPROGS
   ************************************************************
   $INCLUDE SYINCLUDE COMMON
   **
   ** IDE edit history **

   CALL @MP.OPEN("SM.CUSTORDER", SM.CUSTORDER, OPENSTAT)
   CALL @MP.OPEN("SM.ORDERS", SM.ORDERS, OPENSTAT)

   CUSTORDER.KEY = "JIGS437694"
   READ CUSTOMER.ORDER FROM SM.CUSTORDER, CUSTORDER.KEY THEN

    AMOUNT.OF.ORDERS = COUNT(CUSTOMER.ORDER<1>,@VM) + 0
    AMOUNT.OF.ORDER.STATUS = COUNT (CUSTOMER.ORDER<3>,@VM) + 0

    CHECKED.ORDER.STATUS = ""
    ORDER.KEY = ""

    CORRECT.VALUES = ""
    LAST.POS = 0
    LAST.POS2 = 0
    IF USER.ID = "JCRI" THEN DEBUG

    IF AMOUNT.OF.ORDERS # AMOUNT.OF.ORDER.STATUS THEN
        FOR I = 1 TO AMOUNT.OF.ORDERS

            POS.OF.VM = INDEX(CUSTOMER.ORDER<1>,@VM,I)
            ORDER.KEY = CUSTOMER.ORDER<1>[LAST.POS,POS.OF.VM-1]
            LAST.POS = POS.OF.VM

            READ ORDER FROM SM.ORDERS, ORDER.KEY THEN

                CHECKED.ORDER.STATUS = ORDER<31>
                POS.OF.STATUS = INDEX(CUSTOMER.ORDER<3>,@VM,I)
                ORDER.STATUS = CUSTOMER.ORDER<3>[LAST.POS2,POS.OF.STATUS-1]
                LAST.POS2 = POS.OF.STATUS

                IF CHECKED.ORDER.STATUS # ORDER.STATUS THEN
                    CORRECT.VALUES<I> = CHECKED.ORDER.STATUS
                END ELSE
                    CORRECT.VALUES<I> = CHECKED.ORDER.STATUS
                END
            END
        NEXT I
    END

END