Problem creating Sales Order throught AIF

Latest Axapta / Dynamics AX FAQ Pages

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

Solution (Verified) This post has 1 verified solution | 16 Replies | 3 Followers

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro posted on 2012-3-7 22:51

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

Solution (Verified) Verified Solution

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Solution (Verified) Pedro replied on 2012-3-12 11:58
Verified by Pedro

Ok!

I have found the error. Was a custom event we had in SalesLineType, validateField method. It should throw an uncaptured Exception which gets to AIF. I suppose.

Being able to debug with AIF was the only way to get to the error.

Thanks!

All Replies

Male
17 Posts
433 Points
Joined: 2011-7-12
Last Online:
2014-4-10 1:00
Location: brisbane, australia
shashi replied on 2012-3-8 1:06

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.

Male
2,159 Posts
47,311 Points
Joined: 2003-1-21
Last Online:
2014-12-5 15:28
Location: Herts, England
Moderator

Hi,

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

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

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 10:10

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.

Male
2,159 Posts
47,311 Points
Joined: 2003-1-21
Last Online:
2014-12-5 15:28
Location: Herts, England
Moderator

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.

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 10:30

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;

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 11:06

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

Male
2,159 Posts
47,311 Points
Joined: 2003-1-21
Last Online:
2014-12-5 15:28
Location: Herts, England
Moderator

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

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 12:29

Hi

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

Is that normal?

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 12:29

Hi

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

Is that normal?

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 15:47

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?

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-8 17:30

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

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-9 10:03

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?

Male
2,159 Posts
47,311 Points
Joined: 2003-1-21
Last Online:
2014-12-5 15:28
Location: Herts, England
Moderator

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.

 

 

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

46 Posts
657 Points
Joined: 2012-3-7
Last Online:
2013-8-9 16:39
Location: Gutersloh (Germany)
Pedro replied on 2012-3-9 11:45

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>

Page 1 of 2 (17 items) 1 2 Next > | Get this RSS feed | Bookmark and Share