Hoje tive que fazer o seguinte select funcionar no ax:

SELECT a.CommissionGroupId, SUM(b.LineAmount)
FROM InventTable a INNER JOIN CustInvoiceTrans b ON a.itemid = b.itemid
WHERE b.invoiceid = ‘U000033’
GROUP BY a.CommissionGroupId;

Esse select, traduzido pra X++ fica:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
static void calculateCommission(Args _args)
{
    InventTable             inventTable;
    CustInvoiceTrans        custInvoiceTrans;
    ;
    while select CommissionGroupId from inventTable group by CommissionGroupId
      join sum(LineAmount) from custInvoiceTrans
    where
      custInvoiceTrans.itemId == inventTable.ItemId &&
      custInvoiceTrans.invoiceId == "U000033"
    {
        .......
    }
}

[]s