Grouping Line Items

Use this procedure to define a statement that groups line items with the same VAT code.
  1. On the next line in the Editor list box, enter the following statement:
    i=1;

    while i <= ildlimit do

    begin

       j=1;
       while j <= stllimit do

       begin

          if $ILD[1][i].#CD12 = $STL[j].#CD12:2 then

          begin

             $STL[j].#LVLA = $STL[j].#LVLA + $ILD[1][i].#LEXC;
             $STL[j].#NRIL = $STL[j].#NRIL + 1;

             break;

          end

          j=j+1;

       end

       if j > stllimit then

       begin

          $STL[j].#SEQA:7 = j;

          $STL[j].#VATP:2 = $ILD[1][i].#VATP;

          $STL[j].#CD12:2 = $ILD[1][i].#CD12;

          $STL[j].#LVLA = $ILD[1][i].#LEXC;

          $STL[j].#NRIL = 1;

          stllimit = stllimit + 1;

       end

       i=i+1;

    end
  2. Press Enter twice to insert a blank line after the statement.
    Note: It is not necessary to include a blank line after this statement. However, doing so may improve readability of the extended rule.