Working with flat files in peoplesoft
1) Using Filelayout
2) Using Array
Using Array:
Declare Function ClearData PeopleCode N_SR_RUNCNTL.N_SELECTION_TYPE FieldFormula;
Declare Function add_attachment PeopleCode N_SR_ATTACH_WRK.ATTACHADD FieldChange;
Declare Function display_attachment_buttons PeopleCode N_SR_ATTACH_WRK.ATTACHADD RowInit;
Local number &CurRow, &RETCODE;
Local string &Guid, &URL_ID;
Local Rowset &RS1, &Rs_Std;
Local Rowset &Level1;
rem local record &RS1;
/****************************************************************/
/* Call the correct database record where your file attachment */
/* will be stored
N_MOODLE_INTFC_R2_ATTACH */
/****************************************************************/
&URL_ID = "URL.N_MOODLE_INTFC_R2_ATTACH"; /************************ */
/* In order to make sure the attachmentname is unique */
/* you can add a GUID in front of your File name */
/*************************************************************** */
&Level1 = GetLevel0()(1).GetRowset(Scroll.N_NINT09_R2_TMP);
&Level1.Flush();
add_attachment(@&URL_ID, "", &Guid, 0, True, "Record.N_NINT09_R2_RC", N_NINT09_R2_RC.ATTACHSYSFILENAME, N_NINT09_R2_RC.ATTACHUSERFILE, 2, &RETCODE);
If &RETCODE = %Attachment_Success Then
rem display_attachment_buttons("Success");
&filepath = GetCwd();
&InputfileName = N_NINT09_R2_RC.ATTACHSYSFILENAME.Value;
&M = GetAttachment(URL.N_MOODLE_INTFC_R2_ATTACH, &InputfileName, &filepath | &InputfileName);
&N_File_Input = GetFile(&filepath | &InputfileName, "r", "a", %FilePath_Absolute);
&N_File_Input.SetFileLayout(FileLayout.N_SR_NINT09_FL);
rem &RS1 = CreateRecord(RECORD.N_NINT09_R2_TMP);
&num = 0;
&RS1 = &N_File_Input.CreateRowset();
&RS1 = &N_File_Input.ReadRowset();
&RS1 = &N_File_Input.ReadRowset();
rem ClearData();
/*************************START READING FROM INPUT FILE**************************************/
While &RS1 <> Null;
/*****************************INSERT INTO TEMPORARY RECORD*********************************/
&Row = &Level1.ActiveRowCount;
&Level1.InsertRow(&Row);
rem MessageBox(0, "", 0, 0, "Row :" | &Row);
rem MessageBox(0, "", 0, 0, "Runc Cntl :" | N_NINT09_R2_RC.RUN_CNTL_ID.Value);
rem MessageBox(0, "", 0, 0, "Emplid :" | &RS1(1).GetRecord(1).EMPLID.Value);
&Level1(&Row + 1).N_NINT09_R2_TMP.OPRID.Value = %OperatorId;
&Level1(&Row + 1).N_NINT09_R2_TMP.RUN_CNTL_ID.Value = N_NINT09_R2_RC.RUN_CNTL_ID.Value;
&Level1(&Row + 1).N_NINT09_R2_TMP.EMPLID.Value = &RS1(1).GetRecord(1).EMPLID.Value;
&Level1(&Row + 1).N_NINT09_R2_TMP.STRM.Value = &RS1(1).GetRecord(1).STRM.Value;
&Level1(&Row + 1).N_NINT09_R2_TMP.CLASS_NBR.Value = &RS1(1).GetRecord(1).CLASS_NBR.Value;
&Level1(&Row + 1).N_NINT09_R2_TMP.CRSE_GRADE_INPUT.Value = &RS1(1).GetRecord(1).CRSE_GRADE_INPUT.Value;
&RS1 = &N_File_Input.ReadRowset();
End-While; /*Read Lines inside a file*/
For &I = &Level1.ActiveRowCount To 1 Step - 1
If None(&Level1.GetRow(&I).N_NINT09_R2_TMP.OPRID.Value) Then
&Level1.DeleteRow(&I);
End-If;
End-For;
&N_File_Input.Close();
Else
N_NINT09_R2_RC.ATTACHUSERFILE.Value = "";
End-If;
No comments:
Post a Comment