condition for GL entry document no=salesInvoiceLine Doucment No

hello, i want to compare G/L entry document no=sales Invoice Line document no and then calculation line discount.

With G/L entry DO BEGIN

WITH SALES INovice lIne Do begin

Repeat

Repeat

if G/L Entry.DocumentNO=Sales Invoice Line.Document NO then begin

TOTAL:=TOTAL+sales InvoicelIne.LineDiscount%;

END;

UNTIL SALES INVOICE lINE.NEXT=0;

UNTIL G/L entry .next=0;

but it is not working.

how can i do this?

please help me to write this loop.

You want to do this process for all g/lentries and sales invoice lines?

you need to get the records first and then do repeat like

IF glentry.findset then

repeat

// apply filter on sales invoice line if you want to apply any filters

IF salesinvline.findset then

repeat

// your cal

until salesinvline.next = 0;

until glentry.next = 0;

WITH “G/L Entry” DO BEGIN

WITH “Sales Invoice Line” DO BEGIN

IF “G/L Entry”.FIND(’-’) THEN BEGIN
REPEAT

REPEAT

IF “G/L Entry”.Amount>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

totalcash_posted:= totalcash_posted+“G/L Entry”.Amount;

END;

‘CREDCARD’:
BEGIN

totalcredit_posted:= totalcredit_posted+“G/L Entry”.Amount;

END;
ELSE BEGIN

totalother_posted:= totalother_posted+“G/L Entry”.Amount;

END;

END;
END;

UNTIL “Sales Invoice Line”.NEXT<=0;

UNTIL “G/L Entry”.NEXT<=0;

but when i check glentry.document no=slaes invoice line.documetn no. it is not working?

I dont think it will work also

WITH “G/L Entry” DO BEGIN

WITH “Sales Invoice Line” DO BEGIN

IF “G/L Entry”.FIND(’-’) THEN BEGIN
REPEAT

REPEAT

try with

WITH “G/L Entry” DO BEGIN

IF “G/L Entry”.FIND(’-’) THEN BEGIN
REPEAT

WITH “Sales Invoice Line” DO BEGIN

REPEAT

WITH “G/L Entry” DO BEGIN

IF “G/L Entry”.FIND(’-’) THEN BEGIN
REPEAT

WITH “Sales Invoice Line” DO BEGIN

REPEAT

IF “G/L Entry”.Amount>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

totalcash_posted:= totalcash_posted+“G/L Entry”.Amount;

END;

‘CREDCARD’:
BEGIN

totalcredit_posted:= totalcredit_posted+“G/L Entry”.Amount;

END;
ELSE BEGIN

totalother_posted:= totalother_posted+“G/L Entry”.Amount;

END;

END;
END;

IF GLine.“Inv. Discount (LCY)”>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalInvdiscountGline:= BycashtotalInvdiscountGline+GLine.“Inv. Discount (LCY)”;

END;

‘CREDCARD’:
BEGIN

BycredittotalInvdiscountGline:= BycredittotalInvdiscountGline+GLine.“Inv. Discount (LCY)”;

END;
ELSE BEGIN

ByothertotalInvdiscountGline:= ByothertotalInvdiscountGline+GLine.“Inv. Discount (LCY)”;

END;

END;
END;

IF GLine.“Payment Discount %”>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalPaydiscountGline:= BycashtotalPaydiscountGline+GLine.“Payment Discount %”;

END;

‘CREDCARD’:
BEGIN

BycredittotalPaydiscountGline:= BycredittotalPaydiscountGline+GLine.“Payment Discount %”;

END;
ELSE BEGIN

ByothertotalPaydiscountGline:= ByothertotalPaydiscountGline+GLine.“Payment Discount %”;

END;

END;
END;

IF GLine.“VAT Base Discount %”>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalVatdiscountGline:= BycashtotalVatdiscountGline+GLine.“VAT Base Discount %”;

END;

‘CREDCARD’:
BEGIN

BycredittotalVatdiscountGline:= BycredittotalVatdiscountGline+GLine.“VAT Base Discount %”;

END;
ELSE BEGIN

ByothertotalVatdiscountGline:= ByothertotalVatdiscountGline+GLine.“VAT Base Discount %”;

END;

END;
END;

IF GLine.“Job Line Discount %”>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalPaydiscountGline:= BycashtotalPaydiscountGline+GLine.“Job Line Discount %”;

END;

‘CREDCARD’:
BEGIN

BycredittotalPaydiscountGline:= BycredittotalPaydiscountGline+GLine.“Job Line Discount %”;

END;
ELSE BEGIN

ByothertotalPaydiscountGline:= ByothertotalPaydiscountGline+GLine.“Job Line Discount %”;

END;

END;
END;

IF “Sales Invoice Line”.“Line Discount %”>0 THEN BEGIN
CASE “Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalLinediscountSIn:= BycashtotalLinediscountSIn+“Sales Invoice Line”.“Line Discount %”;

END;

‘CREDCARD’:
BEGIN

BycredittotalLinediscountSIn:= BycredittotalLinediscountSIn+“Sales Invoice Line”.“Line Discount %”;

END;
ELSE BEGIN

ByothertotalLinediscountSIn:=ByothertotalLinediscountSIn+“Sales Invoice Line”.“Line Discount %”;

END;

END;

END;

UNTIL “Sales Invoice Line”.NEXT<=0;

END;
UNTIL “G/L Entry”.NEXT<=0;

END;

END;

where should i check glentry.documentno=sales invoice line document no?

i want to do this with a function. how can i make a function for it?

As I said in my first post

you should add

IF glentry.findset then

repeat

// Here you need to put setrange on Document No.

IF salesinvline.findset then

repeat

// your cal

until salesinvline.next = 0;

until glentry.next = 0;