Show TOC

Procedure documentationAdding the Classes Locate this document in the navigation structure

Procedure

Creating the Web Module
  1. In the SAP NetWeaver Developer Studio, choose   File   New   Project  .

  2. In the wizard that appears, expand the Development Infrastructure node and choose Development Component. Choose Next.

  3. In the screen that appears, expand the J2EE node, and choose Web Module. Choose Next.

  4. In the screen that appears, choose the software component where you want to create the DCs. For example, expand the 'Local Development' node and choose MyComponents [demo.sap.com]. Choose Next.

  5. In the screen that appears, enter buyer_wm in the Name field. Choose Finish.

The Java EE perspective opens and in the Project Explorer view, you should see the buyer_wm node.

Note Note

If the Project Explorer view does not open, choose   Window   Show View   Other   and in the dialog box that appears expand the General node and choose Project Explorer. Choose OK.

End of the note.
Creating Classes in the Web Module

Make sure you are in the Java EE perspective.

  1. In the Project Explorer view, expand the buyer_wm node and in the context menu of Java Resources: source node, choose   New   Class.  

    Note Note

    If you do not see the Class option in the context menu of the Java Resources: source node, choose   New   Other.   In the dialog box that appears, choose Class.

    End of the note.
  2. In the screen that appears, enter com.sap.buyer in the Package field.

  3. Enter Buyer in the Name field and choose Finish.

    You should see the com.sap.buyer node under the Java Resources: source node.

  4. Double-click Buyer.java under the com.sap.buyer node.

    The Buyer.java window appears.

  5. Delete all existing lines and copy the following lines into the window:

    Syntax Syntax

    1. package com.sap.buyer;
      import java.io.Serializable;
      public class Buyer implements Serializable{
      public Buyer()
      	{		
      	}	
      	String buyersname;
      	String buyersspendinghabit;
      	String buyerscredit;
      	double setdiscount;	
      	public String getBuyersname() {
      		return buyersname;
      	}
      	public void setBuyersname(String buyersname) {
      		this.buyersname = buyersname;
      	}
      	public String getBuyersspendinghabit() {
      		return buyersspendinghabit;
      	}
      	public void setBuyersspendinghabit(String buyersspendinghabit) {
      		this.buyersspendinghabit = buyersspendinghabit;
      	}	
      	public String getBuyerscredit() {
      		return buyerscredit;
      	}
      	public void setBuyerscredit(String buyerscredit) {
      		this.buyerscredit = buyerscredit;
      	}	
      	public double getSetdiscount() {
      		return setdiscount;
      	}
      	public void setSetdiscount(double setdiscount) {
      		this.setdiscount = setdiscount;
      	}
      }
      
    End of the code.
  6. Press Ctrl+Shift+F.

  7. Save the changes.

Defining the Public Parts

Make sure you are in the Development Infrastructure perspective.

  1. In the Component Browser view, expand the Local Development node, MyComponents [demo.sap.com] node (the software component in which Development Component has been created), and double-click the buyer_wm node.

    Note Note

    If the Component Browser view is not open, choose   Window   Show View   Other   and in the dialog box that appears expand the Development Infrastructure node and choose Component Browser. Choose OK.

    End of the note.
  2. In the Component Properties view, choose the Public Parts tab and in the page that appears, choose Add.

    Note Note

    If the Component Properties view does not open, choose   Window   Show View   Other   and in the dialog box that appears expand the Development Infrastructure node and choose Component Properties. Choose OK.

    End of the note.
  3. In the screen that appears, enter public in the Name field. Choose Finish.

    You should see the public node under the Defined Public Parts section.

  4. In the context menu of the public node, choose Manage Entities.

  5. In the screen that appears, under the Entities section, expand the Java Class, com, sap and buyer nodes, select the Buyer java class checkbox.

  6. Choose Finish.

Adding Dependencies to the Rules Composer DC
  1. In the Component Browser view, view, expand the Local Development node, MyComponents [demo.sap.com] node (the software component in which Development Component has been created) and double-click the buyerrules node.

  2. In the Component Properties view, choose the Dependencies tab and in the page that appears, choose Add.

  3. In the dialog box that appears, expand the MyComponents node and select the buyer_wm checkbox. Choose Next.

  4. In the screen that appears, under Dependency Details section, only select the Design Time checkbox.

  5. Choose Finish.

  6. In the Dependencies tab page, expand the buyer_wm node and choose the war node. Choose Remove and in the dialog box that appears choose Yes.

  7. In the Component Browser view, expand the MyComponents [demo.sap.com] node and in the context menu of the buyerrules node, choose Build. Choose OK.

  8. Check the Infrastructure Console for message.

Adding Classes to the Rules Composer DC

Make sure you are in the Rules Composer perspective.

  1. In the Project Explorer view, expand the buyerrules node, the Rules Modeling node and double-click the Project Resourcesnode.

  2. In the Project Aliases Editor that appears, choose the Aliases tab and in the tab page that appears, choose the Add button and in the menu that appears choose Class.

  3. In the dialog box that appears, expand the com.sap.buyer node and double-click Buyer.

  4. Choose Finish.

  5. In the Alias Name section, expand the Buyer node and select all the relevant classes.

  6. Save the changes.