mnmhema
19th March 2012, 16:38
Please help me with the following code. I am getting fatal error while compiling.
after.tccom100.fovn.1:
before.layout:
if printdeif = 1 and tccom100.fovn <> " "
then
counter= counter + 1 |skal tælle medtagne records
invoice.date=cisli205.idat/(24*60*60) +719163
res= num.to.date(invoice.date,yearno,monthno,month_dayno )
if monthno >=1 and monthno <=3 then period.date = str$(yearno)&"-03-31"
else
if monthno >=4 and monthno <=6 then period.date = str$(yearno)&"-06-30"
else
if monthno >=7 and monthno <=9 then period.date = str$(yearno)&"-09-30"
else
if monthno >=10 and monthno <=12 then period.date = str$(yearno)&"-12-31"
endif
endif
endif
endif
tax.country = tccom100.fovn
tax.number =strip$(tccom100.fovn(3;14))
if strip$(tccom100.fovn) = "" then
Part1 = """TAX number missing on customer"";"""";"""& period.date&""";""12345"";"""&tax.country&""";"""&tax.number&""";"""
else
Part1 = """2"";"""";"""& period.date&""";""12345"";"""&tax.country&""";"""&tax.number&""";"""
endif
if type = "SO1" then
Part2="""str$(round(goods.amount.hc,0,1))"";""0"";"""&cisli205.itbp&""";"""
else
Part2 = """0"";""str$(round(goods.amount.hc,0,1))"";"""&cisli205.itbp&""";"""
end if
line.data.2 = Part1 & Part2
else
lattr.print=false
endif
günther
19th March 2012, 16:43
Hi.
First of all, the compiler tells you a line number where the error occurs. Normally, that helps a lot.
But I would say the errors are your Parts1 und Parts2 assignments. In Baan, you have to use the ampersand (&) to add strings.
Günther
mark_h
19th March 2012, 16:44
This is the correct forum for this type question. The code and utilities forum is for sharing working code examples.
Post what the error is? I am not sure about that part1 and part2 setup. That certainly looks like it could be simplified. I would comment out those sections just to see if it compiled.
mnmhema
19th March 2012, 17:01
Hi
Thanks for your reply.
The Part text is to show columns if a tax number is present or not. Then I need to show the column for goods.amount.hc,0,1 in column 7 or 8 depending upon the type. I am using Part 2 for this. Finally I combine Part 1 and Part2 to show the line.data.2.
The error is:
line 168 if not expected.
line 176 if not expected.
line 178 else not expected.
bdittmar
19th March 2012, 17:49
Hello,
does your code show the lines ?
Post your code with numbering (Lines), so someone maybe able to help.
Check the code at line 168,176,178 maybe your if - then - else - endif is not coded in a proper way or outside a section because of "not expected" ....
Regards
BaanInOhio
19th March 2012, 18:20
Probably too many double quotes. You can easily lose track of them when bunching them up in the string = using "" to specify a single " in a quoted string. I like to use a local variable for the double quote [dq = chr$(34)] and just add it to the string where you want the embedded double quotes to go.
mystring = "abc " & dq & "123" & dq
You can successfully build the string using back-to-back double quotes but it is very easy to get them out of sync - a "dq" variable is a little easier to read and debug.
When using LN, you can use the "quoted.string" call to easily put the double quotes around a portion of a string.
mnmhema
19th March 2012, 21:06
Here is my code:
declaration:
extern domain tcamnt goods.amount.hc
extern domain tcamnt total.goods.amount.hc
table ttcmcs010
string type(3)
string line.data.0(30)
string line.data.2(120)
string line.data.10(40)
extern domain tcpono counter
extern domain tcpono res
long yearno
long monthno
long month_dayno
string tax.country.cisli205(3)
string tax.country(2)
string tax.number(12)
string period.date(10)
domain tcpono printdeif
extern domain tfgld.date invoice.date
string se.number
string Part1
string Part2
string dq
dq== chr$(34)
before.report.1:
before.layout:
line.data.0= """0"";""14837906"";""LISTE"";;;;;""slet kolonne"""
before.tccom100.fovn.1:
before.layout:
printdeif=2
lattr.print=false
goods.amount.hc = 0
detail.1:
before.layout:
lattr.print = false
select tcmcs010.txcd
from tcmcs010
where tcmcs010._index1 = {:cisli205.txct}
AND tcmcs010.txcd = "DK"
selectdo
type=cisli205.ityp
tax.country.cisli205=cisli205.txct
if (type="SI1" or type="SI5") then
se.number="1234"
endif
on case type
case "SI1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SO1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SIA":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SC1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
| endcase
endselect
after.tccom100.fovn.1:
before.layout:
if printdeif = 1 and tccom100.fovn <> " "
then
counter= counter + 1 |skal tælle medtagne records
invoice.date=cisli205.idat/(24*60*60) +719163
res= num.to.date(invoice.date,yearno,monthno,month_dayno )
if monthno >=1 and monthno <=3 then period.date = str$(yearno)&"-03-31"
else
if monthno >=4 and monthno <=6 then period.date = str$(yearno)&"-06-30"
else
if monthno >=7 and monthno <=9 then period.date = str$(yearno)&"-09-30"
else
if monthno >=10 and monthno <=12 then period.date = str$(yearno)&"-12-31"
endif
endif
endif
endif
tax.country = tccom100.fovn
tax.number =strip$(tccom100.fovn(3;14))
if strip$(tccom100.fovn) = "" then
Part1 = """TAX number missing on customer"";"""";"""& period.date&""";""1234"";"""&tax.country&""";"""&tax.number&""";"""
else
Part1 = """2"";"""";"""& period.date&""";""1234"";"""&tax.country&""";"""&tax.number&""";"""
end if
if type = "SO1" then
Part2= """0""";""" & str$(round(goods.amount.hc,0,1)) &""";"""& cisli205.itbp"""
else
Part2= """str$(round(goods.amount.hc,0,1)) & """;""" & 0 & """;"""& cisli205.itbp""
end if
line.data.2 = Part1 & Part2
else
lattr.print=false
endif
after.layout:
total.goods.amount.hc=total.goods.amount.hc + goods.amount.hc
after.report.1:
before.layout:
line.data.10= """10"";"""&str$(counter)&""";"""&str$(round(total.goods.amount.hc,0,1))&""";;;;;""slettes"""
bdittmar
20th March 2012, 09:56
Here is my code:
declaration:
extern domain tcamnt goods.amount.hc
extern domain tcamnt total.goods.amount.hc
table ttcmcs010
string type(3)
string line.data.0(30)
string line.data.2(120)
string line.data.10(40)
extern domain tcpono counter
extern domain tcpono res
long yearno
long monthno
long month_dayno
string tax.country.cisli205(3)
string tax.country(2)
string tax.number(12)
string period.date(10)
domain tcpono printdeif
extern domain tfgld.date invoice.date
string se.number
string Part1
string Part2
string dq
dq== chr$(34)
before.report.1:
before.layout:
line.data.0= """0"";""14837906"";""LISTE"";;;;;""slet kolonne"""
before.tccom100.fovn.1:
before.layout:
printdeif=2
lattr.print=false
goods.amount.hc = 0
detail.1:
before.layout:
lattr.print = false
select tcmcs010.txcd
from tcmcs010
where tcmcs010._index1 = {:cisli205.txct}
AND tcmcs010.txcd = "DK"
selectdo
type=cisli205.ityp
tax.country.cisli205=cisli205.txct
if (type="SI1" or type="SI5") then
se.number="1234"
endif
on case type
case "SI1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SO1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SIA":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
case "SC1":
if tax.country.cisli205<>"DK " then
goods.amount.hc=cisli205.amth(1) + goods.amount.hc
printdeif = 1
endif
break
| endcase
endselect
after.tccom100.fovn.1:
before.layout:
if printdeif = 1 and tccom100.fovn <> " "
then
counter= counter + 1 |skal tælle medtagne records
invoice.date=cisli205.idat/(24*60*60) +719163
res= num.to.date(invoice.date,yearno,monthno,month_dayno )
if monthno >=1 and monthno <=3 then period.date = str$(yearno)&"-03-31"
else
if monthno >=4 and monthno <=6 then period.date = str$(yearno)&"-06-30"
else
if monthno >=7 and monthno <=9 then period.date = str$(yearno)&"-09-30"
else
if monthno >=10 and monthno <=12 then period.date = str$(yearno)&"-12-31"
endif
endif
endif
endif
!! endif missing ???
tax.country = tccom100.fovn
tax.number =strip$(tccom100.fovn(3;14))
if strip$(tccom100.fovn) = "" then
Part1 = """TAX number missing on customer"";"""";"""& period.date&""";""1234"";"""&tax.country&""";"""&tax.number&""";"""
else
Part1 = """2"";"""";"""& period.date&""";""1234"";"""&tax.country&""";"""&tax.number&""";"""
end if <-- endif !
if type = "SO1" then
Part2= """0""";""" & str$(round(goods.amount.hc,0,1)) &""";"""& cisli205.itbp"""
else
Part2= """str$(round(goods.amount.hc,0,1)) & """;""" & 0 & """;"""& cisli205.itbp""
end if <-- endif !
line.data.2 = Part1 & Part2
else
lattr.print=false
endif
after.layout:
total.goods.amount.hc=total.goods.amount.hc + goods.amount.hc
after.report.1:
before.layout:
line.data.10= """10"";"""&str$(counter)&""";"""&str$(round(total.goods.amount.hc,0,1))&""";;;;;""slettes"""
Hello,
end if should be endif and looks like a endif is missing at "if printdeif ........"
Regards
mnmhema
20th March 2012, 10:05
I found the error myself. Actually I have to use endif, but I was using end if. Stupid me! Thanks to Mark, bdittmar and BaanInOhio.
mnmhema
20th March 2012, 10:08
Hi bdittmar
I just read your reply. Thanks. I have still problem in Part1 and Part2 string. I am new to this programming and I don't know how to write string texts. :-(
BaanInOhio
20th March 2012, 18:53
Here's a slightly different way to do it. As stated in an earlier post, I avoid using the double-double quotes within a string since it is confusing to debug and for the next guy to read. I will use the "concat" function when building a string, especially when the fields must be surrounded by double quotes. Another nice thing about concat is that the conversion from numbers to strings is done automatically. In the example below, the delimiter that will be placed between the string fields is ";" (including the double quotes). All you have to do after building the string is to add the double quotes around the entire string (warning - not compiled, just an example...)
string delimitr(3)
| Put ";" (including double-quote) between each field.
delimitr = chr$(34) & ";" & chr$(34)
if isspace(tccom100.fovn) then
Part1 = concat(delimitr, "TAX number missing on customer", "", period.date, "1234", tax.country, tax.number)
else
Part1 = concat(delimitr, 2, "", period.date, 1234, tax.country, tax.number)
endif
| Put double quotes on the ends of the string.
Part1 = chr$(34) & Part1 & chr$(34)
if (type = "SO1") then
Part2= concat(delimitr, 0, round(goods.amount.hc,0,1), cisli205.itbp)
else
Part2= concat(delimitr, round(goods.amount.hc,0,1), 0, cisli205.itbp)
endif
| Put double quotes on the ends of the string.
Part2 = chr$(34) & Part2 & chr$(34)
mnmhema
20th March 2012, 20:38
Hi BaanInOhio
This is really easy to understand. Thanks a lot for your tip. :-)
mnmhema
21st March 2012, 13:27
Hi BaanInOhio
When I tried your suggestion, I get "Unresolved reference to concat" error while compiling the report script.
EdHubbard
21st March 2012, 13:37
It's concat$ (i.e. a dollar sign at the end) :)
mnmhema
21st March 2012, 14:27
delimitr = chr$(34) & ";" & chr$(34)
Part1 = concat$(delimitr, "TAX number missing on customer", "", period.date, "1234", tax.country, tax.number)
when I use the delimitr variable as above, the semi colon symbol is missing in the output string.
mark_h
21st March 2012, 14:41
Do you really need the " around the ;? Just try the ";" in place of delimitr to start with and see if it works for you - like this:
Part1 = concat$(";", "TAX number missing on customer", "", period.date, "1234", tax.country, tax.number)
bdittmar
21st March 2012, 15:35
delimitr = chr$(34) & ";" & chr$(34)
Part1 = concat$(delimitr, "TAX number missing on customer", "", period.date, "1234", tax.country, tax.number)
when I use the delimitr variable as above, the semi colon symbol is missing in the output string.
Hello,
from LN progguide :
concat$()
Syntax:
function string concat$ (string separator, void expr ...)
Description
This converts one or more expressions to strings and merges the expressions into a single string. You can use string.scan() to split the string again into its individual parts.
This function is used mainly by the report processor to save unsorted records in a sequential file for subsequent sorting.
Arguments
string separator The separator to be placed between individual values in the merged string.
void expr ... One or more expressions of type long, double, or string.
Context
This function can be used in all script types.
Example
string ret(100)
long a
string b(5)
double d
a = 10
b = "hello"
d = 1.123456
ret = concat$( "|",a*10,b,d ) | ret now contains "100|hello|1.123456"
Regards
mnmhema
22nd March 2012, 09:26
I can get ; as the separator in the output string, when I use
Part1 = concat$(";", "TAX number missing on customer", "", period.date, "1234", tax.country, tax.number)
I need the " around the ; because I need double quotes around the output texts.
mark_h
22nd March 2012, 14:49
Well it just dawned on me that the string separator can only be one character. So you could build it using the & like:
delimitr = chr$(34) & ";" & chr$(34)
part1 = "TAX number missing on customer " & delimitr & period.date & delimitr & "1234" & delimitr & tax.country & delimitr & tax.number
Not sure what it will look like, but if other quotes are needed you can include chr$(34) in the code like this:
part1 = chr$(24) & "TAX number missing on customer " & chr$(24) & delimitr & period.date & delimitr & "1234" & delimitr & tax.country & delimitr & tax.number
Just make sure part1 or part2 is big enough to hold all the characters.
mnmhema
22nd March 2012, 15:57
Thanks mark! It helped me. :-)
BaanInOhio
22nd March 2012, 18:12
Well it just dawned on me that the string separator can only be one character.
I went back into my library and noticed this as well. I thought I used a multiple-character delimiter in the past but found that it wasn't the case. You can still use concat$ with a single ";" delimiter with "quoted.string" to put the quotes around each of your text fields:
delimitr = chr$(34) & ";" & chr$(34)
part1 = concat$(";", quoted.string("TAX number missing on customer "), quoted.string(period.date), quoted.string("1234"), quoted.string(tax.country), quoted.string(tax.number))
quoted.string expects a string in the first (only) argument, so conversions from other data types must be done first or within the argument, like quoted.string(str$(number)).
You might want to write a little utility to check for a double-quote character in strings that could contain one (like item description or customer name) since quoted.string will not return anything when double-quotes are in the string.