Conditional update of a field in a Master TStruct – Example

Scenario  – Conditionally Updating  stock in Inventory Master

The inventory master in a store gets updated when items are purchased. Let us try a scenario in which when a receipt is entered, the received quantity is to be added to the item quantity based on the user’s choice. If user enters ‘Yes’ the quantity should be added to the item quantity or else no update takes place.

There are two TStructs in this case – an Inventory Master to maintain all the items and an Item Receipt for recording all the Items received. Inventory Master has already been defined in the previous scenario  Updating a field using MDMap.

Detail TStruct –  Item Receipt

Master TStruct – Inventory Master

Create the Item Receipt based on the definition given below

Type  Name  Caption  Properties 
TStruct Recpt Item Receipt TransId = Recpt
DC dc1 Detail TableName= itemreceipt
InputField ItemCode Item Code

Data Type = Character

Data Width =15

ModeOfEntry = Select

Details : From TStruct

Select TStruct = Inventory Master

Select Field to list in Selection Window = ItemCode

InputField ItemName Item Name

DataType = Character

Data Width =50

ModeOfEntry = Fill

Details :

Master = ItemCode

Source = ItemName

InputField ReceiptQty Receipt Qty DataType = Numeric
InputField StockUpdate Stock Update ? DataType = Character

ModeOfEntry = Select

Details : From List

List values : Yes,No

InputField UpdateField UpdateField DataType = Character

ModeOfEntry = Calculate

Expression = IIF ( StockUpdate = {Yes}, {T},{F})

Hidden = True


  • In the Item Receipt TStruct, insert an MDMap control.Set the properties as follows:
Type  Name  Properties 
MDMap Caption = Stock Receipt UpdateMasterTransaction = Inventory MasterMaster Field  = OpeningQty

Detail Field = ReceiptQty

MasterSearchField = Default

Detail Search Field = ItemCode

Update Type = Add

ControlField = UpdateField


  • Save the TStruct definition .
  • Click Run, open the Inventory Master form and use List View to make a note of one item and its Opening Quantity (Assume that for Item C, the opening quantity is 1000).
  • Open the Item Receipt form and enter a receipt for any item, in this case, item C. Let the receipt quantity for the Item C be 3000. Save the information entered.
  • Based on the value in the StockUpdate field the inventory master may or may not be updated .

Case 1 :If ‘Yes’ is selected in the field StockUpdate in the Inventory Form , it could be seen that the opening quantity for the Item C is updated with the receipt quantity  ( 4000 will be displayed).

Case 2 : In case the StockUpdate is set as ‘No’ , then the stock is not updated. In the Inventory Master the quantity for Item C will remain unchanged (1000).