CREATE NEW TREE
来源:互联网 发布:小郡主芊芊 知乎 编辑:程序博客网 时间:2024/05/06 10:05
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");
- CREATE NEW TREE
- Create a new role
- Create new test cases
- Rails : new, build, create
- create new thread
- gtkmm create new gtype
- Create a new user
- Play create new application
- magento create new locale
- create New Virtual Device
- R12 create new quotation
- easyui Create Async Tree
- Create new internet access point
- How to create new geodatabases
- delphi new dispose create free
- Rails 之 new build create
- new一个不如create一个
- create new post for jekyll
- 关于group by查询得到分组后每组的最小值的记录
- 命令行部署Reporting services报表
- 线下推广网站的7种方法
- struts1和struts2的区别
- 面试中出现频率较高的英语问题及精彩回答
- CREATE NEW TREE
- 老公我们一起好好努力吧!
- 夜 2008-6-8
- 国内SOA发展现况与面临的挑战
- LoadString、LoadIcon和LoadCursor函数
- 用PSP完美阅读PDF书籍
- 成为一个成功Jsp程序员的九步
- delphi7 开发ActiveX的学习备忘
- Object Association