cancel
Showing results for 
Search instead for 
Did you mean: 

How to get currently logged in user on 'Bill of Material' Form in Add-Mode

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos
68

Dear All,

I am using a UDF on 'Bill of Material' Form in SAP. This UDF is named as Current_User. I want in this UDF the user name that is currently logged in to SAP. I am able to get user name at form load event. But when 'Bill of Material' Form comes in ADD Mode, the user name doesn't display. What can I do for this problem.? Here is my code:

public override void Handle_SBO_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)

{

BubbleEvent = true;

try

{

if ((mst_FormUIDModal != null))

{

if (FormUID != mst_FormUIDModal)

{

bool dbo_FormFound = false;

foreach (SAPbouiCOM.Form dsa_Form in this.SBO_Application.Forms)

{

if (dsa_Form.UniqueID == mst_FormUIDModal)

{

if (FormUID != mst_FormUIDModal)

{

if (this.SBO_Application.Forms.Item(mst_FormUIDModal).Selected == false)

{

this.SBO_Application.Forms.Item(mst_FormUIDModal).Select();

}

BubbleEvent = false;

return;

}

dbo_FormFound = true;

}

}

if (!dbo_FormFound)

{

this.mst_FormUIDModal = null;

}

}

}

if (pVal.BeforeAction == false)

{

switch (pVal.EventType)

{

case BoEventTypes.et_FORM_LOAD:

{

if (pVal.FormType == -672)

{

Program.Curr_User = SBO_Company.UserName;

doc_form = this.SBO_Application.Forms.GetForm(pVal.FormType.ToString(), pVal.FormTypeCount);

((SAPbouiCOM.EditText)doc_form.Items.Item("U_User").Specific).Value = Program.Curr_User;

}

} break;

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear All,

Please help me regarding my problem. Its really very necessary. Any suggestion will be appreciated.

Former Member
0 Kudos

hai,

You have displayed the current user in edit box only in Form data load event.Upto my knowledge When form mode changes values does not retain in edittext. we need to load the values manually once again when mode changes.

So, like et_FORM_LOAD event, assign the value when add mode is triggered.

In menu event,

if (pVal.BeforeAction == false)

{

Case "1282"

oForm = SBO_Application.Forms.ActiveForm;

if (pVal.FormType == -672)

{

Program.Curr_User = SBO_Company.UserName;

doc_form = this.SBO_Application.Forms.GetForm(pVal.FormType.ToString(), pVal.FormTypeCount);

((SAPbouiCOM.EditText)doc_form.Items.Item("U_User").Specific).Value = Program.Curr_User;

}

}

Hope this helps you.

Thanks & Regards,

Parvatha Solai.N

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear ParvathaSolai,

Thank you for your reply but in Menu Event, how can we get (pVal.FormType). Please review your code & reply me regarding this. Thank You.

Former Member
0 Kudos

Hello

You can define a Formatted Seach, and bind it you your UDF

Select USER_CODE from ousr where usersign = $[USER]

This selects user code (logon name) as FMS.

You may use this. It is easy to implement.

Regards

János

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear ParvathaSolai,

Thanks for your reply. Using your code I have done what I wanted. But now my user defined forms are not working. Because whenever I press CTRL+A, it catches the event written for system form 'Bill of Material' And my form doesn't catch the event written for it. How can I handle it.? Help me please.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

Hi,

You need not to write any sdk code for this task. You just create a user query as mentioned above and save it with some name.

Then Open the Bill Of Material Screen, just click in the required field, then click alt + shift + f2 to assign a Formatted Serach.

Then Select 3 rd Option "Search in Existing User-Defined Values According to Saved Query"

Then Click on the button "Open Saved Query"

It will open the Query Manager. Select the Saved Query.

Enable the Option "Auto Refresh When Field Changes"

In the Drop Down list, select the Value "Parent Item"

Then Select the Option Refresh Regularly or Display Saved Values.

This will automatically put the user code if the parent item is selected.

You an achieve this by without SDK Code.

PS:

There is a change in the Above Query:

Select USER_CODE from ousr where userid = $[USER]

Edited by: Manikandan K on Dec 22, 2011 2:00 PM

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Manikandan K,

Thank you dear for your reply but my problem is that i want the currently logged in user at the form load event. Because I m using a Authorization add-on in which user can watch only those items to which user has permission. And according to your query, user will have to always click on that field.

Answers (0)