How to Combine Multiple Input Flat Files for EDI

Purpose of Document

 

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. 

Please refer to the following site for My Oracle Support Terms of use: 
http://docs.oracle.com/cd/E25290_01/doc.60/e25224/preface.htm#MOSHP983

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:


And 3 different type of flat files:

Sequence of event:

  1. Check whether Target File 01 does exist from EDI folder
  2. If there is a file with same file name then archive it into EDIArchive folder
  3. Copy all the source files to Target File 01
  4. Copy is successful then move the original file to EDIArchive02 folder
  5. 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: