fl

Published on May 2016 | Categories: Documents | Downloads: 84 | Comments: 0 | Views: 1294
of 46
Download PDF   Embed   Report

Comments

Content

I started working with file layouts. I did a file layout with records at 0,1,2,3 levels. here it goes Records have parent-child relationship between them Local File &FL1; Local Record &REC, &REC1, &REC2, &REC3; Local SQL &SQL, &SQL1, &SQL2, &SQL3; &FL1 = GetFile("c:\temp\test25.txt", "A", %FilePath_Absolute); If &FL1.IsOpen Then &FL1.SetFileLayout(FileLayout.SH_FL3); &REC = CreateRecord(Record.SDEPT_TBL); &REC1 = CreateRecord(Record.SEMPL_TBL); &REC2 = CreateRecord(Record.SDEPEN_TBL); &REC3 = CreateRecord(Record.SEDU_TBL); &SQL = CreateSQL("%SELECTALL(:1)", &REC); &SQL1 = CreateSQL("%SELECTALL(:1)", &REC1); &SQL2 = CreateSQL("%SELECTALL(:1)", &REC2); &SQL3 = CreateSQL("%SELECTALL(:1)", &REC3); While &SQL.Fetch(&REC) &FL1.WriteRecord(&REC); End-While; While &SQL1.Fetch(&REC1) &FL1.WriteRecord(&REC1); End-While; While &SQL2.Fetch(&REC2) &FL1.WriteRecord(&REC2); End-While; While &SQL3.Fetch(&REC3) &FL1.WriteRecord(&REC3); End-While; End-If; &FL1.Close();

I would like to know whether the above code is a right approach to perform outbound. If possible can anyone help me with implementing the same using rowsets.
Join this group

Popular White Paper On This Topic



Databases and ERP Selection: Oracle vs. SQL Server

4 Replies
0

ps_fresher replied Jan 1, 0001

I was curious because in Peoplebooks most of the programs use rowsets to perform these operations and O thought it might be the appropriate to use rowsets only. Vivek, can you post that code which uses the WriteRowset(). It would be useful for everyone.
0

Vivek Semwal replied Jan 1, 0001

HI, Please find the below code for writing rows in file using filelayout. Local File &FIL_ABSCON_File; Local Rowset &out_rowset, &HdgHeader_Rowset, &RECROWSET; &FIL_ABSCON_File = GetFile(&filename, "W", %FilePath_Absolute); If &FIL_ABSCON_File.IsOpen Then /*use file layout for header text*/ If &FIL_ABSCON_File.SetFileLayout(FileLayout.ICI_A BSCON_HDR) Then; &HdgHeader_Rowset = &FIL_ABSCON_File.CreateRowset(); &HdgHeader_Record = &HdgHeader_Rowset.GetRow(1).GetRecord(Record.IC I_ABSCON_MNGR); &FIL_ABSCON_File.WriteRecord(&HdgHeader_Rec ord);

End-If; If &FIL_ABSCON_File.SetFileLayout(FileLayout.ICI_A BSCON_DAT_FL) Then &out_rowset = &FIL_ABSCON_File.CreateRowset(); &num_read = &out_rowset.Fill(); If &num_read > 0 Then &FIL_ABSCON_File.WriteRowset(&out_rowset, True); End-If Else Warning MsgGetText(0, 0, "", "SetFile layout failed", ""); End-If; &FIL_ABSCON_File.Close(); End-If;
0

Vivek Semwal replied Nov 17, 2011

Hi, Can you please elaborate what actually you want because I had already done something similar where I had write record values in a file using WriteRowset() method.

22222222222222222222222222222222

&file = GetFile(&strFilePath, "W", %FilePath_Relative); &file.SetFileLayout(MY_FILE_LAYOUT); &myRs = &file.CreateRowset(); This will instantiate the object. You can then &recPerson = CreateRecord(Record.PERSON); &recPersonal = CreateRecord(Record.PERSONAL_DATA); /* Loop through PERSON rec */ While &sql.Fetch(&recPerson)

