Cust/Item Stat by Salesp. - add filter by Item Category Code

emulsifiedemulsified Member Posts: 139
Report 10049 Cust./Item Stat. by Salespers.

How would I add a tab for Item to the report?

The Value Entry table doesn't contain 'Item Category Code' field for Item and I need to filter by 'Item Category Code'.

How can this be accomplished??

Any suggestions?
Half-empy or half-full how do you view your database?

Thanks.

Comments

  • MChilariMChilari Member Posts: 47
    You can accomplish it in multiple ways, one of the easiest way is

    1) Add Item as a data item to the report and set "MaxIteration" Property to 1.
    2) Add Item Category Code" as a flowfield to Value Entry table
    3) Add Code in the On PredataItem of "Value Entry" data item to filter on "Item Category Code" Field.

    Thanks
  • emulsifiedemulsified Member Posts: 139
    I would like to Add Code in the On PredataItem of "Value Entry" data item to filter on "Item Category Code" Field but I am not sure that would work.

    Here is my code:

    Value Entry - OnPreDataItem()
    Item.GET("Value Entry"."Item No.");
    IF Item."Item Category Code" <> 'COSTUMES' THEN CurrReport.SKIP;
    
    CASE SalespersonToUse OF
      SalespersonToUse::"Assigned To Customer":
        SETRANGE("Salespers./Purch. Code");
      SalespersonToUse::"Assigned To Sales Order":
        SETRANGE("Salespers./Purch. Code","Salesperson/Purchaser".Code);
    END;
    
    CurrReport.CREATETOTALS("Invoiced Quantity","Sales Amount (Actual)",Profit,"Discount Amount");
    

    We have items like 4235X-SALE and it has an "Item Category Code" of 'COSTUMES'. So if the current "Value Entry"."Item No." does not have 'COSTUMES' as its "Item Category Code" from the Item table I do not want it to be in the report totals.

    When running this report we do not select a specific Item No. instead for our purpose we use a wildcard like *SALE*|*A* to get the Items we want to be reported on but some items that meet the above criteria fall into several categories so we need a way of limiting our report to Item."Item Category Code" = 'COSTUMES'

    Here is the entire code of the report:
    OBJECT Report 10049 Cust./Item Stat. by Salespers.
    {
      OBJECT-PROPERTIES
      {
        Date=11/30/07;
        Time=[ 9:02:23 PM];
        Modified=Yes;
        Version List=NAVUS3.70;
      }
      PROPERTIES
      {
        CaptionML=[ENU=Cust./Item Stat. by Salespers.;
                   ESM=Estad. cliente/prod. por vendedor;
                   FRC=Statistiques articles/client par repr‚sentant;
                   ENC=Cust./Item Stat. by Salespers.];
        OnPreReport=BEGIN
                      CompanyInformation.GET;
                      FilterString := "Salesperson/Purchaser".GETFILTERS;
                      FilterString2 := Customer.GETFILTERS;
                      FilterString3 := "Value Entry".GETFILTERS;
                      CASE SalespersonToUse OF
                        SalespersonToUse::"Assigned To Customer":
                          SalespersonString := Text002;
                        SalespersonToUse::"Assigned To Sales Order":
                          SalespersonString := Text003;
                        ELSE
                          ERROR(Text001);
                      END;
                    END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table13;
            DataItemTableView=SORTING(Code);
            PrintOnlyIfDetail=Yes;
            ReqFilterHeadingML=[ENU=Salesperson;
                                ESM=Vendedor;
                                FRC=Repr‚sentant;
                                ENC=Salesperson];
            OnPreDataItem=BEGIN
                            CurrReport.CREATETOTALS("Value Entry"."Sales Amount (Actual)",Profit,"Value Entry"."Discount Amount");
                          END;
    
            OnAfterGetRecord=BEGIN
                               CurrReport.NEWPAGEPERRECORD := OnlyOnePerPage;
                             END;
    
            ReqFilterFields=Code,Name;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1692;
              }
              CONTROLS
              {
                { 1001;Label        ;0    ;0    ;7500 ;423  ;FontSize=8;
                                                             FontBold=Yes;
                                                             CaptionML=[ENU=Customer/Item Statistics by Salesperson;
                                                                        ESM=Estad¡sticas cliente/producto por vendedor;
                                                                        FRC=Statistiques client/article par repr‚sentant;
                                                                        ENC=Customer/Item Statistics by Salesperson] }
                { 1002;TextBox      ;14850;0    ;2100 ;423  ;HorzAlign=Right;
                                                             SourceExpr=FORMAT(TODAY,0,4) }
                { 1003;TextBox      ;17100;0    ;1050 ;423  ;HorzAlign=Right;
                                                             SourceExpr=TIME;
                                                             Format=<Hours12>:<Minutes,2> <AM/PM> }
                { 1004;TextBox      ;0    ;423  ;7500 ;423  ;SourceExpr=CompanyInformation.Name }
                { 1005;Label        ;16950;423  ;750  ;423  ;ParentControl=1006;
                                                             HorzAlign=Right }
                { 1006;TextBox      ;17700;423  ;450  ;423  ;CaptionML=[ENU=Page;
                                                                        ESM=P gina;
                                                                        FRC=Page;
                                                                        ENC=Page];
                                                             SourceExpr=CurrReport.PAGENO }
                { 1007;TextBox      ;16650;846  ;1500 ;423  ;HorzAlign=Right;
                                                             SourceExpr=USERID }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 9   ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr="Salesperson/Purchaser".TABLECAPTION + ':  ' + FilterString }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString2 <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 10  ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr=Customer.TABLECAPTION + ':  ' + FilterString2 }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString3 <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 11  ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr="Value Entry".TABLECAPTION + ':  ' + FilterString3 }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=846;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT(CurrReport.PAGENO = 1);
                             END;
    
              }
              CONTROLS
              {
                { 1020000;TextBox   ;0    ;0    ;18150;423  ;SourceExpr=SalespersonString }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1692;
              }
              CONTROLS
              {
                { 12  ;Label        ;0    ;0    ;1650 ;423  ;ParentControl=27;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 13  ;Label        ;3000 ;0    ;4500 ;423  ;ParentControl=28;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 15  ;Label        ;300  ;423  ;1650 ;423  ;ParentControl=34;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 16  ;Label        ;3300 ;423  ;4500 ;423  ;ParentControl=35;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 17  ;Label        ;14400;423  ;1500 ;846  ;ParentControl=49;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes;
                                                             CaptionML=ENU=Price }
                { 20  ;Label        ;6150 ;846  ;2250 ;423  ;ParentControl=46;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 21  ;Label        ;8550 ;846  ;3750 ;423  ;ParentControl=47;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 22  ;Label        ;12750;423  ;1050 ;846  ;ParentControl=48;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 23  ;Label        ;16050;423  ;1800 ;846  ;ParentControl=50;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 1000000000;Label  ;450  ;846  ;1650 ;423  ;VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             CaptionML=ENU=Date }
                { 1000000003;Label  ;3450 ;846  ;2550 ;423  ;VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             CaptionML=ENU=Document Number }
              }
               }
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18150;
                SectionHeight=423;
              }
              CONTROLS
              {
                { 27  ;TextBox      ;0    ;0    ;1500 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Salesperson;
                                                                        ESM=Vendedor;
                                                                        FRC=Repr‚sentant;
                                                                        ENC=Salesperson];
                                                             SourceExpr=Code }
                { 28  ;TextBox      ;3000 ;0    ;4500 ;423  ;CaptionML=[ENU=Salesperson Name;
                                                                        ESM=Nombre vendedor;
                                                                        FRC=Nom du repr‚sentant;
                                                                        ENC=Salesperson Name];
                                                             SourceExpr=Name }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=1269;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 29  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Value Entry"."Sales Amount (Actual)" }
                { 33  ;Label        ;3000 ;423  ;6600 ;423  ;PadChar=.;
                                                             CaptionML=[ENU=Report Totals;
                                                                        ESM=Informe totales;
                                                                        FRC=Rapport des totaux;
                                                                        ENC=Report Totals] }
              }
               }
          }
           }
        { PROPERTIES
          {
            DataItemIndent=1;
            DataItemTable=Table18;
            DataItemTableView=SORTING(Salesperson Code,No.);
            PrintOnlyIfDetail=Yes;
            OnPreDataItem=BEGIN
                            CASE SalespersonToUse OF
                              SalespersonToUse::"Assigned To Customer":
                                BEGIN
                                  SETCURRENTKEY("Salesperson Code","No.");
                                  SETRANGE("Salesperson Code","Salesperson/Purchaser".Code);
                                END;
                              SalespersonToUse::"Assigned To Sales Order":
                                BEGIN
                                  SETCURRENTKEY("No.");
                                  SETRANGE("Salesperson Code");
                                END;
                            END;
    
                            CurrReport.CREATETOTALS("Value Entry"."Sales Amount (Actual)",Profit,"Value Entry"."Discount Amount");
                          END;
    
            ReqFilterFields=No.,Search Name;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18150;
                SectionHeight=1269;
              }
              CONTROLS
              {
                { 34  ;TextBox      ;300  ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Customer No.;
                                                                        ESM=N§ cliente;
                                                                        FRC=Nø de client;
                                                                        ENC=Customer No.];
                                                             SourceExpr="No." }
                { 35  ;TextBox      ;3300 ;423  ;4500 ;423  ;CaptionML=[ENU=Customer Name;
                                                                        ESM=Nombre cliente;
                                                                        FRC=Nom du client;
                                                                        ENC=Customer Name];
                                                             SourceExpr=Name }
                { 36  ;TextBox      ;10050;423  ;2250 ;423  ;SourceExpr="Phone No." }
                { 37  ;TextBox      ;13950;423  ;3750 ;423  ;SourceExpr=Contact }
                { 38  ;Label        ;9000 ;423  ;900  ;423  ;FontBold=Yes;
                                                             CaptionML=[ENU=Phone:;
                                                                        ESM=Tel‚fono:;
                                                                        FRC=T‚l‚phone:;
                                                                        ENC=Phone:] }
                { 39  ;Label        ;12600;423  ;1200 ;423  ;FontBold=Yes;
                                                             CaptionML=[ENU=Contact:;
                                                                        ESM=Contacto:;
                                                                        FRC=Contact :;
                                                                        ENC=Contact:] }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=1692;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 40  ;TextBox      ;0    ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             SourceExpr="Salesperson/Purchaser".Code }
                { 41  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Value Entry"."Sales Amount (Actual)" }
                { 45  ;Label        ;3000 ;423  ;5100 ;423  ;PadChar=.;
                                                             CaptionML=[ENU=Salesperson Totals;
                                                                        ESM=Totales vendedor;
                                                                        FRC=Totaux du repr‚sentant;
                                                                        ENC=Salesperson Totals] }
              }
               }
          }
           }
        { PROPERTIES
          {
            DataItemIndent=2;
            DataItemTable=Table5802;
            DataItemTableView=SORTING(Source Type,Source No.,Item Ledger Entry Type,Item No.,Posting Date)
                              WHERE(Source Type=CONST(Customer),
                                    Item Ledger Entry Type=CONST(Sale),
                                    Expected Cost=CONST(No));
            OnPreDataItem=BEGIN
                            Item.GET("Value Entry"."Item No.");
                            IF Item."Item Category Code" <> 'COSTUMES' THEN CurrReport.SKIP;
    
                            CASE SalespersonToUse OF
                              SalespersonToUse::"Assigned To Customer":
                                SETRANGE("Salespers./Purch. Code");
                              SalespersonToUse::"Assigned To Sales Order":
                                SETRANGE("Salespers./Purch. Code","Salesperson/Purchaser".Code);
                            END;
    
                            CurrReport.CREATETOTALS("Invoiced Quantity","Sales Amount (Actual)",Profit,"Discount Amount");
                          END;
    
            OnAfterGetRecord=BEGIN
                               Profit := "Sales Amount (Actual)" + "Cost Amount (Actual)";
                               "Discount Amount" := -"Discount Amount";
                             END;
    
            ReqFilterFields=Item No.,Inventory Posting Group,Posting Date;
            GroupTotalFields=Item No.;
            DataItemLink=Source No.=FIELD(No.),
                         Global Dimension 1 Code=FIELD(Global Dimension 1 Filter),
                         Global Dimension 2 Code=FIELD(Global Dimension 2 Filter);
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=GroupFooter;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                               IF NOT Item.GET("Item No.") THEN BEGIN
                                 Item.Description  := 'Others';
                                 Item."Base Unit of Measure" := '';
                               END;
                             END;
    
              }
              CONTROLS
              {
                { 46  ;TextBox      ;6150 ;0    ;2250 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Item No." }
                { 47  ;TextBox      ;8550 ;0    ;3600 ;423  ;CaptionML=[ENU=Item Description;
                                                                        ESM=Descripci¢n producto;
                                                                        FRC=Description d'article;
                                                                        ENC=Item Description];
                                                             SourceExpr=Item.Description }
                { 48  ;TextBox      ;12750;0    ;1050 ;423  ;CaptionML=[ENU=Quantity;
                                                                        ESM=Cantidad;
                                                                        FRC=Quantit‚;
                                                                        ENC=Quantity];
                                                             SourceExpr=-"Invoiced Quantity" }
                { 49  ;TextBox      ;14400;0    ;1500 ;423  ;CaptionML=[ENU=Unit of Measure;
                                                                        ESM=Unidad medida;
                                                                        FRC=Unit‚ de mesure;
                                                                        ENC=Unit of Measure];
                                                             SourceExpr=Item."Unit Price" }
                { 50  ;TextBox      ;16050;0    ;1800 ;423  ;CaptionML=[ENU=Amount;
                                                                        ESM=Importe;
                                                                        FRC=Montant;
                                                                        ENC=Amount];
                                                             SourceExpr="Sales Amount (Actual)" }
                { 1000000001;TextBox;450  ;0    ;2250 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Value Entry"."Posting Date" }
                { 1000000002;TextBox;3450 ;0    ;2100 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Value Entry"."Document No." }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=846;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 54  ;TextBox      ;300  ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             SourceExpr=Customer."No." }
                { 55  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Sales Amount (Actual)" }
                { 59  ;Label        ;3300 ;423  ;4800 ;423  ;MultiLine=No;
                                                             PadChar=.;
                                                             CaptionML=[ENU=Customer Totals;
                                                                        ESM=Totales cliente;
                                                                        FRC=Totaux du client;
                                                                        ENC=Customer Totals] }
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=7150;
          Height=990;
          SaveValues=Yes;
        }
        CONTROLS
        {
          { 2   ;CheckBox     ;3410 ;550  ;330  ;440  ;ShowCaption=No;
                                                       SourceExpr=OnlyOnePerPage }
          { 3   ;Label        ;0    ;550  ;3300 ;440  ;ParentControl=2;
                                                       CaptionML=[ENU=New Page per Salesperson;
                                                                  ESM=Nueva p g. por vendedor;
                                                                  FRC=Nouvelle page par repr‚sentant;
                                                                  ENC=New Page per Salesperson] }
          { 1020000;TextBox   ;3410 ;0    ;3740 ;440  ;CaptionML=[ENU=Salesperson To Use;
                                                                  ESM=Vendedor que se utilizar ;
                                                                  FRC=Repr‚sentant … utiliser;
                                                                  ENC=Salesperson To Use];
                                                       OptionCaptionML=[ENU=Assigned To Customer,Assigned To Sales Order;
                                                                        ESM=Asignado a cliente,Asignado a pedido venta;
                                                                        FRC=Affect‚ … client,Affect‚ … document de vente;
                                                                        ENC=Assigned To Customer,Assigned To Sales Order];
                                                       OptionString=Assigned To Customer,Assigned To Sales Order;
                                                       SourceExpr=SalespersonToUse }
          { 1020001;Label     ;0    ;0    ;3300 ;440  ;ParentControl=1020000 }
        }
      }
      CODE
      {
        VAR
          FilterString@1000 : Text[250];
          FilterString2@1001 : Text[250];
          FilterString3@1002 : Text[250];
          Profit@1003 : Decimal;
          "Profit%"@1004 : Decimal;
          OnlyOnePerPage@1005 : Boolean;
          CompanyInformation@1007 : Record 79;
          SalespersonToUse@1020000 : 'Assigned To Customer,Assigned To Sales Order';
          SalespersonString@1020001 : Text[250];
          Text001@1020002 : TextConst 'ENU=Invalid option chosen for Salesperson To Use.;ESM=Opci¢n no v lida para Vendedor que se utilizar .;FRC=Option invalide choisie pour le repr‚sentant … utiliser.;ENC=Invalid option chosen for Salesperson To Use.';
          Text002@1020003 : TextConst 'ENU=Individual sale shows under the Salesperson assigned to that Customer.;ESM=Cada venta se muestra en el vendedor asignado a ese cliente.;FRC=La vente individuelle s''affiche sous le repr‚sentant attribu‚ … ce client.;ENC=Individual sale shows under the Salesperson assigned to that Customer.';
          Text003@1020004 : TextConst 'ENU=Individual sale shows under the Salesperson assigned to that individual Sales Order.;ESM=Cada venta se muestra en el vendedor asignado al correspondiente pedido de venta.;FRC=La vente individuelle s''affiche sous le repr‚sentant attribu‚ … ce document de vente individuel.;ENC=Individual sale shows under the Salesperson assigned to that individual Sales Order.';
          Item@1000000000 : Record 27;
    
        PROCEDURE "CalculateProfit%"@1();
        BEGIN
          IF "Value Entry"."Sales Amount (Actual)" <> 0 THEN
            "Profit%" := ROUND(100 * Profit / "Value Entry"."Sales Amount (Actual)",0.1)
          ELSE
            "Profit%" := 0;
        END;
    
        BEGIN
        END.
      }
    }
    

    Any help would be greatly appreciated.

    Thanks.
    Half-empy or half-full how do you view your database?

    Thanks.
  • emulsifiedemulsified Member Posts: 139
    I would like to Add Code in the On PredataItem of "Value Entry" data item to filter on "Item Category Code" Field but I am not sure that would work.

    Here is my code:

    Value Entry - OnPreDataItem()
    Item.GET("Value Entry"."Item No.");
    IF Item."Item Category Code" <> 'COSTUMES' THEN CurrReport.SKIP;
    
    CASE SalespersonToUse OF
      SalespersonToUse::"Assigned To Customer":
        SETRANGE("Salespers./Purch. Code");
      SalespersonToUse::"Assigned To Sales Order":
        SETRANGE("Salespers./Purch. Code","Salesperson/Purchaser".Code);
    END;
    
    CurrReport.CREATETOTALS("Invoiced Quantity","Sales Amount (Actual)",Profit,"Discount Amount");
    

    We have items like 4235X-SALE and it has an "Item Category Code" of 'COSTUMES'. So if the current "Value Entry"."Item No." does not have 'COSTUMES' as its "Item Category Code" from the Item table I do not want it to be in the report totals.

    When running this report we do not select a specific Item No. instead for our purpose we use a wildcard like *SALE*|*A* to get the Items we want to be reported on but some items that meet the above criteria fall into several categories so we need a way of limiting our report to Item."Item Category Code" = 'COSTUMES'

    Here is the entire code of the report:
    OBJECT Report 10049 Cust./Item Stat. by Salespers.
    {
      OBJECT-PROPERTIES
      {
        Date=11/30/07;
        Time=[ 9:02:23 PM];
        Modified=Yes;
        Version List=NAVUS3.70;
      }
      PROPERTIES
      {
        CaptionML=[ENU=Cust./Item Stat. by Salespers.;
                   ESM=Estad. cliente/prod. por vendedor;
                   FRC=Statistiques articles/client par repr‚sentant;
                   ENC=Cust./Item Stat. by Salespers.];
        OnPreReport=BEGIN
                      CompanyInformation.GET;
                      FilterString := "Salesperson/Purchaser".GETFILTERS;
                      FilterString2 := Customer.GETFILTERS;
                      FilterString3 := "Value Entry".GETFILTERS;
                      CASE SalespersonToUse OF
                        SalespersonToUse::"Assigned To Customer":
                          SalespersonString := Text002;
                        SalespersonToUse::"Assigned To Sales Order":
                          SalespersonString := Text003;
                        ELSE
                          ERROR(Text001);
                      END;
                    END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table13;
            DataItemTableView=SORTING(Code);
            PrintOnlyIfDetail=Yes;
            ReqFilterHeadingML=[ENU=Salesperson;
                                ESM=Vendedor;
                                FRC=Repr‚sentant;
                                ENC=Salesperson];
            OnPreDataItem=BEGIN
                            CurrReport.CREATETOTALS("Value Entry"."Sales Amount (Actual)",Profit,"Value Entry"."Discount Amount");
                          END;
    
            OnAfterGetRecord=BEGIN
                               CurrReport.NEWPAGEPERRECORD := OnlyOnePerPage;
                             END;
    
            ReqFilterFields=Code,Name;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1692;
              }
              CONTROLS
              {
                { 1001;Label        ;0    ;0    ;7500 ;423  ;FontSize=8;
                                                             FontBold=Yes;
                                                             CaptionML=[ENU=Customer/Item Statistics by Salesperson;
                                                                        ESM=Estad¡sticas cliente/producto por vendedor;
                                                                        FRC=Statistiques client/article par repr‚sentant;
                                                                        ENC=Customer/Item Statistics by Salesperson] }
                { 1002;TextBox      ;14850;0    ;2100 ;423  ;HorzAlign=Right;
                                                             SourceExpr=FORMAT(TODAY,0,4) }
                { 1003;TextBox      ;17100;0    ;1050 ;423  ;HorzAlign=Right;
                                                             SourceExpr=TIME;
                                                             Format=<Hours12>:<Minutes,2> <AM/PM> }
                { 1004;TextBox      ;0    ;423  ;7500 ;423  ;SourceExpr=CompanyInformation.Name }
                { 1005;Label        ;16950;423  ;750  ;423  ;ParentControl=1006;
                                                             HorzAlign=Right }
                { 1006;TextBox      ;17700;423  ;450  ;423  ;CaptionML=[ENU=Page;
                                                                        ESM=P gina;
                                                                        FRC=Page;
                                                                        ENC=Page];
                                                             SourceExpr=CurrReport.PAGENO }
                { 1007;TextBox      ;16650;846  ;1500 ;423  ;HorzAlign=Right;
                                                             SourceExpr=USERID }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 9   ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr="Salesperson/Purchaser".TABLECAPTION + ':  ' + FilterString }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString2 <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 10  ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr=Customer.TABLECAPTION + ':  ' + FilterString2 }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT((CurrReport.PAGENO = 1) AND (FilterString3 <> ''));
                             END;
    
              }
              CONTROLS
              {
                { 11  ;TextBox      ;0    ;0    ;18150;423  ;SourceExpr="Value Entry".TABLECAPTION + ':  ' + FilterString3 }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=846;
                OnPreSection=BEGIN
                               CurrReport.SHOWOUTPUT(CurrReport.PAGENO = 1);
                             END;
    
              }
              CONTROLS
              {
                { 1020000;TextBox   ;0    ;0    ;18150;423  ;SourceExpr=SalespersonString }
              }
               }
            { PROPERTIES
              {
                SectionType=Header;
                PrintOnEveryPage=Yes;
                SectionWidth=18150;
                SectionHeight=1692;
              }
              CONTROLS
              {
                { 12  ;Label        ;0    ;0    ;1650 ;423  ;ParentControl=27;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 13  ;Label        ;3000 ;0    ;4500 ;423  ;ParentControl=28;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 15  ;Label        ;300  ;423  ;1650 ;423  ;ParentControl=34;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 16  ;Label        ;3300 ;423  ;4500 ;423  ;ParentControl=35;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 17  ;Label        ;14400;423  ;1500 ;846  ;ParentControl=49;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes;
                                                             CaptionML=ENU=Price }
                { 20  ;Label        ;6150 ;846  ;2250 ;423  ;ParentControl=46;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 21  ;Label        ;8550 ;846  ;3750 ;423  ;ParentControl=47;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 22  ;Label        ;12750;423  ;1050 ;846  ;ParentControl=48;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             MultiLine=Yes }
                { 23  ;Label        ;16050;423  ;1800 ;846  ;ParentControl=50;
                                                             HorzAlign=Right;
                                                             VertAlign=Bottom;
                                                             FontBold=Yes }
                { 1000000000;Label  ;450  ;846  ;1650 ;423  ;VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             CaptionML=ENU=Date }
                { 1000000003;Label  ;3450 ;846  ;2550 ;423  ;VertAlign=Bottom;
                                                             FontBold=Yes;
                                                             CaptionML=ENU=Document Number }
              }
               }
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18150;
                SectionHeight=423;
              }
              CONTROLS
              {
                { 27  ;TextBox      ;0    ;0    ;1500 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Salesperson;
                                                                        ESM=Vendedor;
                                                                        FRC=Repr‚sentant;
                                                                        ENC=Salesperson];
                                                             SourceExpr=Code }
                { 28  ;TextBox      ;3000 ;0    ;4500 ;423  ;CaptionML=[ENU=Salesperson Name;
                                                                        ESM=Nombre vendedor;
                                                                        FRC=Nom du repr‚sentant;
                                                                        ENC=Salesperson Name];
                                                             SourceExpr=Name }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=1269;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 29  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Value Entry"."Sales Amount (Actual)" }
                { 33  ;Label        ;3000 ;423  ;6600 ;423  ;PadChar=.;
                                                             CaptionML=[ENU=Report Totals;
                                                                        ESM=Informe totales;
                                                                        FRC=Rapport des totaux;
                                                                        ENC=Report Totals] }
              }
               }
          }
           }
        { PROPERTIES
          {
            DataItemIndent=1;
            DataItemTable=Table18;
            DataItemTableView=SORTING(Salesperson Code,No.);
            PrintOnlyIfDetail=Yes;
            OnPreDataItem=BEGIN
                            CASE SalespersonToUse OF
                              SalespersonToUse::"Assigned To Customer":
                                BEGIN
                                  SETCURRENTKEY("Salesperson Code","No.");
                                  SETRANGE("Salesperson Code","Salesperson/Purchaser".Code);
                                END;
                              SalespersonToUse::"Assigned To Sales Order":
                                BEGIN
                                  SETCURRENTKEY("No.");
                                  SETRANGE("Salesperson Code");
                                END;
                            END;
    
                            CurrReport.CREATETOTALS("Value Entry"."Sales Amount (Actual)",Profit,"Value Entry"."Discount Amount");
                          END;
    
            ReqFilterFields=No.,Search Name;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=18150;
                SectionHeight=1269;
              }
              CONTROLS
              {
                { 34  ;TextBox      ;300  ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Customer No.;
                                                                        ESM=N§ cliente;
                                                                        FRC=Nø de client;
                                                                        ENC=Customer No.];
                                                             SourceExpr="No." }
                { 35  ;TextBox      ;3300 ;423  ;4500 ;423  ;CaptionML=[ENU=Customer Name;
                                                                        ESM=Nombre cliente;
                                                                        FRC=Nom du client;
                                                                        ENC=Customer Name];
                                                             SourceExpr=Name }
                { 36  ;TextBox      ;10050;423  ;2250 ;423  ;SourceExpr="Phone No." }
                { 37  ;TextBox      ;13950;423  ;3750 ;423  ;SourceExpr=Contact }
                { 38  ;Label        ;9000 ;423  ;900  ;423  ;FontBold=Yes;
                                                             CaptionML=[ENU=Phone:;
                                                                        ESM=Tel‚fono:;
                                                                        FRC=T‚l‚phone:;
                                                                        ENC=Phone:] }
                { 39  ;Label        ;12600;423  ;1200 ;423  ;FontBold=Yes;
                                                             CaptionML=[ENU=Contact:;
                                                                        ESM=Contacto:;
                                                                        FRC=Contact :;
                                                                        ENC=Contact:] }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=1692;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 40  ;TextBox      ;0    ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             SourceExpr="Salesperson/Purchaser".Code }
                { 41  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Value Entry"."Sales Amount (Actual)" }
                { 45  ;Label        ;3000 ;423  ;5100 ;423  ;PadChar=.;
                                                             CaptionML=[ENU=Salesperson Totals;
                                                                        ESM=Totales vendedor;
                                                                        FRC=Totaux du repr‚sentant;
                                                                        ENC=Salesperson Totals] }
              }
               }
          }
           }
        { PROPERTIES
          {
            DataItemIndent=2;
            DataItemTable=Table5802;
            DataItemTableView=SORTING(Source Type,Source No.,Item Ledger Entry Type,Item No.,Posting Date)
                              WHERE(Source Type=CONST(Customer),
                                    Item Ledger Entry Type=CONST(Sale),
                                    Expected Cost=CONST(No));
            OnPreDataItem=BEGIN
                            Item.GET("Value Entry"."Item No.");
                            IF Item."Item Category Code" <> 'COSTUMES' THEN CurrReport.SKIP;
    
                            CASE SalespersonToUse OF
                              SalespersonToUse::"Assigned To Customer":
                                SETRANGE("Salespers./Purch. Code");
                              SalespersonToUse::"Assigned To Sales Order":
                                SETRANGE("Salespers./Purch. Code","Salesperson/Purchaser".Code);
                            END;
    
                            CurrReport.CREATETOTALS("Invoiced Quantity","Sales Amount (Actual)",Profit,"Discount Amount");
                          END;
    
            OnAfterGetRecord=BEGIN
                               Profit := "Sales Amount (Actual)" + "Cost Amount (Actual)";
                               "Discount Amount" := -"Discount Amount";
                             END;
    
            ReqFilterFields=Item No.,Inventory Posting Group,Posting Date;
            GroupTotalFields=Item No.;
            DataItemLink=Source No.=FIELD(No.),
                         Global Dimension 1 Code=FIELD(Global Dimension 1 Filter),
                         Global Dimension 2 Code=FIELD(Global Dimension 2 Filter);
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=GroupFooter;
                SectionWidth=18150;
                SectionHeight=423;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                               IF NOT Item.GET("Item No.") THEN BEGIN
                                 Item.Description  := 'Others';
                                 Item."Base Unit of Measure" := '';
                               END;
                             END;
    
              }
              CONTROLS
              {
                { 46  ;TextBox      ;6150 ;0    ;2250 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Item No." }
                { 47  ;TextBox      ;8550 ;0    ;3600 ;423  ;CaptionML=[ENU=Item Description;
                                                                        ESM=Descripci¢n producto;
                                                                        FRC=Description d'article;
                                                                        ENC=Item Description];
                                                             SourceExpr=Item.Description }
                { 48  ;TextBox      ;12750;0    ;1050 ;423  ;CaptionML=[ENU=Quantity;
                                                                        ESM=Cantidad;
                                                                        FRC=Quantit‚;
                                                                        ENC=Quantity];
                                                             SourceExpr=-"Invoiced Quantity" }
                { 49  ;TextBox      ;14400;0    ;1500 ;423  ;CaptionML=[ENU=Unit of Measure;
                                                                        ESM=Unidad medida;
                                                                        FRC=Unit‚ de mesure;
                                                                        ENC=Unit of Measure];
                                                             SourceExpr=Item."Unit Price" }
                { 50  ;TextBox      ;16050;0    ;1800 ;423  ;CaptionML=[ENU=Amount;
                                                                        ESM=Importe;
                                                                        FRC=Montant;
                                                                        ENC=Amount];
                                                             SourceExpr="Sales Amount (Actual)" }
                { 1000000001;TextBox;450  ;0    ;2250 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Value Entry"."Posting Date" }
                { 1000000002;TextBox;3450 ;0    ;2100 ;423  ;HorzAlign=Left;
                                                             CaptionML=[ENU=Item Number;
                                                                        ESM=N§ producto;
                                                                        FRC=Num‚ro d'article;
                                                                        ENC=Item Number];
                                                             SourceExpr="Value Entry"."Document No." }
              }
               }
            { PROPERTIES
              {
                SectionType=Footer;
                SectionWidth=18150;
                SectionHeight=846;
                OnPreSection=BEGIN
                               "CalculateProfit%";
                             END;
    
              }
              CONTROLS
              {
                { 54  ;TextBox      ;300  ;423  ;1500 ;423  ;HorzAlign=Left;
                                                             SourceExpr=Customer."No." }
                { 55  ;TextBox      ;16050;423  ;1800 ;423  ;SourceExpr="Sales Amount (Actual)" }
                { 59  ;Label        ;3300 ;423  ;4800 ;423  ;MultiLine=No;
                                                             PadChar=.;
                                                             CaptionML=[ENU=Customer Totals;
                                                                        ESM=Totales cliente;
                                                                        FRC=Totaux du client;
                                                                        ENC=Customer Totals] }
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=7150;
          Height=990;
          SaveValues=Yes;
        }
        CONTROLS
        {
          { 2   ;CheckBox     ;3410 ;550  ;330  ;440  ;ShowCaption=No;
                                                       SourceExpr=OnlyOnePerPage }
          { 3   ;Label        ;0    ;550  ;3300 ;440  ;ParentControl=2;
                                                       CaptionML=[ENU=New Page per Salesperson;
                                                                  ESM=Nueva p g. por vendedor;
                                                                  FRC=Nouvelle page par repr‚sentant;
                                                                  ENC=New Page per Salesperson] }
          { 1020000;TextBox   ;3410 ;0    ;3740 ;440  ;CaptionML=[ENU=Salesperson To Use;
                                                                  ESM=Vendedor que se utilizar ;
                                                                  FRC=Repr‚sentant … utiliser;
                                                                  ENC=Salesperson To Use];
                                                       OptionCaptionML=[ENU=Assigned To Customer,Assigned To Sales Order;
                                                                        ESM=Asignado a cliente,Asignado a pedido venta;
                                                                        FRC=Affect‚ … client,Affect‚ … document de vente;
                                                                        ENC=Assigned To Customer,Assigned To Sales Order];
                                                       OptionString=Assigned To Customer,Assigned To Sales Order;
                                                       SourceExpr=SalespersonToUse }
          { 1020001;Label     ;0    ;0    ;3300 ;440  ;ParentControl=1020000 }
        }
      }
      CODE
      {
        VAR
          FilterString@1000 : Text[250];
          FilterString2@1001 : Text[250];
          FilterString3@1002 : Text[250];
          Profit@1003 : Decimal;
          "Profit%"@1004 : Decimal;
          OnlyOnePerPage@1005 : Boolean;
          CompanyInformation@1007 : Record 79;
          SalespersonToUse@1020000 : 'Assigned To Customer,Assigned To Sales Order';
          SalespersonString@1020001 : Text[250];
          Text001@1020002 : TextConst 'ENU=Invalid option chosen for Salesperson To Use.;ESM=Opci¢n no v lida para Vendedor que se utilizar .;FRC=Option invalide choisie pour le repr‚sentant … utiliser.;ENC=Invalid option chosen for Salesperson To Use.';
          Text002@1020003 : TextConst 'ENU=Individual sale shows under the Salesperson assigned to that Customer.;ESM=Cada venta se muestra en el vendedor asignado a ese cliente.;FRC=La vente individuelle s''affiche sous le repr‚sentant attribu‚ … ce client.;ENC=Individual sale shows under the Salesperson assigned to that Customer.';
          Text003@1020004 : TextConst 'ENU=Individual sale shows under the Salesperson assigned to that individual Sales Order.;ESM=Cada venta se muestra en el vendedor asignado al correspondiente pedido de venta.;FRC=La vente individuelle s''affiche sous le repr‚sentant attribu‚ … ce document de vente individuel.;ENC=Individual sale shows under the Salesperson assigned to that individual Sales Order.';
          Item@1000000000 : Record 27;
    
        PROCEDURE "CalculateProfit%"@1();
        BEGIN
          IF "Value Entry"."Sales Amount (Actual)" <> 0 THEN
            "Profit%" := ROUND(100 * Profit / "Value Entry"."Sales Amount (Actual)",0.1)
          ELSE
            "Profit%" := 0;
        END;
    
        BEGIN
        END.
      }
    }
    

    Any help would be greatly appreciated.

    Thanks.
    Half-empy or half-full how do you view your database?

    Thanks.
Sign In or Register to comment.