0% found this document useful (0 votes)
183 views38 pages

File Layout: © 2008 Computer Sciences Corporation

Uploaded by

Anand Dhayal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views38 pages

File Layout: © 2008 Computer Sciences Corporation

Uploaded by

Anand Dhayal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 38

File Layout

© 2008 Computer Sciences Corporation


File Layouts

• 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

Create a new File Layout


File>New>File Layout

12/08/21
CSC Confidential 7
Create file layout

File Layout Properties

12/08/21
CSC Confidential 8
Create file layout

Adding File Records or Segment to the File Layout


•File records and file fields added to file layout can be of two ways:
They can be base on existing record and field definitions in the
database.
Or
They can be construct directly in file layout, without reference to
any database records or fields. A file record that’s construct this way
is added as a segment, but the result is an ordinary file record.

12/08/21
CSC Confidential 9
Create file layout

• Continuation……How to add records to file layout


 Drag and drop a database record
Or
 Insert a database record
Or
 Insert a segment
Or
 Insert a child segment

12/08/21
CSC Confidential 10
Create file layout

File Record or Segment Properties

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

File layout with one segment and two records in hierarchy

12/08/21
CSC Confidential 14
Create file layout

Previewing Input Data

12/08/21
CSC Confidential 15
Create file layout

Considerations for FIXED Format:


• When you change the length or starting position of any file fields, or
if you insert a new file field between two existing ones. It’s possible
to overlay fields. Results are unpredictable.
• 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.

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

Generating and Running the Import Program:

• Clicking the AE button on the toolbar, will generate the Application


Engine import program with associated import PeopleCode.

• 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.

• Topics covered in this session are:


 Data type
 Scope
 File security considerations
 File access interruption recovery
 File layout error processing
 File class built-in functions
 File class methods
 File class properties

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

Local File &MYFILE;

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 - It associates a specific file layout definition with the


file object executing this method, providing easy access to rowset
data.

• 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

Program flow for reading from a file:


• Declare objects
• Instantiate the objects
• Open a flat file in read mode
• Associate file layout definition with the file object
• Read the data from file
• Insert into PS tables
• Close the file

12/08/21
CSC Confidential 31
File Class

Sample PeopleCode for reading from file:

Local File &MYFILE; Local Record &REC;


Local array of string &ARRAY;
&MYFILE = GetFile("c:\temp\Case.txt", "R", %FilePath_Absolute);
&REC = CreateRecord(RECORD.RC_CASE);
&ARRAY = CreateArrayRept("", 0);
If &MYFILE.IsOpen Then
&MYFILE.SetFileLayout(FILELAYOUT.RC_CASE)
While &MYFILE.ReadLine(&STRING);
&ARRAY = Split(&STRING, ",");
For &I = 1 To &REC.FieldCount
&REC.GetField(&I).Value = &ARRAY[&I];
End-For;
&REC.Insert();
End-While;
End-If;

12/08/21
CSC Confidential 32
File Class

Program flow for writing into a file:


• Declare Objects
• Instantiate the objects
• Open a file in write mode
• Associate file layout definition with the file object
• Fetch the data from PS tables
• Write data to file
• Close the file

12/08/21
CSC Confidential 33
File Class

Sample PeopleCode for writing into file:

Local File &MYFILE;


Local Record &REC;
&MYFILE = GetFile(“Case.txt", “W");
If &MYFILE.IsOpen Then
&MYFILE.SetFileLayout(FILELAYOUT.RC_CASE)
&REC = CreateRecord(RECORD.RC_CASE);
&SQL = CreateSQL("%Selectall(:1)", &REC);
While &SQL.Fetch(&REC)
&MYFILE.WriteRecord(&REC);
End-While;
End-If;
&MYFILE.Close();

12/08/21
CSC Confidential 34
File Class

Sample Fixed format file with hierarchy records:


8113 Frumman,Wolfgang
08/06/1999 000001 8219 Going to
London office
100 000015 I 08/06/1999
200 000030 I 08/06/1999
300 000009 I 08/06/1999
09/06/1999 000004 7707 What to do
after he arrives
100 000022 I 08/06/1999
200 000008 I 08/06/1999
300 000018 I 08/06/1999
400 000019 I 08/06/1999
8101 Penrose,Steven
07/06/1999 000006 8229 New hire
1 000033 I 08/06/1999
2 000034 I 08/06/1999
3 000035 I 08/06/1999

12/08/21
CSC Confidential 35
File Class

Sample Fixed format file with segment record:


888 A
000 8553 JUR 1990-12-12 1990-12-17 5 .0 Local Jury
Duty P N
888 A
000 8553 MAT 1992-02-20 1992-10-01 224 .0 Maternity
Leave U N
888 A
000 8553 MAT 1994-08-19 1995-03-01 194 .0 Maternity
U Y
888 A
000 8553 PER 1993-04-15 1993-04-19 4 .0
U N Personal
Day required

12/08/21
CSC Confidential 36
12/08/21
CSC Confidential 37
12/08/21
CSC Confidential 38

You might also like