Create flat file with AE

Local File &File;
Local string &FILE_NAME, &CHARSET, &COMPANY_NAME, &COMPANY_PADDED, &LINES_PADDED, &AMOUNT_PADDED;
Local number &LINES, &AMOUNT;
Local Record &HEADER_REC, &TRANSACTION_REC;
Local SQL &HEADER_SQL, &TRANSACTION_SQL;
Declare Function LPAD PeopleCode FUNCLIB_GPCN.PADDINGLEFT FieldFormula;
Declare Function RPAD PeopleCode FUNCLIB_GPCN.PADDINGRGHT FieldFormula;

&TRANSACTION_REC = CreateRecord(Record.GPCN_EFT1_TAO);

&FILE_NAME = "gpcn_bank.txt";
&CHARSET = "U";

&File = GetFile(&FILE_NAME, "W", &CHARSET);
If &File.IsOpen Then
   If &File.SetFileLayout(FileLayout.GPCN_EFT_CCBS) Then
     
      /* Write 1st Line of the Header Rows */
      &COMPANY_NAME = GPCN_EFT_AET.ACCOUNT_NAME;
      &COMPANY_PADDED = RPAD(&COMPANY_NAME, 31, "=");
      &File.WriteLine(&COMPANY_PADDED);
     
      /* Write 2nd Line of the Header Rows */
      &LINES = GPCN_EFT_AET.SEQUENCE_NBR_6;
      &LINES_PADDED = LPAD(String(&LINES), 6, "0");
      &File.WriteLine(&LINES_PADDED | "=========================");
     
      /* Write 3rd Line of the Header Rows */
      &AMOUNT = GPCN_EFT_AET.SEQ_NBR;
      &AMOUNT_PADDED = LPAD(String(&AMOUNT), 12, "0");
      &File.WriteLine(&AMOUNT_PADDED | "===================");
     
      /* Write 4th Line of the Header Rows */
      &File.WriteLine("================***************");
     
      /* Write Transaction Rows */
      &TRANSACTION_SQL = CreateSQL("%Selectall(:1) Where PROCESS_INSTANCE=:2", &TRANSACTION_REC, GPCN_EFT_AET.PROCESS_INSTANCE);
      While &TRANSACTION_SQL.Fetch(&TRANSACTION_REC)
         &File.WriteRecord(&TRANSACTION_REC);
      End-While;
     
   End-If;
Else
   GPCN_EFT_AET.ERROR_TYPE = "501"; /*Error Writing to File*/
End-If;
&File.Close();

转载于:https://www.cnblogs.com/GoDevil/archive/2009/01/13/1375027.html

你可能感兴趣的:(Create flat file with AE)