Output incorrect on Voucher

Hi All, I have question about output on Voucher so I will change it for all voucher in system. I will show output like this.


LineNo. AccNo. Description/Descriptin 2 1000 11000 AAAAAAA /aaaaaaaaaaa 2000 21000 BBBBBBB/bbbbbbbbbbb 3000 11000 AAAAAAA/ccccccccccccc

Problem is description 2 not corrent by AccNo. in each line. Description 2 on line 3000 at AccNo. show on Voucher is AAAAAAA/aaaaaaa is not show correct output is AAAAAAA/ ccccccccccc I will show you two codes that I use for different voucher. but both show incorrect on Description 2. Code No.1 CLEAR(Desc2); PurchInvLine.RESET; PurchInvLine.SETRANGE("Document No.","Document No."); PurchInvLine.SETRANGE(Type,PurchInvLine.Type::"G/L Account"); PurchInvLine.SETRANGE("No.","G/L Account No."); IF PurchInvLine.FIND('-') THEN BEGIN GLEntry.RESET; GLEntry.SETRANGE("Document No.",PurchInvLine."Document No."); GLEntry.SETRANGE("G/L Account No.",PurchInvLine."No."); IF GLEntry.FIND('-') THEN BEGIN REPEAT Desc2 := PurchInvLine."Description 2"; UNTIL GLEntry.NEXT = 0; END; CLEAR(AccDesc); IF GLAcc.GET(AccNo) THEN BEGIN IF Desc2 <> '' THEN AccDesc := Desc + '/' + Desc2; END; IF GLAcc.GET(AccNo) THEN BEGIN IF Desc2 = '' THEN AccDesc := Desc; END; END; Code No.2 CLEAR(AccNo); CLEAR(Desc); CLEAR(Desc2); CLEAR(AccName); IF Type = Type::"G/L Account" THEN AccNo := "No." ELSE IF Type = Type::Item THEN BEGIN IF GenPostingSetup.GET("Gen. Bus. Posting Group","Gen. Prod. Posting Group") THEN AccNo := GenPostingSetup."Purch. Account"; END ELSE IF Type = Type::"Fixed Asset" THEN BEGIN FA.GET("No."); IF FAPostingSetup.GET(FA."FA Posting Group") THEN AccNo := FAPostingSetup."Acquisition Cost Account"; END; PurchLine.RESET; PurchLine.SETRANGE("Document No.","Document No."); PurchLine.SETRANGE(Type,Type::"G/L Account"); PurchLine.SETRANGE("No.","No."); IF PurchLine.FIND('-') THEN BEGIN Desc := PurchLine.Description; Desc2 := PurchLine."Description 2"; END; IF GLAcc.GET(AccNo) THEN BEGIN IF Desc2 <> '' THEN AccName := Desc + '/' + Desc2; END; IF GLAcc.GET(AccNo) THEN BEGIN IF Desc2 = '' THEN AccName := Desc; END; What do you think. What the best code??? for beginner like me. but Actually problem is not codes. Real Problem is output that show on “Description 2” that I mention above. Can anybody help me please? How I should to do? thank for advance klum

Ok, … So step one is to get some keys in there, and that is going to be an issue. Second, your code and use of repeat until is totally wrong, so you need to start again. From what I can see you are trying to link Purchase lines to GL Entry lines, but the problem is that since they are filtered by the same piece of data, how can you link one to the next. Well basically once Navision has linked and used up elements of a key, it then appends the primary key to make the secondary key. Thus you need to do the following. Keep in mind that GL entries will have been posted in the same order that that they were scanned ont he purchase line, so you need to sort and then filter GL entries by Doc No and Posting Date (posting date comes from the Purch Header). I am not going to actually wrtie the code for you, but if this is not enough help, please post further questions for more answers.

Oh and by the way a much easier solution is just to add a flow field to the Purchase Line table, but I did want to try to answert your actual questions, thus my posting above. Just create a flow field witht he following :


Lookup(“G/L Account”.Name WHERE (No.=FIELD(No.)))

please remember to use the Key “Type,No.” and filter type,type::GL account