PeopleSoft-PeopleCode代码调用薪资计算AE、Job和处理结果记录

代码调用AE、Job

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
try

Local ProcessRequest &RQST;
Local Record &rec1;

/*获取当前语言代码*/
Local string &LANGE = %Language;
rem 获取入参;
Local string &strGpAction = LH_GP_DX_WRK.LH_GP_ACTION.Value; /*薪酬操作类型*/
Local string &strCalRunId = LH_GP_DX_WRK.CAL_RUN_ID.Value; /*日历组ID*/
Local string &strOprid = LH_GP_DX_WRK.OPRID.Value; /*用户ID*/

rem 校验必填项;
If None(&strGpAction) Or
None(&strCalRunId) Or
None(&strOprid) Then
throw CreateException(0, 0, ",errorMsg:必填项未填,请检查数据准确性!,")
End-If;

rem 判断入参有效性;
Local string &Flag;
SQLExec("SELECT 'Y' FROM PSOPRDEFN U where u.oprid = :1", &strOprid, &Flag);
If None(&Flag) Then
throw CreateException(0, 0, ",errorMsg:PS用户不存在,请检查数据!,")
End-If;

/* If &strGpAction = "A" Then
Else
If &strGpAction = "C" Then
Else
throw CreateException(0, 0, "薪酬计算类型值无效,请检查数据准确性!")
End-If;
End-If; */

/*处理并发情况*/
Local string &strRunId;
SQLExec("select L.RUNSTATUS from PS_LH_GP_PDPAE_LOG L WHERE L.CAL_RUN_ID = :1 AND L.RUNSTATUS = '7'", &strCalRunId, &strRunId);
If &strRunId = "7" Then
throw CreateException(0, 0, ",errorMsg:该日历组ID正在计算处理中,无法同时发起多次!,")
End-If;

rem 处理薪酬计算进程运行控制表;
&rec1 = CreateRecord(Record.GP_RUNCTL);
&rec1.RUN_CNTL_ID.Value = "INTF_" | &strCalRunId;
&rec1.CAL_RUN_ID.Value = &strCalRunId;
&rec1.OPRID.Value = &strOprid;

rem 关账数据无法重算;
Local string &strRunOpenTS, &strRunFinalizedTS;
SQLExec("SELECT c.RUN_OPEN_TS,c.RUN_FINALIZED_TS FROM PS_GP_CAL_RUN C WHERE C.CAL_RUN_ID = :1", &strCalRunId, &strRunOpenTS, &strRunFinalizedTS);
If None(&strRunFinalizedTS) Then
rem 日历组ID未关帐情况下,日历组ID有效性校验;
Local string &strExists;
SQLExec("select 'X' from PS_GP_CAL_RUN_SRCH R WHERE R.OPRID = :1 AND R.CAL_RUN_ID = :2", &strOprid, &strCalRunId, &strExists);
If None(&strExists) Then
throw CreateException(0, 0, ",errorMsg:日历组ID不存在或用户无权限,请检查数据!,")
End-If;
If All(&strRunOpenTS) Then
rem 非第一次,重新计算;
If &strGpAction = "A" Then
rem 【取消】;
&rec1.RUN_CANCEL_IND.Value = "N";
rem 【标识收款人】 ;
&rec1.RUN_IDNT_IND.Value = "N";
rem 【计算】;
&rec1.RUN_CALC_IND.Value = "Y";
End-If;
REM 【取消】计算;
If &strGpAction = "C" Then
rem 【取消】;
&rec1.RUN_CANCEL_IND.Value = "Y";
rem 【标识收款人】 ;
&rec1.RUN_IDNT_IND.Value = "N";
rem 【计算】;
&rec1.RUN_CALC_IND.Value = "N";
End-If;
Else
rem 第一次计算;
If &strGpAction = "A" Then
rem 【取消】;
&rec1.RUN_CANCEL_IND.Value = "N";
rem 【标识收款人】 ;
&rec1.RUN_IDNT_IND.Value = "Y";
rem 【计算】;
&rec1.RUN_CALC_IND.Value = "Y";
End-If;
If &strGpAction = "C" Then
throw CreateException(0, 0, ",errorMsg:该日历组ID未计算过,无法取消计算!,");
End-If;
End-If;
Else
throw CreateException(0, 0, ",errorMsg:该日历组ID已关账,无法重新计算,请检查数据!,")
End-If;

