Hi NAV guys,
I need to filter a set of values from 2 tables. How to use SETRANGE or SETFILTER in below mentioned scenario?
For eg.:
"Customer Posting Group" (table), "Receivables Account" (field) contains 4 records: 12101; 12102, 12103; 12104.
"G/L Entry" (table), "G/L Account No." (field) contains many records. Say totally 20 records. And it contains
3 records in 12101;
3 records in 12102;
4 records in 12103;
0 record in 12104.
How can I filter the above mentioned 10 records alone? I am doing this in dataport. Can anyone help me out in this regard?
Regards,
NAV Pecker.
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Explaining you in little more details. There are two tables.
1. "Customer Posting Group" - This table has a field named "Receivables Account" and this table contains 4 records.
2. "G/L Entry" - This table has a field named "G/L Account No." and this table contains 10 records.
I need to add the Amount field in G/L Entry table by grouping/filtering 12101 seperately (4 records), 12102 (3 records seperately), 12103 (2 records) seperately and 12104 (1 record seperately) and store in a variable varAmount. Also, I should leave the other records which cannot be filtered. This I am doing in dataport and export it. How to proceed with this? Hope I am clear.
Regards,
NAVPecker.
Code :
Customer_Posting_Group.RESET;
Customer_Posting_Group.SETFILTER(Customer_Posting_Group."Receivables Account",'12101|12102|12103|12104');
IF Customer_Posting_Group.FINDFIRST THEN
REPEAT
GL_Entry.RESET;
GL_Entry.SETRANGE(GL_Entry."G/L Account No.",Customer_Posting_Group."Receivables Account");
IF GL_Entry.FINDFIRST THEN
REPEAT
// 1st Time for 12101-4 Times , 2nd Time for 12102-3 Times, 3rd Time for 12103-2 Times, & So On...
UNTIL GL_Entry.NEXT=0;
UNTIL Customer_Posting_Group.NEXT=0;
Note : In Table Customer_Posting_Group "Receivables Account" if not a primary key field. "Receivables Account" Value 12101, may be repeat. If "Receivables Account" 12101 2 times in Table Customer_Posting_Group then upper loop is repeat 2 times for 12101 & inner loop is repeat 1st 12101 - 4 Times, 2nd 12101 - 4 Times.
Hope this helps you.
Thanks & Regards,
Purvesh Maisuria.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!