As If Currency Coding Example (API 1.4.2 and EnterpriseOne Tools 9.2.1)

The following example code shows what the code in Example of Coding for Currency would look like using As If currency:

//create a currency processing object
AggregationInfo.CurrencyProcessing currency = new AggregationInfo.CurrencyProcessing(loginEnv);
//select the CURRENCYCODE type of processing
currency.setType(AggregationInfo.CurrencyProcessing.CURRENCYCODE);
//add the key column of CRCD
currency.addToKeyCols("F20112.CRCD");
//add the currency column to be processed as EXPFAMT
currency.addToCurrencyCols("F20112.EXPFAMT");
currency.setAsIfCurrency("USD");
aggregation.setCurrency(currency);

The line highlighted in bold is the Java code line for As If currency, which was added to the currency processing object. The code line specifies that all values should be changed to USD.

The following code shows the JSON output for this example:

{
    "ds_F20112": {
        "output": [
            {
                "groupBy": {
                    "F20112.EMPLOYID": 6002
                },
                "F20112.EXPFAMT_SUM": 5232.88,
                "F20112.EXPFAMT_AVG": 290.72,
                "currencyCode": "USD",
                "currencyDecimals": 2
            },
            {
                "groupBy": {
                    "F20112.EMPLOYID": 6001
                },
                "F20112.EXPFAMT_SUM": 1218.42,
                "F20112.EXPFAMT_AVG": 609.21,
                "currencyCode": "USD",
                "currencyDecimals": 2
            },
            {
                "groupBy": {
                    "F20112.EMPLOYID": 5651
                },
                "F20112.EXPFAMT_SUM": 214.06,
                "F20112.EXPFAMT_AVG": 71.35,
                "currencyCode": "USD",
                "currencyDecimals": 2
            },
            {
                "groupBy": {
                    "F20112.EMPLOYID": 5127
                },
                "F20112.EXPFAMT_SUM": 2845,
                "F20112.EXPFAMT_AVG": 1422.5,
                "currencyCode": "USD",
                "currencyDecimals": 2
            },
            {
                "groupBy": {
                    "F20112.EMPLOYID": 7702
                },
                "F20112.EXPFAMT_SUM": 918,
                "F20112.EXPFAMT_AVG": 306,
                "currencyCode": "USD",
                "currencyDecimals": 2
            }
        ]
    }
}

The following image shows the charting of the data in this example:

This image is described in the surrounding text.