PeopleSoft-客制化表数据复制

客制化表数据复制

代码如下:

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
If None(&retMsg) Then
rem 工作经历;
//创建rowSet;
Local Rowset &workRs = CreateRowset(Record.C_HIR_WK_EX_TBL);
//判断&workRs是否有数据,如果有,进行处理;
If All(&workRs.GetRow(1).C_HIR_WK_EX_TBL.NID_SPECIAL_CHAR.Value) Then
//调用Fill方法,筛选数据;
&workRs.Fill(" WHERE NID_SPECIAL_CHAR=:1", &perRcd.NID_SPECIAL_CHAR.Value);
//调用函数进行表复制;
&retMsg = submitDataList(&workRs, "C_HIR_WK_EX_TBL", "C_PRE_WK_EX_TBL");
End-If;
End-If;

/* 提交数据行函数 */
Function submitDataList(&rs As Rowset, &forRcdName As string, &toRcdName As string) Returns string
/*
args:&rs - Rowset类型;&forRcdName - string类型;&toRcdName - string类型;
retuen:返回值 string类型;
*/
&rtnMsg = "";
try
Local Record &toRcd = CreateRecord(@("RECORD." | &toRcdName));
For &i = 1 To &rs.ActiveRowCount
//调用函数进行复制保存表每行的数据
submitRcdInfo(&rs.GetRow(&i).GetRecord(@("RECORD." | &forRcdName)), &toRcd);
End-For;
catch Exception &ex
&rtnMsg = &ex.ToString();
end-try;
Return &rtnMsg;
End-Function;

/*复制并保存表信息函数*/
Function submitRcdInfo(&fromRcd As Record, &toRcd As Record)
//复制数据
&fromRcd.CopyFieldsTo(&toRcd);
//插入
&toRcd.Insert();
//更新
&toRcd.Update();
End-Function;

非客制化表一般利用CI写入数据

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
143
144
145
146
147
148
149
150
151
152
/*利用CI写入职务数据*/
Function inputJob(&perRcd As Record) Returns string
Local ApiObject &oJobCollection, &oJob;
Local ApiObject &oCompensationCollection, &oCompensation;

try
&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 *****;
//获取CI对象
&oCJobDataEmpCi = &oSession.GetCompIntfc(CompIntfc.C_JOB_DATA_EMP_CI);
//如果没有创建成功的话,提示,可能是CI不存在或者用户没有CI权限
If &oCJobDataEmpCi = Null Then
&rtnMsg = errorHandler();
REM throw CreateException(0, 0, "GetCompIntfc failed");
End-If;
rem ***** Set the Component Interface Mode *****;
&oCJobDataEmpCi.InteractiveMode = False;
//CI具有获取历史记录功能
&oCJobDataEmpCi.GetHistoryItems = True;
//CI具有编辑修改历史记录功能
&oCJobDataEmpCi.EditHistoryItems = False;

rem ***** Set Component Interface Get/Create Keys *****;
//确定CI主键;
&oCJobDataEmpCi.EMPLID = &perRcd.EMPLID.Value;
&oCJobDataEmpCi.EMPL_RCD = 0;

//根据0层主键获取CI
rem If Not &oCJobDataEmpCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
rem &rtnMsg = errorHandler();
rem throw CreateException(0, 0, "Get failed");
rem End-If;
//根据0层主键创建CI
rem ***** Execute Create ******;
If Not &oCJobDataEmpCi.Create() Then;
rem ***** Unable to Create Component Interface for the Add keys provided. *****;
&rtnMsg = errorHandler();
rem throw CreateException(0, 0, "Create failed");
Else
//根据0层CI获取到1层JOB表集合;
&oJobCollection = &oCJobDataEmpCi.JOB;
Local integer &i164;
For &i164 = 1 To &oJobCollection.Count;
//遍历拿到表对象
&oJob = &oJobCollection.Item(&i164);
&oJob.EFFDT_0 = &perRcd.HIRE_DT.Value;
rem &oJob.EFFSEQ = [*];
&oJob.DEPTID = &perRcd.DEPTID.Value;;
rem &oJob.JOBCODE = [*];
&oJob.SUPERVISOR_ID = &perRcd.SUPERVISOR_ID.Value;
/* rem &oJob.ACTION_0 = [*];
rem &oJob.ACTION_REASON = [*];
rem &oJob.LOCATION = [*];
rem &oJob.TAX_LOCATION_CD = [*];
rem &oJob.JOB_ENTRY_DT = [*];
rem &oJob.SHIFT = [*];
rem &oJob.REG_TEMP = [*];
rem &oJob.FULL_PART_TIME = [*]; */
&oJob.COMPANY = &perRcd.COMPANYID.Value;
/* rem &oJob.PAYGROUP = [*];
rem &oJob.BAS_GROUP_ID = [*];
rem &oJob.ELIG_CONFIG1 = [*];
rem &oJob.ELIG_CONFIG2 = [*];
rem &oJob.ELIG_CONFIG3 = [*];
rem &oJob.ELIG_CONFIG4 = [*];
rem &oJob.ELIG_CONFIG5 = [*];
rem &oJob.ELIG_CONFIG6 = [*];
rem &oJob.ELIG_CONFIG7 = [*];
rem &oJob.ELIG_CONFIG8 = [*];
rem &oJob.ELIG_CONFIG9 = [*];
rem &oJob.EMPL_TYPE = [*];
rem &oJob.HOLIDAY_SCHEDULE = [*];
rem &oJob.STD_HOURS_0 = [*];
rem &oJob.STD_HRS_FREQUENCY = [*];
rem &oJob.OFFICER_CD = [*]; */
&oJob.EMPL_CLASS = &perRcd.EMPL_CLASS.Value;
/* rem &oJob.SAL_ADMIN_PLAN = [*];
rem &oJob.GRADE = [*];
rem &oJob.GRADE_ENTRY_DT = [*];
rem &oJob.STEP = [*];
rem &oJob.STEP_ENTRY_DT = [*];
rem &oJob.GL_PAY_TYPE = [*];
rem &oJob.EARNS_DIST_TYPE = [*];
rem &oJob.COMP_FREQUENCY = [*];
rem &oJob.ANNL_BENEF_BASE_RT = [*];
rem &oJob.SHIFT_RT = [*];
rem &oJob.SHIFT_FACTOR = [*];*/
&oJob.PAY_SYSTEM_FLG = "OT";
&oJob.BUSINESS_UNIT = &perRcd.BUSINESS_UNIT.Value;

