Setinstancenosys

This instruction performs an assignment between the properties of a class instance and the content of a file class or a mask class (for example, an [F:xxxx] table buffer or [M:yyyy] mask class), in one direction or the other. It works exactly as setinstance, but it excludes technical properties from the assignment.

This transfer is based on the property names and the column names; the transfer is done only on the common names.

When the transfer is done between a collection in an instance and an array in the mask (ie. a block identified by a rank from 1 to 99), the current collection index is given in the syntax, and the current index in the mask array is given by the nolign system variable (that goes from 1 to the number of lines).

This instruction is used intensively by the CRUD operation support implemented in the supervisor layer. The name of the columns in the database tables and the name of the property in a class must be the same if the development partner wants to benefit from a complete automatic management of class persistence in the database. If this is not the case for some properties, the development partner must write the assignment directly in the corresponding events available in CRUD management.

Syntax

(1) SetInstancenosys [F:xxxx] With INSTANCE_NAME(2) SetInstancenosys INSTANCE_NAME With [F:xxxx](3) SetInstancenosys [M:xxxx] RANK With INSTANCE_NAME.COLLECTION(INDEX)(4) SetInstancenosys [M:xxxx] With INSTANCE_NAME(5) SetInstancenosys INSTANCE_NAME.COLLECTION(INDEX) With [M:xxxx] RANK(6) SetInstancenosys INSTANCE_NAME With [M:xxxx]
**Notes:**

The properties that are excluded from the transfer are the following:

PropertyDescription
UpdtickRevision number
AUUIDUnique ID
CREDATCreation date
UPDDATUpdate date
CREUSRUser who performed the creation
UPDUSRUser who performed the last update
CREDATTIMCreation date time
UPDDATTIMUpdate date time

Examples

This first example involves only a class and a table:
# Instance pointer on a customer classLocal Instance MY_CUSTOMER Using C_CUSTOMERLocal File CUSTOMERS [CUST]# Let's create a instance in memory for a customerMY_CUSTOMER = NewInstance C_CUSTOMER AllocGroup Null# Let's read a customer record, and transfer the data in the instance createdRead [CUST]CODE="CUST1234"SetInstancenosys MY_CUSTOMER With [F:ORD]
This second example involves a class with a collection, a mask with an array, and two tables (header / line) :
# Instance pointer on a sales order classLocal Instance MY_SALESORDER Using C_SALESORDER# Table declarationLocal File SALESORDER [ORD], SALESLINE [LINE]# Mask declarationLocal Mask SALESORDER [ORD]# Other variable declarationLocal Shortint LNUM# Let's create an instance in memory for a customerMY_SALESORDER = NewInstance C_SALESORDER AllocGroup Null# Let's read a salesorder header, and transfer the data in the instance createdRead [ORD]ORDERID="0012345"SetInstancenosys MY_SALESORDER With [F:ORD] # Let's read the lines that in a collectionFor [LINE]ORDLIN Where [LINE]ORDLIN=[F:ORD]ORDLINLNUM=fmet MY_SALESORDER.ADDLINE("LINES",[V]CST_ALASTPOS)If LNUM>=0SetInstancenosys MY_SALESORDER.LINES(LNUM) With [F:LINE]ElseBreakEndifNext# Here we might work and modify sales order instance....# Let's transfer the class in a mask that has the line array at rank 20# We suppose here that :# - all the lines are valid (no test about ASTALIN property in LINES)# - the logical order is the same than the physical order (nolign directly used as the loop index)SetInstancenosys [M:ORD] with MY_SALESORDERFor nolign=1 to maxtab(MY_SALESORDER.LINES)SetInstancenosys [M:ORD] 20 With MY_SALESORDER.LINES(nolign)Next nolign

See also

Structure, Instance, SetInstance, NewInstance, FreeInstance, FreeGroup, allocgrp, cast, null