Skip to Content
1

Problems on Rollback transaction

Jun 13, 2017 at 07:01 AM

95

avatar image

Hi all.

When I use start transaction and end transaction with SAPbobsCOM.BoWfTransOpt.wf_RollBack, its unable get user fields from UserTable. for example:

oCompany.StartTransaction();
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
/////////////
SAPbobsCOM.UserTable oUserTable = null;
oUserTable = oCompany.UserTables.Item(TableName);
oUserTable.GetByKey(KeyValue);

after this, every user field (oUserTable.UserFields.Fields.Item(FieldName).Value) is empty

10 |10000 characters needed characters left characters exceeded

What SAP version are you using?

0

SAP Business One Version for HANA 9.2 PL04

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

avatar image
Former Member Jun 13, 2017 at 12:08 PM
1

i have checked, and there is a same problem in my code

Share
10 |10000 characters needed characters left characters exceeded
DIEGO LOTHER Jun 13, 2017 at 11:27 AM
-2

Hi Giorgi,

Do you have certain that your KeyValue exists in your database?

When you use GetByKey, you need validate if the method found the register with an if clause. Like this:

if (oUserTable.GetByKey(KeyValue))
{
//Do your logic.
}

Hope it helps.

Kind Regards,

Diego Lother

Show 1 Share
10 |10000 characters needed characters left characters exceeded

The problem is that oUserTable.GetByKey(KeyValue) STOPS WORKING AFTER

oCompany.StartTransaction();

oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);/////////////

It begins to return empty values. The parameter is the same, the record is still in the database, but

oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);///////////// <-- this fragment causes .Getbykey() function return empty values

0
ANKIT CHAUHAN
Jun 13, 2017 at 11:11 AM
0

Hi Giorgi Abulashvili,

Could you please help to provide the exact code that you are using at the moment?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Show 14 Share
10 |10000 characters needed characters left characters exceeded
oCompany.StartTransaction();
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);

string U_accPayable = getUDFValue(oCompany, "BDOSACRT", "U_accPayable", U_accrCode).ToString();

/////////////////////////

public static object getUDFValue(SAPbobsCOM.Company oCompany, string TableName, string FieldName, string KeyValue)
        {            
            SAPbobsCOM.UserTable oUserTable = null;
            oUserTable = oCompany.UserTables.Item(TableName);
            oUserTable.GetByKey(KeyValue);
            if (oUserTable.GetByKey(KeyValue))
            {
                return oUserTable.UserFields.Fields.Item(FieldName).Value;
            }
            else
            {
                return null;
            }
        } 

0

When I commit transaction everything is fine, the function "getUDFValue" returns the correct value, but when I rollback transaction - returns empty value

0

What exactly are you commiting/rollback ?

0

Hi,

Unfortunately, this issue cannot be reproduced on DEMO Database on SAP Business One Version 9.2 PL07. Following code is being used:

oCompany.StartTransaction();
SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
oDoc.CardCode = "C20000";
oDoc.Lines.ItemCode = "A00001";
oDoc.DocDueDate = DateTime.Now;
int AS = oDoc.Add();

if (AS == 0)
{
    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
}
else
{
    string str = oCompany.GetLastErrorDescription();
}
string U_accPayable = getUDFValue(oCompany, "MASTER", "Name", "1").ToString();






public static object getUDFValue(SAPbobsCOM.Company oCompany, string TableName, string FieldName, string KeyValue)
        {
            SAPbobsCOM.UserTable oUserTable = null;
            oUserTable = oCompany.UserTables.Item("MASTER");


            if (oUserTable.GetByKey(KeyValue) == true)
            {
                string str = oUserTable.UserFields.Fields.Item("U_TEST").Value;
                return oUserTable.UserFields.Fields.Item("U_TEST").Value;
            }
            return null;
        }


Could you please confirm your SAP Business One Version?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

SAP Business One Version for HANA 9.2 PL04.

This issue reproduced only when transaction ends with RollBack

0

Hi,

Have you had a chance to look at my code? Could you please confirm whether I am doing exactly the same thing or not?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

I'm doing the same. And "U_accPayable" has empty value after wf_RollBack

0

I copied your code

0

Hi ANKIT/Giorgi,

I have tested exactly the same code provided on the question on SAP B1 9.1 PL 13 and SAP B1 9.2 PL 7 on demo database, without success to reproduce the situation. My database is SQL Server 2014, maybe can be a bug with DI API with Hana.

Giorgi could you share all code executed?

The code that I tested:

                oCompany.StartTransaction();


                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                SAPbobsCOM.UserTable oUserTable = null;
                oUserTable = oCompany.UserTables.Item("GT_COMS");
                if(oUserTable.GetByKey("000000000000000000000000000004"))
                {
                    Console.WriteLine(oUserTable.UserFields.Fields.Item("U_GT_Qtde").Value);
                }

Kind Regards,

Diego Lother

0

Hi, my code is exactly as yours. At first I rollback the transaction and after it get the user table value

0

What exactly are you commiting/rollback ?

0

I create journal entry. This part of code is in another class, but it does not matter. When somewhere you do rollback, after this, UserFields values from UDT are empty

0

Hi,

I have done another test on DEMO Database on SAP Business One 9.2 PL08 Version for SAP HANA but haven't been able to reproduce it.

One more thing, where have you instantiated the "oUserTable", is it inside the Transaction or Outside the Transaction?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

1

Hi. outside the transaction

0