&oJob.C_STD_POSN_ID = &perRcd.C_POSITION_ID.Value;
rem WinMessage(&perRcd.C_POSN_RANK_ID.Value);
rem &oJob.C_POSN_RANK_ID = &perRcd.C_POSN_RANK_ID.Value;
&oJob.C_LINE_MANAGEMENT = &perRcd.C_LINE_MANAGEMENT.Value;
&oJob.COUNTRY_0 = &perRcd.COUNTRY.Value;
&oJob.CITY = &perRcd.CITY.Value;
&oJob.C_HIR_MNG_ID = &perRcd.C_HIR_MNG_ID.Value;
&oJob.C_IS_EXIST_HC = &perRcd.C_IS_EXIST_HC.Value;
rem &oJob.C_ACTION_SUBREASON = [*];
rem Local string &cSalaryType;
rem SQLExec("SELECT h.C_SALARY_TYPE FROM PS_C_HIRE_TBL h WHERE h.emplid = :1 ", &perRcd.EMPLID.Value, &cSalaryType);
rem &oJob.C_SALARY_TYPE = &cSalaryType;
&oJob.C_SALARY_TYPE = &perRcd.C_SALARY_TYPE.Value;
/*rem WinMessage("ID:" | &perRcd.EMPLID.Value | "---薪酬制" | &cSalaryType);*/

//获取薪酬表内容
Local Rowset &xcRs = CreateRowset(Record.C_HIRE_XC_TBL);
&xcRs.Fill(" WHERE emplid = :1", &perRcd.EMPLID.Value);
rem ***** Set COMPENSATION Collection Field Properties -- Parent: JOB Collection *****;
//根据0层CI获取1层COMPENSATION表集合
&oCompensationCollection = &oJob.COMPENSATION;
Local integer &i29;
For &i29 = 1 To &xcRs.ActiveRowCount;
If &i29 = 1 Then
//第一个COMPENSATION表对象直接赋值;
&oCompensation = &oCompensationCollection.Item(1);
Else
//每进入一次循环则插入一个COMPENSATION表对象;
&oCompensation = &oCompensationCollection.insertItem(1);
End-If;
&oCompensation.COMP_EFFSEQ = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMP_EFFSEQ.Value;
&oCompensation.COMP_RATECD = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMP_RATECD.Value;
&oCompensation.COMP_RATE_POINTS = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMP_RATE_POINTS.Value;
&oCompensation.COMPRATE_0 = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMPRATE.Value;
&oCompensation.COMP_PCT = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMP_PCT.Value;
&oCompensation.COMP_FREQUENCY_0 = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.COMP_FREQUENCY.Value;
&oCompensation.CURRENCY_CD_0 = &xcRs.GetRow(&i29).C_HIRE_XC_TBL.CURRENCY_CD.Value;
End-For;
End-For;

rem ***** Execute Save *****;
If Not &oCJobDataEmpCi.Save() Then;
&rtnMsg = errorHandler();
rem throw CreateException(0, 0, "Save failed");
End-If;
End-If;

catch Exception &ex
&rtnMsg = &ex.ToString();
end-try;

Return &rtnMsg;

End-Function;