EDIFACT How to group, spilt, sort and sum up values from a EDI string into variables in VB.NET -
i new vb.net 2008. have tricky task resolve, regarding extracting characters (values) long string, extracted values text shall summed , sorted keywords, reformatted , saved csv file.
it looks longer :
unh+ram6957'company1by500c10'zew+reqest6957'company2sl200c20'company1sl300c10'zew
the values seperated ' .
as first step splitted string make readable, used function like:
dim lineoftext string dim integer dim arytextfile() string lineoftext = p_edi arytextfile = lineoftext.split("'") = 0 ubound(arytextfile) console.writeline((arytextfile(i))) next
now result looks like:
unb+unoa:1+ccp:zew+ste:zew+100901:1200+2010917283 unh+m000001+ordrsp:d:96a:un:egt102 bgm+02g::zew+nomres24364+34 dtm+z05:0:805 dtm+137:201009011000:203 dtm+z01:201009090400201009100400:719 rff+ahi:gscompany1 nad+zso+ccp::zew nad+zsh+gsstatkraft::zew tdt+41g++70 loc+z11+:::ttf lin+1+23 loc+z11+:::ttf qty+z05:0:kw1 dtm+2:201009090400201009100400:719 nad+zus+gsbnp::zew lin+2+23 loc+z11+:::ttf qty+z05:0:kw1 dtm+2:201009090400201009100400:719 nad+zus+gsbpa::zew
so far good:
now have extract date , time header: line looks like:
**dtm+137**:201009011000:203 should dtm+137:2010.09.01-10:00:203 , store 'incomming_dtm' variable example
now message period interresting know: line looke like:
**dtm+z01**:201009090400201009100400:719 output should like: dtm+z01 2010.09.09-04:00, 2010.09.10-04:00 , store 'period_dtm' variable
as next step need parse next lines until reaches keyword lin like:
lin+1+23 loc+z11+:::ttf qty+z05:0:kw1 dtm+2:201009090400201009100400:719 nad+zus+gsbnp::zew nad+zsh+company1rph n001::zew (p character in word -> sell qty:0 kw/h) lin+2+23 loc+z11+:::ttf qty+z05:0:kw1 dtm+2:201009090400201009100400:719 nad+zus+gsbpa::zew nad+zsh+company1rrh n001::zew (r character in word -> buy qty:0 kw/h)
and store keywords "qty" "dtm" "nad+zsh"
, following characters variables.
then need parse until reaches next lin keyword , store keywords there vaiables again. goal of complicated exercise is, sum values of qty , nad+zsh+company1rvh , nad+zsh+company1rph
if have closer @ last zwo charaters in company1rrh , company1rph see rh , ph, rh means buy , ph means sell. maybe possible store buy or sell contract vaiable each lin?
i need sum sells , buys found in string. every lin marks time period of 1 hour, have 24 series per string contains 24 lin every lin have time period, buy or sell keywords , quantity.
can please me task?
as first step, storing keywords , follwoing characters variables start. might until parser reaches lin
, store found values csv file or array?, parse until next lin , on...
i create csv file out of results like: csv should contain 24 records 1 per every hour per every lin..
dim csvdata = & "," & "traded_qty" & "," & dtm+z01 & "," & "n" & "," & qty & "," & "kwh/h" & "," & contract console.writeline(csvdata) creating csv file true flag -> append data csv. dim csvfile string = "c:\test.csv" dim outfile io.streamwriter = my.computer.filesystem.opentextfilewriter(csvfile, true)
any ideas highly welcome, consider complex task espacial new vb.net.
thank in advance!
i see "edi" in code. if edi format, should have, or able get, kind of edi specification. likely, fixed-length specification, meaning "value x characters 1 9", "value y characters 10 11", "value z character 12", etc.
Comments
Post a Comment