cancel
Showing results for 
Search instead for 
Did you mean: 

abuot GetNewObjectKey()

mahmuod_qaid
Explorer
0 Kudos

hi all

i am using sdk for create AR\invoice program working good . but when save invoice  return number of new document  not correct.

for example my program return number of new doc is 16803  . but when search in the last invoice in SAP number deffrent number 16805 .

this code

if (con() == false)

                return;

            SAPbobsCOM.Documents oInvoices = (SAPbobsCOM.Documents)Vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

oInvoices.CardCode = "C99999";

                       // umenty  ugpentry

                        oInvoices.Lines.ItemCode = ItemCode;

                        oInvoices.Lines.Quantity = Quantity;

                        oInvoices.Lines.UnitPrice = UnitPrice;

                        oInvoices.Lines.UoMEntry = UoMEntry;

                        oInvoices.Comments = "by mahmuode pos2";

                        oInvoices.Printed = SAPbobsCOM.PrintStatusEnum.psYes;

                         oInvoices.Lines.Add();

if (lRetCode != 0)

            {

                Vcmp.GetLastError(out lErrCode, out sErrMsg);

                MessageBox.Show(sErrMsg);

            }

            else

            {

                string num = Vcmp.GetNewObjectKey();

                MessageBox.Show("Invoice [" + Vcmp.GetNewObjectKey() + "] created!");

                add_pyment(Convert.ToInt16(num), Convert.ToDouble(label_price.Text));

                print(Convert.ToInt16(num));

               

            } 

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You can used "GetNewObjectCode" instead of "GetNewObjectKey". Because "GetNewObjectKey" is every time SAP user created a document you'll get the result. Unlike in "GetNewObjectCode".

                Dim oJVNumber As String = ""

                oCompany.GetNewObjectCode(oJVNumber)

mahmuod_qaid
Explorer
0 Kudos

thank you also same problem when return number (16805) in SAP is 16807                 string oJVNumber ="";                 Vcmp.GetNewObjectCode(out oJVNumber);

former_member185682
Active Contributor
0 Kudos

Hi Mahmuod,

If the GetNewObjectCode doesn't work, call GetNewObjectKey() and use the value in a query in the database to get the DocNum.

query = "SELECT DocNum FROM OINV WHERE DocEntry = " + yourKey;

Hope it helps.


Best regards,

Diego Lother


View Diego Lother's profile on LinkedIn

former_member185682
Active Contributor
0 Kudos

Hi,

Just to explain the diference between GetNewObjectKey and GetNewObjectCode:

You can use this method GetNewObjectKey, instead of GetNewObjectCode, for development technologies that do not support return value as an Out parameter, such as ASP.

Both methods retrieves the key of the last added record.

Provided by : SDK help file.


Best regards,

Diego Lother


View Diego Lother's profile on LinkedIn