Explore Categories

 

 PDF

Procedural-Object/Collection Related Actions

NEW OBJECT

The action  New Object takes two parameters Object Type and Object Identifier. The syntax is:

Syntax

NEW OBJECT : <Object Type>: [:<Object Identifier>]

Where,

<Object Type> is the type of the object to be created,

<Object Identifier> is the unique identifier of the object. This parameter is optional. In case this is not specified, it creates a blank object of the specified type.

The actions Save Target/Alter Target/Create Target is used along with New Object for specific usage. There are three scenarios to consider for this:

  • In case a Blank Object is created using ‘New Object’ without specifying the Object Identifier, the actions ‘Save Target’ and ‘Create Target’ will work, while ‘Alter Target’ would fail.
  • In case an existing object is brought into context by specifying Object Identifier with ‘New Object’, the actions ‘Save Target’ and ‘Alter Target’ will work, while ‘Create Target’ would fail.

Note: Save Target’ saves the current Object, whether it is a blank new Object, or an existing Object for Alteration.

  • When an Object Identifier is specified with ‘New Object’ and the object does not exist in the database, the Action ‘Save Target’ fails, as ‘New Object’ does not create a blank object.

In order to overcome the scenario (3), the Action ‘New Object’ has been enhanced to accept an additional parameter ‘Force Create Flag’ along with the Object Identifier. This forces the creation of an empty blank object, in case the Object with Identifier does not exist in the database.

Syntax

NEW OBJECT : <Object Type>: [:<Object Identifier>[:<Forced Create Flag>]]

Where,

<Object Type> is the type of the object to be created,

<Object Identifier> is the unique identifier of the object.

<Forced Create Flag> is an Optional Flag and is required only if <Object Identifier>is specified. If the Flag is set to TRUE, then if the object identified by <Object Identifier>exists, the object is altered; otherwise, a new empty object of the specified type is created.

Example

         |

01: NEW OBJECT : Group : ##EGroupName : TRUE

02: SET VALUE : Name : ##NGroupName

03: SAVE TARGET

         |

If the ledger identified by ‘##EGroupName’ exists in Tally database, then the objects are altered by the action SAVE TARGET; else, a new object is created as the Forced flag is set to ‘YES’.

 

INSERT COLLECTION OBJECT

This action inserts the new object of the type specified in the collection and makes it as the current target object. This object is inserted into the collection at the end. This Action takes only Secondary Collection as the parameter.

Syntax

INSERT COLLECTION OBJECT : <CollectionName>

Where,

< CollectionName > is the name of the Secondary Collection.

Example

01 : INSERT COLLECTION OBJECT : Ledger Entries

This insets a new object ‘Ledger Entries’ in memory under Voucher, and sets it as the target object. Later, by using other methods of this, the target object can be set and saved to Tally DB.

SET VALUE

This action sets the value of a method for the target object. The value formula is evaluated with respect to the current object context. This can use the new method formula syntax. Using this, it is possible to access any value from the current object.

Syntax

SET VALUE : <Method Name>[: <Value Formula>]

Where,

< Method Name > is the name of the method, and

< Value Formula > is the value which needs to be set to the method. It is optional. If the second parameter is not specified, it searches for the same method in the context object and the value is set based on it. If the source method name is same as in Target Object, then the Source Object method name is optional.

Example: 1

01 : SET VA L UE : Ledger Name : $LedgerName

OR

01 : SET VA L UE : Ledger Name

These statements set the values of ‘Ledger Entries’ Object from the current Object context.

Example: 2

02 : WALK COL L ECTION : Vouchers of My Objects

03 : NEW OBJECT : Voucher

;; Since the methods Date, VoucherTypeName are same in the source object and target object, they are not specified again as SET VALUE : DATE : $Date.

04 : SET VALUE : D ate

05 : SET VALUE : VoucherTypeName

Example: 3

[Function : Sample Function]

Object : Ledger : “Party 1”

01 : NEW O B JECT : Ledger : “Party 2”

;; absence of Value expression will assume that same method to be copied from source

02 : SET V A LUE : Parent

03 : ACCEPT ALTER

‘Party 1’ is a ledger under the Group ‘North Debtors’ and Party 2 is a Ledger under the Group ‘South Debtors’. After the execution of this function, Party 2 will also come under the Group ‘South Debtors’.

 RESET VALUE

This action sets the value of the method using the Value Formula. If Value Formula is not specified, it sets the existing value to null.

Syntax

RESET VALUE : MethodName [: Value Formula]

Where,

< Method Name > is the name of the method, and

< Value Formula > is an optional parameter and if it is used, it will reset the value of the method.

Example

01 : SET VALUE : Ledger Name : $LedgerName

02 : RESET VALUE : Ledger Name : “New Value”

In this code snippet, RESET VALUE resets the value of the method ‘Ledger Name’

 CREATE TARGET/ACCEPT CREATE

It accepts the Target Object to the Company Data base, i.e., it saves the target object to the database. This creates a new object in the database if it does not exist, else results in an error.

Syntax

CREATE TARGET / ACCEPT CREATE

SAVE TARGET/ ACCEPT

It accepts the Target Object to the Company Tally DB. If another object exists in the Tally DB with the same identifier, then the object is altered, else a new object is created.

Syntax

SAVE TARGET / ACCEPT

ALTER TARGET/ACCEPT ALTER

It allows altering an exiting object in the Tally Data Base. If the object does not exist, it results in an error.

Syntax

ALTER TARGET / ACCEPT ALTER

 SET OBJECT

It sets the current object with the Object Specification. If no object specification is given, the target object will be set as the current object. Only Secondary Object can be used along with this Action.

Syntax

SET OBJECT [:<Object Spec>]

Where,

< Object Spec > is the name of the Secondary Object.

Example:

[Function : Sample Function]

Object : Ledger : “My Test Ledger”

01 : LOG : $Name

02 : SET O B JECT : BillAllocat i ons[1]

03 : LOG : $Name

04 : SET O B JECT : ..

05 : LOG : $Name

Initially, the context object is Ledger, so $Name gives the name of the Ledger. By Using ‘ SET OBJECT ’, the current Object is changed to first Bill allocation. So, the second $Name is giving the Bill name. The Fourth line changes the current Object back to ‘Ledger’ using dotted notation.

SET TARGET

This action sets the target object with the Object Specification . If no object specification is given , then the current object will be set a s the target object .

Syntax

SET TARGET : <Object Spec>

Where,

<Object Spec> is the name of the Object.

Example:

01 : SET TARGET : Group

This sets the ‘Group’ Object as the Target Object. Later, by using other methods of this, the target object can be set and saved to the Tally DB.

WALK COLTLECION

The Walk Collection is used to execute a set of statements for each object of the collection.

Syntax

Walk Collection : <Expression> [:<Rev Flag>]

Where,

<Expression> can be any expression which evaluates to a collection name.

<Rev Flag> can be any expression which evaluates to a logical value. If it is True, then the collection objects are traversed in reverse order. This parameter is optional. The Default value is False.

Example

[Function : Test Function]

Parameter : parmcoll

        |

        |

05 : WALK COLLECTION : ##parmColl : Yes

The collection name is passed as a parameter to the function ‘Test function’ and is walked in reverse order.

The code snippet to call the function ‘Test function’ from a key is as follows:

[Key : DC Call Function]

Key : Enter

Action : CALL : Test Function : ##CollName

The collection name is passed through the variable ‘CollName’.

 

 

Post a Comment

Is this information useful?
YesNo
Helpful?