Showing posts with label Peoplecode. Show all posts
Showing posts with label Peoplecode. Show all posts
How to write a Health Benefit Component Interface Peoplesoft Peoplecode.

The Following is the typical health benefit component interface peoplecode.
Local File &fileLog;
Local ApiObject &oSession, &oKzlHealthBenefits;
Local ApiObject &oBenefitParticCollection, &oBenefitPartic;
Local ApiObject &oHealthBenefitCollection, &oHealthBenefit;
Local ApiObject &oHealthDependntCollection, &oHealthDependnt;

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

&oPSMessageCollection = &oSession.PSMessages;
&Proc_Error = &Proc_Error + 1;
For &i = 1 To &oPSMessageCollection.Count
&oPSMessage = &oPSMessageCollection.Item(&i);
&sErrMsgSetNum = &oPSMessage.MessageSetNumber;
&sErrMsgNum = &oPSMessage.MessageNumber;
&sErrMsgText = &oPSMessage.Text;
SQLExec("SELECT KZL_ABN FROM PS_KZL_ABN_TBL WHERE EMPLID =:1", &Emplid, &Kzl_Abn);
&fileLog.WriteLine("*******************************************************************");
&fileLog.WriteLine("Address Book Number :" | &Kzl_Abn);
&fileLog.WriteLine("Emplid :" | &Emplid);
&fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
&fileLog.WriteLine("*******************************************************************");
End-For;
rem ***** Delete the Messages from the collection *****;
&oPSMessageCollection.DeleteAll();
End-Function;

&fileLog = GetFile("C:\temp\KZL_HEALTH_BENEFITS.log", "w", "a", %FilePath_Absolute);

&REC_HEALTH_BEN = CreateRecord(Record.KZL_HEALTH_BEN);
&SQL_HEALTH_BEN = CreateSQL("%SelectAll(:1) where STATUS_FLAG =:2", &REC_HEALTH_BEN, "S");

While &SQL_HEALTH_BEN.Fetch(&REC_HEALTH_BEN)
try
&Proc_Count = &Proc_Count + 1;
rem ***** Set the Log File *****;
rem &fileLog = GetFile("C:\temp\KZL_HEALTH_BENEFITS.log", "w", "a", %FilePath_Absolute);
&fileLog.WriteLine("Begin");
rem ***** Get current PeopleSoft Session *****;
&oSession = %Session;
&oSession.PSMessagesMode = 1;

rem ***** Get the Component Interface *****;
&oKzlHealthBenefits = &oSession.GetCompIntfc(CompIntfc.KZL_HEALTH_BENEFITS);
If &oKzlHealthBenefits = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc failed");
End-If;

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

rem ***** Set Component Interface Get/Create Keys *****;
&Emplid = &REC_HEALTH_BEN.EMPLID.Value;
&oKzlHealthBenefits.EMPLID = &Emplid;
&oKzlHealthBenefits.EMPL_RCD = &REC_HEALTH_BEN.EMPL_RCD.Value;

rem ***** Execute Get *****;
If Not &oKzlHealthBenefits.Get() Then
rem ***** No rows exist for the specified keys.*****;
errorHandler();
throw CreateException(0, 0, "Get failed");
End-If;
&PlanType = &REC_HEALTH_BEN.PLAN_TYPE.VALUE;
&fileLog.WriteLine("&PlanType =" | &PlanType);

&oBenefitParticCollection = &oKzlHealthBenefits.BENEFIT_PARTIC;
&oBenefitPartic = &oBenefitParticCollection.ItemByKeys(&PlanType);
&fileLog.WriteLine("In Ben Partic");
If &oBenefitPartic <> Null Then
Else
&oBenefitPartic = &oBenefitParticCollection.Item(1);


