Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
gianluca_calloni
Participant

A little and short Blog post to explain what i done to filter data in a Crystal Report depending the user logged in SAP.

Here the link of the discussion where many people help me to solve this "issue": Crystal Report - Sales order filtered by current logged in user

THE GOALS

Create some reports for:

  • Sales Quotation (OQUT / /QUT1)
  • Sales Order (ORDR / RDR1)
  • Sales Delivery (ODLN / DLN1)
  • Sales Invioce (OINV/INV1)

The report show the itemcode, price, discount grouped by BP Code.

In sap we have 3 user (USER_A, USER_B, USER_C) which can see all the data.

Every other user can see only the BP data for which he is sales agent.

So.. We suppose to use sales order tables, but is the same with all other sales documents...

STEP 1

In Crystal Report load the following tables:

  • ORDR
  • RDR1
  • OSLP
  • OHEM
  • OUSR

Then create a join through:

  • ORDR.slpcode and OSLP.slpcode
  • OSLP.slpcode and OHEM.salesprson
  • OHEM.userid and OUSR.userid

STEP 2

Create a parameter PrintByUserName@ which return the user name of the user logged in SAP B1 (from OUSR.U_NAME).

STEP 3

Create a function (i use the name CHEK_USER...) to check which user is logged in.

The code could be:


StringVar Array MasterUser;
StringVar User;
Redim MasterUser [3];
MasterUser[1] := "USER_A";
MasterUser[2] := "USER_B";
MasterUSer[3] :="USER_C";
if ({?PrintByUserName@} in MasterUser) then
(
     User := "*";
)
else
(
     User := {?PrintByUserName}
)


So the function give back the "*" (if the user is USER_A or USER_B or USER_C) or the name of the logged in user if the user is someone else...

STEP 4

In Crystal Report, in the WHERE clause, just put the code


{OUSR.U_NAME} like {@CHECK_USER}

And this is..

If you are USER_A or USER_B or USER_C you can see all the data..

If you are someone else.. You can see only the data for which you are set as Sales Agent.

I hope this could help someone other..

Sorry for my english

Have a nice day

--LUCA

3 Comments
Labels in this area