Skip to Content
0

Adding UDF's and confirmation via DI-API (C#)

Jun 27, 2017 at 02:47 PM

53

avatar image

I have some code to add a few UDF's. It looks like this:

        private void OACTButton_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            //define our company name
            SAPbobsCOM.Company oCompany = (SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany();
            //Let us know that we're doing something
            Application.SBO_Application.SetStatusBarMessage("Adding Fields to OACT. Please wait.", SAPbouiCOM.BoMessageTime.bmt_Short, false);

            SAPbobsCOM.UserFieldsMD oRRecRG = ((SAPbobsCOM.UserFieldsMD)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)));
            //Let us know that we're adding this field
            Application.SBO_Application.SetStatusBarMessage("Adding mwaRRecRG", SAPbouiCOM.BoMessageTime.bmt_Short, false);
            oRRecRG.TableName = "OACT";
            oRRecRG.Name = "mwaRRecRG";
            oRRecRG.Description = "Rev Rec Revenue Group";
            oRRecRG.Type = SAPbobsCOM.BoFieldTypes.db_Alpha;
            oRRecRG.EditSize = 10;
            oRRecRG.Add();
            //Let us know that we're adding this field
            Application.SBO_Application.SetStatusBarMessage("Adding fields to OACT complete.", SAPbouiCOM.BoMessageTime.bmt_Short, false);
        }

The codes works, and the field gets added without any issue. However, there is a significant delay between when it says "Adding fields to OACT complete" and when the field is ACTUALLY added. How would I delay that message from showing up until after the field is finished being added?

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

2 Answers

Danilo Kasparian Jun 27, 2017 at 03:51 PM
1

Just adding more info on what Ankit posted.

To avoid the slowness you don`t need to use GetDICompany everytime you run your event. We usually set a Company as a static var and getDICompany only once (At the beginning of the application), for all events you just use this var without needing to run GetDICompany

Share
10 |10000 characters needed characters left characters exceeded
ANKIT CHAUHAN
Jun 27, 2017 at 02:55 PM
0

Hi Dallin Stone,

Not sure whether I am getting you correctly, you can opt out to try as follows:

lRetCode = oUserFieldsMD.Add();

if (lRetCode != 0)
{
    SBO_Company.GetLastError(out lErrCode, out sErrMsg);
    Interaction.MsgBox(sErrMsg, MsgBoxStyle.Critical, "ARECO");
    return (false);
}
else if (lRetCode == 0)
{
    Application.SBO_Application.SetStatusBarMessage("Adding fields to OACT complete.", SAPbouiCOM.BoMessageTime.bmt_Short, false);
}

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Share
10 |10000 characters needed characters left characters exceeded