cancel
Showing results for 
Search instead for 
Did you mean: 

Differentiating add and update item event

former_member211473
Contributor
0 Kudos

While developing an addon i need to differentiate between form add and update mode

here is my code for add option -

private void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
    {
        BubbleEvent = true;
        if (((pVal.ItemUID == "1") & (pVal.EventType == SAPbouiCOM.BoEventTyes.et_ITEM_PRESSED) & (pVal.Before_Action == false)))
        {
            if(oForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE)
            {
             // code for adding values
             }
         }

and here is my code for update -

 if (((pVal.ItemUID == "1") & (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) & (pVal.ActionSuccess == true)))
        {
            if ((oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE))
            {
               //   code for update
            }
        }
   }

while add block is working fine and update block isn't.

The control doesn't enter the below mention update block.

 if ((oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE))
            {
               //   code for update
            }  

If i remove the above block ( boformmode=update mode ) and directly write my update code under actionsucces = true, i am able to update my field values, but it contradicts with the find button.

I am using a single button with id = 1;

how should i manage my requirement ?? Any valuable inputs ?? please suggest !!

Thank You

Ranu Vijay

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member416544
Participant
0 Kudos

Hi Ranu Vijay,

If you are working with SAP System windows, for the best practice use below line of code

public void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
  
{
BubbleEvent = true;
try
   {
if (BusinessObjectInfo.FormTypeEx == "134" && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.BeforeAction == false && BusinessObjectInfo.ActionSuccess == true && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
{
//code for add
}
if (BusinessObjectInfo.FormTypeEx == "134" && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.BeforeAction == false && BusinessObjectInfo.ActionSuccess == true && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE)
{
//code for update
}
}
   }
  catch (System.Exception ex)
   {
   SBO_Application.MessageBox(ex.Message);
   }

Thanks

Chenna.

former_member211473
Contributor
0 Kudos

Hi Chenna,

I have created my own form, well I understood the logic, will try and update you.

Thank you for your valuable input.

Ranu Vijay

former_member211473
Contributor
0 Kudos

Hi Chenna

If you can provide some valuable input to my another question regarding find options, which I posted today itself, it would be very nice of you.

Thank You

former_member416544
Participant
0 Kudos

Hi Ranu,

If you requirement is full-filled, please close the answer with 'Accept' the answer.

Thanks,

Chenna

former_member416544
Participant
0 Kudos

Hi Ranu,

did you solved the issue?