cancel
Showing results for 
Search instead for 
Did you mean: 

Application in JSP DynPage

Former Member
0 Kudos

Hi All,

I want to create an application in JSP DynPage which should access data from R/3. Please provide some link or tutorial how to start.

Regards

Nikhil Bansal

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member182416
Active Contributor
0 Kudos

Hi ,

Here is What you do .

1.Write this code in a DynPage to get the Data

here i am calling a BAPI from Sales Module as Example.


public DefaultTableViewModel getData(String USER, String PWD,String R3ip) {
			com.sap.mw.jco.IRepository repository;

			JCO.Pool pool = JCO.getClientPoolManager().getPool("R3");
			if (pool == null) {
				//JCO.removeClientPool("R3");
				JCO.addClientPool(
					"R3",
					10,
					"285",
					USER,
					PWD,
					"EN",
					"R3ip",
					"00");
			}
			repository = JCO.createRepository("TTL", "R3");

			JCO.Client client = null;
			//			Get a function template from the repository
			IFunctionTemplate ftemplate =
				repository.getFunctionTemplate("BAPI_SALESORDER_GETSTATUS");

			//		 Create a function from the template
			JCO.Function function = ftemplate.getFunction();

						client = JCO.getClient("R3");

						JCO.ParameterList input = function.getImportParameterList();

			input.setValue("0053100700", "SALESDOCUMENT");

						client.execute(function);

			JCO.Table sales_orders =
				function.getTableParameterList().getTable("STATUSINFO");
			//*********************
			Vector row = new Vector();
			Vector tbl = new Vector();
			Vector colNames = new Vector();
			//	Loop over all rows
			do {
				//	Loop over all columns in the current row
				for (JCO.FieldIterator e = sales_orders.fields();
					e.hasMoreElements();
					) {
					JCO.Field field = e.nextField();
					row.add(field.getString());
					//System.out.println(field.getName() + ":t" + field.getString());
				} //for
				tbl.add(row);
			} while (sales_orders.nextRow());

			sales_orders = null;
			sales_orders =
				function.getTableParameterList().getTable("STATUSINFO");

			sales_orders.nextRow();
			for (JCO.FieldIterator e = sales_orders.fields();
				e.hasMoreElements();
				) {
				JCO.Field field = e.nextField();
				colNames.add(field.getName().toString());

			}

			DefaultTableViewModel dtvModel =
				new DefaultTableViewModel(tbl, colNames);

			JCO.releaseClient(client);
			//**********************
			return dtvModel;
		}



2. Create a Bean to Store the Data



import com.sapportals.htmlb.table.DefaultTableViewModel;


public class DataBean implements Serializable {
public DefaultTableViewModel model;

public DefaultTableViewModel getModel() {
	return model;
}


public void setModel(DefaultTableViewModel model) {
	this.model = model;
}


}

3. Use this Bean in JSP


<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean 
	id="myBean" 
	scope="session" 
	class="DataBean" 
	/>

	<hbj:content 
		id="myContext">
		<hbj:page 
			title="PageTitle">
			<hbj:form 
				id="myFormId">
																<hbj:tableView 
								id="MessageTable" 
								model="myBean.model" 
								design="ALTERNATING" 
								headerVisible="true" 
								footerVisible="true" 
								fillUpEmptyRows="true" 
								navigationMode="BYLINE" 
								selectionMode="SINGLESELECT" 
								headerText="Inbox" 
								visibleFirstRow="1" 
								width="500">
	
							</hbj:tableView>
					
			</hbj:form>
		</hbj:page>
	</hbj:content>

4. Call the getData method in DynPage doInitialization() Method.

Here save the data in the Bean and save the bean in Session.

Thats the Complete Solution For you.

if u need further inputs do write back.

Regards

Rajendra

Former Member
0 Kudos

hI

Please tell me where will I find the dynpage in my project to write the above code .My project has MAsthead par file. It has lightweightheader.jsp file from which I want to connect to R/3 and fetch data but where is the dynpage for that.

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Nikhil

There is a tutorial in the link mentioned by me

Here is some more links

https://wiki.sdn.sap.com/wiki/display/EP/Connectivity

regards

kalyan

sid_sunny
Contributor
0 Kudos

Hi Nikhil,

You can refer to these documents.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a83ec690-0201-0010-14ac-bd1d75e24a7d">Simplified Queries of SAP Tables from Java</a>

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2ea1d990-0201-0010-6cb3-b4722ee85d9e">Introduction to the EP Perspective within SAP NetWeaver Developer Studio</a>

Regards

Sid

venkatakalyan_karanam
Active Contributor
0 Kudos