Skip to Content

JAVA Part

JAR files required:


com.sap.portal.ivs.connectorserviceapi.jar,connectionapi.jar,connector.jar,ConnectorHelper.jar,GenericConnector.jar

It’s time for JAVA side of this application. The recursive logic to build the tree is the one from the weblog Build Your Own KM Navigation iView Using HTMLB Tree with minor modification. Now, the following steps will describe how to create the portal component to talk to the RFC and display the BOM.

Step 1:

Create a Dynpage component using NWDS or eclipse and add the following source code

/* Built By: Prakash Singh

  • Technical Consultant

  • Universal System Technologies, Inc

  • 2500 W. Lake Mary Blvd., Ste 212-A

  • Lake Mary, FL 32746 USA

  • M 407-474-2216

*/

package com.ust.explodebom;

import java.util.Iterator;

import java.util.Vector;

import javax.resource.cci.MappedRecord;

import javax.resource.cci.RecordFactory;

import com.sapportals.connector.connection.IConnection;

import com.sapportals.connector.execution.functions.IInteraction;

import com.sapportals.connector.execution.functions.IInteractionSpec;

import com.sapportals.connector.execution.structures.IRecord;

import com.sapportals.connector.execution.structures.IRecordSet;

import com.sapportals.htmlb.Button;

import com.sapportals.htmlb.Form;

import com.sapportals.htmlb.GridLayout;

import com.sapportals.htmlb.Group;

import com.sapportals.htmlb.InputField;

import com.sapportals.htmlb.Label;

import com.sapportals.htmlb.Tree;

import com.sapportals.htmlb.TreeNode;

import com.sapportals.htmlb.enum.GroupDesign;

import com.sapportals.htmlb.event.Event;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.ivs.cg.ConnectionProperties;

import com.sapportals.portal.ivs.cg.IConnectorGatewayService;

import com.sapportals.portal.ivs.cg.IConnectorService;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.runtime.PortalRuntime;

public class display extends PageProcessorComponent {

     public DynPage getPage() {

          return new displayDynPage();

     }

     public static class displayDynPage extends DynPage {

          /**

          

  • Initialization code executed once per user.

           */

          String rootmatnr;

          String rootdescr;

          String plant, application, material;

          Vector data;

          public void doInitialization() {

               plant = “”;

               application = “”;

               material = “”;

          }

          /**

          

  • Input handling code. In general called the first time with the second page request from the user.

           */

          public void doProcessAfterInput() throws PageException {

          }

          /**

          

  • Create output. Called once per request.

           */

          public void doProcessBeforeOutput() throws PageException {

               Form myForm = this.getForm(); // get the form from DynPage

               // create your GUI here….

               Group myGroup = new Group();

               myForm.addComponent(myGroup);

               myGroup.setWidth(“350”);

               myGroup.setDesign(GroupDesign.SAPCOLOR);

               myGroup.setTitle(“Explode BOM (Level by Level)”);

               GridLayout gl = new GridLayout();

               myGroup.addComponent(gl);

               gl.setCellSpacing(5);

               GridLayout gl1 = new GridLayout();

               gl.addComponent(1, 1, gl1);

               Label lblmaterial = new Label(“Material”);

               gl1.addComponent(1, 1, lblmaterial);

               InputField inpmaterial = new InputField(“material”);

               inpmaterial.setValue(material);

               gl1.addComponent(1, 2, inpmaterial);

               Label lblplant = new Label(“Plant”);

               gl1.addComponent(2, 1, lblplant);

               InputField inpplant = new InputField(“plant”);

               inpplant.setValue(plant);

               gl1.addComponent(2, 2, inpplant);

               Label lblapplication = new Label(“BOM Application”);

               gl1.addComponent(3, 1, lblapplication);

               InputField inpapplication = new InputField(“application”);

               inpapplication.setValue(application);

               gl1.addComponent(3, 2, inpapplication);

               Button buttondisplay = new Button(“Display”);

               buttondisplay.setText(“Display”);

               buttondisplay.setOnClick(“Display”);

               gl1.addComponent(4, 1, buttondisplay);

               

               if (!material.equals(“”) && !application.equals(“”) && !plant.equals(“”))

               {

               IPortalComponentResponse response =

                    (IPortalComponentResponse) this.getResponse();

               try {

                    execute_rfc();

                    //set the root node to top material.

                    Tree tree = new Tree(“BOM”, “BOM”);

                    TreeNode root = new TreeNode(rootmatnr, rootdescr);

                    root.setOpen(true);

                    tree.setRootNode(root);

                    Iterator i = data.iterator();

                    //Build hierarchy via recursive method calls

                    addNode(0, rootmatnr, data, root);

                    gl.addComponent(2, 1, tree);

                    

               } catch (Exception e) {

                    response.write(e.getMessage());

               }

               }

          

          }

          public void onDisplay(Event event) throws PageException {

               InputField materialfld =

                    (InputField) getComponentByName(“material”);

               InputField plantfld = (InputField) getComponentByName(“plant”);

               InputField applicationfld =

                    (InputField) getComponentByName(“application”);

               material = materialfld.getValueAsDataType().toString().toUpperCase();

               plant = plantfld.getValueAsDataType().toString().toUpperCase();

               application = applicationfld.getValueAsDataType().toString().toUpperCase();

          }

          public void addNode(

               int index,

               String pname,

               Vector data,

               TreeNode treeNode) {

               for (int j = index; j

BAM! you got yourself a BOM explosion application

image

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member
    Hi Prakash

    I am trying your example…

    I would like to know Where can I get these jar files

    connectionapi.jar,connector.jar,ConnectorHelper.jar,GenericConnector.jar

    Regards
    Senthil

    (0) 
    1. Former Member Post author
      You should find these jars in portalapps directory. If you don’t find it then send a email to me and i will send it to you. thank you.

      Prakash

      (0) 
  2. Former Member
    hi Prakash Singh, i need exactly this, but i give the bomusage and not the bom application like you, my question is, can i do exactly the same as you but in VC? im very new on this and its difficult for me, can you help me?
    (0) 

Leave a Reply