This is how to get applied documents with applied amount from related customer or vendor document using codeunit in C/AL programming.
I created a codeunit to get applied document.You can download the codeunit (fob/txt formats) using following links.
After download object you can change current object id 50000 to another id using txt object.
Now you can import the codeunt to related database.
Now see how to use this codeunit.
This code unit have two functions to get applied docs fro, customer and vendor entries.
These each functions have 3 parameters.
First parameter is what is the document rec (Customer / vendor Ledger Entry) want to get applied document.
Second parameter is temporary rec (Customer / vendor Ledger Entry) to add applied documents details.
Third parameter is Boolean to get applied amount with LCY or not.
***Note : (Delete all the temporary rec data to fresh before get new document applied data).
See the following example.
After call these functions, you can get all applied document record using TEMP (Customer / vendor Ledger Entry) rec. "Amount to Apply" field in TEMP rec is represent applied amount.