Using reformat component
Input port :
record
decimal("\x01") trx_date = NULL("") /*INTEGER*/;
decimal("\x01") id_card = NULL("") /*INTEGER*/;
utf8 string("\x01", maximum_length=40) name = NULL("") /*VARCHAR(20) CHARACTER SET LATIN*/;
utf8 string("\x01", maximum_length=40) ttype = NULL("") /*VARCHAR(20) CHARACTER SET LATIN*/;
utf8 string("\x01", maximum_length=10) expired = NULL("") /*VARCHAR(5) CHARACTER SET LATIN*/;
string(1) newline = "\n";
end
Output Port:
record
utf8 string(unsigned integer(2)) filename;
record
utf8 string("\n") message = "";
end message;
end;
Transform script:
let unsigned integer(2) file_count = 1;
let unsigned integer(4) rec_count = 1;
out :: reformat(in) =
begin
let unsigned integer(2) temp_rec_count = 0;
let utf8 string(unsigned integer(2)) temp_filename ='FileName_';
let record
utf8 string("\n") message = "";
end temp_message = allocate();
//temp_filename = temp_filename + '_' + string_lpad((string(""))(decimal(""))file_count, 3, '0');
temp_filename = temp_filename + '_' + (string (8)) (datetime("yyyymmdd"))now1() +'_' + (string(6))(datetime("HH24MISS"))datetime_add(now1(),0,0,0,file_count);
temp_message.message = (string_lrtrim(((string(30))in.id_card))+";OKE;"+in.name);
rec_count = rec_count + 1;
if (rec_count > 3000)
begin
file_count = file_count + 1;
rec_count = 1;
end;
out.filename:: temp_filename;
out.message :: temp_message;
end;
write to file using Write Multiple Files component
input port : propagate from reformat
Transform script :
type output_type= record
utf8 string("\n") message;
end; /*Metadata for records written to output files*/
filename :: get_filename(in) =
begin
filename :: string_concat("${FOLDER_NAME}/", in.filename, ".txt");
end;
write :: reformat(in) =
begin
write :: in.message;
end;