Flat File manipulation in EnterpriseOne Scott B. Zuke

advertisement
Flat File manipulation in EnterpriseOne
Scott B. Zuke
September 7, 2004
There are many different ways to output information to a flat file. This example will
make use of the business function, B0500025, Export to Flat File. The business function
notes, along with the notes for two other flat file manipulation functions, are included at
the end of this document.
The business function requires two parameters, the record to be written (the text) and the
path to the file.
If the file doesn’t exist, it will create it. I’ve used this in the past with a timestamp in
order to generate unique files. If you write to the same file for subsequent runs of the
same batch job, the records will append.
Here’s an example of the function in use. Notice that everything in this example is hardcoded. Typically you’d want to use variables to store text values and paths.
B0500025
Simple Example:
=====================================================
SECTION: main [GROUP SECTION] (S2)
=====================================================
OBJECT: SECTION
EVENT: Do Section
----------------------------------------------------------------------Export to Flat File
"mytest,yourtest,1234,true,0,1" -> szRecord
"c:\temp\mytesting.txt" -> szPath
UNDEFINED <- cStatus
More complex example:
Listing of ER for Report: Flat File example (R55FLAT)
****************************************************************
GLOBALS: Global Variable
****************************************************************
rpt_tempdatetime (GS2A)
rpt_DirectoryPath (DRPT)
rpt_outputString (TXT9)
rpt_delimiter (EV01)
=====================================================
SECTION: main [GROUP SECTION] (S2)
=====================================================
OBJECT: SECTION
EVENT: Initialize Section
----------------------------------------------------------------------VA rpt_delimiter = ","
Get Current Date and Time
VA rpt_tempdatetime <- szDateTime
VA rpt_DirectoryPath = concat("c:\mytest\",[VA rpt_tempdatetime] )
VA rpt_DirectoryPath = concat([VA rpt_DirectoryPath],".txt")
----------------------------------------------------------------------EVENT: Do Section
----------------------------------------------------------------------evt_counter (MATH01)
evt_textCounter (A201)
While VA evt_counter is less than or equal to "20.00"
VA rpt_outputString = ""
Convert Math Numeric To A String with Decimals
VA evt_counter -> mnMathNumericToConvert
VA evt_textCounter <- szReturnString
VA rpt_outputString = concat([VA rpt_outputString],"Hello World")
VA rpt_outputString = concat([VA rpt_outputString],[VA rpt_delimiter])
VA rpt_outputString = concat([VA rpt_outputString],[VA evt_textCounter])
VA rpt_outputString = concat([VA rpt_outputString],[VA rpt_delimiter])
VA rpt_outputString = concat([VA rpt_outputString],"true")
VA rpt_outputString = concat([VA rpt_outputString],[VA rpt_delimiter])
VA rpt_outputString = concat([VA rpt_outputString],[SL UserID
Export to Flat File
VA rpt_outputString -> szRecord
VA rpt_DirectoryPath -> szPath
UNDEFINED <- cStatus
VA evt_counter = [VA evt_counter]+1
End While
])
Business Function Notes
B0500025, Export to Flat File
=====================================================
Functional Description
The function accepts two input parameters, the record and file name and
returns status.
Purpose
To create flat file that collects records that will be later exported
to another database.
Setup Notes and Prerequisites
The path for the output file must exist.
Special Logic
Technical Specification
First the file is opened in append mode or it's created if it doesn't
exist. Then the record is written into the file, new line character
will not be added automatically it has to be included in the record. On
the end the file is closed and return status is returned.
=====================================================
Business Function Notes
B34A1010, Open Flat File
=====================================================
1.
Functional Description
1.1
Purpose
This business function will open a flat (text) file and store the file
pointer for subsequent use.
1.2
Setup Notes and Prerequisites
The flat file path name & filename must be valid
where this business function is to be run.
2.
Technical Specifications
2.4
Processing
for the platform
1. If the szFilePath is blank, set cErrorCode to '1' and
szErrorMessageId to "3143".
2. Open the file
If cAppendMode is '1', open the text file with mode "a+", otherwise
open with mode "w"
If the file pointer is not null, store it with jdeStoreDataPointer
and return the id in idFilePtr.
If the file pointer is null, set cErrorCode to '1' and set
szErrorMessageId to "078D".
=====================================================
Business Function Notes
B34A1010, Close Flat File
=====================================================
1.
Functional Description
1.1
Purpose
This business function closes a flat (text) file that has been opened
by Flat File Operations - Open File (in the same source).
2.
Technical Specifications
2.4
Processing
1. Retrieve the file pointer using jdeRetrieveDataPtr with the
idFilePtr as input.
If the file pointer is null, set cErrorCode = '1' and
szErrorMessageId to "3143".
2. Close the file
Close the file and call jdeRemoveDataPointer with the idFilePtr as
input.
=====================================================
Download