on 05-16-2014 8:30 PM
Hi
Building a formula which works as expected with the commented code. When I uncomment, I was getting an error that highlights the else line at the bottom (NewBOM := "";) with a message that says "a boolean is expected here". After playing around with semicolons and brackets, the error now says "a number is required".
Keener, less bleary eyes might see what I'm doing wrong. I hope so.
Thanks!
whileprintingrecords;
global numbervar CurrInv; global numbervar CurrPOS; global numbervar CurrBOM;
global numbervar PrevInv; global numbervar PrevPOS; global numbervar PrevBOM;
global stringvar NewInv; global stringvar NewPOS; global stringvar NewBOM;
global stringvar CommTypePOS; global stringvar CommTypeInv;
global numbervar CommRatePOS; global numbervar CommRateInv;
if isnull({Commission.AROBP_A_IDINVC}) then CurrInv := 0 else CurrInv := {Commission.AROBP_A_IDINVC};
if isnull({Commission.POS_POS_NR}) then CurrPOS := 0 else CurrPOS := {Commission.POS_POS_NR};
if isnull({Commission.STKL_BOM_ID}) then CurrBOM := 0 else CurrBOM := {Commission.STKL_BOM_ID};
if CurrInv <> PrevInv
then (NewInv := "I";)
else (NewInv := "";);
if CurrInv <> PrevInv or CurrPOS <> PrevPOS
then (NewPOS := "P";)
else (NewPOS := "";);
if CurrInv <> PrevInv or CurrPOS <> PrevPOS or CurrBOM <> PrevBOM
then (NewBOM := "B";
(if {@Flag_STKL_Alice}
then (CommTypePOS := "";
CommTypeInv := "ALI";
// (if ({Commission.ARSAP_NAMEEMPL} = 'Bernard Ruhl'
// or {Commission.ARSAP_NAMEEMPL} = 'MB Building Products'
// or {Commission.ARSAP_NAMEEMPL} = 'Carlan Group'
// or {Commission.ARSAP_NAMEEMPL} = 'Gerald Fornell')
// then (CommRateInv := 10;)
// );
);
);
)
PrevInv := CurrInv; PrevPOS := CurrPOS; PrevBOM := CurrBOM;
hey Matthew, try moving your newbom around so it's like this in the last big paragraph...
if CurrInv <> PrevInv or CurrPOS <> PrevPOS or CurrBOM <> PrevBOM
then ((if {@Flag_STKL_Alice}
then (CommTypePOS := "";
CommTypeInv := "ALI";
(if ({Commission.ARSAP_NAMEEMPL} = 'Bernard Ruhl'
or {Commission.ARSAP_NAMEEMPL} = 'MB Building Products'
or {Commission.ARSAP_NAMEEMPL} = 'Carlan Group'
or {Commission.ARSAP_NAMEEMPL} = 'Gerald Fornell')
then (CommRateInv := 10;)
);
);
);NewBOM := "B";
)
else (NewBOM := "";);
PrevInv := CurrInv; PrevPOS := CurrPOS; PrevBOM := CurrBOM;
the reason could be that commrateinv is a number type where as newbom is a text and hence your if then else is going from a number to a text.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you,
The repositioning of the NewBOM := "B" worked like a charm, but I've run into another issue that is probably just failing memory. I can't seem to get the logic for NAMEEMPL to work. This is a field that is printing on the same (detail) line. In my first example, the NAMEEMPL is Bernhard. I am trying all combinations I can think of for the name or a like statement. Getting all kind of circuitous results when I try to google CRYSTAL REPORTS LIKE STATEMENT SYNTAX.
I thought that maybe the code was just being ignored, but if I comment out the line with like 'B%', and uncomment the statement above it, I get the 10 value.
What am I missing?
if CurrInv <> PrevInv or CurrPOS <> PrevPOS or CurrBOM <> PrevBOM
then ( (if {@Flag_STKL_Alice}
then (CommTypePOS := "";
CommTypeInv := "ALI";
// (if {@Flag_STKL_Alice}
(if {Commission.ARSAP_NAMEEMPL} like 'B%'
// or {Commission.ARSAP_NAMEEMPL} = 'MB Building Products'
// or {Commission.ARSAP_NAMEEMPL} = 'Carlan Group'
// or {Commission.ARSAP_NAMEEMPL} = 'Gerald Fornell'
then (CommRateInv := 10;);
);
);
);NewBOM := "B";
)
else (NewBOM := "";);
Okay, found it, * not %.
Thank you everyone for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would change the variable declarations to initialize the string vars to empty strings so that you don't have to do an "Else". Something like this:
global numbervar CurrInv; global numbervar CurrPOS; global numbervar CurrBOM;
global numbervar PrevInv; global numbervar PrevPOS; global numbervar PrevBOM;
global stringvar NewInv := "";
global stringvar NewPOS := "";
global numbervar CommRatePOS; global numbervar CommRateInv;
global stringvar NewBOM := "";
global stringvar CommTypePOS := "";
global stringvar CommTypeInv := "";
As for the error - is a particular line highlighted when you get it? Your formula looks ok so there may be a data type mismatch between a field and the variable you're assigning it to. Without knowing your data, I can't tell you which one, though.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.