[S] Check if item category code equals a given Category Code

tompynationtompynation Member Posts: 398
Hi, i have following method:



BerekenPercentageStof(varType : Text[1];valRound : Boolean) : Decimallv_Massa := 0;
lv_TotaalMassa := 0;
lv_Resultaat := 0;

gv_GrondstofSamenStelling.RESET;
IF gv_GrondstofSamenStelling.FINDFIRST THEN BEGIN
REPEAT
lv_Item.GET(gv_GrondstofSamenStelling.Grondstof);
IF lv_Item."Item Category Code" = lv_Item."Item Category Code"::varType THEN
lv_Massa += gv_GrondstofSamenStelling.Hoeveelheid;


UNTIL gv_GrondstofSamenStelling.NEXT = 0;
END;

lv_Resultaat = lv_Massa / lv_TotaalMassa * 100;

IF valRound THEN
EXIT(ROUND(lv_Resultaat,0.001,'>'));
ELSE
EXIT(lv_Resultaat);


Now on this line i get the error when i try to save and compile saying me that 'Isnt an allowed option'

How should i check if the just retrieved item his Item category code, equals the varType : Text[1];

Comments

  • DenSterDenSter Member Posts: 8,305
    First of all, don't use FINDFIRST when you're going to loop through records. That's what FINDSET is for.

    I guess your question is about this line:
    IF lv_Item."Item Category Code" = lv_Item."Item Category Code"::varType
    
    The double colon is used to evaluate option values, and the Item Category Code is not an option value. I'm not quite sure what you want to accomplish, but if you are going to compare values, those values need to be the same data type. So with the Item Category Code field being a Code10 type field, you will need to change the parameter to also be a Code10 type. Then in your code it should then say something like this:
    IF Item."Item Category Code" = parItemCategoryCode THEN ....
    
  • tompynationtompynation Member Posts: 398
    thanks
Sign In or Register to comment.