blairwatkins
Programmer
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 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;
}