Skip to Content
0

When SAP is checking authorization through DI API?

Nov 22, 2017 at 12:56 PM

93

avatar image
Former Member

I've got such code:

     SAPbobsCOM.Documents mainEntry = ConnectionHolder.GetCompany(Token).GetBusinessObject(BoObjectTypes.oInventoryGenEntry);

 if (mainEntry.Add() != 0)
                   {
                       throw new UDOException(ConnectionHolder.GetCompany(Token).GetLastErrorDescription(), "");
                   }

Is checking authorization is in moment of adding document or I have to write some additional code to check.

I'm wondering if this is SAP issue. My example is that when I have 'No authorization' for closing period. System on UI is working properly and prevent of adding documents but when I'm adding document programaticly system doesn't throw any message.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Nov 30, 2017 at 01:44 PM
0

Solution: SAP note 2108119

Share
10 |10000 characters needed characters left characters exceeded
Johan Hakkesteegt Nov 22, 2017 at 01:16 PM
0

Hi Sebastian,

Usually an addon can connect to B1 in three different ways:

  1. In an internal addon, the DI API will use the user that is logged in at that moment, unless you would have somehow hard coded another user.
  2. An external addon can access a B1 client that is open on the machine at that moment, and the DI API will then also use the logged in user unless you would have somehow hard coded another user.
  3. An external addon can access B1 if you provide it a user name and password.

The question is, which user is actually logging in?

Regards,

Johan

Show 14 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for your answer Johan.

There is no hard coded user as far as I know. How can I check this info about user?

Is that should be in: mainEntry ?

Regards,

Sebastian

0

You need to look at the part of the code that actually creates the connection, so probably the ConnectionHolder object.

Regards,

Johan

0
Former Member

User is ok. I've checked that and is the same programaticly like in UI. Connection holder is holding proper user. Any other suggestions of checking those authorization?

0

You are talking about closing a period, but your code is creating an inventory transaction. All I can think of is to double check the authorization settings for the user.

Perhaps DIEGO LOTHER can shed some more light on this issue, he is better versed in the SDK than I.

I also recommend that you add the SAP Business One SDK tag to this question.

0

Hi Sebastian Straszewski,

Could you please help to provide the screenshot for the case when you are trying to add the document manually via SAP Business One Client?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0
Former Member

2017-11-17-11-36-25.jpg

Hi Ankit,

Here you are.

On screen there is also my configuration.

Kind regards,

Sebastian

1

Hi Sebastian,

Could you please post the DI API code where you close the period as user 'John'?

Regards,

Johan

0
Former Member

Hi Johan,

I don't have such code. Maybe I've wrong understood you. You ask for DI API code where I'm changing status of period from unlocked to locked. Maybe you ask for code where I'm changing authorization for 'No authorization' for closing periods. In both examples we change that only through UI.

Johan could you provide some details to that quastion?

Kind regards,

Sebastian

0

Hi Sebastian,

I just reread your question, and I think I misunderstood. Could you please explain once more what exactly you were able to do with code, that you were not able to do in the client?

Regards,

Johan

0
Former Member

I'm not able to do some staff with code. I think it maybe problem with DI or I need to write some line of code which is handling checking authorizations. By client everything is alright. When user who has authorizaiton setting for closing periods as 'No authorization' program is blocking for creating document. On status bar is message from my screen informing that "User is not authorized for data entry....".

By code there no blocking:

    SAPbobsCOM.Documents mainEntry = ConnectionHolder.GetCompany(Token).GetBusinessObject(BoObjectTypes.oInventoryGenEntry);

if(mainEntry.Add()!=0)

{

thrownew UDOException(ConnectionHolder.GetCompany(Token).GetLastErrorDescription(),"");

}

Kind Regards,

Sebastian

1

Hi Sebastian,

Okay, so if I understand you correctly, the user is not able to add a document in a closed period in the B1 client, but he can add the document through the DI API?

In your code above you have not determined the document's date (DocDate). That means that the document will get added "today". What was the Period Status of the current period at the moment you tested your code? Could you please post a screenshot of the current period settings?

Regards,

Johan

0
Former Member

Hi Johan,

I've chcecked DocDate and it is in period which is closed. Posting period for 11.2017 is set to closed. With those dates everything is ok.

Kind Regards,

Sebastian

0

Hi Sebastian,

In that case, I recommend that you check SAP Notes and if necessary log a message with SAP Support.

The DI API should honor all authorizations. That is the basic idea of the DI API. Your code should throw an exception just like you expected.

Regards,

Johan

0

Hi Sebastian Straszewski,

I would also recommend you to report it to SAP support. Actually, a user with no authorizations to "Closing Period" cannot add Inventory transactions no matter what.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0