Skip to Content
0

Problem with CFL when loading UDO data

Nov 16, 2017 at 02:42 PM

92

avatar image

Hi all,

In order to explain easily the problem we are facing in our UDO form, let's consider we have a simple UDO form with Code and Name columns only. After creating a simple AddOn in B1Studio with user form mapped for this simple UDO, we then added a CFL type 4 (Items) and mapped in the Code TextField of our user form, to allow the selection of any SAP Item (OITM.ItemCode) and add it to our UDO.

The form works correctly when we add, find or delete UDO data.

However, when we select an item in the CFL whose data already exists in or UDO, its data is loaded correctly into the form but BUT the form ALWAYS changes to UPDATE mode, even if we force it to OK mode! We are only showing the UDO data for selected item in CFL, so the form should stay in OK mode after data is loaded into form...

This is the code we use to load UDO data during CFL after event:

        private void EditText0_ChooseFromListAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
{
    SAPbouiCOM.ISBOChooseFromListEventArg pCflArgs = (SAPbouiCOM.ISBOChooseFromListEventArg)pVal;
    if (pCflArgs.SelectedObjects == null) return;

    // Get select CFL ItemCode
    SAPbouiCOM.DataTable dt = pCflArgs.SelectedObjects;
    string sItemCode = dt.GetValue(0, 0).ToString().Trim();

    // Load UDO data for selected Model on form
    SAPbouiCOM.Conditions pConds = new SAPbouiCOM.Conditions();
    SAPbouiCOM.Condition pCond = pConds.Add();
    pCond.Alias = "Code";
    pCond.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
    pCond.CondVal = sItemCode;
    UIAPIRawForm.DataSources.DBDataSources.Item("@TAB").Query(pConds);

    // Force form to go to OK mode: DOES NOT WORK!
    UIAPIRawForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE;
}

Is there any way to force the UDO form to show in OK mode?

We tried several other alternatives, but can't find a solution for it. The last line does not work, and the form ALWAYS changes to UPDATE mode...

Thanks!

mdias

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

2 Answers

Manuel Dias Nov 17, 2017 at 05:10 PM
0

Hi Edy,

I believe the problem is related with the way we load UDO data during the CFL event.

If we load the UDO data with a specific button, it works fine:

        private void Button2_ClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            // Load UDO specific data just for test purposes...
            SAPbouiCOM.Conditions pConds = new SAPbouiCOM.Conditions();
            SAPbouiCOM.Condition pCond = pConds.Add();
            pCond.Alias = "Code";
            pCond.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
            pCond.CondVal = "BB";
            UIAPIRawForm.DataSources.DBDataSources.Item("@TAB").Query(pConds);
        }

However, the same code inside the CFL after event, always sets the form mode in UPDATE mode...

After several attempts, we found the problem: the CFL was defined with AutoFill to true. When we set it to false, the form stays in OK mode after UDO data is loaded. One more UI-API little tricks that complicates B1 development...

Thanks anyway Edy

mdias

Share
10 |10000 characters needed characters left characters exceeded
Edy Simon Nov 17, 2017 at 12:31 AM
0

Hi Manuel,

You should re-think of your process here.
Loading of existing data should be done in 'Find' mode not in 'Ok' or 'Add' mode.
Any alteration of items on the form in 'Ok' mode will change the form mode to 'Update'


Coming to your problem, are you sure the form mode changes right after this event? or is there any other event after this?
Can you see in your event logger and try to set the ok mode in the next event?
Usually form mode will change from OK to 'Update' because there are changes on the UI level. Changes on the DataSource level will not change the form mode.


Regards

Edy

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

Hi Edy,

Thanks for your answer.

I have several problems regarding your comments:

- When you say "event logger", how can I check it? in the past SAP had the B1 event logger app, but it was discontinued... Do you have any other tool that can help tracking easily these B1 events?

- How do you implement the find mode in a UDO form? I tried to use the following code I found in other posts, but it does not work since it conflicts with other form events. If you have a better solution, please let me know.

mdias

// Force data load on my UDO form
UIAPIRawForm.Mode = SAPbouiCOM.BoFormMode.fm_FIND_MODE;
UIAPIRawForm.DataSources.DBDataSources.Item("@MY_UDO").SetValue("Code", 0, "123");
UIAPIRawForm.Items.Item("1").Click(SAPbouiCOM.BoCellClickType.ct_Regular);
0