If All(&oBenefitPartic.PLAN_TYPE) Then
&oBenefitPartic = &oBenefitParticCollection.InsertItem(1);
End-If;
&oBenefitPartic.PLAN_TYPE = &PlanType;
End-If;
rem ***** Set HEALTH_BENEFIT Collection Field Properties -- Parent: BENEFIT_PARTIC Collection *****;
&Effdt = &REC_HEALTH_BEN.EFFDT.Value;
&fileLog.WriteLine(" &Effdt = " | &Effdt);
&oHealthBenefitCollection = &oBenefitPartic.HEALTH_BENEFIT;
&oHealthBenefit = &oHealthBenefitCollection.ItemByKeys(&Effdt);
&fileLog.WriteLine("In Health Ben");
If &oHealthBenefit <> Null Then
&oHealthBenefit = &oHealthBenefitCollection.Item(1);
Else
&oHealthBenefit = &oHealthBenefitCollection.Item(1);
If All(&oHealthBenefit.EFFDT) Then
&oHealthBenefit = &oHealthBenefitCollection.InsertItem(1);

End-If;
&oHealthBenefit.EFFDT = &Effdt;
End-If;
&Covrg_Cd = &REC_HEALTH_BEN.COVRG_CD.Value;
rem &Effdt = &REC_HEALTH_BEN.EFFDT.Value;
&Health_Provider_Id = &REC_HEALTH_BEN.HLTH_PROVIDER_ID.Value;
&Previously_Seen = &REC_HEALTH_BEN.PREVIOUSLY_SEEN.Value;
&Oth_Insurance_Ind = &REC_HEALTH_BEN.OTH_INSURANCE_IND.Value;
&Oth_Insurance_Name = &REC_HEALTH_BEN.OTH_INSURANCE_NAME.Value;
REM &oHealthBenefit.EFFDT = &Effdt;
&oHealthBenefit.COVERAGE_BEGIN_DT = &REC_HEALTH_BEN.COVERAGE_BEGIN_DT.Value;
&oHealthBenefit.COVERAGE_ELECT = &REC_HEALTH_BEN.COVERAGE_ELECT.Value;
&oHealthBenefit.COVERAGE_ELECT_DT = &REC_HEALTH_BEN.COVERAGE_ELECT_DT.Value;
&oHealthBenefit.BENEFIT_PLAN = &REC_HEALTH_BEN.BENEFIT_PLAN.Value;
&oHealthBenefit.COVRG_CD = &Covrg_Cd;
&oHealthBenefit.MED_PREM_PRETAX = &REC_HEALTH_BEN.MED_PREM_PRETAX.Value;
&oHealthBenefit.HLTH_PROVIDER_ID = &Health_Provider_Id;
&oHealthBenefit.PREVIOUSLY_SEEN = &Previously_Seen;
&oHealthBenefit.OTH_INSURANCE_IND = &Oth_Insurance_Ind;
&oHealthBenefit.OTH_INSURANCE_NAME = &Oth_Insurance_Name;
&oHealthBenefit.COBRA_EVENT_ID = &REC_HEALTH_BEN.COBRA_EVENT_ID.value;
rem ***** Set HEALTH_DEPENDNT Collection Field Properties -- Parent: HEALTH_BENEFIT Collection *****;

Evaluate &Covrg_Cd
When 2
&oHealthDependntCollection = &oHealthBenefit.HEALTH_DEPENDNT;
SQLExec("SELECT DEPENDENT_BENEF FROM PS_DEPENDENT_BENEF WHERE EMPLID =:1 AND RELATIONSHIP='SP'", &Emplid, &Dependent_Benef);
&oHealthDependnt = &oHealthDependntCollection.ItemByKeys(&Dependent_Benef);
If &oHealthDependnt <> Null Then
Else
&oHealthDependnt = &oHealthDependntCollection.Item(1);
If All(&oHealthDependnt.DEPENDENT_BENEF) Then
&oHealthDependnt = &oHealthDependntCollection.InsertItem(1);
End-If;
&oHealthDependnt.DEPENDENT_BENEF = &Dependent_Benef;
&oHealthDependnt.HLTH_PROVIDER_ID_1 = &Health_Provider_Id;
&oHealthDependnt.PREVIOUSLY_SEEN_1 = &Previously_Seen;
&oHealthDependnt.OTH_INSURANCE_IND_1 = &Oth_Insurance_Ind;
&oHealthDependnt.OTH_INSURANCE_NAME_1 = &Oth_Insurance_Name;
End-If;
Break;

