Converter (ZENGIN to MizuhoCSV)
Generates a general transfer file for Mizuho Bank. The file of “ZENGIN format” defined by the Japanese Bankers Association is converted to the file for “Mizuho Business Web” service. Each line consists of “Customer Code 1” and “payment amount”.
Configs
  • A: Select FILES DATA for ZENGIN.txt (Multiple not supported) *
  • B: Select FILES DATA for Mizuho.csv (update) *
  • Bx: Set the file name if you want to save as a different name#{EL}
Script (click to open)
// GraalJS Script (engine type: 2)
//////// START "main()" ////////
main();
function main(){ 


//// == Config Retrieving / 工程コンフィグの参照 ==
const dataIdA = configs.get( "conf_DataIdA" ) + "";
const dataIdB = configs.get( "conf_DataIdB" ) + "";
const saveAs  = configs.get( "conf_SaveAs" ) + "";
// 'java.lang.String' (String Obj) to javascript primitive 'string'

let fileName = "";
if( saveAs === "" ){
  fileName = "Mizuho.csv";
}else{
  fileName = saveAs;
}


//// == Data Retrieving / ワークフローデータの参照 ==
var myFiles = engine.findDataByNumber( dataIdA ); 
var upFiles = engine.findDataByNumber( dataIdB ); 
// java.util.ArrayList
if (myFiles === null || myFiles.size() != 1) {
  throw new Error( "\n One-file attachment is only valid. \n" );
}
if (upFiles === null ) {
  upFiles = new java.util.ArrayList();
}

//// == Calculating / 演算 ==
/// Read Lines
let myLineCounter = 0;
let allText       = "";
fileRepository.readFile(myFiles.get(0), "Shift_JIS", function(line) {
  allText += line;
  myLineCounter++;
});
engine.log( "#Line of Text-File: " + myLineCounter );

/// Remove CRLF
allText = allText.replace(/\r?\n/g, "");

/// Divide into 120 characters each
let arrRecords = allText.match(/[\s\S]{120}/g);
if (arrRecords === null || !arrRecords[0].startsWith("1") ) {
  throw new Error( "\n Not a ZENGIN file \n" );
}

/// Generate CSV
let csvText = "";
for( let i = 0; i < arrRecords.length; i++ ){
  if( arrRecords[i].startsWith("2") ){
    engine.log( i + " is a data record" );
    csvText += arrRecords[i].slice( 20, 23 );
    csvText += arrRecords[i].slice( 43, 50 );
    csvText += ",";
    csvText += arrRecords[i].slice( 80, 90 );
    csvText += ",0";
    csvText += "\n";
  }
}

/// Generate CSV files
csvText = csvText.trim(); // remove last "\n"
let arrCsvText = csvText.split("\n");
let numOfFiles = Math.ceil( arrCsvText.length / 20 );
engine.log( "# of Output Files: " + numOfFiles );

/// Add to Files Array
for( let i = 0; i < numOfFiles; i++ ){
  const csvFileText = arrCsvText.slice( i*20, i*20+20 ).join("\n");
  if( i !== 0 ){ fileName = fileName.replace(/(\.[\w\d]+)$/i, "-"+(i+1)+"$1");}
  upFiles.add( new com.questetra.bpms.core.event.scripttask.NewQfile(
    fileName, "text/comma-separated-values; charset=Shift_JIS", csvFileText ));
}

//// == Data Updating / ワークフローデータへの代入 ==
engine.setDataByNumber( dataIdB, upFiles );

} //////// END "main()" ////////

Download

2021-07-08 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/converter-zengin-to-mizuhocsv-2021/
The Add-on import feature is available with Professional or Enterprise edition.

Capture

%d bloggers like this: