Leader Board

Walkthrough: Creating a Service Using the AIF Document Service Wizard

 

This walkthrough will cover how to create a document query, a new service, and a document schema when you need to create a service that is not included with Application Integration Framework (AIF). You can use services to expose X++ business logic. After you have created a service, you can use it from modules within Microsoft Dynamics AX and external applications. Services enable you to create reusable business logic. For information about which services are included with AIF, see Standard Axd Documents.

In the following scenario, you want to send data to an external system for reporting. You also need to receive information through AIF from an external accounting system and then create a journal entry and its associated lines. In this scenario, a journal and its entries are contained in the LedgerJournalTable and theLedgerJournalTrans tables.

NoteNote

In this example, you will create a new service from a query that has the data source set to LedgerJournalTable and the LedgerJournalTrans tables. The general journal service is already included in AIF so you must be careful when you name objects so that they do not conflict with the existing general journal service. The name of the included class is AxdLedgerGeneralJournal. The query name for the included document is also AxdLedgerGeneralJournal.

The following illustration shows the relationship between the LedgerJournalTable table and the LedgerJournalTrans table (shown here with an abbreviated field list).

Ledger Journal Tables

The tables that contain journal entries.

This walkthrough illustrates the following tasks:

  • Create a document query

  • Create the service

  • Generate the document schema

  • Set up AIF components

  • Deploy the service for sending

  • Code the outbound exchange

  • Deploy the service for receiving

  • Code the inbound exchange

Prerequisites


To complete this walkthrough, you will need:

  • Microsoft Dynamics AX

  • A license file that has access to AIF

Creating a Document Query


You will use the AIF Document Service Wizard to create a service from a document query. The first step is to create the document query. For more information about document queries, see How to: Create a Document Query.

To create a document query
  1. Press CTRL-D to open the AOT, right-click Queries, and then click New Query.

  2. Expand the node for the new query that is named something like Query1.

  3. In the AOT, right-click Data Dictionary, and then click Open New Window.

  4. In the second AOT window, expand the Tables node and drag the LedgerJournalTable table onto the Data Sources node under the new query in the first window. By default, all of the fields in the data source are included in the query.

    For more information, see How to: Create Queries by Using the AOT.

  5. Right-click the new query, and then click Properties. In the Properties sheet, rename the query data source table from LedgerJournalTable_1 toLedgerJournalTable.

  6. In the first AOT window, expand the LedgerJournalTable node. Drag the LedgerJournalTrans table onto the LedgerJournalTable data sources node.

  7. Right-click the new query, click Properties. In the Properties sheet, rename the query data source table from LedgerJournalTrans_1 to LedgerJournalTrans.

  8. Set the JoinMode property to OuterJoin.

  9. In the AOT, click the new query, in the Properties sheet, set the Name property to AxdLedgerJournal.

    NoteNote

    As a best practice, the query name should always be the same as the document class name. This is especially true when you use the AIF Document Service Wizard to generate the service because it defaults the document name to that of the query.

  10. In the AOT, expand the LedgerJournalTrans data source node, right-click Relations, and then select New Relation. By default, a relation is created between the LedgerJournalTable.JournalNum field and the LedgerJournalTrans.JournalNum field. This is because the JournalNum field is of a data type that is based on the LedgerJournalId extended data type which has a relation to the LedgerJournalTable.

  11. Press Ctrl+S to save the AxdLedgerJournal query.

Creating a Service


You will use the AIF Document Service Wizard to create the service, document class, Ax<Table> classes, and other service related artifacts. For more information, see How to: Create a Service Using the AIF Document Service Wizard.