&rec1.PRC_NUM.Value = 1;
&rec1.SUSP_ACTIVE_IND.Value = "N";
&rec1.RUN_UNFREEZE_IND.Value = "N";
&rec1.RUN_RECALC_ALL_IND.Value = "N";
&rec1.RUN_FREEZE_IND.Value = "N";
&rec1.RUN_FINAL_IND.Value = "N";

&rec1.RUN_SUSPEND_IND.Value = "N";
&rec1.RUN_TRACE_OPTN.Value = "N";
&rec1.RUN_PHASE_OPTN.Value = "1";
&rec1.RUN_PHASE_STEP.Value = "01";
&rec1.UPDATE_STATS_IND.Value = "Y";
&rec1.STOP_BULK_IND.Value = "N";
&rec1.LANGUAGE_CD.Value = "ZHS";
&rec1.PRC_SAVE_TS.Value = %Datetime;
&rec1.GP_PROC_MON_IND.Value = "Y";

REM 默认更新,无法更新则插入新数据;
If Not &rec1.Insert() Then
&rec1.Update();
End-If;

&swSession = GetSession();
/*切换传入用户*/
&swSession.connect(1, "", &strOprid, "", 0);
rem 设置默认语言;
SetLanguage(&LANGE);

rem 调用薪资计算程序;
&RQST = CreateProcessRequest();
&RQST.RunControlID = "INTF_" | &strCalRunId;
rem 调用PSJob ;
&RQST.ProcessType = "PSJob";
&RQST.JobName = "GP_PAYE";
rem 调用AE ;
rem &RQST.ProcessType = "AppEngine";
rem &RQST.ProcessName = "GP_PAYE";
&RQST.Schedule();

LH_GP_DX_WRK.PRCSINSTANCE.Value = Value(&RQST.ProcessInstance);
rem 日志记录,用于后续查询;
Local Record &rcdLog = CreateRecord(Record.LH_GP_PDPAE_LOG);
&rcdLog.PRCSINSTANCE.Value = &RQST.ProcessInstance;
&rcdLog.RUNCNTLID.Value = "INTF_" | &strCalRunId;
&rcdLog.OPRID.Value = &strOprid;
&rcdLog.LH_GP_ACTION.Value = &strGpAction;
&rcdLog.CAL_RUN_ID.Value = &strCalRunId;
&rcdLog.RQSTDTTM.Value = "";
&rcdLog.ENDDTTM.Value = "";
&rcdLog.RUNSTATUS.Value = "7";
&rcdLog.RUNSTATUSDESCR.Value = "正在处理";
&rcdLog.COMMENTS.Value = " ";
&rcdLog.Insert();

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

查询 薪酬计算 结果,并写入日志表

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
/*系统进程运行情况监控,并返回报错信息*/
Function getMsg(&ProcessInstance) Returns string
&RSBatMsgLog = CreateRowset(Record.PMN_MSGLOG_VW);
rem &RSBatMsgLog.Flush();
&RSBatMsgLog.fill("WHERE PROCESSINSTANCE = :1", &ProcessInstance);

REM create the message;
For &iCount = 1 To &RSBatMsgLog.ActiveRowCount
&MESSAGE_SET_NBR = &RSBatMsgLog.getrow(&iCount).PMN_MSGLOG_VW.MESSAGE_SET_NBR.value;
&MESSAGE_NBR = &RSBatMsgLog.getrow(&iCount).PMN_MSGLOG_VW.MESSAGE_NBR.value;
REM proceed if message set number and message number greater than 0;
&MessageParm1 = "";
&MessageParm2 = "";
&MessageParm3 = "";
&MessageParm4 = "";
&MessageParm5 = "";
&MessageParm6 = "";
&MessageParm7 = "";
&MessageParm8 = "";
&MessageParm9 = "";
&MessageParm10 = "";

