Start of Content Area

Procedure documentationImplementing the Source Code for the View Locate the document in its SAP Library structure

The following source code text for the SalesOrder view shows you how you get the operations available for the business object and how you then bind these to the dropdown box. Firstly, create a reference to the OBN service IuserObjectBasedNavigation in the wdDoInit() method. Then determine the current user. Then you see the definition of the system and business object. You can get the list of the available operations. Dynamically filling the context node with the operations is the last implementation step in this method.

Afterwards, provide the View context with information as to how object-based navigation is to run with the selection made from the dropdown box (method onActionDropDownAction) while taking the respective operation into consideration. The context now requires for this only the name of the current operation element.

 

Implementation in the SalesOrderView

  public void wdDoInit()

  {

   //@@begin wdDoInit()

 

   //Create a reference to the OBN service

   IUserObjectBasedNavigation obnService

   =(IUserObjectBasedNavigation) WDPortalUtils.getServiceReference(

   IUserObjectBasedNavigation.KEY);

 

   //Determine current user

   IUser user = null;

         try

         {

            user= WDClientUser.getCurrentUser().getSAPUser();

         }

         catch (WDUMException e)

         {

            wdComponentAPI.getMessageManager().reportException(

               "Failed to get current user: " + 

               e.getLocalizedMessage(),

               true);

         }

 

   //Define system and business object

   String system = "MyOBNSystem";//Name of system used

   String bo = "SalesOrder";//Name of business object

 

   //Get list of available operations

   Listoperations = obnService.getTargets(system, bo, user);

 

   //Dynamically fill the context node with the operations

         if (operations != null)

         {

          IPrivateSalesOrderView.IOperationsElement

          newOperation = null;

         for (Iterator iter = operations.iterator(); iter.hasNext();)

         {

          IOBNTarget target = (IOBNTarget) iter.next();

          newOperation =  

          wdContext.nodeOperations().createOperationsElement();

          newOperation.setCaption(target.getOperationFriendlyName());

          newOperation.setName(target.getOperationName().substring

          (target.getOperationName().lastIndexOf('/')+1));

          wdContext.nodeOperations().addElement(newOperation);

         } 

         }

   //@@end

  }

 

Implementation in the Dropdown Box of the SalesOrderView

public void onActionDropDownAction(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

  {

    //@@begin onActionDropDownAction(ServerEvent)

    //int sel = wdContext.nodeOperations().getLeadSelection();

    //wdComponentAPI.getMessageManager().reportSuccess("Element number "+ sel +"
      selected!");

      IWDNode naNode = wdContext.getChildNode("Names",0);

         int leadSel = naNode.getLeadSelection();

         IWDNodeElement naEl = naNode.getElementAt(leadSel);

         String mode = naEl.getAttributeAsText("Cz");

        

         IWDNodeElement newNaEl = naNode.createElement();

         newNaEl.setAttributeValue("Cz",mode);

        

         naNode.addElement(newNaEl);

     //Navigation to currently selected operation and transfer of the parameter mode

if (wdContext.currentOperationsElement() != null)

     {

      WDPortalNavigation.navigateToObjectWithSpecificOperation

      ("MyOBNSystem","SalesOrder","SalesOrder",        

       wdContext.currentOperationsElement().getName(),

       "mode="+mode+"&ShowHeader=false");

     }

 

    //@@end

  }

 

In closing, choose the context menu entry Source ® Organize from any position in the source code so that the import for the required packages can run automatically.

 

This graphic is explained in the accompanying text In the next chapter Defining Parameter Transfer, you will define a method – for filling the context – which you can access from within the interface view.

 

 

End of Content Area