When = 3
&oHealthDependntCollection = &oHealthBenefit.HEALTH_DEPENDNT;
rem &oHealthDependnt = &oHealthDependntCollection.Item(1);
SQLExec("SELECT DEPENDENT_BENEF FROM PS_DEPENDENT_BENEF WHERE EMPLID =:1 AND RELATIONSHIP='C'", &Emplid, &Dependent_Benef);
&oHealthDependnt = &oHealthDependntCollection.ItemByKey(&Dependent_Benef);
If &oHealthDependnt <> Null Then
Else
&oHealthDependnt = &oHealthDependntCollection.Item(1);
If All(&oHealthDependnt.DEPENDENT_BENEF) Then
&oHealthDependnt = &oHealthDependntCollection.InsertItem(1);
End-If;
&oHealthDependnt.DEPENDENT_BENEF = &Dependent_Benef;
&oHealthDependnt.HLTH_PROVIDER_ID_1 = &Health_Provider_Id;
&oHealthDependnt.PREVIOUSLY_SEEN_1 = &Previously_Seen;
&oHealthDependnt.OTH_INSURANCE_IND_1 = &Oth_Insurance_Ind;
&oHealthDependnt.OTH_INSURANCE_NAME_1 = &Oth_Insurance_Name;
End-If;
Break;
When 4
&oHealthDependntCollection = &oHealthBenefit.HEALTH_DEPENDNT;

rem &oHealthDependnt = &oHealthDependntCollection.Item(1);
SQLExec("SELECT DEPENDENT_BENEF FROM PS_DEPENDENT_BENEF WHERE EMPLID =:1 AND RELATIONSHIP='SP'", &Emplid, &Dependent_Benef);
&oHealthDependnt = &oHealthDependntCollection.ItemByKey(&Dependent_Benef);
If &oHealthDependnt <> Null Then
Else
&oHealthDependnt = &oHealthDependntCollection.Item(1);
If All(&oHealthDependnt.DEPENDENT_BENEF) Then
&oHealthDependnt = &oHealthDependntCollection.InsertItem(1);
End-If;
&oHealthDependnt.DEPENDENT_BENEF = &Dependent_Benef;
&oHealthDependnt.HLTH_PROVIDER_ID_1 = &Health_Provider_Id;
&oHealthDependnt.PREVIOUSLY_SEEN_1 = &Previously_Seen;
&oHealthDependnt.OTH_INSURANCE_IND_1 = &Oth_Insurance_Ind;
&oHealthDependnt.OTH_INSURANCE_NAME_1 = &Oth_Insurance_Name;
End-If;

rem &oHealthDependnt = &oHealthDependntCollection.InsertItem(1);
SQLExec("SELECT DEPENDENT_BENEF FROM PS_DEPENDENT_BENEF WHERE EMPLID =:1 AND RELATIONSHIP='C'", &Emplid, &Dependent_Benef);
&oHealthDependnt = &oHealthDependntCollection.ItemByKey(&Dependent_Benef);
If &oHealthDependnt <> Null Then
Else
&oHealthDependnt = &oHealthDependntCollection.Item(1);
If All(&oHealthDependnt.DEPENDENT_BENEF) Then
&oHealthDependnt = &oHealthDependntCollection.InsertItem(1);
End-If;
&oHealthDependnt.DEPENDENT_BENEF = &Dependent_Benef;
&oHealthDependnt.HLTH_PROVIDER_ID_1 = &Health_Provider_Id;
&oHealthDependnt.PREVIOUSLY_SEEN_1 = &Previously_Seen;
&oHealthDependnt.OTH_INSURANCE_IND_1 = &Oth_Insurance_Ind;
&oHealthDependnt.OTH_INSURANCE_NAME_1 = &Oth_Insurance_Name;
End-If;
Break;
When-Other
Break;
End-Evaluate;


rem ***** Clear all Fields *****;
&Dependent_Benef = " ";
&Health_Provider_Id = " ";
&Covrg_Cd = " ";
&Effdt = " ";
&Previously_Seen = " ";
&Oth_Insurance_Ind = " ";
&Oth_Insurance_Name = " ";
rem ***** End: Get/Set Component Interface Properties *****;
rem ***** Execute Save *****;
If Not &oKzlHealthBenefits.Save() Then;
errorHandler();
throw CreateException(0, 0, "Save failed");
End-If;

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