&recPersonal.GetField(Field.EMPLID).value = &recPerson.GetField(Field.EMPLID).value; &recPersonal.SelectByKeys(); &recPerson.CopyFieldsTo(&myRs.GetRow(1).Get Record(Record.PERSON)); /* Depending on whether Personal is a sibling */ &recPersonal.CopyFieldsTo(&MyRs.Getrow(1).G etRecord(Record.PERSONAL_DATA); /* OR if it is a child*/ &recPersonal.CopyFieldsTo(&myRS.GetRow(1).G etRowset(Scroll.PERSONAL_DATA).GetRow(1).GetRecord(Record. PERSONAL_DATA)); /* Write the rowset to the file */ &file.WriteRowset(&myRs); /* reset the rowset */ &myRS.Flush(); End-while;

3333333333333333333333333333333333333333

Multiple output files using a single File Layout

psfin asked Jul 9, 2010 | Replies (2)

Is it possible to create multiple output files using a single File Layout? The File Layout will have more than one File record - Record A, B, C and these are not parent-child tables. I have added 2 Records to the File Layout and dragged it to the AE peoplecode how to see how it looks like: &FILE1 = GetFile("", "r", "a", %FilePath_Absolute); &LOGFILE = GetFile(".err", "W", %FilePath_Absolute); &FILE1.SetFileLayout(FileLayout.SAMPLEFILELAYO UT); &LOGFILE.SetFileLayout(FileLayout.SAMPLEFILELA YOUT); &RS1 = &FILE1.CreateRowset(); &RS = CreateRowset(CreateRowset(RECORD.A),CreateRowset(R ECORD.B)); &SQL1 = CreateSQL("%Insert(:1)"); It looks like it is creating only a single rowset and single file. Thank you
Join this group

Popular White Paper On This Topic



How Mobile is Changing the Way You View Your Customers

2 Replies
0

Dan Kibler replied Jul 9, 2010

as far as I know, 1 FileLayout = 1 file; in or out.
0

Diana Nye replied Jul 13, 2010

I want to update this post because you can definitely have more than one record in a file layout and create an output file for each record in your file layout. I have done this within an Application Engine process and insert data into 3 different records. I read the data from each specific record, link it to the file layout, and write out each line of output. This may be hard to read without the formatting but hopefully it is helpful anyway. Here is a portion of my code: /*get the 3 output files */ &file_dem = GetFile(&filename1, "W", %FilePath_Absolute); &file_car = GetFile(&filename2, "W", %FilePath_Absolute); &file_dep = GetFile(&filename3, "W", %FilePath_Absolute); /*write the data */ If &file_dem.IsOpen Then If &file_dem.SetFileLayout(FileLayout.G_COBRA) Then &demo = CreateRecord(Record.G_COBRA_DEMO); &file_car.SetFileLayout(FileLayout.G_COBRA); &carrier = CreateRecord(Record.G_COBRA_CARRIER); &file_dep.SetFileLayout(FileLayout.G_COBRA); &dep = CreateRecord(Record.G_COBRA_DEP); &SQL1 = CreateSQL("%Selectall(:1) ORDER BY 1", &demo); While &SQL1.Fetch(&demo) &SQL2 = CreateSQL("%Selectall(:1) WHERE G_INSURED_SSN = :2", &carrier, &demo.G_INSURED_SSN.Value); While &SQL2.Fetch(&carrier) &file_car.WriteRecord(&carrier); &car_cnt = &car_cnt 1; End-While; &SQL3 = CreateSQL("%Selectall(:1) WHERE G_INSURED_SSN = :2", &dep, &demo.G_INSURED_SSN.Value); While &SQL3.Fetch(&dep)

&file_dep.WriteRecord(&dep); &dep_cnt = &dep_cnt 1; End-While; SQLExec("Select Max(CBR_COVRG_SET) from %Table(:1) where G_INSURED_SSN = :2", &carrier, &demo.G_INSURED_SSN.Value, &max_level); &demo.CBR_COVRG_SET.Value = &max_level; &file_dem.WriteRecord(&demo); G_COBRA_AET.RECORD_COUNT.Value = G_COBRA_AET.RECORD_COUNT.Value 1; /* track #employees processed */ End-While; end-if; end-if;

44444444444444444444444444444444444444444444444

Hi, I only know Inbound get generated automatically while dragging code I have added one function for outbound in the same inbound code Function EditRecord(&REC As Record) Returns boolean; Local integer &E; REM &REC.ExecuteEdits(?it_Required ?it_DateRange ?it_YesNo ?it_TranslateTable ?it_PromptTable ?it_OneZero); &REC.ExecuteEdits(?it_Required ?it_DateRange ?it_YesNo ?it_OneZero); If &REC.IsEditError Then For &E = 1 To &REC.FieldCount &MYFIELD = &REC.GetField(&E); If &MYFIELD.EditError Then &MSGNUM = &MYFIELD.MessageNumber; &MSGSET = &MYFIELD.MessageSetNumber; &LOGFILE.WriteLine("****Record:" | &REC.Name | ", Field:" | &MYFIELD.Name); &LOGFILE.WriteLine("****" | MsgGet(&MSGSET, &MSGNUM, "")); End-If;

End-For; Return False; Else Return True; End-If; End-Function; Function writerowset() Local File &file2; Local Rowset &rs3; &fill = "where 1=1"; &file2 = GetFile("C:/temp/file2.txt", "W", "a", %FilePath_Absolute); &file2.SetFileLayout(FileLayout.ICI_IN_OUT_BOUN D); &rs3 = &file2.CreateRowset(); &nb = &rs3.Fill(&fill); If &nb > 0 Then; &file2.WriteRowset(&rs3, True); End-If; &file2.Close(); End-Function; Function ImportSegment(&RS2 As Rowset, &RSParent As Rowset) Local Rowset &RS1, &RSP; Local string &RecordName; Local Record &REC2, &RECP; Local SQL &SQL1; Local integer &I, &L; &SQL1 = CreateSQL("%Insert(:1)"); &RecordName = "RECORD." | &RS2.DBRecordName; &REC2 = CreateRecord(@(&RecordName)); &RECP = &RSParent(1).GetRecord(@(&RecordName)); For &I = 1 To &RS2.ActiveRowCount &RS2(&I).GetRecord(1).CopyFieldsTo(&REC 2);

If (EditRecord(&REC2)) Then &SQL1.Execute(&REC2); &RS2(&I).GetRecord(1).CopyFieldsTo(&REC P); For &L = 1 To &RS2.GetRow(&I).ChildCount &RS1 = &RS2.GetRow(&I).GetRowset(&L); If (&RS1 <> Null) Then &RSP = &RSParent.GetRow(1).GetRowset(&L); ImportSegment(&RS1, &RSP); End-If; End-For; If &RSParent.ActiveRowCount > 0 Then &RSParent.DeleteRow(1); End-If; Else &LOGFILE.WriteRowset(&RS); &LOGFILE.WriteLine("****Correct error in this record and delete all error messages"); &LOGFILE.WriteRecord(&REC2); For &L = 1 To &RS2.GetRow(&I).ChildCount &RS1 = &RS2.GetRow(&I).GetRowset(&L); If (&RS1 <> Null) Then &LOGFILE.WriteRowset(&RS1); End-If; End-For; End-If; End-For; End-Function; rem *****************************************************************; rem * PeopleCode to Import Data *; rem *****************************************************************; Local File &FILE1; Local File &filecsv; Local Record &REC1; Local SQL &SQL1; Local Rowset &RS1, &RS2; Local integer &M;

rem &filecsv="C:\file.csv"; &FILE1 = GetFile("C:/temp/file.csv", "r", "a", %FilePath_Absolute); &LOGFILE = GetFile("C:/temp/err.txt", "W", %FilePath_Absolute); &FILE1.SetFileLayout(FileLayout.ICI_IN_OUT_BOUN D); &LOGFILE.SetFileLayout(FileLayout.ICI_IN_OUT_BO UND); &RS1 = &FILE1.CreateRowset(); &RS = CreateRowset(Record.ICI_IN_OUTBOUND); &SQL1 = CreateSQL("%Insert(:1)"); &RS1 = &FILE1.ReadRowset(); While &RS1 <> Null; ImportSegment(&RS1, &RS); &RS1 = &FILE1.ReadRowset(); End-While;

&FILE1.Close(); &LOGFILE.Close(); writerowset();

White Papers and Webcasts
Popular

   

The Future of Database and Data Warehousing Software Related State, local, and provincial governments target ... IT Management - Enterprise WLAN Solutions Comparison Guide The Top 7 Considerations for Your Wireless Network More White Papers 0

Vivek Semwal replied Aug 6

We have to write manual code for outbound,In the same inbound code i have one function ( writerowset() ) for outbound please check Function EditRecord(&REC As Record) Returns boolean; Local integer &E; REM &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + %Edit_YesNo + %Edit_TranslateTable + %Edit_PromptTable + %Edit_OneZero); &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + %Edit_YesNo + %Edit_OneZero); If &REC.IsEditError Then For &E = 1 To &REC.FieldCount &MYFIELD = &REC.GetField(&E); If &MYFIELD.EditError Then &MSGNUM = &MYFIELD.MessageNumber; &MSGSET = &MYFIELD.MessageSetNumber; &LOGFILE.WriteLine("****Record:" | &REC.Name | ", Field:" | &MYFIELD.Name); &LOGFILE.WriteLine("****" | MsgGet(&MSGSET, &MSGNUM, "")); End-If; End-For; Return False; Else Return True; End-If; End-Function; Function writerowset() Local File &file2; Local Rowset &rs3; &fill = "where 1=1"; &file2 = GetFile("C:/temp/file2.txt", "W", "a", %FilePath_Absolute); &file2.SetFileLayout(FileLayout.ICI_IN_OUT_BOUN D); &rs3 = &file2.CreateRowset(); &nb = &rs3.Fill(&fill);

