Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OE xapi item entry problem

Status
Not open for further replies.

blairwatkins

Programmer
Aug 17, 2008
6
NZ
Hi I hope someone can help with a problem I am having with inserting items into an order header.

If I don't add any items the order inserts fine but when I try to insert an item into the order it fails with 1180 error number "Invalid revision API state or call".

I am quite sure I have all the correct views open but am a little unsure about the LINENUM or if I need to set the ORDUNIQ for the items as the insert for the order header happens after the detail. I am using C with the XAPI which there is very little documentation on. Any help would be much apprectiated.

DWORD EnterOrder( char *custno, char *shipto, long numItems, char *items[], char *quantities[])
{
//DEFINE THE VARS
CHAR orderuniq [SIZEOF_OEORDH_ORDUNIQ];
CHAR cust [SIZEOF_OEORDH_CUSTOMER+1];
CHAR ship [SIZEOF_OEORDH_SHIPTO+1];
CHAR item [SIZEOF_OEORDD_ITEM+1];
CHAR quantity [SIZEOF_OEORDD_QTYORDERED+1];
INT linenum [SIZEOF_OEORDD_LINENUM];
int i;

//FORMAT CUSTOMER AND SHIPTO FOR ORDER HEADER
strCopyBZ (cust, SIZEOF_OEORDH_CUSTOMER, custno);
cust [SIZEOF_OEORDH_CUSTOMER] = 0;
strCopyBZ (ship, SIZEOF_OEORDH_SHIPTO, shipto);
ship [SIZEOF_OEORDH_SHIPTO] = 0;

//SET ORDER HEADER
_fmemset (orderuniq, 0, SIZEOF_OEORDH_ORDUNIQ);
SUCCEEDED_AT( PUT_FIELD ( oeordh, orderuniq, OEORDH, ORDUNIQ, FALSE) );
SUCCEEDED_AT( xapiViewInit (session, oeordh.rvh, oeordh.view) );
SUCCEEDED_AT( PUT_FIELD (oeordh, cust, OEORDH, CUSTOMER, TRUE) );
SUCCEEDED_AT( PUT_FIELD (oeordh, ship, OEORDH, SHIPTO, TRUE) );


//LOOP THROUGH THE ITEMS
for( i=0; i<numItems; i++ )
{
//FORMAT THE ITEM STRING
strCopyBZ (item, SIZEOF_OEORDD_ITEM, items);
item [SIZEOF_OEORDD_ITEM] = 0;

//SET THE QUANTITY CHAR STRING TO A DECIMAL
strToBcd( quantities, quantity, SIZEOF_OEORDD_QTYORDERED, 4 );

//GET THE LAST LINENUM
SUCCEEDED_AT( GET_FIELD (oeordd, linenum, OEORDD, LINENUM) );

//CLEAR THE VIEW DATA
SUCCEEDED_AT( xapiViewInit (session, oeordd.rvh, oeordd.view) );

//SET THE ORDER NUMBER
SUCCEEDED_AT( PUT_FIELD ( oeordd, orderuniq, OEORDD, ORDUNIQ, FALSE) );
//SET THE LINENUM
SUCCEEDED_AT( PUT_FIELD (oeordd, linenum, OEORDD, LINENUM, FALSE) );
//SET THE ITEM
SUCCEEDED_AT( PUT_FIELD (oeordd, item, OEORDD, ITEM, TRUE) );
//SET THE QUANTITY
SUCCEEDED_AT( PUT_FIELD (oeordd, quantity, OEORDD, QTYORDERED, TRUE) );

//INSERT THE ITEM
SUCCEEDED_AT( xapiViewInsert (session, oeordd.rvh, oeordd.view) );
}
//END THE FOR LOOP FOR INSERTING PRODUCTS



//INSERT THE ORDER HEADER
SUCCEEDED_AT( xapiViewInsert (session, oeordh.rvh, oeordh.view) );


return XAPI_SUCCESS;

}
 
If you use the views correctly then you do not need to set ORDUNIQ, that is taken care of by the views. The same applies to LINENUM.

Some basics:
Always state which Accpac version and database you are working with, that way we can give version specific advice.
Make sure you are opening and composing the correct views, record a macro to get the information.
Set OEORDH.ORDER = 0 before you do OEORDH.Init
Do not set OEORDD.ORDUNIQ and OEORDD.LINENUM

 
I am working with:
Accpac Version 5.5A
MS SQL Server 2005
5.5A SDK
C using XAPI

Thanks for the response. Good to know that LINENUM and ORDUNIQ are taken care of by the views, unfortunatly still does not solve the issue. I have removed from my code and still same error??

When I record a macro the things that exist in the macro which do not exist in my code are:
PAYMENT 'Payment Number'
PRNCOMPNUM 'Parent Component Number'
COMPNUM 'Component Number'

I have not seen the above in the 1 sample OE insert script I have been basing aspects of mine on.

I have compared my views to that of the macro and everything is identical.

I really don't know where to look next?

Any advice would be good.

Thanks
 
One other thing in regards to the strToBcd looking at the debug information Quantity is looking like it is empty once it goes through the strToBcd function? Not sure if this is correct? Could this error be due to QTYORDERED being empty?

//SET AN ITEM QUANTITY
char item_quantity = "5";

//SET QUANTITY CHAR TO A BCD
strToBcd( item_quantity, quantity, SIZEOF_OEORDD_QTYORDERED, 4 );

//SET THE QUANTITY
SUCCEEDED_AT( PUT_FIELD (oeordd, quantity, OEORDD, QTYORDERED, TRUE) );
 
What happens if you just plug in 5 in the quantity field?
 
It fails at the below line before it gets to the insert line as its expecting a BCD I think?

//SET THE QUANTITY
SUCCEEDED_AT( PUT_FIELD (oeordd, quantity, OEORDD, QTYORDERED, TRUE) );

 
This is some of the fugliest code I've seen in years. Have you thought about using VB or .Net? C, C#, or C++ have zero benefits.
 
Linux, ho lee cow, you must be the first person trying that.

Looking at the variable declaration for quantity something looks off:
CHAR quantity [SIZEOF_OEORDD_QTYORDERED+1];
The quantity variable should be a number, not string. The strToBcd function takes a string and converts it to a number.

The second issue is that I believe your header and detail views are not composed, that is why you are getting the revision list error when you insert the detail record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top