Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 38
The Process-Order Server ($SER2)
! Check that there is still enough stock on hand to satisfy
! the order:
ORDER^REPLY.QUANTITY^ON^HAND := PART^REC.QUANTITY^ON^HAND
- ORDER^REQUEST.QTY^ORDERED;
! If not enough stock, unlock the record and return with
! negative stock indication:
IF ORDER^REPLY.QUANTITY^ON^HAND < 0 THEN
BEGIN
CALL UNLOCKREC(INV^FNUM);
SBUFFER[0] ':=' ORDER^REPLY FOR $LEN(ORDER^REPLY);
REPLY^LEN := $LEN(ORDER^REPLY);
REPLY^ERROR := 0;
RETURN;
END;
! If there is enough stock, update the inventory record:
PART^REC.QUANTITY^ON^HAND := ORDER^REPLY.QUANTITY^ON^HAND;
CALL WRITEUPDATEUNLOCKX(INV^FNUM,PART^REC,$LEN(PART^REC));
!------------------------------
!Add new order record to orders
!file and prepare reply message
!with new order number.
!------------------------------
! Blank the ORDER^RECORD structure:
ORDER^RECORD.ORDER^NUMBER ':='
($LEN(ORDER^RECORD) / 2) * [" "];
ORDER^RECORD.QTY^ORDERED := 0;
K := 0;
WHILE K < 3 DO
BEGIN
ORDER^RECORD.DATE^ORDERED[K] := 0;
ORDER^RECORD.DATE^SHIPPED[K] := 0;
K := K + 1;
END;