# # ITSV GmbH # CCDB - Command and Control Database # # FILE: dquerymfile_LLOADCFENZ.txt # DESCRIPTION: dquery definition for LOADCFENZ # # HISTORY: 20200910 WSC add "rueckfrageinfo" # @group SVCLCFSTATCFENZ @querytitle DGD-Auswertung zu ELDA-nicht-zustellbar-Clearingfälle laden @querydescription lädt die monatliche Auswertung über ELDA-nicht-zustellbar-Clearingfälle in die Tabelle CCCFUNZ @attributenames mfileid:mfileid:{{mfileidoptions}} @mfileidoptions {"labeltext":"Lade-Managed-File ID","typedesc":"Managed File ID der Datei, die geladen werden soll, diese muss den MFILETYPE \"DGDCFENZ\" haben"} @input_encoding iso-8859-15 @querytype function @function seqtrans.seqtrans @FLIST repdatnum,traeger,parparrolleid_partner,partnerrollenart_kurz,bknr,vsnr,status,referenzwert,einlange_dat,xpath @TLIST repdatnum,traeger,parparrolleid_partner,partnerrollenart_kurz,bknr,vsnr,status,referenzwert,einlange_dat,rueckfrageinfo,zuordnungsinfo @TYLIST varchar(32),varchar(2),varchar(32),varchar(32),varchar(10),varchar(10),varchar(20),varchar(70),varchar(19),varchar(1024),varchar(4096) @SVTLIST 05:BVAEB-EB,11:ÖGK-W,12:ÖGK-N,13:ÖGK-B,14:ÖGK-O,15:ÖGK-ST,16:ÖGK-K,17:ÖGK-S,18:ÖGK-T,19:ÖGK-V @init.qexpression this.load_file = load_file; this.csv_rep_func = function(linetext,repres) { let rp = new Array(); fldarr = this.load_file.splitCSVline(linetext,{linesep: ";", quotechar: "\""}); rp.push("LOADCFENZ: Trying to repair fields: "+aux.objTxt(fldarr)); if (fldarr.length<5) { rp.push("too few fields, no repair possible"); if (repres) repres.info = rp.join("\n"); return linetext; } if (fldarr.length>5) { /* if #4 is no valid Datum, referenzwert may be split up by one or more ";" in it */ let rex = /[0-9]{1,4}\-[0-9]{1,2}\-[0-9]{1,2}\s.+/; while ((fldarr.length>5) && (fldarr[4]!="") && (!rex.test(fldarr[4]))) { rp.push("record has still "+fldarr.length+" fields, fld#4 is no valid DATUM/ZEIT (and also not empty), try merging #3+#4"); let rep = fldarr[3]+"%3B"+fldarr[4]; fldarr.splice(4,1); fldarr[3] = rep; linetext = fldarr.join(";"); } } if (repres) repres.info = rp.join("\n"); return linetext; }.bind(this); ~query.tsteps # # <>: # if (this.init_done) goto record_proper # # <>: initialization: get MFILE info # qexpression proc: { this.progstat.current_mfileid = this.cdata.MFILEID; if (!this.init_done) { this.FLIST = this.query.FLIST; this.tfnames = this.FLIST.split(","); this.FVLIST = "::" + this.tfnames.join("::,::") + "::"; this.TLIST = this.query.TLIST; this.ttnames = this.TLIST.split(","); this.TVLIST = "::" + this.ttnames.join("::,::") + "::"; this.ttypes = this.query.TYLIST.split(","); this.svta = this.query.SVTLIST.split(","); this.svts = {}; let fs; for (let ti=0; ti=0) { /* we have erstell_ts, rename it to "enlange_dat" */ this.inputresult.setMetaDataName(rfi,"einlange_dat"); this.cdata = this.inputresult.getRowObject(this.recnum,"value"); /* reload CDATA, as names have changed, for first row */ } else { this.errcoll.collect(null,"input dataset does not have column "+flfn[fi]+", but also no replacement column \"erstell_ts\", no repair possible"); } } else if (flfn[fi]=="vsnr") { /* we don't have "vsnr", check for possible replacement */ rfi = this.inputresult.findColumn("VSNR"); if (rfi>=0) { /* we don't have "vsnr", but we do have "VSNR", rename it */ this.inputresult.setMetaDataName(rfi,"vsnr"); this.cdata = this.inputresult.getRowObject(this.recnum,"value"); /* reload CDATA, as names have changed, for first row */ } else { /* we don't have neither "vsnr" nor "VSNR", replace with empty string => add one last empty column */ let vcolnum = this.inputresult.addMetaDataName("vsnr"); for (let ri=0; ri>: initialization: check if table there (if not, the SQL step will fail and everything will be rolled back) # sql select * from @@tablename@@ limit 1,1 result_varname cres catch_errors true post_qexpression proc: { if (this.cres.error) { this.errcoll.collect(null,"Error getting infomation about "+this.tablename,{ db_result: this.cres }); break proc; } let ci; this.missCols = new Array(); for (let ti=0; tiaux.objTxt(this.ares)+"" }]); then_goto add_next_column # # <>: init done # columns_ok: qexpression this.init_done = true; # # <>: check and prepare record, look up Zuordnungen # record_proper: pre_qexpression proc: { let tr = String("00" + this.cdata.traeger); this.cdata.traeger = tr.substring(tr.length-2); let pd = this.cdata.einlange_dat; if (!aux.isDate(pd)) { pd = aux.dateFromString(this.cdata.einlange_dat); if (pd.error) { this.cdata.einlange_dat = String(this.cdata.einlange_dat); /* 16.07.2021: do not stop on date error to pass data, BEICON corrupted erstell_ts for 2021.07 dataset this.errcoll.collect(pd.error,"einlange_dat of "+this.recnum+" is no valid Date() but: "+aux.objTxt(this.cdata.einlange_dat), this.cdata); if (pd.errcoll) this.errcoll.append(pd.errcoll); break proc; */ } } else { this.cdata.einlange_dat = pd; this.cdata.edt_old = this.cdata.einlange_dat; this.cdata.einlange_dat = aux.svDateTime(this.cdata.einlange_dat); } if (this.cdata.einlange_dat.length>19) { this.cdata.einlange_dat = ("?" + this.cdata.einlange_dat).substring(0,19); this.ppush([this.phead("WRONG_EINLANGE_DAT"),"einlange_dat(corr)="+this.cdata.einlange_dat,"CDATA: "+aux.objTxt(this.cdata),"RECNUM="+this.recnum]); } this.cdata.rueckfrageinfo = this.cdata.xpath; /* 20200910 - get "rueckfrageinfo" from "xpath" in input */ if (!this.rfis) this.rfis = {}; if (!this.rfis[this.cdata.rueckfrageinfo]) { this.rfis[this.cdata.rueckfrageinfo] = { ANZAHL: 0 }; } this.rfis[this.cdata.rueckfrageinfo].ANZAHL++; this.traegerkurz = this.svts[this.cdata.traeger].name; /* this.tstep.sql = "select * from SVCLZUODUMP where traeger='"+this.traegerkurz+"' and bknr='"+this.cdata.bknr+"'"; */ } # sql select 'NO_SQL_CALCULATED' # named_params traegerkurz,bknr # result_varname zres #post_qexpression # let zuoa = new Array(); # let zrow; # for (let ri=0; ri>: insert the record # sql insert into @@tablename@@(@@TLIST@@) values(@@TVLIST@@) named_params @@TLIST@@ post_qexpression this.recsprocessed++; # # <>: check if this was the last record # if (!this.is_last_record) goto record_done # # <>: all records processed, mark MFILE as loaded # pre_qexpression this.LOADFINISHED = aux.nowstring(); this.load_mfileattributes.loadstate = "loaded"; delete this.load_mfileattributes.to_reconvert; delete this.load_mfileattributes.unloadtime; this.load_mfileattribs = JSON.stringify(this.load_mfileattributes); sql update CCMFILES SET MFILEATTRIBS=::load_mfileattribs:: WHERE MFILEID=::mfileid:: named_params load_mfileattribs,mfileid post_qexpression for (let rfi in this.rfis) { this.ppush([this.phead("rueckfrageinfoanzahl"),"ruckfrageinfo="+rfi,"ANZAHL="+this.rfis[rfi].ANZAHL,""]); } ppush(this,[this.ppfx+"_complete","MFILEID_TO_LOAD="+this.mfileid,"RECORDS_TO_PROCESS="+this.recstoprocess,"RECORDS_PROCESSED="+this.recsprocessed]); # # <>: end of record processing # record_done: end