Friday, December 19, 2008

Set Examples

static void JobSetExamples(Args _args)

{

    custTable   custTable_1;

    custTable   custTable_2;

    Set         setCustTable_1;

    Set         setCustTable_2;

    Set         compare;



    set record2set(common _record)

    {

        DictTable       dictTable;

        DictField       dictField;

        FieldId         fieldId;

        Set             recordSet;

        ;



        dictTable = new DictTable(_record.tableId);

        recordSet = new Set(Types::String);



        for (fieldId = dictTable.fieldNext(0);fieldId;fieldId = dictTable.fieldNext(fieldId))

        {

            dictField = dictTable.fieldObject(fieldId);

            if (!dictField.isSystem() && dictField.arraySize() == 1)

                recordSet.add(strfmt("%1#%2",dictField.name(),_record.(fieldId)));

        }



        return recordSet;

    }

    ;



    custTable_1            = CustTable::find('4000');

    custTable_2            = CustTable::find('4000');

    custTable_1.AccountNum = "1234";

    custTable_1.Name       = "Test";

    custTable_2.CreditMax  = 333.33;



    setCustTable_1 = record2set(custTable_1);

    setCustTable_2 = record2set(custTable_2);



    compare = Set::difference(setCustTable_1,setCustTable_2);

    print compare.toString();



    compare = Set::difference(setCustTable_2,setCustTable_1);

    print compare.toString();



    compare = Set::intersection(setCustTable_1,setCustTable_2);

    print compare.toString();



    compare = Set::union(setCustTable_1,setCustTable_2);

    print compare.toString();



    pause;

}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...