File Layout: © 2008 Computer Sciences Corporation
File Layout: © 2008 Computer Sciences Corporation
• Introduction
• Create file layout
• Using file layout
• File Class
12/08/21
CSC Confidential 2
Introduction
• Integration tools & Utilities:
Application Messaging
Integration Broker
Component Interface
Business Interlinks
File Layout (In Scope for Today’s class)
Merchant Integration
Message Agent
Database Agent
Application Engine (AE)
…………………….and many more
12/08/21
CSC Confidential 3
Introduction
Definition:
• A file layout is a definition that represents the data structure of a flat
(text) file to be processed.
• It identifies where in the file, data fields are located.
• It allows application developers to access data from a file as they
would a message or a panel buffer (scroll).
When To Use?
• When you need to load a flat file to a table, or when you need
to unload a table to a flat file
12/08/21
CSC Confidential 4
Introduction
Supported file formats:
• Fixed Position (FIXED): Each field has a starting position and a
length which together specify its location in the file. This is the
default format for new file layouts.
• Comma Separated Values (CSV): Fields are located in the file by
their sequence, separated from each other by commas.
• XML Tagged (XML): A field is located not by its position or
sequence within a record, but by the named XML tags
surrounding it.
12/08/21
CSC Confidential 5
Introduction
File layout structure:
• A file layout is a collection of file records, which in turn are a collection
of fields, each of which has a describable location.
If the file is a plain text file, data is read or written using text strings.
If the file is based on a File Layout, can use text strings, rowset, or
record objects, it simplifies reading, writing, and manipulating
hierarchical transaction data.
File Layout
File Record
File Field
12/08/21
CSC Confidential 6
Create file layout
12/08/21
CSC Confidential 7
Create file layout
12/08/21
CSC Confidential 8
Create file layout
12/08/21
CSC Confidential 9
Create file layout
12/08/21
CSC Confidential 10
Create file layout
12/08/21
CSC Confidential 11
Create file layout
• Adding File Fields to the File Record
Drag and drop a database field
Or
Insert a database field
Or
Insert a file field
12/08/21
CSC Confidential 12
Create file layout
File Field Properties
12/08/21
CSC Confidential 13
Create file layout
12/08/21
CSC Confidential 14
Create file layout
12/08/21
CSC Confidential 15
Create file layout
Attribute
12/08/21
CSC Confidential 16
Create file layout
Considerations for CSV Format:
• Both the qualifier and the delimiter accept a blank as a valid value.
• If a field is NULL, you don't have to use qualifiers. In the following
example, Field2 is NULL.
Field1,,Field3,Field4. . .
Attribute
12/08/21
CSC Confidential 17
Create file layout
Considerations for XML Format:
• XML input file must contain at least the fields that are specified in
the file layout definition. If any fields are missed in the file, the input
rowset won’t contain any data.
• If XML input file contains extra fields that aren’t specified in the file
layout definition, the ReadRowset method will ignore the extra
fields.
• When a record is inserted into a file layout, fields of type Long are
converted to type Character, with a length of 0. You must set a field
length greater than 0 before you can save the file layout.
12/08/21
CSC Confidential 18
Using file layout
• Clicking the Run Program button on the toolbar, the file data is
imported into the database
12/08/21
CSC Confidential 19
Using file layout
Generating AE Program
12/08/21
CSC Confidential 20
Using file layout
AE Program Import PeopleCode
12/08/21
CSC Confidential 21
Using file layout
Running Import AE Program
12/08/21
CSC Confidential 22
File Class
• File class, is one of the PeopleSoft’s OOB Class which provides
methods and properties for reading from and writing to external files.
12/08/21
CSC Confidential 23
File Class
Data type:
• File Object is an instance of the File class, file object is declared using
the File data type
Scope:
• A file object can only be instantiated from PeopleCode, that is, in
message subscription PeopleCode, Component Interface PeopleCode,
record field PeopleCode etc…
12/08/21
CSC Confidential 24
File Class
File Security:
• PeopleSoft doesn't provide security checks on access to the files, but
security can be provided by writing PeopleCode program to prevent
the user from reading or writing files that they should
12/08/21
CSC Confidential 25
File Class
File Access Interruption Recovery:
• GetPosition or SetPosition methods are used to minimize the loss of
work in the event of a system failure during file access.
• This can be handled only when the file is opened in “U” update mode.
&MYFILE.Open(&SOMENAME, "U");
If &MYFILE.IsOpen Then
while &MYFILE.ReadLine(&SOMESTRING)
/* Process the contents of each &SOMESTRING */
&LASTPOS = &MYFILE.GetPosition();
End-While;
End-If;
If &MYFILE.IsOpen Then
&MYFILE.SetPosition(&LASTPOS);
while &MYFILE.ReadLine(&SOMESTRING)
/* Process the contents of each &SOMESTRING */ End-While;
End-If;
12/08/21
CSC Confidential 26
File Class
Error Handling:
• IsEditError rowset object’s property is used to trap errors that occurs on
any field in any record of a rowset object
• IsError file object’s property is used to trap errors that are not detected
at record level
• ExecuteEdits function is used to verify that the data in the record is valid
(has the correct format, the right data type, and so on…)
ExecuteEdits([editlevels]);
editlevels: %Edit_DateRange; %Edit_OneZero;
%Edit_PromptTable; %Edit_Required;
%Edit_TranslateTable; %Edit_YesNo
12/08/21
CSC Confidential 27
File Class
Built-in Functions:
•FileExists
FileExists(filename [, pathtype])
•FindFiles
FindFiles(filespec_pattern [, pathtype])
•GetFile
GetFile(filename, mode [, charset] [, pathtype])
mode: R-Read; W-Write; A-Append; U-Update; E-Conditional
"exist" read; N- Conditional “New" write
pathtype:%FilePath_Relative; %FilePath_Absoulte
12/08/21
CSC Confidential 28
File Class
Methods:
• Close, Open, Delete
• ReadRecord, WriteRecord
• CreateRowset, ReadRowset, WriteRowset
• SetFileLayout
• GetPosition, SetPosition
• ReadLine, WriteLine
• SetFileLayout(FILELAYOUT.filelayoutname)
12/08/21
CSC Confidential 29
File Class
Properties:
• CurrentRecord
• IsError
• IsNewField
• IsOpen
• Name
• IgnoreInvalidId
12/08/21
CSC Confidential 30
File Class
12/08/21
CSC Confidential 31
File Class
12/08/21
CSC Confidential 32
File Class
12/08/21
CSC Confidential 33
File Class
12/08/21
CSC Confidential 34
File Class
12/08/21
CSC Confidential 35
File Class
12/08/21
CSC Confidential 36
12/08/21
CSC Confidential 37
12/08/21
CSC Confidential 38