If &MESSAGE_SET_NBR = 0 And
&MESSAGE_NBR = 0 Then
&MESSAGE_SET_NBR = 65;
&MESSAGE_NBR = 30;
End-If;
If &MESSAGE_SET_NBR > 0 And
&MESSAGE_NBR > 0 Then
&MESSAGE_SEQ = &RSBatMsgLog.getrow(&iCount).PMN_MSGLOG_VW.MESSAGE_SEQ.value;
&WhereMessage = "WHERE PROCESS_INSTANCE = :1 AND MESSAGE_SEQ = :2";

&sql = CreateSQL("SELECT PARM_SEQ, MESSAGE_PARM FROM PS_MESSAGE_LOGPARM " | &WhereMessage, &ProcessInstance, &MESSAGE_SEQ);

While &sql.Fetch(&iParmSeq, &MessageParm);
Evaluate &iParmSeq
When 1
&MessageParm1 = &MessageParm;
Break;
When 2
&MessageParm2 = &MessageParm;
Break;
When 3
&MessageParm3 = &MessageParm;
Break;
When 4
&MessageParm4 = &MessageParm;
Break;
When 5
&MessageParm5 = &MessageParm;
Break;
When 6
&MessageParm6 = &MessageParm;
Break;
When 7
&MessageParm7 = &MessageParm;
Break;
When 8
&MessageParm8 = &MessageParm;
Break;
When 9
&MessageParm9 = &MessageParm;
Break;
When 10
&MessageParm10 = &MessageParm;
Break;
End-Evaluate;
End-While;
&MESSAGE_TEXT = &MESSAGE_TEXT | Char(13) | MsgGetText(&MESSAGE_SET_NBR, &MESSAGE_NBR, "", &MessageParm1, &MessageParm2, &MessageParm3, &MessageParm4, &MessageParm5, &MessageParm6, &MessageParm7, &MessageParm8, &MessageParm9, &MessageParm10);

End-If;
End-For;
Return &MESSAGE_TEXT
End-Function;

rem 获取当前进程的实例ID;
Local number &prcsInstance = LH_GP_R_LOG_AET.PROCESS_INSTANCE.Value;

REM 找到同一PSjob中的薪酬COBOL计算程序的的实例ID;

Local number &mainJobpPcsInstance; /*Psjob-GP_PAYE实例ID*/
SQLExec("SELECT R1.JOBINSTANCE FROM PSPRCSRQST R1 where R1.PRCSINSTANCE = :1 ", &prcsInstance, &mainJobpPcsInstance);

Local number &cobolSqlPcsInstance; /*COBOL SQL-GPPDPRUN实例ID*/
SQLExec("SELECT R.PRCSINSTANCE FROM PSPRCSRQST R WHERE R.JOBINSTANCE = :1 AND R.PRCSTYPE = 'COBOL SQL' AND R.PRCSNAME = 'GPPDPRUN'", &mainJobpPcsInstance, &cobolSqlPcsInstance);

/*查询服务错误进程ID,更新接口请求的日志表中*/
rem 注意:日志中的进程实例ID为PSjob作业GP_PAYE的实例ID,但是需要找到子cobol进程GPPDPRUN的报错信息更新写入日志表;

Local SQL &getAeSql = CreateSQL("SELECT a.PRCSINSTANCE ,a.runstatus,a.runstatusdescr,a.rqstdttm, a.ENDDTTM FROM ps_PMN_PRCSLIST a WHERE a.prcsname = 'GPPDPRUN' and a.prcsinstance = :1", &cobolSqlPcsInstance);
Local Record &rcd = CreateRecord(Record.LH_GP_PDPAE_LOG);
While &getAeSql.Fetch(&prcsId, &runStatus, &runStatusDescr, &dttmRqst, &dttmEmd)
&rcd.PRCSINSTANCE.Value = &mainJobpPcsInstance;
If &rcd.SelectByKey() Then
&rcd.RQSTDTTM.Value = &dttmRqst;
&rcd.ENDDTTM.Value = &dttmEmd;
&rcd.RUNSTATUS.Value = &runStatus;
&rcd.RUNSTATUSDESCR.Value = &runStatusDescr;
&rcd.COMMENTS.Value = getMsg(&prcsId);
&rcd.Update();
End-If;

End-While;