S++Business systems language
DEMO SOURCE · SPP / APP / PHYRead the book

petshop-40-queries.spp

petshop/catalogue/petshop-40-queries.spp

Download original file · Petstore source contents

1domain petshop;23Scenario serial readShopInventory(Goods, Goods[], StockLine[]) {4    prepareProductSelection;5    listProducts;6    prepareInventorySelection;7    findStockLine;8    identify(StockLine[]);9}1011Scenario serial readShopMerchant(Merchant) {12    configureMerchantLookup;13    findMerchant;14    identify(Merchant);15}1617atomic calculate prepareProductSelection(Goods) {18    Goods.active = true;19}2021atomic calculate filterProducts(Goods, Goods[]) {22    Goods[] filtered = new Goods[] {23    };24    for (Goods product : Goods[]) {25        if (Goods.category == null || Goods.category == "" || product.category == Goods.category) {26            filtered = append(filtered, product);27        }28    }29    Goods[] = filtered;30}3132Scenario serial browseShopProducts(Goods, Goods[]) {33    prepareProductSelection;34    listProducts;35    localizeCatalog;36    filterProducts;37}