Skip to main content

Notifications

Announcements

No record found.

Implementing SysOperationFramework in Ax2012- Through service class and contract class

Hi,

SysOperationFramework or Business Operations Framework (BOF) is the one newly introduced in AX2012 to substitute Runbasebatch framework. I would like to provide code different code samples to implement BOF. In this post, will provide an example which illustrates its implementation only through service class and contract class(without any controller class). I used a service class (namely) CG_DataService and a contract class (namely)CG_DataContract.

Class: CG_DataContract and Method: classDeclaration

[DataContractAttribute]
class CG_DataContract
{
    ItemId          itemId;
}

Class: CG_DataContract and Method: parmItemId

[DataMemberAttribute]
public Itemid parmItemId(Itemid _itemId = itemId)
{
    itemId = _itemId;

    return itemId;
}

Class: CG_DataService and Method: classDeclaration

class CG_DataService extends SysOperationServiceBase
{
    // Contract Variables
    ItemId                  itemId;   
}

Class: CG_DataService and Method: startOperation

[SysEntryPointAttribute]
public void startOperation(CG_DataContract _dataContract)
{
    System.Exception ex;
    #OCCRetryCount

    itemId         = _dataContract.parmItemId();    

    try
    {
        this.processOperation();
    }

    catch (Exception::Deadlock)
    {
        retry;
    }

    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }

    catch (Exception::Error)
    {
        error(strFmt("Error occured"));
        retry;
    }

    catch (Exception::CLRError)
    {
        ex = ClrInterop::getLastException();

        if (ex != null)
        {
            ex = ex.get_InnerException();
            if (ex != null)
            {
                error(strFmt("Error occured"));
            }
        }

        retry;
    }
}


Class: CG_DataService and Method: processOperation

private void processOperation()
{
   // Displays the selected ItemId
    info(strFmt("%1", itemId));
}

 Create a menuItem by type Action for CG_DataService  class and provide following properties(highlighted in yellow) on it. On execution it displays the itemId we selected.

2046.SOF_2D00_Service.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments