Problem creating Sales Order throught AIF

Hi all,

I am trying to create a sales order throught AIF in ax 2012 using the File Adapter and I get and error which says that I need to introduce the sales order because the field sales order (auftrag in german) has to be filled.

This happens in my installation but if I try this in the VM with the contoso database everything is fine.

I am relatively new to AIF and I have no idea of the best way to debug or find was is causing the error.

Thanks

  • Is this error from the Exception log?

    Exception log can be found at: System Administration --> Periodic --> Services and Application integration framework --> Exceptions

    That may give more details about the error.

  • Hi,

    Please post the actual error message from Exceptions log as Shashi mentioned.

    Also are you able to manually create a sales order successfully?

  • In reply to Harish Mohanbabu:

    Hi thanks!

    The message is:

    Field Sales order must be filled in.

    I found this strange because with the VM the sales order is created automatically. I also have the right number sequence for sales orders on my system.

  • In reply to Harish Mohanbabu:

    Hi,

    Harish Mohanbabu
    Also are you able to manually create a sales order successfully?

    I suspect number sequence for SO must be wrongly setup in your installation. Please try to create SO manually and let us know.

  • In reply to Harish Mohanbabu:

    Hi!

    I can create a sales order with this code:

     

    SalesTable salesTable;

    SalesLine salesLine;

    NumberSeq NumberSeq;

    ;

     

     

     

     

     

    ttsBegin

    ;

    salesTable.clear();

     

    NumberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());

     

    salesTable.SalesId = NumberSeq.num();

    salesTable.initValue();

    salesTable.CustAccount =

     

    '10001';

    salesTable.initFromCustTable();

    salesTable.DeliveryDate =

     

    mkDate(01,01,2012);

    salesTable.ShippingDateRequested = salesTable.DeliveryDate;

     

     

     

    if

    (!salesTable.validateWrite())

     

     

     

    throw error("I cant write salestable");

    salesTable.insert();

    info(salesTable.SalesId);

     

     

     

    ttsCommit;

  • In reply to Pedro:

    Hi

    There is a way to test/debug the code which AIF runs in order to create this sales order? It would be good to know in which line of code the error comes. I have to make more interfaces and I am spending so much time which only this.

    Thanks

  • In reply to Pedro:

    Hi,

    This was discussed a while back here.  

    Any way for debugging AIF, you have to make code change mentioned here http://blogs.msdn.com/b/dynamics_ax_horizon/archive/2010/09/01/debug-in-aif-classes.aspx

  • In reply to Harish Mohanbabu:

    Hi

    I have checked and AxSalesLine.doSave method is called before than AxSalesTable.doSae method.

    Is that normal?

  • In reply to Harish Mohanbabu:

    Hi

    I have checked and AxSalesLine.doSave method is called before than AxSalesTable.doSave method.

    Is that normal?

  • In reply to Pedro:

    Hi!

    Thanks for the link! Now I am able to debug the AIF code. The problem is that everything works ok but when salesLine.insert is called I get an error because the salesLineType class can not read the previous inserted salesTable.

    I have checked and AxSalesTable doSave and SalesTable.insert are called...

    Maybe a bug out there?

  • In reply to Pedro:

    Hi!

    I am narrowing the error and it happens on SalesTableType.insert just AFTER the ttscommit I have an Exception. I have checked and the ttscommit is ok so I dont understand why I have an exception here if the last sentence of code (ttscommit) is executed ok.

    Quite strange and confusing

  • In reply to Pedro:

    Hi,

    I still have the Exception in SalesTableType insert althought all the code runs until the end of the ttsbegin - ttscommit block. I have checked the events and every time I try this I get this messages:

    Object Server 01: RPC error: RPC exception 1702 occurred in session 11 process is Ax32Serv.exe thread is 6804(User: prodrig1, ClientType: Worker)

    Any ideas?

  • In reply to Pedro:

    Hi,

    RPC exception 1702 has been around for quite some time.  This error can pop up at different scenarios.  One such scenario is detailed here -  http://blogs.msdn.com/b/floditt/archive/2009/01/29/rpc-error-1702-when-calling-a-winapi-method-from-a-batch-job.aspx.   If you google, you will find other scenarios.

    So in the beginning you received this error 'Field Sales order must be filled in'.  And now when you started debugging you receive RPC error.  Is this correct? In this case, you have to trace where exactly you receive these errors and in what order.

    Also please can you post XML file that you are using.

     

     

  • In reply to Harish Mohanbabu:

    Hi,

    With debugging I have discovered that the exception is raised at SalesTableType.insert. I have checked and everything runs ok but at the end after the ttscommit an exception is raised so the SalesTable record is not inserted. Later I get the error about Sales Order field is missing because the system tries to create the sales line but because the sales order was not inserted it can not find it.

    The file is this:

    <?xml version="1.0" encoding="utf-8" ?>

    <Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">

    <Header>

      <MessageId>{5602D03A-4280-404D-9F27-738BE0FEA13E}</MessageId>

      <Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create</Action>

    </Header>

      <Body>

        <MessageParts>

          <SalesOrder xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">

            <SalesTable class="entity">

              <CustAccount>10001</CustAccount>

              <DeliveryDate>2011-10-11</DeliveryDate>

              <PurchOrderFormNum>PO</PurchOrderFormNum>

              <ReceiptDateRequested>2011-11-11</ReceiptDateRequested>

              <SalesLine class="entity">

                <ItemId>1090002</ItemId>

                <SalesQty>18</SalesQty>

                <SalesUnit>kg</SalesUnit>

              </SalesLine>

            </SalesTable>

          </SalesOrder>

        </MessageParts>

      </Body>

    </Envelope>

  • In reply to Harish Mohanbabu:

    Hi, Here is the xml:

    <?xml version="1.0" encoding="utf-8" ?>

    <Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">

    <Header>

      <MessageId>{5602D03A-4280-404D-9F27-738BE0FEA13E}</MessageId>

      <Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create</Action>

    </Header>

      <Body>

        <MessageParts>

          <SalesOrder xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">

            <SalesTable class="entity">

              <CustAccount>10001</CustAccount>

              <DeliveryDate>2011-10-11</DeliveryDate>

              <PurchOrderFormNum>PO</PurchOrderFormNum>

              <ReceiptDateRequested>2011-11-11</ReceiptDateRequested>

              <SalesLine class="entity">

                <ItemId>1090002</ItemId>

                <SalesQty>18</SalesQty>

                <SalesUnit>kg</SalesUnit>

              </SalesLine>

            </SalesTable>

          </SalesOrder>

        </MessageParts>

      </Body>

    </Envelope>

Related
Recommended