IT源码网

Call Component Interface from AE

flyfish 2021年04月03日 程序员 429 0

Local File &Source, &fileLog;Local string &strLine, &FilePath, &EmplStatus;Local array of string &Item;Local number &Line, &SucCNT, &FailCNT;

Local ApiObject &oSession, &oCiJobDataChange;Local ApiObject &oCollNameTypeVwCollection, &oCollNameTypeVw;Local ApiObject &oCollNamesCollection, &oCollNames;Local ApiObject &oCollAddressTypeVwCollection, &oCollAddressTypeVw;Local ApiObject &oCollAddressesCollection, &oCollAddresses;Local ApiObject &oCollPersonalPhoneCollection, &oCollPersonalPhone;Local ApiObject &oCollEmailAddressesCollection, &oCollEmailAddresses;Local ApiObject &oCollPersDataEffdtCollection, &oCollPersDataEffdt;Local ApiObject &oCollPersNidCollection, &oCollPersNid;Local ApiObject &oCollJobCollection, &oCollJob;Local ApiObject &oCollJobJrCollection, &oCollJobJr;Local ApiObject &oCollCompensationCollection, &oCollCompensation;Local ApiObject &oCollJobEarnsDistCollection, &oCollJobEarnsDist;Local ApiObject &oCollBenProgParticCollection, &oCollBenProgPartic;

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;      &fileLog.WriteLine("          " | &sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);   End-For;   rem ***** Delete the Messages from the collection *****;   &oPSMessageCollection.DeleteAll();End-Function;

rem ***** Set the Log File *****;&fileLog = GetFile("CI_JOB_DATA_CHANGE.log", "w", "a", %FilePath_Relative);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 *****;&oCiJobDataChange = &oSession.GetCompIntfc(CompIntfc.TSC_SALARY_INCREASE_CI);If &oCiJobDataChange = Null Then   &fileLog.WriteLine("Error in Get ComponentInterface - TSC_SALARY_INCREASE_CI.");   errorHandler();   throw CreateException(0, 0, "GetCompIntfc failed");Else   &fileLog.WriteLine("Success! Get ComponentInterface - TSC_SALARY_INCREASE_CI.");End-If;

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

rem &FilePath = "E:\interface\" | %DbName | "\salary\z_load_salary.csv";&FilePath = "E:\test.csv";&Source = GetFile(&FilePath, "R", %FilePath_Absolute);

&Line = 0;&SucCNT = 0;&FailCNT = 0;

&fileLog.WriteLine("------------------------------------------------------------------------------------------------------------------------------");

While &Source.ReadLine(&strLine)      &Line = &Line + 1;   &Item = Split(&strLine, ",");         SQLExec("SELECT A.EMPL_STATUS FROM PS_JOB A WHERE A.EMPLID = :1 AND A.EMPL_RCD = 0 AND A.EFFDT = (SELECT MAX(B.EFFDT) FROM PS_JOB B WHERE B.EMPLID = A.EMPLID AND B.EMPL_RCD = 0) ", &Item [1], &EmplStatus);      If &EmplStatus = "A" Then            rem ***** Set Component Interface Get/Create Keys *****;      If All(&Item [1]) Then         &oCiJobDataChange.KEYPROP_EMPLID = &Item [1];      End-If;      &oCiJobDataChange.KEYPROP_EMPL_RCD = 0;            rem ***** Execute Create ******;      If Not &oCiJobDataChange.Get() Then;         rem ***** Unable to Create Component Interface for the Add keys provided. *****;         &fileLog.WriteLine("Error! Can Not Get Employee When Processing " | &Line | ", Employee " | &Item [1] | ".");         errorHandler();      Else                  rem ***** Set/Get COLL_JOB Collection Field Properties -- Parent: PS_ROOT Collection *****;         &oCollJobCollection = &oCiJobDataChange.COLL_JOB;         &oCollJob = &oCollJobCollection.InsertItem(&oCollJobCollection.CurrentItemNum());         &oCollJob.KEYPROP_EFFDT = Date(&Item [2]);                  SQLExec("SELECT COUNT(*) FROM PS_JOB WHERE EMPLID=:1 AND EMPL_RCD=:2 AND EFFDT=%DateIn(:3)", &Item [1], 0, &Item [2], &CNT);                  &oCollJob.KEYPROP_EFFSEQ = &CNT;         &oCollJob.PROP_ACTION = &Item [3];                  If Not None(&Item [4]) Then            &oCollJob.PROP_ACTION_REASON = &Item [4];         End-If;                  rem ***** Set COLL_COMPENSATION Collection Field Properties -- Parent: COLL_JOB Collection *****;         If &Item.Len >= 5 Then            If Not None(&Item [5]) Then               &oCollCompensationCollection = &oCollJob.COLL_COMPENSATION;               &oCollCompensation = &oCollCompensationCollection.Item(1);               REM &oCollCompensation.KEYPROP_COMP_RATECD = "MONPAY";               &oCollCompensation.PROP_COMPRATE = &Item [5];                              &oCollJob.PROP_CALC_COMP_BTN = "!";            End-If;         End-If;                  rem ***** Execute Save *****;         If Not &oCiJobDataChange.Save() Then;                        REM Count as Fail;            &FailCNT = &FailCNT + 1;            &fileLog.WriteLine("Error! Can Not Save Employee When Process Line " | &Line | ", Employee " | &Item [1] | ".");            errorHandler();         Else                        REM Count as Success;            &FailCNT = &FailCNT + 1;            &fileLog.WriteLine("Success! Finish Process Line " | &Line | ", Employee " | &Item [1] | ".");            errorHandler();         End-If;                  rem ***** Execute Cancel *****;         If Not &oCiJobDataChange.Cancel() Then;            &fileLog.WriteLine("Error! Can Not Cancel Employee When Process Line " | &Line | ", Employee " | &Item [1] | ".");            errorHandler();         End-If;               End-If;         Else      REM When Employee Status Is Not Active;      &fileLog.WriteLine("Error! Can Process Inactive Employee When Process Line " | &Line | ", Employee " | &Item [1] | ".");            REM Count as Fail;      &FailCNT = &FailCNT + 1;   End-If;      CommitWork();   CollectGarbage();   End-While;

&fileLog.WriteLine("End");&fileLog.Close();

转载于:https://www.cnblogs.com/GoDevil/archive/2009/07/10/1520567.html


评论关闭
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!