Generating the outbound xml file using File system adapater in ax 2012 AIF

  1. Generating the outbound xml file for selected record or single record – using document service(file system adapter).
  2. Generating the outbound xml file for all records( i.e. specified criteria on the query) – using document service(file system adapter).

    Example: Generating the outbound xml file for selected record or single record.
    Below is the code to generate the outbound xml file for the selected record.
    static void GenerateXmlSelectedRecord(Args _args)
    {
    AxdSendContext      axdSendContext  = AxdSendContext::construct();
    AifEntityKey        aifEntityKey    = AifEntityKey::construct();
    AifEntityKeyList    aifEntityKeyList = AifEntityKeyList::construct();
    Map                 keyData;
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    CustTable           custTable;
    int i,j;
    CustCustomerService CustCustomerService = CustCustomerService::construct();
    ;
    custTable = CustTable::find(‘Cust001’);

    keyData = SysDictTable::getKeyData(custTable);
    aifEntityKey.parmTableId(custTable.TableId);
    aifEntityKey.parmRecId(custTable.RecId);
    aifEntityKey.parmKeyDataMap(keyData);

    aifEntityKeyList.addEntityKey(aifEntityKey);

    axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
    axdSendContext.parmSecurity(false);

    aifConstraint.parmType(AifConstraintType::NoConstraint) ;
    aifConstraintList.addConstraint(aifConstraint) ;

    info(strFmt(“%1”,custTable.AccountNum));
    AifSendService::SubmitDefault(  classnum(CustCustomerService),
    aifEntityKey,
    aifConstraintList,
    AifSendMode::Async,
    axdSendContext.pack());
    }

    Example: Generating the outbound xml file for all records( i.e. specified criteria on the query).
    Below is the code to generate the outbound xml for all the records or specified criteria.

    static void GenerateMutiplerecords(Args _args)
    {
    CustTable           custTable;
    AxdSendContext      axdSendContext      = AxdSendContext::construct();
    AifEntityKey        aifEntityKey        = AifEntityKey::construct();
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    AifEndpointList     endpointList;
    AifActionId         actionId;
    Query               query;
    QueryBuildDataSource    qbds;

    query               = new Query(queryStr(AxdCustomer));
    AxdSend::removeChildDs(query);

    actionId            = AifSendService::getDefaultSendAction(classnum(CustCustomerService), AifSendActionType::SendByQuery);
    aifConstraint.parmType(AifConstraintType::NoConstraint);
    aifConstraintList.addConstraint(aifConstraint) ;
    endpointList        = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);

    AifSendService::SubmitFromQuery(actionId,endpointList,query,AifSendMode::Async);
    }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s