I wrote a function by using the same code used in "Applied Entries" page. In the page it returns a set of records. But in my function, returns entry nos of applied entries for a given Cust. Ledger Entry.
Here is the function :
Parameters :
This is a input parameter, which takes the Entry No of the Cust. Ledger Entry that needs to get the applied entries. If we want to get applied entries for a sales invoice, give the entry no of the cust. ledger entry relates to the sales invoice.
Var Name DataType No CustLedgerEntryNo Integer
Return Value :
The function returns a text value that can be used as a filter to "Cust. Ledger Entry" table "Entry No." field. The return value includes entry nos relate to applied entries. (Eg: 465|486|2586|6389)
Name EntryNoFilter Return Type Text
Local Vareables :
Name DataType Subtype DtldCustLedgEntry1_ Record Detailed Cust. Ledg. Entry DtldCustLedgEntry2_ Record Detailed Cust. Ledg. Entry CustLedgerEntry_ Record Cust. Ledger Entry
GetAppliedCustEntries(CustLedgerEntryNo : Integer) EntryNoFilter : Text
//[S.ROSHAN] -- START
DtldCustLedgEntry1_.SETCURRENTKEY("Cust. Ledger Entry No.");
DtldCustLedgEntry1_.SETRANGE("Cust. Ledger Entry No.",CustLedgerEntryNo);
DtldCustLedgEntry1_.SETRANGE(Unapplied,FALSE);
IF DtldCustLedgEntry1_.FIND('-') THEN
REPEAT
IF DtldCustLedgEntry1_."Cust. Ledger Entry No." = DtldCustLedgEntry1_."Applied Cust. Ledger Entry No." THEN BEGIN
DtldCustLedgEntry2_.INIT;
DtldCustLedgEntry2_.SETCURRENTKEY("Applied Cust. Ledger Entry No.","Entry Type");
DtldCustLedgEntry2_.SETRANGE( "Applied Cust. Ledger Entry No.",DtldCustLedgEntry1_."Applied Cust. Ledger Entry No.");
DtldCustLedgEntry2_.SETRANGE("Entry Type",DtldCustLedgEntry2_."Entry Type"::Application);
DtldCustLedgEntry2_.SETRANGE(Unapplied,FALSE);
IF DtldCustLedgEntry2_.FIND('-') THEN
REPEAT
IF DtldCustLedgEntry2_."Cust. Ledger Entry No." <> DtldCustLedgEntry2_."Applied Cust. Ledger Entry No." THEN BEGIN
CustLedgerEntry_.SETCURRENTKEY("Entry No.");
CustLedgerEntry_.SETRANGE("Entry No.",DtldCustLedgEntry2_."Cust. Ledger Entry No.");
IF CustLedgerEntry_.FIND('-') THEN BEGIN
IF EntryNoFilter = '' THEN
EntryNoFilter := FORMAT(CustLedgerEntry_."Entry No.")
ELSE
EntryNoFilter := EntryNoFilter + '|' + FORMAT(CustLedgerEntry_."Entry No.");
END;
END;
UNTIL DtldCustLedgEntry2_.NEXT = 0;
END ELSE BEGIN
CustLedgerEntry_.SETCURRENTKEY("Entry No.");
CustLedgerEntry_.SETRANGE("Entry No.",DtldCustLedgEntry1_."Applied Cust. Ledger Entry No.");
IF CustLedgerEntry_.FIND('-') THEN BEGIN
IF EntryNoFilter = '' THEN
EntryNoFilter := FORMAT(CustLedgerEntry_."Entry No.")
ELSE
EntryNoFilter := EntryNoFilter + '|' + FORMAT(CustLedgerEntry_."Entry No.");
END;
END;
UNTIL DtldCustLedgEntry1_.NEXT = 0;
//[S.ROSHAN] -- END
Hope this is useful. Thank You.