cancel
Showing results for 
Search instead for 
Did you mean: 

Filter default navigation

Former Member
0 Kudos

Greetings.

        I am developing an AddOn, and in one of the screens I need develop a method of navigation that use some filters. In this case, I can only navigate the records of the current month. I am currently making use of a RecordSet and capturing the MenuEvent 'Previous', 'Next' and others. This way I can make the navigation, however, has some problems and have to constantly block the default load method of the SBO.

        So, is there another way to accomplish this filter?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Paulo,

I assumed you are using dbdatasource as your underlying data source for the form.

You can create a condition object and

   oDBDataSource.Query(oConditions)

Regards

Edy

Former Member
0 Kudos

Hi Edy,


But these conditions do not serve only to load the data? I have made use of it, but to load specific records. In search mode, they would serve to filter then?

Thanks,

Regards,

Ph.E

edy_simon
Active Contributor
0 Kudos

Hi Paulo,

Sorry for the late reply.

There seems to be no direct way to filter the navigation button.

But we can make use of this method to show our expected record:

-Catch the before menu event of the Navigation Button.

-Use a RecordSet object to get the next/Previous docEntry you want to show.

-Set the DocEntry/PK of the record into the Condition.

-Execute the DBDataSource.Query(Condition) method

-Set the bubbleevents = false.

Regards

Edy

Former Member
0 Kudos

Hi,

can you give me an example? I'm working on the same thing and I'm a little confused.

I am filtering an ChooseFromList but the navigation is fixed in the record not work next

Former Member
0 Kudos

Hey Edy,

 

          Is exactly what I am doing. But, you agree with me that there should be an easier way.

          Thanks.

 

Regards

Former Member
0 Kudos

Hi Jairo,

     I will try to explain this in a simplified form.

OnMenuEvent:

bool lBubbleEvent = true;

if (pVal.MenuUID == MENUID_NEXT  || pVal.MenuUID == MENUID_PREVIOUS ||

    pVal.MenuUID == MENUID_FIRST || pVal.MenuUID == MENUID_LAST)

{

          //oNavInicio = Determines if this is the first time that this browsing

          //Whenever filter the RecordSet, set to true

          if (pVal.BeforeAction)

          {

                    switch (pVal.MenuUID)

                    {

                              case MENUID_NEXT:

                                        if (oNavInicio)

                                        {

                                                  oRecordSet.MoveFirst();

                                                  oNavInicio = false;

                                        }

                                        else

                                        {

                                                  if (!oRecordSet.EoF)

                                                  {

                                                            oRecordSet.MoveNext();

                                                            if (oRecordSet.EoF)

                                                                      oRecordSet.MoveFirst();

                                                  }

                                        }

                                        break;

                              case MENUID_PREVIOUS:

                                        if (oNavInicio)

                                        {

                                                  oRecordSet.MoveLast();

                                                  oNavInicio = false;

                                        }

                                        else

                                        {

                                                  if (!oRecordSet.BoF)

                                                            oRecordSet.MovePrevious();

                                                  else

                                                            oRecordSet.MoveLast();

                                        }

                                        break;

                              case MENUID_FIRST:

                                        oRecordSet.MoveFirst();

                                        break;

                              case MENUID_LAST:

                                        oRecordSet.MoveLast();

                                        break;

                    }

                    Form.Freeze();

                    // Put form in OK Mode

                    mForm.Mode = BoFormMode.fm_OK_MODE;

                    // Filter the DBDataSource with RecordSet's current record.

                    LoadByDocEntry(oRecordSet.Fields.Item("DocEntry").Value);

                    mForm.UnFreeze();

                    // Don't let the following the normal flow of SBO event

                    lBubbleEvent = false;

          }

}

bubbleEvent = lBubbleEvent;

LoadByDocEntry

private void LoadByDocEntry(int aDocEntry)

{

          Conditions oConditions  = Connection.Interface.CreateObject(BoCreatableObjectType.cot_Conditions);

          Condition  oCondition = oConditions.Add();

          oCondition.Alias = "DocEntry";

          oCondition.Operation = BoConditionOperation.co_EQUAL;

          oCondition.CondVal = Convert.ToString(aDocEntry);

          Form.DataSources.DBDataSources.Item("YOUR_TABLE").Query(oConditions);

          Form.DataSources.DBDataSources.Item("YOUR_TABLE").Offset = 0;

}

FilterRecordSet

private void FiltrarRecordSet()

{

          oRecordSet = (SAPbobsCOM.Recordset)Connection.Database.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

          oRecordSet.DoQuery(string.Format("select DocEntry from [YOUR_TABLE] where FIELD_TO_FILTER = {0}", VALUE));

          oNavInicio = true;

}

List of MenuID:

MENU IDID
First Data Record1290
Previous Record1289
Next Record1288
Last Data Record1291


I hope I haven't forgotten anything.

Any questions please write below.

Regards,

0 Kudos

Hello Dear,

Please have you been able to resolve this. I also want to implement this.

Please if you have, please kindly send me the code

Regards

0 Kudos
Hello Paulo,
I saw ur comment on this sap site and I am thinking you can help me with the issue I am having at the moment‏

  
i want to filter default navigation of UDO form‏ using ur suggestion works to a point‏

it works for a single form i.e master data form but when it does not work when i am using both master and detail form together‏

 
i can navigate to filter but it does not show the detail records of the current master record‏

  
pls how can i achieve this‏
Thanks

Answers (0)