i need to add a line in my C/AL but it shows "End"should come here"

Hi All,

i have a C/AL Code that originally handle my target value:

IF gtItem.Strength = 1 THEN
BEGIN
IF gvDimValue.“28 Day Minimum Units” = 0 THEN
gvTarget:= (gtItem.“Specified Strength”*(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)
ELSE
gvTarget:= (gtItem.“Specified Strength”+(gvDimValue."28 Day Minimum"10))/(gvCementTar/100+1);
END
ELSE
BEGIN
IF gvDimValue.“28 Day Minimum Units” = 0 THEN
gvTarget:= (gtItem.“Specified Strength”
(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)
ELSE
gvTarget:= (gtItem.“Specified Strength”+gvDimValue.“28 Day Minimum”)/(gvCementTar/100+1);
END;

Now my report need to handle the specified Strenght value and i need to add it to become like this:

IF gtItem.Strength = 1 THEN
BEGIN
IF gvDimValue.“28 Day Minimum Units” = 0 THEN
gvTarget:= (gtItem.“Specified Strength”(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)
gvSpecStr2:= (gtItem.“Specified Strength”
(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)
ELSE
gvTarget:= (gtItem.“Specified Strength”+(gvDimValue."28 Day Minimum"10))/(gvCementTar/100+1);
gvSpecStr2:= (gtITem.“Specified Strength”+(gvDimValue."28 Day Minimum"10))/(gvCementTar/100+1);
END
ELSE
BEGIN
IF gvDimValue.“28 Day Minimum Units” = 0 THEN
gvTarget:= (gtItem.“Specified Strength”
(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)
gvSpecStr2:= (gtItem.“Specified Strength”
(gvDimValue.“28 Day Minimum”/100))/(gvCementTar/100+1)

ELSE
gvTarget:= (gtItem.“Specified Strength”+gvDimValue.“28 Day Minimum”)/(gvCementTar/100+1);
gvSpecStr2:= (gtItem.“Specified Strength”+gvDimValue.“28 Day Minimum”)/(gvCementTar/100+1);

END;

When i run compile, the NAV shows “End should come here” …

Any idea on how to solve it?

You need to understand WHY you are using BEGIN’s and END’s. They mark the beginning and end of multiple statements. And a SEMICOLON marks the end of a statement. In you first example you had only one statement, so a semicolon was not needed, but in the second you have two statements (which always must be separated by semicolons), so here you also need BEGIN-END’s to work.

           IF gtItem.Strength = 1 THEN BEGIN
              IF gvDimValue."28 Day Minimum Units" = 0 THEN BEGIN
                 gvTarget:= (gtItem."Specified Strength"*(gvDimValue."28 Day Minimum"/100))/(gvCementTar/100+1);
                 gvSpecStr2:= (gtItem."Specified Strength"*(gvDimValue."28 Day Minimum"/100))/(gvCementTar/100+1);
              END ELSE BEGIN
                 gvTarget:= (gtItem."Specified Strength"+(gvDimValue."28 Day Minimum"*10))/(gvCementTar/100+1);
                 gvSpecStr2:= (gtITem."Specified Strength"+(gvDimValue."28 Day Minimum"*10))/(gvCementTar/100+1);
              END                 
           END ELSE BEGIN
              IF gvDimValue."28 Day Minimum Units" = 0 THEN BEGIN
                 gvTarget:= (gtItem."Specified Strength"*(gvDimValue."28 Day Minimum"/100))/(gvCementTar/100+1);
                 gvSpecStr2:= (gtItem."Specified Strength"*(gvDimValue."28 Day Minimum"/100))/(gvCementTar/100+1);
              END ELSE BEGIN
                 gvTarget:= (gtItem."Specified Strength"+gvDimValue."28 Day Minimum")/(gvCementTar/100+1);
                 gvSpecStr2:= (gtItem."Specified Strength"+gvDimValue."28 Day Minimum")/(gvCementTar/100+1);
              END
           END;

The syntax used in AL (both the original AL, C/AL and the new AL) is based upon Pascal. These pages explains it for you: http://wiki.freepascal.org/If and http://wiki.freepascal.org/Begin