Thursday, November 7, 2024

Copy Data From One Table To Another Table By Using buf2buf- Ax 2012 BUF2BUF buf2buf

/// <summary>

/// Global class used for generic methods.

/// added by santhosh 

/// </summary>

class LSGlobal

{

    public static void buf2buf(Common  _from, Common  _to)

    {

        DictTable   dictTableFrom   = new DictTable(_from.TableId);

        DictTable   dictTableTo     = new DictTable(_to.TableId);

        DictField   dictFieldFrom;

        FieldId     fieldIdFrom     = dictTableFrom.fieldNext(0);

        FieldId     fieldIdTo;


        while (fieldIdFrom && ! isSysId(fieldIdFrom))

        {

            dictFieldFrom   = new DictField(_from.TableId, fieldIdFrom);


            if(dictFieldFrom)

            {

                fieldIdTo = dictTableTo.fieldName2Id(dictFieldFrom.name());


                if(fieldIdTo)

                _to.(fieldIdTo) = _from.(fieldIdFrom);

            }

            fieldIdFrom = dictTableFrom.fieldNext(fieldIdFrom);

        }

    }



}




Link https://rahulmsdax.blogspot.com/2015/04/copy-data-from-one-table-to-another.html?m=1