Code Puzzle

SjoerdSjoerd Member Posts: 13
I have this data in tables 355 (Ledger Entry Dimension) and 359 (Posted Document Dimension).

How can I code to obtain the line nr (in this case 20000) in table 359 when i know that:
Movement number 335 and 336 in table 355 correspond to Doc Nr 1 in Table 359 and that the dimension codes and values are exactly the same.

355

Table Nr Mov. Dimension Code Dimension Value
17 335 DimCode1 Value1
17 335 DimCode2 Value2
17 335 DimCode3 Value3
17 336 DimCode1 Value1
17 336 DimCode2 Value2
17 336 DimCode3 Value4


359
Nº Tabela Doc Nr. Line Nr.Dimension Code Dimension Value
123 Doc Nr 1 10000 DimCode1 Value1
123 Doc Nr 1 10000 DimCode2 Value2
123 Doc Nr 1 10000 DimCode3 Value3
123 Doc Nr 1 20000 DimCode1 Value1
123 Doc Nr 1 20000 DimCode2 Value2
123 Doc Nr 1 20000 DimCode3 Value4


( I later on will need this linenumber to get the corresponding description in table 123, (Purchase Invoice Line))

Comments

  • matttraxmatttrax Member Posts: 2,309
    Well you have G/L Entries as indicated by Table 17 in the ledger entry dimension table. Click Navigate on a Posted Invoice and see how it works. That should start you in the right direction.
  • SjoerdSjoerd Member Posts: 13
    It has to be done in a report, and not in a form!
    to be more especific, in the after get record event from a g/l entry record.
  • AlbertvhAlbertvh Member Posts: 516
    Hi,

    In the gl ledger entry table you have the document number and if the source type field is vendor you should be able to get the purchase Line record. So you could do something like this
    PurchLine.SETRANGE("Document No.,GlLedgerEntry."Document No.");
    IF PurchLine.FINDSET THEN
      REPEAT
        T359.SETRANGE("Document No.",GlLedgerEntry."Document No.");
        T359.SETRANGE("Line No.",PurchLine."Line No.");
        IF T359.FINDSET THEN
          do whatever
      UNTIL PurchLine.NEXT = 0;
    

    Hope this helps

    Albert
  • SjoerdSjoerd Member Posts: 13
    Thank you Albert,

    but I have a question about the Setrange function, how does it work exactly?

    does
    T359.SETRANGE("Line No.",PurchLine."Line No.")
    filter the values in the the t359 table to all those values that have "line no." en de filtered purchline table? I have multiple lines in the the purchline table.
    If it works like this can I filter the t355 table with the dimension values in the 359 table, like this?

    T359.SETRANGE(T359."Dimension Code", "T355"."Dimension Code");
    T359.SETRANGE(T359."Dimension Value Code", "T355"."Dimension Value Code" ) ;

    I tried it but it does not seems to work.
  • AlbertvhAlbertvh Member Posts: 516
    Hi,
    you should filter T355 like this
    T355.setrange("Table ID",DATABASE::"G/L Ledger Entry");
    T355.SETRANGE("Entry No.",GLLedgerEntry."Entry No.");
    IF T355.FINDSET THEN
       REPEAT
          do whatever
       UNTIL T355.NEXT = 0;
    

    You may have to read the General Ledger Setup table to see which dimension you need.

    Edit: Please see the online help for setrange

    Regards,

    Albert
Sign In or Register to comment.