To create a service by using the AIF Document Service Wizard
  1. From the Microsoft Dynamics AX menu, point to Tools, point to Development tools, point to Wizards, and then select AIF Document Service Wizard. The Welcome screen appears.

  2. Click Next.

  3. In the Select document parameters screen, in the Query field, select the AxdLedgerJournal query. The default setting is the document name.

  4. Click Next.

  5. In the Select code generation parameters screen, the Class names default setting is based on the AxdLedgerJournal query selected.

  6. Select the Read and Create service operations that the service will expose. The AxdLedgerJournal class must support reading of a single journal and its entries and the creation of a single journal and its entries. For more information, see Document Class Service Operations.

  7. Click Next.

  8. In the Generate code screen, you can review the artifacts that will be generated, and then click Generate.

  9. The Completed screen displays the artifacts that the wizard created, and then click Finish.

    NoteNote

    The current release generates an error for this scenario. Complete the following steps to compile without an error.

  10. In the Compiler output window, click the Errors and warnings tab, and then double-click the LedgerJournal_LedgerJournalTrans application object name.

  11. Replace the first line with the following code.

    other

    public DimensionLedgerJournal parmInterCoDimension(DimensionLedgerJournal _value = Dimensions::emptyDimension())


  12. Press Ctrl+S to save the changes and close the code editor.


Generating a Document Schema





The document schema or XSD defines the structure and format of the XML that is serialized or deserialized by the document class. In AIF, the schema for each document is generated by iterating through the query associated with the document class. The document schema defines the XML rules for the document. For more information, see Document Schema Overview.

When you use the AIF Document Service Wizard to create a service, it automatically creates an X++ job that you can run to generate the document schema. Use the following steps to generate the document schema for the service.

To generate the document schema for the service



  1. Press Ctrl+Shift+P to open the Projects form.



  2. Expand the Private node, and then double-click the AxdLedgerJournal project. This project contains all of the objects created by the AIF Document Service Wizard that are related to the new service.



  3. Double-click the GenerateXSDSchema_AxdLedgerJournal job to open it in the code editor.



  4. Press F5 to run the job.


When you run this job, it creates a file that contains the schema for all of the fields in the document. The file location is c:\XSDSchema_AxdLedgerJournal.xml. Now that the service has been generated, your scenario may require you to add custom business logic code to the document service classes. For simplicity purposes, we will consider this service implementation complete.

Setting Up the AIF Components





You must do some general setup to use AIF. In the following sections you will configure a file system transport adapter, create and configure a directory, add a channel, and set up the AIF batch services. In this section, you will configure the file system as the transport, and you must first configure a file system adapter.

To configure the file system adapter



  1. On the Setup pane in the Basic module, expand Application Integration Framework, and then click Transport Adapters.



  2. Click on the Adapter class drop-down arrow, and then select the AIFFileSystemAdapter. There may be a slight delay while Microsoft Dynamics AX scans for adapters.



  3. Select Active to make the adapter available for use in a channel.


You must create an inbound and an outbound directory. The inbound directory is where the XML files that come into AIF will be put. The outbound directory is where XML files produced by AIF will be put. When the batch jobs are started, AIF will poll the inbound directory for files.

To create and configure a directory



  1. In Windows Explorer, create an inbound and an outbound directory.



  2. Configure the directories with the appropriate permissions. For more information, see "Configure the file system for AIF" in the Server and Database Administration Help.


The channels associate the file system adapter with the file system directories that you just created. You must create two channels: one for the outbound directory and one for the inbound directory. For more information, see "Create a channel" in the Server and Database Administration Help.

To add the outbound channel



  1. In the Application Integration Framework pane, click Channels.



  2. In the Channels form, press CTRL+N to create a new channel.



  3. Enter the identification information for the new channel, including a unique identifier in the Channel ID field and a friendly name in the Name field.



  4. Select Active to activate the channel.



  5. In the Adapter field, select File System Adapter.



  6. In the Direction field, select Outbound.



  7. In the Address field, select the outbound directory (file folder) that you just created. You can select an existing directory or click Make New Folder to make a new directory.


To add the inbound channel



  1. Press CTRL+N to create a new channel.



  2. Enter the identification information for the new channel, including a unique identifier in the Channel ID field and a friendly name in the Name field.



  3. Click Active to activate the channel.



  4. Select File System Adapter in the Adapter field.



  5. In the Direction field, select Inbound.



  6. In the Address field, select the inbound directory (file folder) that you just created. You can select an existing directory or click Make New Folder to make a new directory.



  7. In the Response channel field, select the outbound channel that you previously created. The response channel is used to respond back to the source endpoint with verification results or error responses to inbound transfers. This is the channel in which AIF will put the sales order that is requested.


Deploying the Service for Sending





In this section, you will deploy the service for sending.

To deploy the service for sending



  1. In the AOT, expand the Services node, right-click the LedgerJournalService service, and then click Properties.



  2. In the Properties sheet, set Namespace to http://tempuri.org. When you deploy your own service, you should use your namespace.



  3. Set the SecurityKey to LedgerJournals. For more information, see Security for AIF Document Services. All services must be secured with a security key.



  4. In the Navigation Pane, click Basic.



  5. In the Setup menu, expand the Application Integration Framework node, and then click Services.



  6. In the AIF Services form, click Refresh. There may be a slight delay while the services are refreshed.



  7. Click Enabled next to the LedgerJournalService service, and then close the AIF Services window.

    NoteNote

    In this example, you will not expose the service as a Web service. For information on how to expose a service as a Web service, see "Configuring document exchanges with Web services" in the Server and Database Administration Help.


After the service is enabled, you must associate it with one or more endpoints in order to send a document. In this section, you will associate a service with an endpoint.

To configure an endpoint



  1. In the Navigation Pane, click Basic, in the Setup pane, expand the Application Integration Framework node, and then click Endpoints.



  2. Select an endpoint other than the Default Endpoint. For information on how to create an endpoint, see "Create an Endpoint" in the Server and Database Administration Help.

    NoteNote

    Be sure to set the Outbound Channel ID. With the endpoint selected, click the General tab. Click the Outbound channel ID dropdown and select the outbound channel you created in an earlier step.



  3. Click the Action policies button.



  4. Click the Action ID drop-down arrow, and then select LedgerJournalService.read.



  5. In the Endpoint Action Policies form, with the LedgerJournalService.read action ID selected, click the Status field, click the drop-down arrow, and then clickEnabled.



  6. Click the Logging mode field, click the drop-down arrow, and then select Log All.



  7. Press Ctrl+S to save the endpoint action policy and leave the Endpoint Action Policies form open.


By default, none of the fields in the new document are selected. You must specify the fields in the service that can be sent in the outbound document for the specified endpoint.

To specify the fields that can be sent



  1. Select LedgerJournalService.read, and then click the Data policies button.



  2. In the Parameter Data Policies form, select the Outbound parameter data policy, and then click Data policies.



  3. In the Endpoint action data policies form, click the Set button, and then click Enable all. The XPath field determines which entity is the source of the data element. In AxdLedgerJournal class, a data element can come from the document class itself, the LedgerJournalTable table, or the LedgerJournalTranstable.



  4. Press Ctrl+S to save the endpoint action data policy and close the forms.


Coding the Outbound Exchange





After a new document is created and you have configured the data that will be sent in an outbound exchange, you need to write code to initiate the document transfer. For this example, you will create a Send electronically button on the Journal form.

The first step in writing the code to send a document is to identify the form from which the exchange will be initiated. The following steps describe how to get the form class name for the Journal form.

To identify the send form



  1. In the Navigation Pane, click General Ledger, in the Journals pane, click General journal.



  2. In the Journals pane, click General journal.



  3. Right-click the Journal form, and then click Setup.



  4. Click the Information tab. The Form name field contains the name of the form, and in this case, it should be LedgerJournalTable form. Click the Querytab to see that the form table is the LedgerJournalTable table.


In this section, you will add a button to the JournalLedgerTable form to initiate the sending of the ledger journal document. The user can send the ledger journal as an original or a duplicate. To do this, the form must contain a MenuButton control with two MenuItemButton controls.

To add a button



  1. In the AOT, expand the Forms node and expand the LedgerJournalTable node. Expand the Designs node, expand the Design node, expand theGroup:Group node, right-click ButtonGroup:ButtonGroup, point to New control, and then click MenuButton.

    NoteNote

    The VendPurchOrderJournal form has the same button structure for sending a purchase order. You can use this form as a reference when implementing your own send button.



  2. Right-click the new MenuButton control, click Properties, and then set the following properties.

    Property

    Value

    Name

    SendXMLMenu

    ConfigurationKey

    AIF

    SecurityKey

    LedgerJournals

    Text

    SendElectronically

    NoteNote

    Be sure to assign the relevant configuration key and security key values based on who has the appropriate security to send the custom document.



  3. In the AOT, right-click the SendXMLMenu button control, point to New control, and then click Button. This button specifies that the user is sending an original message.

    Set the following properties on the new Button control.

    Property

    Value

    Name

    SendXMLOriginal

    Text

    Original



  4. In the AOT, right-click the SendXMLMenu button control, point to New control, and then click Button. This button will specify that the user is sending a duplicate message.

    Set the following properties on the new Button control.

    Property

    Value

    Name

    SendXMLDuplicate

    Text

    Duplicate


When the user clicks the Send electronically button, the clicked event calls two methods from the LedgerJournalTable table:



  • canXMLBeSent



  • sendElectronically


These methods contain the code that sends the ledger journal document.

The canXMLBeSent method ensures that an endpoint has been configured for the selected document action. If there is no endpoint configured, the code returnsfalse. In this section you will add this method to the LedgerJournalTable table.

To add the canXMLBeSent table method



  1. In the AOT. Expand the Data Dictionary node, expand the Tables node, and the expand the LedgerJournalTable node.



  2. Right-click the Methods node, and then click New method.



  3. In the code editor, copy the following code into the new method.

    other

    boolean canXMLBeSent()
    {
    boolean ret;
    AifActionId actionId;
    AifEndpointList endpointList;
    AifConstraint aifConstraint = new AifConstraint();
    AifConstraintList aifConstraintList = new AifConstraintList();
    ;

    actionId =
    AifSendService::getDefaultSendAction(classnum(LedgerJournalService), AifSendActionType::SendByKey);

    if(actionId)
    {
    aifConstraint.parmType(AifConstraintType::NoConstraint);
    aifConstraintList.addConstraint(aifConstraint);

    endpointList = AifSendService::getEligibleEndpoints(actionId,
    aifConstraintList);
    if(endpointList.getEndpointCount()>0)
    {
    ret = true;
    }
    }
    return ret;
    }

The sendElectronically method gets the entity key for the selected journal, calls the method that retrieves the data, serializes that data into an XML message, and then sends the document to the gateway queue.

To add code to the sendElectronically table method



  1. In the AOT, in the LedgerJournalTable table, right-click the Methods node, and then click New method.



  2. In the code editor, copy the following code into the new method.

    other

    void sendElectronically(XMLDocPurpose _xMLDocPurpose, 
    AifSendMode _aifSendMode = AifSendMode::Async)
    {
    AxdSendContext axdSendContext = AxdSendContext::construct();
    AifEntityKey aifEntityKey = AifEntityKey::construct();
    Map keyData;
    AifConstraintList aifConstraintList = new AifConstraintList();
    AifConstraint aifConstraint = new AifConstraint();
    ;
    keyData = SysDictTable::getKeyData(this);

    aifEntityKey.parmTableId(this.TableId);
    aifEntityKey.parmRecId(this.RecId);
    aifEntityKey.parmKeyDataMap(keyData);

    axdSendContext.parmXMLDocPurpose(_xMLDocPurpose);
    axdSendContext.parmSecurity(false);

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

    AifSendService::submitDefault(
    classnum(LedgerJournalService),
    aifEntityKey,
    aifConstraintList,
    _aifSendMode,
    axdSendContext.pack());
    }

In this section you will add code to the clicked events for the SendXMLOriginal and SendXMLDuplicate buttons.

To add code to the button clicked events



  1. In the AOT, expand the Forms node and navigate to the LedgerJournalTable form. Expand the form node, expand the Designs node, expand the Designnode, expand the Group:Group node, expand the ButtonGroup:ButtonGroup node, expand the MenuButton:SendXMLMenu node, and then expand the MenutItemButton:SendXMOriginal node.



  2. Right-click the Methods node, click Override Method, and then select clicked.



  3. In the code editor, enter the following code in the clicked event.

    other

    void clicked()
    {
    LedgerJournalTable ledgerJournalTableLocal;
    ;

    for (ledgerJournalTableLocal = LedgerJournalTable_ds.getFirst(true)
    ? LedgerJournalTable_ds.getFirst(true) : LedgerJournalTable;
    ledgerJournalTableLocal;
    ledgerJournalTableLocal = LedgerJournalTable_ds.getNext())

    // Check to see if document can be sent.
    if (ledgerJournalTableLocal.canXMLBeSent())
    {
    // Send the document.
    ledgerJournalTableLocal.sendElectronically(XMLDocPurpose::Original);
    }
    else
    {
    warning (strfmt("@SYS72175"));
    // TODO Add a ledger journal specific error message to the
    // label file.
    // warning (strfmt("@SYSnnnnn",ledgerJournalTableLocal.JournalNum));
    }
    }


  4. Repeat steps 1 through 3 for the MenuItemButton:SendXMLDuplicate control.



  5. In the clicked event of the MenutItemButton:SendXMLDuplicate button control, change XMLDocPurpose::Original to XMLDocPurpose::Duplicate.


For AIF to begin sending and receiving documents for adapter-based exchanges, the services that move documents through the queues must be running as batch jobs within Microsoft Dynamics AX. For more information, see "Start and stop the asynchronous AIF services" in the Server and Database Administration Help.

To test sending the document, you must have AIF configured properly. For information about how to set up AIF, see "Configuring and Managing AIF" in theServer and Database Administration Help. After you have AIF configured, go to the form. From the Navigation Pane, click General ledger , in the Journals pane, click General journal, and then click the Send electronically button. Click one of the journal lines, and then click the Send electronically button. the selected ledger journal and its lines are serialized into XML with header information and sent to the gateway queue. When the AIF batch services run, the message will be selected from the gateway queue and sent to the destination endpoint. For more information about configuring the AIF batch services, see "Start and stop the asynchronous AIF services" in the Server and Database Administration Help.

You have now completed the steps for the first half of this scenario. You can send data to an external system for reporting. You also want to be able to receive information through AIF from an external accounting system and then create a journal entry and its associated lines.

Deploying the Service for Receiving





In this section you will deploy the service for receiving. The following diagram shows the components involved in an inbound exchange that creates ledger journal entries.

AIF Inbound Exchange

An inbound exchange that creates ledger journal entries.

The fields contained in the inbound XML must be enabled in the endpoint data policy. If you have fields enabled in the data policy and they are marked as required, then those fields must be in the inbound XML or an error is generated. If you have fields enabled in the data policy and they are not marked as required, then those fields can be omitted from the inbound XML. In this example, you will use the default endpoint and the Is default policy checkbox is selected so all fields in the document are selected. In this section, you will see the actions and fields selected for the endpoint.

To associate document actions with the default endpoint



  1. In the Navigation Pane, click Basic, in the Setup pane, expand the Application Integration Framework node, and then click Endpoints.



  2. Select the Default Endpoint, and then click Action policies.



  3. Navigate to the LedgerJournalService.create action ID. Click the Logging mode field, click the drop-down arrow, and then select Log All.



  4. Press Ctrl+S to save the endpoint action policy.


Next, you need to write the code to process the incoming document. This code is located in the Axd<Document> class. The ledger journal document class and its components have been created and the document has been configured in AIF. The following steps detail the code that must be added to the AxdLedgerJournalclass so that the journal entry and lines are created. The code for the entire class can be found in AxdLedgerJournal Class Code.

Coding the Inbound Exchange





The first step in coding the inbound exchange is to update the classDeclaration method with the variables that are needed in the other methods.

To add variables to the service class



  1. Press Ctrl+Shift+P to open the Projects window.



  2. Expand the Private node, and then double-click AxdLedgerJournal to open the project that was created for your service.



  3. The project, query, and service class are named AxdLedgerJournal. Expand the AxdLedgerJournal class, and then double-click classDeclaration to open the code editor.



  4. Add the following code.

    other

    class AxdLedgerJournal extends AxdBase
    {
    LedgerJournalTable ledgerJournTable;
    LedgerJournalTrans ledgerJournTrans;
    AifConstraintList aifConstraintList;
    Set accountNumSet;
    }

The checkLedgerJournalTrans method checks for required data and returns an error if the required elements are not found. When implementing a custom class, you must add new error numbers and messages to Microsoft Dynamics AX and update the class accordingly.

The checkLedgerJournalTrans method is called by the prepareForSave method that runs before the records are saved. In this section, you will add code for custom business logic in a new method called checkLedgerJournalTrans and call it from the prepareForSave method.

To add the checkLedgerJournalTrans method



  1. In the AxdLedgerJournal project, right-click the AxdLedgerJournal class, and then click New Method.



  2. In the code editor, change the code to the following.

    other

    protected void checkLedgerJournalTrans(AxledgerJournalTrans
    _axledgerJournalTrans)
    {
    ;
    if (!_axledgerJournalTrans.parmAmountCurCredit() &&
    !_axledgerJournalTrans.parmAmountCurDebit())
    {
    error("@SYS93726");
    }
    if (!_axledgerJournalTrans.parmAccountNum())
    {
    error("@SYS98575");
    }
    if(_axledgerJournalTrans.parmAmountCurCredit() &&
    _axledgerJournalTrans.parmAmountCurDebit())
    {
    error("@SYS93729");
    }
    }

The initMandatoryFieldsMap method specifies which fields are mandatory in the XML that the document class sends or receives. This method is used to specify mandatory fields for the document without specifying them at the table level. For example, when entering table data in a form, you may not require data for certain fields. However, when accepting data through AIF, you may require that those same data elements must contain data. In this section you will override theinitMandatoryFieldsMap method.

To override the initMandatoryFieldsMap method



  1. In the AxdLedgerJournal project, right-click the AxdLedgerJournal class, point to Override Method, and then click initMandatoryFieldsMap.



  2. In the code editor, change the code to the following.

    other

    protected void initMandatoryFieldsMap()
    {
    super();
    this.setParmMethodAsMandatory(classnum(AxledgerJournalTrans),
    methodstr(AxledgerJournalTrans,parmInvoice));
    this.setParmMethodAsMandatory(classnum(AxledgerJournalTrans),
    methodstr(AxledgerJournalTrans,parmDocumentDate));
    this.setParmMethodAsMandatory(classnum(AxledgerJournalTrans),
    methodstr(AxledgerJournalTrans,parmAccountNum)) ;
    }

In this section you will override the new() constructor in order to initialize the accountNumSet variable.

To override the new constructor



  1. In the AxdLedgerJournal project, right-click the AxdLedgerJournal class, point to Override Method, and then click new.



  2. In the code editor, change the code to the following.

    other

    void new()
    {
    ;
    super();
    accountNumSet = new Set(Types::String);
    }

The AxdLedgerJournal.prepareForSave method overrides the method from the AxdBase class. This method is called for each record in the inbound data before the data is saved to the tables.

NoteNote

In an inbound message, the XML cannot contain data for fields that are non-editable in the table. Fields are non-editable when the AllowEdit property is set to No. That is, for each non-editable table field, the field element must not be in the inbound XML or the field element must be filtered out in the endpoint action data policy.

If the record being processed is the parent ledger journal record, the journal is saved and then locked so it cannot be edited or posted by another user or process, as shown in the code in the next procedure.

