CREATE NEW TREE

Tree Classes Implementation

   1.

      Get a session object.

      Before you can get a tree, you have to get a session object. The session controls access to the tree, provides error tracing, enables you to set the runtime environment, and so on. Use the %Session system variable to return a reference to the current PeopleSoft session.

      &Session = %Session;

   2.

      Get a tree object.

      Use the GetTree method specifying a null value (" ") to return a closed tree object.

      &MyTree = &Session.GetTˋree();

   3.

      Create the Tree.

      The Create method creates a new tree with the name PERSONAL_DATA2. To ensure that you have a valid tree, use the All built-in function. Description is a required property (if you don’t specify something for Description you cannot save the tree.)

      &TreeReturn = &MyTree.Create("", "", "PERSONAL_DATA2", "1999-06-01", "PERSONAL_DATA"); &MyTree.description = "test tree";

   4.

      Add a level.

      To add a level, you have to instantiate a level collection. Although there aren’t any levels in the tree, you can still access this collection. Use the Add method with the level collection to add a new level. Remember, the level name must be 8 characters or less. Description is a required property (if you don’t specify something for Description you cannot save the tree.)

      &LvlColl = &MyTree.levels; &Level = &LvlColl.add("FIRST LVL"); &Level.description = "First Level";

   5.

      Add the root node.

      Because this is a new tree, you must first add the root node.

      &RootNode = &MyTree.insertroot("00001");

   6.

      Add a leaf.

      To add a new leaf, you must have a reference to the parent node object. Using the All built-in function ensures that there is a root node before you try to insert the leaf with the InsertChildLeaf method.

      If ALL(&RootNode) Then &NewLeaf = &RootNode.InsertChildLeaf("8000", "8999"); end-if;

   7.

      Save the tree.

      When you execute the Save method, the new tree is saved to the database.

      &RSLT = &MyTree.Save();

      Note. If you’re running the tree API from an Application Engine program, the data won’t actually be committed to the database until the Application Engine program performs a COMMIT.    8.

      Check for errors.

      You can check if there were any errors using the PSMessages property on the session object.

      If All (&RSLT) Then /* errors occurred = do error checking */ &ERRORCOL = &Session.PSMessages; For &I = 1 To &ERRORCOL.count /* do error processing */ End-For; Else /* no errors - saved correctly - do other processing */ End-If;

      If there are multiple errors, all errors are logged to the PSMessages collection, not just the first occurrence of an error.

Note. If you’ve called the Tree API from an Application Engine program, all errors are also logged in the application engine error log tables.

 

Create(SetID, UserKeyValue, TreeName, EffDt, StructureName)

Example

&MYTREE.Create("","","PERSONAL_NEW", "05-05-1997", "PERSONAL_DATA");

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值