If &nb > 0 Then; &file2.WriteRowset(&rs3, True); End-If; &file2.Close(); End-Function; Function ImportSegment(&RS2 As Rowset, &RSParent As Rowset) Local Rowset &RS1, &RSP; Local string &RecordName; Local Record &REC2, &RECP; Local SQL &SQL1; Local integer &I, &L; &SQL1 = CreateSQL("%Insert(:1)"); &RecordName = "RECORD." | &RS2.DBRecordName; &REC2 = CreateRecord(@(&RecordName)); &RECP = &RSParent(1).GetRecord(@(&RecordName)); For &I = 1 To &RS2.ActiveRowCount &RS2(&I).GetRecord(1).CopyFieldsTo(&REC 2); If (EditRecord(&REC2)) Then &SQL1.Execute(&REC2); &RS2(&I).GetRecord(1).CopyFieldsTo(&REC P); For &L = 1 To &RS2.GetRow(&I).ChildCount &RS1 = &RS2.GetRow(&I).GetRowset(&L); If (&RS1 <> Null) Then &RSP = &RSParent.GetRow(1).GetRowset(&L); ImportSegment(&RS1, &RSP); End-If; End-For; If &RSParent.ActiveRowCount > 0 Then &RSParent.DeleteRow(1); End-If; Else &LOGFILE.WriteRowset(&RS); &LOGFILE.WriteLine("****Correct error in this record and delete all error messages");

&LOGFILE.WriteRecord(&REC2); For &L = 1 To &RS2.GetRow(&I).ChildCount &RS1 = &RS2.GetRow(&I).GetRowset(&L); If (&RS1 <> Null) Then &LOGFILE.WriteRowset(&RS1); End-If; End-For; End-If; End-For; End-Function; rem *****************************************************************; rem * PeopleCode to Import Data *; rem *****************************************************************; Local File &FILE1; Local File &filecsv; Local Record &REC1; Local SQL &SQL1; Local Rowset &RS1, &RS2; Local integer &M; rem &filecsv="C:\file.csv"; &FILE1 = GetFile("C:/temp/file.csv", "r", "a", %FilePath_Absolute); &LOGFILE = GetFile("C:/temp/err.txt", "W", %FilePath_Absolute); &FILE1.SetFileLayout(FileLayout.ICI_IN_OUT_BOUN D); &LOGFILE.SetFileLayout(FileLayout.ICI_IN_OUT_BO UND); &RS1 = &FILE1.CreateRowset(); &RS = CreateRowset(Record.ICI_IN_OUTBOUND); &SQL1 = CreateSQL("%Insert(:1)"); &RS1 = &FILE1.ReadRowset(); While &RS1 <> Null; ImportSegment(&RS1, &RS); &RS1 = &FILE1.ReadRowset();

End-While;

&FILE1.Close(); &LOGFILE.Close(); writerowset();

Component Interface Code

Modify PeopleCode using drag-and-drop from Component Interface into App Engine

Mick Fisher asked Feb 14 | Replies (9)

Using Tools 8.50/HR 9.1 Greetings, I'm at the last part of creating a new row using Application Engine via Component Interface. I picked a very simple Component (SCHOOL_TABLE), > created the CI > created a csv file with one row to be inserted > created the Application Engine along with a PeopleCode Action > dragged the CI into the PeopleCode Action

This is where I'm stuck. Apparently I need to modify this PCode to do the insert, but I don't know how. Please help. Here's the auto-generated code: Thank you...Mick /* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '  ' OR default values with references to PeopleCode variables and/or a Rec.Fields. */

Local File &fileLog; Local ApiObject &oSession, &oMickSchool; 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; try