If the record being processed is a child ledger transaction record, the checkLedgerJournalTrans method is called to perform data validation on the transaction data. If the record passes validation, it is then updated with the journal number of the newly added journal. The method returns true and then theAxLedgerJournalTrans.save method is called. The process to save the record to the LedgerJournalTrans table follows the standard process for all document classes. In this section you will modify the prepareForSave method.

To override the prepareForSave method



  1. In the AxdLedgerJournal project, double-click the prepareForSave method.



  2. In the code editor, change the code to the following.

    other

    public boolean prepareForSave(AxdStack _axdStack, str _dataSourceName)
    {
    //TODO: Remember to make code for validating fields that
    //are added to the initMandatoryFieldsMap method
    //that are not mandatory in the table
    axLedgerJournalTable axLedgerJournalTable;
    axLedgerJournalTrans axLedgerJournalTrans;
    AxLedgerJournalTrans_CustPaymJour
    axLedgerJournalTrans_CustPaymJour;

    ;
    switch (classidget(_axdStack.top()))
    {
    case classnum(AxLedgerJournalTable) :
    axLedgerJournalTable = _axdStack.top();
    //TODO Put validating code for LedgerJournTable here
    axledgerJournalTable.save();
    ledgerJournTable = axledgerJournalTable.
    ledgerJournalTable();
    //Lock the journal.
    ledgerJournTable.data(
    JournalTableData::updateBlockServer(
    ledgerJournTable,
    JournalBlockLevel::None,
    JournalBlockLevel::InUse));

    // The save method is called above so return false.
    //The base class save will not be called.
    return false;

    case classnum(AxLedgerJournalTrans) :
    axLedgerJournalTrans = _axdStack.top();
    //TODO Put validating code for LedgerJournalTrans here
    this.checkLedgerJournalTrans(axledgerJournalTrans);
    axLedgerJournalTable = axLedgerJournalTrans.parentAxBC();
    axLedgerJournalTrans.parmJournalNum(
    axLedgerJournalTable.parmJournalNum());
    axLedgerJournalTrans_CustPaymJour =
    AxLedgerJournalTrans_CustPaymJour::
    newLedgerJournalTable(
    axLedgerJournalTable.ledgerJournalTable());
    axLedgerJournalTrans.moveAxLedgerJournalTrans(
    axLedgerJournalTrans_CustPaymJour);
    _axdStack.pop();
    _axdStack.push(axLedgerJournalTrans_CustPaymJour);

    // Return true so that the base class save is called.
    return true;

    default :
    error(strfmt("@SYS88979",
    classId2Name(classidget(_axdStack.top()))));
    return false;
    }
    return false;
    }

The updateNow method overrides the method from the AxdBase class. This method is called after the incoming data has been deserialized and saved. In theAxdLedgerJournal class, the journal is unlocked in this method because at the time that this method is called, all of the data has been successfully saved. In this section you will override the updateNow method.

To override the updateNow method



  1. In the AxdLedgerJournal project, right-click the AxdLedgerJournal class, point to Override Method, and then click updateNow.



  2. In the code editor, change the code to the following.

    other

    public void updateNow()
    {
    ;
    // Unlock the journal.
    ledgerJournTable.data(
    JournalTableData::updateBlockServer(
    ledgerJournTable,
    JournalBlockLevel::InUse,
    JournalBlockLevel::None));
    }

After you have written code for the AxdLedgerJournal document class, the inbound XML data must be created and transferred to AIF by your chosen method: file system transfer, MSMQ, BizTalk, or Web services. For more information, see Example of Inbound XML Message and Updating Data With AIF.

Next Steps





When using an adapter-based exchange, such as file system transfer, MSMQ, or BizTalk, you must run the AIF batch services so that the message will be transferred from the transport channel to the gateway queue. The message is then transferred from the gateway queue, deserialized into an AxdLedgerJournalclass and then saved to the database using the Ax<Table> classes. For more information about configuring the AIF batch services, see "Start and stop the asynchronous Application Integration Framework (AIF) services" in the Server and Database Administration Help.

1 comment: