HOW can i take distinct Document no value from G/L entry table?

WITH “G/L Entry” DO BEGIN

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

//START OF SALES INVOICE LINE.
WITH “Sales Invoice Line” DO BEGIN

IF “Sales Invoice Line”.FIND(’-’) THEN BEGIN
REPEAT

IF ( (“G/L Entry”.“Document No.”= “Sales Invoice Line”.“Document No.”)
AND( “Sales Invoice Line”.“Line Discount %”>0) AND( “G/L Entry”.Amount>0) ) THEN BEGIN

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

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

///////////////END OF SALES INVOICE LINE

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

END;

END;

HOW can i take distinct Document no value from G/L entry table?

try something like below

PrevGlDocno is code type variable with length 20

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

IF PrevGlDocno <> “G/L Entry”.“Document No.” THEN BEGIN

PrevGlDocno := “G/L Entry”.“Document No.”;
REPEAT

//START OF SALES INVOICE LINE.
WITH “Sales Invoice Line” DO BEGIN

END;

at first i need to set a value for prevGIDocno and then i can check next value as like if (a[i]<>a[i+1]]) then a[i]=a[i+1];

can you clear more? how can i check here next value? if data is not sorted then, how can i solve this problem?

i want to pick one document no only one time.

example:

1000

1000

1002

1000

output:=1000 and 1002

Yes, you are right

it should be sorted by Document No.

SrNo – PrevGlDocno - “G/L Entry”.“Document No.” - result

1st loop - blank - 1000 - not same so will enter into loop

2nd loop- 1000 - 1000 - same so skip

3rd loop - 1000 - 1002 - not same so will enter into loop…

Think about it a different way. Start with the Sales Invoice Header, which is itself a distinct list of document numbers. From there you can filter / sort your G/L Entries and Sales Invoice Lines.

hi mohona, it is not working.

it is not working.

hi mohona, i tried it, but it is not working.

Then turn on the debugger and step through the code. Write down what you think each of your variables should be before you look at their values in the debugger.

Did you try with my suggestion above? The Sales Invoice Header table already contains a distinct list of document numbers. Why can’t you start with that table?

YES, i am doing according to your suggestion. but payment method code in G/L entry table. when i loop through this table. it repeat data.

WITH “Sales Invoice Line” DO BEGIN

IF “Sales Invoice Line”.FIND(’-’) THEN BEGIN
REPEAT

WITH “G/L Entry” DO BEGIN

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

IF (( “G/L Entry”.“POS Order No.”= “Sales Invoice Line”.“POS Order No.”)

AND ( “Sales Invoice Line”.“Line Discount %”>0) ) THEN BEGIN

CASE “G/L Entry”.“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;

IF (( “G/L Entry”.“POS Order No.”= “Sales Invoice Line”.“POS Order No.”)
AND ( “Sales Invoice Line”.“Inv. Discount Amount”>0) ) THEN BEGIN

CASE “G/L Entry”.“Payment Method Code” OF
‘CASH’:
BEGIN

BycashtotalInvdiscountSIn:= BycashtotalInvdiscountSIn+“Sales Invoice Line”.“Inv. Discount Amount”;

END;

‘CREDCARD’:
BEGIN

BycredittotalInvdiscountSIn:= BycredittotalInvdiscountSIn+“Sales Invoice Line”.“Inv. Discount Amount”;

END;
ELSE BEGIN

ByothertotalInvdiscountSIn:=ByothertotalInvdiscountSIn+“Sales Invoice Line”.“Inv. Discount Amount”;

END;

END;

END;

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

END;

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

yes, i tried. but my payment method code in G/L entry table.

I see you looping through Sales Invoice LINE. I’m talking about the Sales Invoice HEADER.

sorry, i also did it for sales invoice header. but ERP consultant told me that client wants to take payment method code from G/L entry table.

i also did it for sales invoice header table. but payment method code in g/l entry table. consultant suggest me to take payment method code value from gl entry table. otherwise, i did it for sales header table.

then why dont you go and ask the same consultant what is wrong in your code?

http://dynamicsuser.net/forums/p/46482/234938.aspx