rem ***** Set the Log File *****; &fileLog = GetFile("C:\Temp\MICK_SCHOOL.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); 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 *****; &oMickSchool = &oSession.GetCompIntfc(CompIntfc.MICK_SCHOOL); If &oMickSchool = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If; rem ***** Set the Component Interface Mode *****; &oMickSchool.InteractiveMode = False; &oMickSchool.GetHistoryItems = True; &oMickSchool.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; &oMickSchool.COUNTRY =  ; &oMickSchool.SCHOOL_CODE =  ; rem ***** Execute Get *****; If Not &oMickSchool.Get() Then rem ***** No rows exist for the specified keys.*****;

errorHandler(); throw CreateException(0, 0, "Get failed"); End-If; rem ***** Execute Create ******; rem If Not &oMickSchool.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; rem errorHandler(); rem throw CreateException(0, 0, "Create failed"); rem End-If;

rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; &fileLog.WriteLine("&oMickSchool.COUNT RY = " | &oMickSchool.COUNTRY); rem &oMickSchool.COUNTRY =  ; &fileLog.WriteLine("&oMickSchool.SCHOO L_CODE = " | &oMickSchool.SCHOOL_CODE); rem &oMickSchool.SCHOOL_CODE =  ; &fileLog.WriteLine("&oMickSchool.DESCR = " | &oMickSchool.DESCR); rem &oMickSchool.DESCR =  ; &fileLog.WriteLine("&oMickSchool.STATE = " | &oMickSchool.STATE); rem &oMickSchool.STATE =  ; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; rem If Not &oMickSchool.Save() Then; rem errorHandler(); rem throw CreateException(0, 0, "Save failed"); rem End-If;

rem ***** Execute Cancel *****; rem If Not &oMickSchool.Cancel() Then; rem errorHandler(); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close();
Answer this question

|

Join this group

Popular White Paper On This Topic



Hidden Gems: 5 ERP Vendors You Might Not Have Considered

9 Replies
0

Mick Fisher replied Jan 1, 0001

Thanks Justin for all your help, But should not I have code somewhere that will access my csv? Please see my OP. Mick
0

Justin Clement replied Jan 1, 0001

This may be obvious, but I forgot to add that you should end the AE by either deleting the Staging Table or adding and updating a Processed Flag. J
0

Denise White replied Jan 1, 0001

I think that you can actually base the file layout on the school table that you are loading, and if you create a standalone rowset/row, also based on the school table, you can load the file data to that without a need for a staging table. Although I'm not such an expert on file layouts; I haven't created one from scratch, but maintained and used ones that prior developers created, and I know that we weren't using any additional tables.
1

Justin Clement replied Feb 14

Ok here goes, my comments/changes begin with REM REM everything above this point should be fine rem ***** Set Component Interface Get/Create Keys *****; &oMickSchool.COUNTRY = Your_Country_Value_from_CSV; &oMickSchool.SCHOOL_CODE = Your_School_Code_from_CSV; REM do not need this unless you think it may already exist rem ***** Execute Get *****; REM If Not &oMickSchool.Get() Then rem ***** No rows exist for the specified keys.*****; REM errorHandler(); REM throw CreateException(0, 0, "Get failed");

REM End-If; REM This you need rem ***** Execute Create ******; if Not &oMickSchool.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; ErrorHandler(); throw CreateException(0, 0, "Create failed"); End-If rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; REM do not need these as they were set above. rem &fileLog.WriteLine("&oMickSchool.COUNT RY = " | &oMickSchool.COUNTRY); rem &oMickSchool.COUNTRY = ; rem&fileLog.WriteLine("&oMickSchool.S CHOO L_CODE = " | &oMickSchool.SCHOOL_CODE); rem &oMickSchool.SCHOOL_CODE = ; REM start adding all non-key fields from the CSV for level 0 &fileLog.WriteLine("&oMickSchool.DESCR = " | &oMickSchool.DESCR); &oMickSchool.DESCR = Your_DESCR_from_CSV REM Etc REM If you have level1, level2 you do the same and would have to loop through multiples rem ***** End: Get/Set Component Interface Properties *****; REM you need this too rem ***** Execute Save *****; If Not &oMickSchool.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; REM should not need the Cancel

rem ***** Execute Cancel *****; rem If Not &oMickSchool.Cancel() Then; rem errorHandler(); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close();

And that should basically do it Justin

White Papers and Webcasts
Popular

   

2011 ERP (Enterprise Resources Planning) Comparison Guide Related Drive ERP Success The Keys to the Kingdom: Limiting Active Directory ... Databases and ERP Selection: Oracle vs. SQL Server More White Papers 0

Denise White replied Feb 14

If you are reading the data from an external file, you should also create a File Layout for it, to read it. Once you have the data read, so that you can access the values using record.field notation, in the above code: In the rem ***** Set Component Interface Get/Create Keys *****; section, assign the appropriate

record.fields to the key fields. On the Get and Create, since you are trying to add a new row, instead of modifying an existing one, you should comment out the Get and uncomment the Create. If you may eventually have records in your file that might or might not exist, you might want to combine them in a conditional so that if the Get fails, it executes the Create, instead of throwing the error, and only throw the error if both the Get and the Create fail. In the rem ***** Get/Set Level 0 Field Properties *****; section, take out the "rem" from the assignment statements, and assign the appropriate record.fields to the individual fields. For example, change rem &oMickSchool.DESCR = ; to &oMickSchool.DESCR = yourrecord.descr; I don't think you should have to populate COUNTRY and SCHOOL_CODE in this section, since you would have populated them as keys in the earlier section. Uncomment the Save and Cancel. I'm assuming you didn't remove anything, although I've usually seen the level 0 and lower levels handled as rowsets in the generated code, but maybe because there is only a level 0, with only Add or Update/Display available, it doesn't bother with that.
0

Justin Clement replied Feb 15

Sorry based on the OP I figured you already had the code to process the CSV. Like Denise said you can use File Layouts to process the CSV. I would probably place the values in a Staging Table. For example you could use a PeopleCode Step as follows: Local File &FILE1;

Local Record &your_stg_tbl, &your_FL_tbl; Local SQL &SQL1; Local Rowset &RS1, &RS2; REM you can also add in logic to open and write to a log file, but i am leaving it out. GetFile("Your_Path\Your_File","r&qu ot;,"a", %FilePath_Absolute); &FILE1.SetFileLayout(FileLayout.Your_FileLayout ); &RS1 = &FILE1.CreateRowset(); &RS2 = CreateRowset(Record.Your_Staging_Table); &SQL1 = CreateSQL("%Insert(:1)"); &RS1 = &FILE1.ReadRowset(); While &RS1 <> Null; &your_stg_tbl = &RS2(1).GetRecord(Your_Staging_Table); &your_FL_tbl = &RS1(1).GetRecord(Record.Your_FileLayout_Table) ; &your_stg_tbl.GetField(Field.COUNTRY).Value = &your_FL_tbl.GEtField(field.COUNTRY).Value; REM repeat for all fields; REM and you can set some Default values not from the CSV. &SQL1.Execute(&your_stg_tbl); &RS1 = &FILE1.ReadRowset(); End-While; &FILE1.Close(); That should just about do it for the CSV, then you can have a SQL step that loops through the staging table placing the values into your AET table, followed by the PeopleCode Step that does the CI logic. Your assignments in the CI would then look like &oMickSchool.COUNTRY = Your_AET_Rcd.COUNTRY.Value;

&oMickSchool.SCHOOL_CODE = Your_AET_Rcd.SCHOOL_CODE.Value; Etc... HTH Justin
0

Mick Fisher replied Feb 15

Thank you Justin and Denise, Whey do I need both the file AND a File Layout/Table? @Justin - why do I need a staging table when I already have the Table from the File Layout? Also, what is the purpose of "r&qu ot;," within your REM you can also add in logic to open and write to a log file, but i am leaving it out. GetFile("Your_Path\Your_File","r&am p;qu ot;,"a", %FilePath_Absolute); Statement. Thanks...Mick
0

Justin Clement replied Feb 15

Mick: >>Why do I need a staging table when I already have the Table from the File Layout? You don't necessarily need to use a Staging Table, as long your SQL that retreives the inserted rows can identify between those loaded in the current process vs. those from a previous process. If your table is custom then I guess you could just add the Processed flag to that table. I try not to customize delivered tables so sometimes staging tables work best.

>>Also, what is the purpose of "r&qu ot;," This is an Ittoolbox quirk. it was actually a quote " that got converted to "&qu ot" Justin
0

Mick Fisher replied Mar 15

For all of you who want the final for using a file into Component Interface into App Engine. /* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '  ' OR default values with references to PeopleCode variables and/or a Rec.Fields. */ Rem JCC - Added another file &CSVfile & added Record for the File Layout; Local File &fileLog, &CSVfile; Local Record &MICK_SCHOOL_DES; Local ApiObject &oSession, &oMickSchoolDescr; 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; try rem ***** Set the Log File *****; &fileLog = GetFile("C:\Temp\MICK_SCHOOL.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); Local string &Mick_Text; Local array of string &File_Column_Data; &CSVfile = GetFile("C:\Temp\School.csv", "r", %FilePath_Absolute); If &CSVfile.IsOpen Then While &CSVfile.ReadLine(&Mick_Text) rem ***** Get current PeopleSoft Session *****; &oSession = %Session; &oSession.PSMessagesMode = 3; rem ***** Get the Component Interface *****; &oMickSchoolDescr = &oSession.GetCompIntfc(CompIntfc.MICK_SCHOOL_DE SCR); If &oMickSchoolDescr = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If;

rem ***** Set the Component Interface Mode *****; &oMickSchoolDescr.InteractiveMode = True;

&oMickSchoolDescr.GetHistoryItems = False; &oMickSchoolDescr.EditHistoryItems = False; &fileLog.WriteLine("First Line = " | &Mick_Text); &File_Column_Data = Split(&Mick_Text, ","); &fileLog.WriteLine("First Column = " | &File_Column_Data [1]); &fileLog.WriteLine("Second Column = " | &File_Column_Data [2]); &fileLog.WriteLine("Third Column = " | &File_Column_Data [3]); &fileLog.WriteLine("Fourth Column = " | &File_Column_Data [4]); &oMickSchoolDescr.COUNTRY = &File_Column_Data [1]; &oMickSchoolDescr.SCHOOL_CODE = &File_Column_Data [2]; &oMickSchoolDescr.DESCR = &File_Column_Data [3]; &oMickSchoolDescr.STATE = &File_Column_Data [4]; rem ***** Execute Create ******; If Not &oMickSchoolDescr.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; rem ***** Execute Save *****; If Not &oMickSchoolDescr.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; End-While; End-If;

catch Exception &ex rem Handle the exception;

&fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close();

222222222222222222222222222222222222222222

Hi all, I am trying to call CI through app engine. I imported data from file to records in Db using file layout. but when I am populating the main tables through CI, I am not able to populate them properly.

Here is the code : /* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '  ' OR default values with references to PeopleCode variables and/or a Rec.Fields. */

Local File &fileLog; Local ApiObject &oSession, &oTest22; Local ApiObject &oCerMainTbl1Collection, &oCerMainTbl1; Local ApiObject &oCerMainTbl2Collection, &oCerMainTbl2; Local ApiObject &oCerMainTbl3Collection, &oCerMainTbl3; Local integer &count; 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; &SQLTEST = "SELECT A.EMPLID,A.ENAME,A.AGE,B.DEPTID,B.DEPARTMENT,C.S_D EPENID,C.S_DNAME,D.CLASSID,D.STATE FROM PS_CER_TBL A,PS_CER_TBL1 B,PS_CER_TBL2 C,PS_CER_TBL3 D WHERE A.EMPLID=B.EMPLID "; &SQLTEST1 = CreateSQL(&SQLTEST); While &SQLTEST1.Fetch(&EMP, &NAM, &AGE, &DEPT, &DPT, &DEPEN, &DNAME, &CID, &STATE) try rem ***** Set the Log File *****; &fileLog = GetFile("C:\temp\TEST22.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); 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 *****; &oTest22 = &oSession.GetCompIntfc(CompIntfc.TEST22);

If &oTest22 = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If;

rem ***** Set the Component Interface Mode *****; &oTest22.InteractiveMode = True; &oTest22.GetHistoryItems = True; &oTest22.EditHistoryItems = True; rem ***** Set Component Interface Get/Create Keys *****; &oTest22.EMPLID = &EMP; rem ***** Execute Create ******; If Not &oTest22.Get() Then; If Not &oTest22.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; End-If;

rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; &fileLog.WriteLine("&oTest22.EMPLID = " | &oTest22.EMPLID); &oTest22.EMPLID = &EMP; &fileLog.WriteLine("&oTest22.ENAME = " | &oTest22.ENAME); &oTest22.ENAME = &NAM; &fileLog.WriteLine("&oTest22.AGE = " | &oTest22.AGE); &oTest22.AGE = &AGE; rem ***** Set/Get CER_MAIN_TBL1 Collection Field Properties -- Parent: PS_ROOT Collection *****; &oCerMainTbl1Collection = &oTest22.CER_MAIN_TBL1;

Local integer &m; For &m = 1 To &oCerMainTbl1Collection.Count; If &oCerMainTbl1Collection.Count = 1 Then &oCerMainTbl1 = &oCerMainTbl1Collection.Item(&m); Else &oCerMainTbl1 = &oCerMainTbl1Collection.InsertItem(&m); End-If; &fileLog.WriteLine("&oCerMainTbl1.DEPT ID = " | &oCerMainTbl1.DEPTID); &oCerMainTbl1.DEPTID = &DEPT; &fileLog.WriteLine("&oCerMainTbl1.DEPA RTMENT = " | &oCerMainTbl1.DEPARTMENT); &oCerMainTbl1.DEPARTMENT = &DPT; rem ***** Set CER_MAIN_TBL2 Collection Field Properties -- Parent: CER_MAIN_TBL1 Collection *****; &oCerMainTbl2Collection = &oCerMainTbl1.CER_MAIN_TBL2; Local integer &j; For &j = 1 To &oCerMainTbl2Collection.Count; If &oCerMainTbl2Collection.Count = 1 Then &oCerMainTbl2 = &oCerMainTbl2Collection.Item(&j); Else &oCerMainTbl2 = &oCerMainTbl2Collection.InsertItem(&j); End-If; &fileLog.WriteLine("&oCerMainTbl2.S_DE PENID = " | &oCerMainTbl2.S_DEPENID); &oCerMainTbl2.S_DEPENID = &DEPEN; &fileLog.WriteLine("&oCerMainTbl2.S_DN AME = " | &oCerMainTbl2.S_DNAME); &oCerMainTbl2.S_DNAME = &DNAME;

rem ***** Set CER_MAIN_TBL3 Collection Field Properties -- Parent: CER_MAIN_TBL2 Collection *****; &oCerMainTbl3Collection = &oCerMainTbl2.CER_MAIN_TBL3; Local integer &k; For &k = 1 To &oCerMainTbl3Collection.Count; If &oCerMainTbl3Collection.Count = 1 Then

&oCerMainTbl3 = &oCerMainTbl3Collection.Item(&k); Else &oCerMainTbl3 = &oCerMainTbl3Collection.InsertItem(&k); End-If; &fileLog.WriteLine("&oCerMainTbl3.CLAS SID = " | &oCerMainTbl3.CLASSID); &oCerMainTbl3.CLASSID = &CID; &fileLog.WriteLine("&oCerMainTbl3.STAT E = " | &oCerMainTbl3.STATE); &oCerMainTbl3.STATE = &STATE; End-For; End-For; End-For; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; If Not &oTest22.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; rem ***** Execute Cancel *****; If Not &oTest22.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; &fileLog.WriteLine("End"); &fileLog.Close();

input (1,2,3,4 are file id from file layout) 1,101,NAME1,23 1,102,NAME2,24 2,101,12,HTML 2,101,13,ORA 2,101,14,JAVA 2,102,15,C 3,101,13,007,DEP_NAME2 3,101,14,008,DEP_NAME3 4,101,13,007,23,C1

output 1,101,NAME1,23 1,102,NAME2,24 2,101,14,JAVA 2,102,15,C 3,101,14,008,DEP_NAME3 3,102,15,008,DEP_NAME3 4,101,14,008,23,C1 4,102,15,008,23,C1
Join this group

Popular White Paper On This Topic



Antivirus Comparison Guide

4 Replies
0

mclove replied Jan 1, 0001

My recommendation would be to separate the data processing from the CI. In the App Engine load a work record with the required fields and pass the work record to a function that contains the CI. This way you could a) reuse the CI and b) separate testing / debugging the dataset versus the CI processing. In either case you should run the PeopleCode debugger on your app engine to verify the dataset is processing the way you think. You’ll probably find the CI is not working on the data that you expect it to be working.
0

vara d replied Dec 19, 2011

In your SQLTEXT , mentioned 4 table , but you have only join between A and B , Can you recheck with the code. Regards PSOFTHUB
0

ps_fresher replied Dec 23, 2011

I am still getting errors even if I mention 4 tables in the join. Local File &fileLog; Local ApiObject &oSession, &oTest22; Local ApiObject &oCerMainTbl1Collection, &oCerMainTbl1; Local ApiObject &oCerMainTbl2Collection, &oCerMainTbl2; Local ApiObject &oCerMainTbl3Collection, &oCerMainTbl3; 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; &SQLTEST = "SELECT A.EMPLID,A.ENAME,A.AGE,B.DEPTID,B.DEPARTMENT,C.S_D EPENID,C.S_DNAME,D.CLASSID,D.STATE FROM PS_CER_TBL A,PS_CER_TBL1 B,PS_CER_TBL2 C,PS_CER_TBL3 D WHERE B.EMPLID=A.EMPLID AND B.EMPLID=C.EMPLID AND C.DEPTID = B.DEPTID AND D.EMPLID=C.EMPLID AND D.DEPTID =C.DEPTID AND D.S_DEPENID =C.S_DEPENID "; &SQLTEST1 = CreateSQL(&SQLTEST); While &SQLTEST1.Fetch(&EMPLID, &ENAME, &AGE, &DEPTID, &DEPARTMENT, &S_DEPENID, &S_DNAME, &CLASSID, &STATE) Try rem ***** Set the Log File *****; &fileLog = GetFile("C:\temp\TEST22.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); 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 *****; &oTest22 = &oSession.GetCompIntfc(CompIntfc.TEST22); If &oTest22 = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If;

rem ***** Set the Component Interface Mode *****; &oTest22.InteractiveMode = False; &oTest22.GetHistoryItems = True; &oTest22.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; &oTest22.EMPLID = &EMPLID; rem ***** Execute Create ******; If Not &oTest22.Get() Then; If Not &oTest22.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; End-If;

rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; &fileLog.WriteLine("&oTest22.EMPLID = " | &oTest22.EMPLID); &oTest22.EMPLID = &EMPLID; &fileLog.WriteLine("&oTest22.ENAME = " | &oTest22.ENAME); &oTest22.ENAME = &ENAME; &fileLog.WriteLine("&oTest22.AGE = " | &oTest22.AGE); &oTest22.AGE = &AGE;

rem ***** Set/Get CER_MAIN_TBL1 Collection Field Properties -- Parent: PS_ROOT Collection *****; &oCerMainTbl1Collection = &oTest22.CER_MAIN_TBL1; Local integer &m; For &m = 1 To &oCerMainTbl1Collection.Count; If &m > 1 Then &oCerMainTbl1 = &oCerMainTbl1Collection.InsertItem(&m); Else &oCerMainTbl1 = &oCerMainTbl1Collection.InsertItem(&m); End-If; &fileLog.WriteLine("&oCerMainTbl1.DEPT ID = " | &oCerMainTbl1.DEPTID); &oCerMainTbl1.DEPTID = &DEPT; &fileLog.WriteLine("&oCerMainTbl1.DEPA RTMENT = " | &oCerMainTbl1.DEPARTMENT); &oCerMainTbl1.DEPARTMENT = &DPT; REM ***** SET CER_MAIN_TBL2 COLLECTION FIELD PROPERTIES -- PARENT: CER_MAIN_TBL1 COLLECTION *****;

&oCerMainTbl2Collection = &oTest22.CER_MAIN_TBL2; Local integer &N; For &N = 1 To &oCerMainTbl2Collection.Count; If &N > 1 Then &oCerMainTbl2 = &oCerMainTbl1Collection.InsertItem(1); Else &oCerMainTbl2 = &oCerMainTbl1Collection.Item(&m); End-If; &fileLog.WriteLine("&oCerMainTbl2.S_DE PENID = " | &oCerMainTbl2.S_DEPENID); &oCerMainTbl2.S_DEPENID = &S_DEPENID; &fileLog.WriteLine("&oCerMainTbl2.S_DN AME = " | &oCerMainTbl2.S_DNAME); &oCerMainTbl2.S_DNAME = &S_DNAME;

REM ***** SET CER_MAIN_TBL3 COLLECTION FIELD PROPERTIES -- PARENT: CER_MAIN_TBL2 COLLECTION *****;

&oCerMainTbl3Collection = &oTest22.CER_MAIN_TBL3; Local integer &P; For &P = 1 To &oCerMainTbl3Collection.Count; If &P > 1 Then &oCerMainTbl3 = &oCerMainTbl1Collection.InsertItem(1); Else &oCerMainTbl3 = &oCerMainTbl1Collection.InsertItem(&m); End-If; &fileLog.WriteLine("&oCerMainTbl3.CLAS SID = " | &oCerMainTbl3.CLASSID); &oCerMainTbl3.CLASSID = &CLASSID; &fileLog.WriteLine("&oCerMainTbl3.STAT E = " | &oCerMainTbl3.STATE); &oCerMainTbl3.STATE = &STATE;

rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; If Not &oTest22.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; rem ***** Execute Cancel *****; If Not &oTest22.Cancel() Then; errorHandler(); throw CreateException(0, 0, "Cancel failed"); End-If; End-For; REM End-While; End-For; REM End-While; End-For; catch Exception &ex rem Handle the exception;

&fileLog.WriteLine(&ex.ToString()); end-try; End-While; &fileLog.WriteLine("End"); &fileLog.Close();
0

vara d replied Dec 24, 2011

One more thing which I have observed is logic error. You have used &oCerMainTbl1Collection.Count as for loop count, when you are trying to insert the data, what is requirement of for loop there with collection? Recheck entire CI code and rewrite it.

3333333333333333333333333333333333333333333333333
I am practicing CI, here is my code: /* ===> This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '

 ' OR default values with references to PeopleCode variables and/or a Rec.Fields. */ Local File &fileLog; Local ApiObject &oSession, &oTest22; Local ApiObject &oCerMainTbl1Collection, &oCerMainTbl1; Local ApiObject &oCerMainTbl2Collection, &oCerMainTbl2; Local ApiObject &oCerMainTbl3Collection, &oCerMainTbl3; 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; &SQLTEST = "SELECT A.EMPLID,A.ENAME,A.AGE,B.DEPTID,B.DEPARTMENT,C.S_D EPENID,C.S_DNAME,D.CLASSID,D.STATE FROM PS_CER_TBL A,PS_CER_TBL1 B,PS_CER_TBL2 C,PS_CER_TBL3 D WHERE B.EMPLID=A.EMPLID AND B.EMPLID=C.EMPLID AND C.DEPTID = B.DEPTID AND D.EMPLID=C.EMPLID AND D.DEPTID =C.DEPTID AND D.S_DEPENID =C.S_DEPENID "; &SQLTEST1 = CreateSQL(&SQLTEST); While &SQLTEST1.Fetch(&EMPLID, &ENAME, &AGE, &DEPTID, &DEPARTMENT, &S_DEPENID, &S_DNAME, &CLASSID, &STATE) try rem ***** Set the Log File *****; &fileLog = GetFile("C:\temp\TEST22.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); 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 *****; &oTest22 = &oSession.GetCompIntfc(CompIntfc.TEST22); If &oTest22 = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If;

rem ***** Set the Component Interface Mode *****; &oTest22.InteractiveMode = False; &oTest22.GetHistoryItems = True; &oTest22.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; &oTest22.EMPLID = &EMPLID; rem ***** Execute Create ******; If Not &oTest22.Get() Then; If Not &oTest22.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; End-If;

rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; &fileLog.WriteLine("&oTest22.EMPLID = " | &oTest22.EMPLID); &oTest22.EMPLID = &EMPLID; &fileLog.WriteLine("&oTest22.ENAME = " | &oTest22.ENAME); &oTest22.ENAME = &ENAME; &fileLog.WriteLine("&oTest22.AGE = " | &oTest22.AGE); &oTest22.AGE = &AGE; rem ***** Set/Get CER_MAIN_TBL1 Collection Field Properties -- Parent: PS_ROOT Collection *****; &oCerMainTbl1Collection = &oTest22.CER_MAIN_TBL1; Local integer &m; For &m = 1 To &oCerMainTbl1Collection.Count; If &m > 1 Then &oCerMainTbl1 = &oCerMainTbl1Collection.InsertItem(&m); Else &oCerMainTbl1 = &oCerMainTbl1Collection.InsertItem(&m); End-If; &fileLog.WriteLine("&oCerMainTbl1.DEPT ID = " | &oCerMainTbl1.DEPTID); &oCerMainTbl1.DEPTID = &DEPT;

&fileLog.WriteLine("&oCerMainTbl1.DEPA RTMENT = " | &oCerMainTbl1.DEPARTMENT); &oCerMainTbl1.DEPARTMENT = &DPT; REM ***** SET CER_MAIN_TBL2 COLLECTION FIELD PROPERTIES -- PARENT: CER_MAIN_TBL1 COLLECTION *****;

&oCerMainTbl2Collection = &oTest22.CER_MAIN_TBL2; Local integer &N; For &N = 1 To &oCerMainTbl2Collection.Count; If &N > 1 Then &oCerMainTbl2 = &oCerMainTbl1Collection.InsertItem(1); Else &oCerMainTbl2 = &oCerMainTbl1Collection.Item(&m); End-If; &fileLog.WriteLine("&oCerMainTbl2.S_DE PENID = " | &oCerMainTbl2.S_DEPENID); &oCerMainTbl2.S_DEPENID = &S_DEPENID; &fileLog.WriteLine("&oCerMainTbl2.S_DN AME = " | &oCerMainTbl2.S_DNAME); &oCerMainTbl2.S_DNAME = &S_DNAME;

REM ***** SET CER_MAIN_TBL3 COLLECTION FIELD PROPERTIES -- PARENT: CER_MAIN_TBL2 COLLECTION *****;

&oCerMainTbl3Collection = &oTest22.CER_MAIN_TBL3; Local integer &P; For &P = 1 To &oCerMainTbl3Collection.Count; If &P > 1 Then &oCerMainTbl3 = &oCerMainTbl1Collection.InsertItem(1); Else &oCerMainTbl3 = &oCerMainTbl1Collection.InsertItem(&m); End-If; &fileLog.WriteLine("&oCerMainTbl3.CLAS SID = " | &oCerMainTbl3.CLASSID); &oCerMainTbl3.CLASSID = &CLASSID; &fileLog.WriteLine("&oCerMainTbl3.STAT E = " | &oCerMainTbl3.STATE); &oCerMainTbl3.STATE = &STATE;

rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; If Not &oTest22.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; rem ***** Execute Cancel *****; If Not &oTest22.Cancel() Then; errorHandler(); throw CreateException(0, 0, "Cancel failed"); End-If; End-For; REM End-While; End-For; REM End-While; End-For; catch Exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; End-While; &fileLog.WriteLine("End"); &fileLog.Close(); The data is being read but not getting inserted into the component (I gave full access in permission list)

444444444444444444444444444444444

hi, I am able to submit single line of data from temp table into PS database using app engine-CI. I need to submit multiple lines at once based on key fields along with key fields (only one time) into different tables. /* ===>

This is a dynamically generated PeopleCode template to be used only as a helper to the application developer. You need to replace all references to '[*]' OR default values with references to PeopleCode variables and/or a Rec.Fields. */ Local File &fileLog; Local ApiObject &oSession, &oKTimeci2Ram; Local ApiObject &oExTimeDtlCollection, &oExTimeDtl; Local ApiObject &oExTimeDtlDlyCollection, &oExTimeDtlDly; 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; rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); End-For; rem ***** Delete the Messages from the collection *****; &oPSMessageCollection.DeleteAll(); End-Function; try rem ***** Set the Log File *****; rem &fileLog = GetFile("C:\temp\K_TIMECI2_RAM.log", "w", "a", %FilePath_Absolute); rem &fileLog.WriteLine("Begin"); 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 *****; &oKTimeci2Ram = &oSession.GetCompIntfc(CompIntfc.K_TIMECI2_RAM); If &oKTimeci2Ram = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If; rem ***** Set the Component Interface Mode *****;

&oKTimeci2Ram.InteractiveMode = True; &oKTimeci2Ram.GetHistoryItems = True; &oKTimeci2Ram.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; &oKTimeci2Ram.EMPLID = K_CISTG_AET.EMPLID; &oKTimeci2Ram.PERIOD_END_DT = K_CISTG_AET.PERIOD_END_DT; &oKTimeci2Ram.TIME_SHEET_ID = "NEXT"; rem ***** Execute Get *****; rem If Not &oKTimeci2Ram.Get() Then rem ***** No rows exist for the specified keys.*****; rem errorHandler(); rem throw CreateException(0, 0, "Get failed"); rem End-If; &oKTimeci2Ram.Create(); rem ***** Execute Create ******; If Not &oKTimeci2Ram.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; Local SQL &sql1; &sql1 = CreateSQL("SELECT deptid,project_id,activity_id,date_under_rpt,time_ quantity from ps_k_cistg_ram WHERE emplid = :1 AND period_end_dt =:2", K_CISTG_AET.EMPLID, K_CISTG_AET.PERIOD_END_DT, &deptid, &project_id, &activity_id, &date_under_rpt, &time_quantity); While &sql1.Fetch(&deptid, &project_id, &activity_id, &date_under_rpt, &time_quantity) rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; rem &fileLog.WriteLine("&oKTimeci2Ram.DEPTID = " | &oKTimeci2Ram.DEPTID); &oKTimeci2Ram.DEPTID = &deptid; rem ***** Set/Get EX_TIME_DTL Collection Field Properties -- Parent: PS_ROOT Collection *****; &oExTimeDtlCollection = &oKTimeci2Ram.EX_TIME_DTL; Local integer &i111; For &i111 = 1 To &oExTimeDtlCollection.Count; &oExTimeDtl = &oExTimeDtlCollection.insertItem(&i111); &oExTimeDtl.PROJECT_ID = &project_id; &oExTimeDtl.ACTIVITY_ID = &activity_id; rem ***** Set EX_TIME_DTL_DLY Collection Field Properties -- Parent: EX_TIME_DTL Collection *****; &oExTimeDtlDlyCollection = &oExTimeDtl.EX_TIME_DTL_DLY; Local integer &i214; For &i214 = 1 To &oExTimeDtlDlyCollection.Count; &oExTimeDtlDly = &oExTimeDtlDlyCollection.insertItem(&i214); rem &fileLog.WriteLine("&oExTimeDtlDly.DATE_UNDER_RPT = " | &oExTimeDtlDly.DATE_UNDER_RPT); &oExTimeDtlDly.DATE_UNDER_RPT = &date_under_rpt;

rem &fileLog.WriteLine("&oExTimeDtlDly.TIME_QUANTITY = " | &oExTimeDtlDly.TIME_QUANTITY); &oExTimeDtlDly.TIME_QUANTITY = &time_quantity; End-For; End-For; End-While; rem ***** End: Get/Set Component Interface Properties *****; &oKTimeci2Ram.Save(); rem ***** Execute Save *****; If Not &oKTimeci2Ram.Save() Then; errorHandler(); throw CreateException(0, 0, "Save failed"); End-If; rem ***** Execute Cancel *****; rem If Not &oKTimeci2Ram.Cancel() Then; rem errorHandler(); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch Exception &ex rem Handle the exception; rem &fileLog.WriteLine(&ex.ToString()); end-try; rem &fileLog.WriteLine("End"); rem &fileLog.Close(); this is the code i have. but am getting error like "ErrorReturn-> 270 - Class Row method GetRowset scroll is invalid. (2,270) TE_TIME_ENTRY2.GBL.PostBuild PCPC:1035 Statement:13" and "Error loading Component Processor {K_TIMECI2_RAM} " .here K_TIMECI2_RAM is my Component interface name. If any one knows the error, please message me,

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close