Report Problem: data from one table printed on wrong line

bryan_Davis
bryan_Davis Member Posts: 3
I'm trying to craft my first report, and I've run into a problem that I can't seem to solve or find described elsewhere.

I'm drawing data from two different tables:

Transfers Buffer (something like an item journal - a custom table)
Item (indented)

The report has a buffers header, a buffers body, an item body, and a buffers footer. In the buffers body, a row has an item number from the buffers table, then item.description, item."vendor no.", etc. populated from the item table so we can easily see what the item is. The line then continues on with more fields from the buffers table.

The item body is blank, 0mm tall, and is only there so I can easily add filters on fields from the item table (like vendor no.) that aren't on the buffer table.

The problem I'm having is that the data in the columns from the item table (item.description, item."vendor no.", etc.) print out not next next to the item number they're associated with, but on the next row down. I don't mean that the report has a whole new line for the item table information, but that the item table information prints out next to the wrong sku!

Because of this, the first row in the report is blank where the item table information is, but the item table information from the last row in the report doesn't show anywhere.

I'm fully ready to believe this is a newbie mistake, but I can't figure out how to undo it. Any suggestions?

Comments

  • couberpu
    couberpu Member Posts: 317
    It sounds like you want all the information from both table to be on the same line. I would define a global variable Item with DataType = Record and SubType = Item ( table27). Then Use Item.GET(<Item No.>) in Buffer - AfterGetRecord. It is something like:
    OBJECT Report 50221 Item Ledger Entry Test
    {
      OBJECT-PROPERTIES
      {
        Date=01/23/07;
        Time=[ 1:07:52 AM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table32;
            DataItemTableView=SORTING(Item No.,Variant Code,Drop Shipment,Location Code,Bin Code,Posting Date);
            OnAfterGetRecord=BEGIN
                               IF Item.GET("Item Ledger Entry"."Item No.") THEN
                                 Desc := Item.Description
                               ELSE
                                 Desc := 'Not on record';
                             END;
           ReqFilterFields=Item No.,Posting Date;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Header;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
                { 1000000000;Label  ;0    ;0    ;1500 ;846  ;ParentControl=1000000001;
                                                             HorzAlign=Left;
                                                             VertAlign=Bottom;
                                                             MultiLine=Yes }
                { 1000000002;Label  ;3600 ;0    ;1500 ;846  ;ParentControl=1000000003;
                                                             HorzAlign=Left;
                                                             VertAlign=Bottom;
                                                             MultiLine=Yes }
                { 1000000005;Label  ;6300 ;0    ;1500 ;846  ;ParentControl=1000000004;
                                                             HorzAlign=Left;
                                                             VertAlign=Bottom;
                                                             MultiLine=Yes }
              }
               }
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
                { 1000000001;TextBox;0    ;0    ;3300 ;423  ;SourceExpr=Item."No." }
                { 1000000003;TextBox;3600 ;0    ;2550 ;423  ;SourceExpr="Item Ledger Entry"."Entry No." }
                { 1000000004;TextBox;6300 ;0    ;3600 ;423  ;CaptionML=ENU=Description;
                                                             SourceExpr=Desc }
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          Item@1000000000 : Record 27;
          Desc@1000000001 : Text[60];
    
        BEGIN
        END.
      }
    }
    
  • kine
    kine Member Posts: 12,562
    Your problem is that the Item dataitem is processed AFTER Buffer dataitem Body section (the dataitems are processed in top-down order).

    As couberpu wrote, you need to get the Item in Buffer dataitem and use the data from this record in the Buffer body section.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bryan_Davis
    bryan_Davis Member Posts: 3
    Couberpu, Kine - thanks very much for the response!

    Actually, I'd tried exactly what you suggested last night, going as far as to but the global variable next to the named field (ItemDesc as the global, and Item.Description as the named field), but the results were the same.

    Kin (from the other post) - I had hesitated to do what you suggested because I was worried about losing the ability to filter on both tables, but I tried it this morning, and it worked perfectly! Thanks very much. Moving the line down into the Item body was definitely the trick. :D

    Sorry about the double-post!