catch Exception &ex
rem Handle the exception;
&fileLog.WriteLine(&ex.ToString());
end-try;
End-While;
&Proc_Success = &Proc_Count - &Proc_Error;
&fileLog.WriteLine("*******************************************************************");
&fileLog.WriteLine("Number of Prcessed Rows:" | &Proc_Count);
&fileLog.WriteLine("Number of Successful Rows :" | &Proc_Success);
&fileLog.WriteLine("Number of Errorful Rows :" | &Proc_Error);
&fileLog.WriteLine("*******************************************************************");
&fileLog.WriteLine("End");
&fileLog.Close();



Share/Bookmark


Local File &fileLog;
Local ApiObject &oSession, &oRuSavingsPlansCi;
Local ApiObject &oBenefitParticCollection, &oBenefitPartic;
Local ApiObject &oSavingsPlanCollection, &oSavingsPlan;
Local ApiObject &oSavingsBeneficCollection, &oSavingsBenefic;
Local ApiObject &oSavingsInvestCollection, &oSavingsInvest;
Local ApiObject &oDepBenefAsofCollection, &oDepBenefAsof;
Local Rowset &rsSavings, &rsSavingsInvest;
Local Record &recSavings, &recSavingsInvest;
Local number &numCount, &numTotCount, &numI, &numJ, &numEmplRcd, &numAmount;
Local string &strEmplid, &strPlanType, &strBenPlanPension, &strEligConfig3, &strBenefitPlan, &strInvestOpt;
Local date &dEffdt;


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;
Local string &STR_Temp;
&STR_Temp = &sErrMsgSetNum | &sErrMsgNum;
Evaluate &STR_Temp
When "9146"
When "1511"
When "9150"
Break;
When-Other
If Substring(&sErrMsgText, 1, 7) = "Warning" Then
Else
&OBJ_LoadFile.WriteLine(" " | &sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
End-If;
End-Evaluate;
End-For;
&oPSMessageCollection.DeleteAll();
End-Function;

Function errorHandlerSuccess()
Local ApiObject &oPSMessageCollection, &oPSMessage;
Local number &i;
Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;
&oPSMessageCollection = &oSession.PSMessages;

&oPSMessageCollection.DeleteAll();
End-Function;

&OBJ_LoadFile = GetFile("C:\PS\KZL_SVNG_CNV_LogFile.log", "W", %FilePath_Absolute);
&OBJ_LoadFile.writeline("*********** Error Details while converting Savings Plan Data **********");
&OBJ_LoadFile.writeline("");
&OBJ_LoadFile.writeline("");
&rsSavings = CreateRowset(Record.KZL_SAVING_STG);
&oSession = %Session;
&oSession.PSMessagesMode = 1;

&oRuSavingsPlansCi = &oSession.GetCompIntfc(CompIntfc.KZL_SAVINGS_PLAN_CI);
If &oRuSavingsPlansCi = Null Then
&OBJ_LoadFile.WriteLine("Cannot Get the CI Object ");
Exit (0);
End-If;

&oRuSavingsPlansCi.InteractiveMode = False;
&oRuSavingsPlansCi.GetHistoryItems = True;
&oRuSavingsPlansCi.EditHistoryItems = True;

&rsSavings = CreateRowset(Record.KZL_SAVING_STG);
&numTotCount = &rsSavings.Fill("ORDER BY EMPLID, DATE1 ");
For &numI = 1 To &numTotCount
&recSavings = &rsSavings(&numI).GetRecord(Record.KZL_SAVING_STG);
&OBJ_LoadFile.writeline("Processing Employee ID:- " | &recSavings.EMPLID.Value | " Date " | &recSavings.DATE1.Value);
SQLExec("SELECT B.BENEFIT_RCD_NBR FROM PS_PER_ORG_ASGN B WHERE B.EMPLID = :1 AND B.EMPL_RCD = (SELECT A.EMPL_RCD FROM PS_JOB A WHERE A.EMPLID = :1 AND A.JOB_INDICATOR = 'P' AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM PS_JOB A_ED WHERE A_ED.EMPLID = A.EMPLID AND A_ED.EMPL_RCD = A.EMPL_RCD AND A_ED.EFFDT <= :2) AND A.EFFSEQ = (SELECT MAX(A_EF.EFFSEQ) FROM PS_JOB A_EF WHERE A_EF.EMPLID = A.EMPLID AND A_EF.EMPL_RCD = A.EMPL_RCD AND A_EF.EFFDT = A.EFFDT))", &recSavings.EMPLID.Value, %Date, &numEmplRcd); &oRuSavingsPlansCi.EMPLID = &recSavings.EMPLID.Value; &oRuSavingsPlansCi.EMPL_RCD = &numEmplRcd; &dEffdt = &recSavings.DATE1.Value; If &oRuSavingsPlansCi.Get() Then &strPlanType = "4Z"; &oBenefitParticCollection = &oRuSavingsPlansCi.BENEFIT_PARTIC; &oBenefitPartic = &oBenefitParticCollection.ItemByKeys(&strPlanType); If &oBenefitPartic <> Null Then
Else
&oBenefitPartic = &oBenefitParticCollection.Item(1);
If All(&oBenefitPartic.PLAN_TYPE) Then
&oBenefitPartic = &oBenefitParticCollection.InsertItem(1);
End-If;
&oBenefitPartic.PLAN_TYPE = &strPlanType;
End-If;
&oSavingsPlanCollection = &oBenefitPartic.SAVINGS_PLAN;
&oSavingsPlan = &oSavingsPlanCollection.ItemByKeys(&dEffdt);
If &oSavingsPlan = Null Then
&oSavingsPlan = &oSavingsPlanCollection.Item(1);
If All(&oSavingsPlan.EFFDT_0) Then
&oSavingsPlan = &oSavingsPlanCollection.InsertItem(1);
End-If;
&oSavingsPlan.COVERAGE_BEGIN_DT = &dEffdt;
&oSavingsPlan.EFFDT = &dEffdt;
&oSavingsPlan.EFFDT_0 = &dEffdt;
&oSavingsPlan.COVERAGE_ELECT = &recSavings.COVERAGE_ELECT.Value;
If &recSavings.COVERAGE_ELECT.Value = "E" Then
&oSavingsPlan.COVERAGE_BEGIN_DT = &dEffdt;
&oSavingsPlan.EFFDT = &dEffdt;
&oSavingsPlan.EFFDT_0 = &dEffdt;
&oSavingsPlan.COVERAGE_ELECT = &recSavings.COVERAGE_ELECT.Value;
&oSavingsPlan.COVERAGE_ELECT_DT = &dEffdt;
&oSavingsPlan.BENEFIT_PLAN = &recSavings.BENEFIT_PLAN.Value;
If &recSavings.SAVINGS_COVRG.Value = "1" Then
&oSavingsPlan.SAVINGS_COVRG = "1";
&oSavingsPlan.FLAT_DED_AMT = &recSavings.FLAT_DED_AMT.Value;
&oSavingsPlan.PCT_GROSS = 0;
End-If;
If &recSavings.SAVINGS_COVRG.Value = "2" Then
&oSavingsPlan.SAVINGS_COVRG = "2";
&oSavingsPlan.PCT_GROSS = &recSavings.PCT_GROSS.Value;
&oSavingsPlan.FLAT_DED_AMT = 0;
End-If;
End-If;
If Not &oRuSavingsPlansCi.Save() Then
errorHandler();
&numErrorCount = &numErrorCount + 1;
Else
errorHandlerSuccess();
&numSuccessCount = &numSuccessCount + 1;
End-If;
Else
End-If;
Else
&OBJ_LoadFile.writeline(" Error:- CI Get failed");
errorHandler();
End-If;
CommitWork();
&oRuSavingsPlansCi.Cancel();
End-For;
SQLExec("SELECT COUNT(DISTINCT EMPLID) FROM PS_KZL_SAVING_STG", &nbrDistinctEmplid);
&OBJ_LoadFile.writeline(" ");
&OBJ_LoadFile.writeline(" ");
&OBJ_LoadFile.writeline(" ");
&OBJ_LoadFile.writeline(" Total Number of Employee Processed:- " | &nbrDistinctEmplid);
&OBJ_LoadFile.writeline(" Total Number of Rows Processed:- " | &numTotCount);
&OBJ_LoadFile.writeline(" Total Number of Rows In Error:- " | Round(&numErrorCount, 0));
&OBJ_LoadFile.writeline(" Total Number of Rows Successfully uploaded:- " | Round(&numSuccessCount, 0));



Share/Bookmark


Send mail using peoplecode.

Alternative to SendMail Function : PT_MCF_MAIL

You can use Application package PT_MCF_MAIL (PeopleTools 8.46 or higher only) to generate emails instead of using SendMail peoplecode function.
Go to the PeopleBooks to get the complete description.
Home > PeopleBooks > Enterprise PeopleTools 8.48 PeopleBook: PeopleCode API Reference > Mail Classes
Go to Mail Classed Example section to see How to use these classes. Following examples are provided.
Creating Text Email
Creating Email and Overriding SMTP Settings
Creating HTML Email
Creating Multi-Part Email With Both Text and HTML Parts
Creating HTML Email with Images
Creating Email with Attachments
Creating Email Attachments Specifying a URL
Creating Multiple Emails
Authenticating Email While Sending
Advantages
Structured Code
Can generate HTML Email
Can override Default SMTP Parameters
Better Error Handling
Send emails return receipt request (email reception notification)
Ability to set Message priority
&RQST = CreateProcessRequest();
&RQST.ProcessType = "Application Engine";
&RQST.ProcessName = "KZL_BENLEAVE";
&RQST.RunControlID = &run_control_id;
&RQST.RunLocation = "Server";
&RQST.Schedule();
Function ImportSegment(&RS2 As Rowset)
Local string &RecordName;
Local Record &REC2;
Local SQL &SQL1;
Local integer &I;
&SQL1 = CreateSQL("%Insert(:1)");
&RecordName = "RECORD." | &RS2.DBRecordName;
&REC2 = CreateRecord(@(&RecordName));
For &I = 1 To &RS2.ActiveRowCount
&RS2(&I).GetRecord(1).CopyFieldsTo(&REC2);
&SQL1.Execute(&REC2);
End-For;
End-Function;

rem *****************************************************************;
rem * PeopleCode to Import Data *;
rem *****************************************************************;
Local File &FILE1;
Local Record &REC1;
Local SQL &SQL1;
Local Rowset &RS1, &RS2;
Local integer &M;
Local string &FileLayoutName, &RecName, &FileName;

&I = 1;
While &I <= 6 Evaluate &I When 1 &FileLayoutName = "FileLayout.KZL_HEALTH_BEN"; &RecName = "RECORD.KZL_HEALTH_BEN"; &FileName = "Health_Benefits"; Break; When 2 &FileLayoutName = "FileLayout.KZL_LIFE_ADD_BN"; &RecName = "RECORD.KZL_LIFE_ADD_BN"; &FileName = "Life_Add_Ben"; Break; When 3 &FileLayoutName = "FileLayout.KZL_PENSION_PLN"; &RecName = "RECORD.KZL_PENSION_PLN"; &FileName = "Pension_Plan"; Break; When 4 &FileLayoutName = "FileLayout.KZL_SAVINGS_PLN"; &RecName = "RECORD.KZL_SAVINGS_PLN"; &FileName = "Savings_Plan"; Break; When 5 &FileLayoutName = "FileLayout.KZL_VACATION_BN"; &RecName = "RECORD.KZL_VACATION_BN"; &FileName = "Vacation_Ben"; Break; When 6 &FileLayoutName = "FileLayout.KZL_DISABLTY_BN"; &RecName = "RECORD.KZL_DISABLTY_BN"; &FileName = "Disability_Ben"; Break; When-Other Break; End-Evaluate; &FilePath = GetURL(URL.KZL_BASE_PATH); &FilePath_Benefits = &FilePath | "BENEFITS\"; &FILE1 = GetFile(&FilePath_Benefits | &FileName | ".csv", "r", %FilePath_Absolute); &LOGFILE = GetFile(&FilePath_Benefits | &FileName | ".err", "W", %FilePath_Absolute); &FILE1.SetFileLayout(@(&FileLayoutName)); &LOGFILE.SetFileLayout(@(&FileLayoutName)); &RS1 = &FILE1.CreateRowset(); &RS = CreateRowset(@(&RecName)); &SQL1 = CreateSQL("%Insert(:1)"); &RS1 = &FILE1.ReadRowset(); While &RS1 <> Null;
ImportSegment(&RS1);
&RS1 = &FILE1.ReadRowset();
End-While;

&FILE1.Close();
&LOGFILE.Close();
&I = &I + 1
End-While;