How to combine multiple flat files into one file as EnterpriseOne flat file conversion application (R47002C) takes a single predefined file name with file path defined in Flat File Cross Reference application (P47002).
Disclaimer: This document may contain information, software, products, services which are not supported by Oracle Support Services and are being provided “as is” without warranty.
Using the suggested workarounds requires advanced knowledge of the JD Edwards EnterpriseOne toolset, including but not limited to using event rules, APIs, business functions,etc.. Although logic examples may be provided; field assistance will need to be requested if the customer requires more detailed development help with their implementation. These are billable activities that are not supported by Oracle Global Support.
Business scenario
10 different customers are sending 10 different files through FTP with different unique file names (e.g., 850IN01, 850IN02, ..., 850IN10 etc.) so conversion has to handle these 10 different files.
Functional specification
There are 3 folders to store the original input files, archiving them as follows:
EDI: Folder which stored the original files from business parties
EDIArchive: Folder to archive files converted
EDIArchive02: Archive the original files from EDI
And 3 different type of flat files:
Source file: the original flat files (e.g., 850IN01, 850IN02, etc.)
Target File 01 (combined): A single merged file which is defined in P47002 (e.g., 850INALL)
Target File 02 (original): To move files to archived location
Sequence of event:
Check whether Target File 01 does exist from EDI folder
If there is a file with same file name then archive it into EDIArchive folder
Copy all the source files to Target File 01
Copy is successful then move the original file to EDIArchive02 folder
Delete Source files from EDI folder
Implementation:
The code below serves as an example only and if needed, you can modify it to meet your business requirement.
/* :::: Example of codes to merge multiple input flat files into a single file done in Report Design Aid::: */
/* Check whether Target File (combined one) does exist in working folder 'EDI' */ /* Start to handle 850INALL in working folder */ VA evt_TargetFile_EXEP = "C:\EDI\850INALL" Operating System File Operations Delete, Rename, File Exists "E" -> BF cActionCode /* To check existence */ VA evt_TargetFile_EXEP <> BF szFileName1 "1" -> BF cSetOneWorldErrorFlag01 VA evt_mnExistenceFlag <- BF mnErrorCodeReturned If VA evt_mnExistenceFlag is equal to <Zero> /* File name 850INALL does exist */ Convert Date To String Based On Format Code /* Optional code */ SL DateToday -> BF jdInputDate_DT "3" -> BF cOutputFormatCode_EV01 VA evt_OutputDateToday <- BF szOutputDateString_DL01 VA evt_Archive_EXEP = concat('C:\EDIARCHIVE\850INALL_',[VA evt_OutputDateToday]) Delete Or Copy Flat File /* To copy 850INALL to Archive folder */ VA evt_TargetFile_EXEP -> BF szOriginalFlatFile VA evt_Archive_EXEP -> BF szNewFlatFile "2" -> BF cActionOnFlatFiles /* Copy Option */ <Zero> -> BF cSuppressErrorMessage VA evt_ErrorCode <- BF cErrorCode VA evt_DataItem <- BF szErrorMessage If VA evt_DataItem is equal to <Blank> /* If 850INALL is copied to ARCHIVE then delete 850INALL from EDI folder */ Delete Or Copy Flat File VA evt_TargetFile_EXEP -> BF szOriginalFlatFile "1" -> BF cActionOnFlatFiles <Zero> -> BF cSuppressErrorMessage VA evt_ErrorCode <- BF cErrorCode VA evt_DataItem <- BF szErrorMessage End If End If /* End of 850INALL */
/* Start: To combine multiple files to a single file */ VA evt_mnFirstFile = "1" VA evt_mnLastFile_SEQ = "99" While VA evt_mnFirstFile is less than or equal to VA evt_mnLastFile_SEQ Convert Math_Numeric To String /* To make string file name for source files */ VA evt_mnFirstFile -> BF mnMathNumeric01 VA evt_szSeqInString_DL01 <- BF szString VA evt_szSeqInString_DL01 = lpad([VA evt_szSeqInString_DL01],"0",2)
VA evt_SourceFile_EXEP = concat('C:\EDI\850IN',[VA evt_szSeqInString_DL01])
Operating System File Operations Delete, Rename, File Exists /* To verify existence. Not exist then exit from loop */ "E" -> BF cActionCode VA evt_SourceFile_EXEP <> BF szFileName1 "1" -> BF cSetOneWorldErrorFlag01 VA evt_mnExistenceFlag <- BF mnErrorCodeReturned
If VA evt_mnExistenceFlag is equal to <Zero> /* Source file name meets */ Delete Or Copy Flat File VA evt_SourceFile_EXEP <> BF szOriginalFlatFile VA evt_TargetFile_EXEP -> BF szNewFlatFile "2" -> BF cActionOnFlatFiles /* To copy file from source to target */ <Zero> -> BF cSuppressErrorMessage VA evt_ErrorCode <- BF cErrorCode VA evt_DataItem <- BF szErrorMessage If VA evt_ErrorCode is not equal to "1" /* Successfully merged then */ VA evt_TargetFile_EXEP = concat('C:\EDIArchive02\850IN',[VA evt_szSeqInString_DL01]) Delete Or Copy Flat File /* to move the original file to EDIArchive02 */ VA evt_SourceFile_EXEP -> BF szOriginalFlatFile VA evt_TargetFile_EXEP -> BF szNewFlatFile "2" -> BF cActionOnFlatFiles <Zero> -> BF cSuppressErrorMessage VA evt_ErrorCode <- BF cErrorCode VA evt_DataItem <- BF szErrorMessage If VA evt_ErrorCode is not equal to "1" /* Original file is copied */ Delete Or Copy Flat File VA evt_SourceFile_EXEP -> BF szOriginalFlatFile "1" -> BF cActionOnFlatFiles /* Delete the original source file */ <Zero> -> BF cSuppressErrorMessage VA evt_ErrorCode <- BF cErrorCode VA evt_DataItem <- BF szErrorMessage End If VA evt_TargetFile_EXEP = "C:\EDI\850INALL" End If End If VA evt_mnFirstFile = [VA evt_mnFirstFile]+1 End While
Note:
Most of FTP applications will enable you to encode/decode and merge multiple files into one.
Manual merge/append is alternative way.
If needed, create a new table to control how flat file is maintained.
For this example, Windows Local Path is used. Since both business functions (B4700230 and B0500180) are not platform specific, you can change the path representation for your platform.
File Name with * or % may not work for any conversion application "/PY812/850IN%".
In referenced business function B4700230 it opens file with option of a+ which stands for "appends". For detail refer <Document 1298219.1> - E1: BSFN: Format and Use of jdeFopen() API Function for Text Files.
For detail on how to use business function referenced refer <Document 661013.1> - E1: BSFN: How to Copy, Delete or Rename a Flat File?