PeopleSoft-PeopleCode调用CI

设计订单录入系统–内部PeopleCode调用 CI

​ 设计思路:建立一个新的订单录入系统,通过提交按钮,通过调用CI 来操作订单管理component 将页面中的数据提交至订单管理系统中,并保存。

​ 流程:设计CI接口 –>建record表–>设计page页面–>生成组件,编写提交按钮触发的PeopleCode代码–>注册组件

设计一个CI接口–基于订单管理系统

点击file ——>new 新建一个component interface ,基于订单管理组件,意思就是该接口对外的接口。

在component interface 的properties设置中,做好备注,在standard methods中勾选可以指定方法的访问权限。保存即可。

新建record表插入需要的已有field,按钮表 ZL_COMMITMENT ,做好每一个record的注释。

​ 因为是需要调用CI接口,所以,field和订单管理系统的一致就可以了。

  • 订单编号:勾选keysearch key(出现在搜索栏的选择项)(自动勾选List Box Item:出现在搜索结果的列表里),并且在Edits中勾选required表示这个field是必填项(即字段前面带*的输入框,无值的话会报错)。
  • 订单子序号:勾选key ,search key,勾选required。注意:translate field,在edits中必须将它的Edit Type —>Table Edit —>Type :Translate Table Edit **,否则在保存page页面的时候,会报该field字段无效的错误。
  • 注意:这里有个orderid,这个id勾选key,search key ,list box item 就好了,不需要勾选required。它与subid两个field组成一个key。
  • 新建表ZL_COMMITMENT 插入一个field COMMITMENT_CNTL,作为控制按钮。在component层面的这个field change的时候写PeopleCode。
  • 保存为HRAPP类型。
  • 重中之重:必须要build这两个record!!!否则,数据库中没有表,程序会报sql错误。

设计page页面。将建好的两个record加入到page中。做好注释

0层的参照订单管理系统的page设计就行。

​ 相同部分设计过程略。

​ 特殊的是0层的按钮设计。

​ 1.添加一个push button 到页面,对其进行设置。注意:要检查层级关系。

1层的这次不要Grid了,采用插入Scroll观察两者的区别。

​ 优点:不需要单独设计drop-down list box格式,会自动识别。

​ 缺点:只能展示一条record记录。

注意:

生成组件component。将page拖进去,改Item Label 的名字。

​ 打开component层面的按钮filed PeopleCode将CI 拖进去,自动生成代码,然后改掉根据需求该代码。[*] 表示需要替换的。

代码具体为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
时间:2019/03/27
作者:赵龙
事件:订单录入系统page中点击提交,通过ci操作订单管理系统,保存提交内容。
*/
/* ===>
This is a dynamically generated PeopleCode template to be used only as a helper
to the application developer.
You need to replace all references to '[*]' OR default values with references to
PeopleCode variables and/or a Rec.Fields. */


Local File &fileLog;
Local ApiObject &oSession, &oZlOrdercomCi;
Local ApiObject &oZlOrderDetCollection, &oZlOrderDet;

Function errorHandler()
Local ApiObject &oPSMessageCollection, &oPSMessage;
Local number &i;
Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;

&oPSMessageCollection = &oSession.PSMessages;
For &i = 1 To &oPSMessageCollection.Count
&oPSMessage = &oPSMessageCollection.Item(&i);
&sErrMsgSetNum = &oPSMessage.MessageSetNumber;
&sErrMsgNum = &oPSMessage.MessageNumber;
&sErrMsgText = &oPSMessage.Text;
rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
MessageBox(0, "", 9999, 9999, "" | &sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
End-For;
rem ***** Delete the Messages from the collection *****;
&oPSMessageCollection.DeleteAll();
End-Function;

try
rem ***** Set the Log File *****;
rem &fileLog = GetFile("C:\Users\zhaolong\AppData\Local\Temp\ZL_ORDERCOM_CI.log", "w", "a", %FilePath_Absolute);
rem &fileLog.WriteLine("Begin");
rem ***** Get current PeopleSoft Session *****;
&oSession = %Session;

rem ***** Set the PeopleSoft Session Error Message Mode *****;
rem ***** 0 - None *****;
rem ***** 1 - PSMessage Collection only (default) *****;
rem ***** 2 - Message Box only *****;
rem ***** 3 - Both collection and message box *****;
&oSession.PSMessagesMode = 1;

rem ***** Get the Component Interface *****;
&oZlOrdercomCi = &oSession.GetCompIntfc(CompIntfc.ZL_ORDERCOM_CI);

If &oZlOrdercomCi = Null Then

errorHandler();
throw CreateException(0, 0, " getCi faidled");
End-If;

rem ***** Set the Component Interface Mode *****;
&oZlOrdercomCi.InteractiveMode = True;
&oZlOrdercomCi.GetHistoryItems = True;
&oZlOrdercomCi.EditHistoryItems = True;

rem ***** Set Component Interface Get/Create Keys *****;
&oZlOrdercomCi.ZL_ORDERID = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERID.Value;

rem ***** Execute Get *****;
If Not &oZlOrdercomCi.Get() Then
MessageBox(0, "", 9999, 9999, "ci没有");
rem ***** Execute Create ******;
If Not &oZlOrdercomCi.Create() Then;
rem ***** Unable to Create Component Interface for the Add keys provided. *****;
MessageBox(0, "", 9999, 9999, "ci对象创建失败");
errorHandler();
throw CreateException(0, 0, "Create failed");
End-If;
End-If;


rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;

&oZlOrdercomCi.ZL_ORDERID = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERID.Value;

MessageBox(0, "", 9999, 9999, "id赋值");
&oZlOrdercomCi.ZL_ORDERDESC = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERDESC.Value;
MessageBox(0, "", 9999, 9999, "描述赋值");


&oZlOrderDetCollection = &oZlOrdercomCi.ZL_ORDER_DET;
Local integer &i17;
For &i17 = &oZlOrderDetCollection.count To 1 Step - 1
&oZlOrderDetCollection.deleteItem(&i17);
End-For;
MessageBox(0, "", 9999, 9999, "清空集合");

For &i17 = 1 To GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).ActiveRowCount;
&oZlOrderDetCollection.insertItem(&oZlOrderDetCollection.count);


&oZlOrderDet = &oZlOrderDetCollection.Item(&oZlOrderDetCollection.count);


&oZlOrderDet.ZL_ORDER_SUBID = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBID.Value;


&oZlOrderDet.ZL_ORDER_SUBTYPE = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBTYPE.Value;


&oZlOrderDet.ZL_ORDER_SUBDESC_1 = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBDESC.Value;


&oZlOrderDet.ZL_ORDERQUAN = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDERQUAN.Value;


&oZlOrderDet.ZL_ORDERPRI = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDERPRI.Value;
MessageBox(0, "", 9999, 9999, "完成第" | &i17 | "个record赋值");

End-For;


rem ***** End: Get/Set Component Interface Properties *****;

rem ***** Execute Save *****;
If Not &oZlOrdercomCi.Save() Then;
MessageBox(0, "", 9999, 9999, "订单导入失败");
errorHandler();
throw CreateException(0, 0, "Save failed");
Else
MessageBox(0, "", 9999, 9999, "订单导入成功");
End-If;

rem ***** Execute Cancel *****;
If Not &oZlOrdercomCi.Cancel() Then;
errorHandler();
throw CreateException(0, 0, "Cancel failed");
End-If;

catch Exception &ex
MessageBox(0, "", 9999, 9999, "运行异常");

end-try;

注册组件。

与订单管理系统相同步骤。过程略。