on 04-08-2008 3:29 PM
Hi experts
i created the webdypro component which displays the MDM table data into webdynpro table in the layout.
can you please provide the sample code where we can retrieve the data from MDM into webdynpro table.
then i can asess where i have mistake in my code which will access the MDM table data into webdynpro table.
Regards
Sunil
Hi Sunil,
If your problem is solved please reward accordingly and mark the thread as Answered.
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sunil,
Below is the code u have asked for.Just specify the details according to your system configuration.
public void wdDoInit()
{
//@@begin wdDoInit()
String serverName = "MDM_SERVER";
String repositoryName = "REP_TEST";
RepositorySessionContext rsc=new RepositorySessionContext(serverName,repositoryName,"Admin");
SessionManager.getInstance().createSession(rsc,SessionTypes.REPOSITORY_SESSION_TYPE,"Admin");
ConnectionAccessor ac=null;
try
{
ac=ConnectionPoolFactory.getInstance(serverName);
}
catch(Exception ex)
{
ex.printStackTrace();
}
//Alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
RepositoryIdentifier repIdentifier = new RepositoryIdentifier(repositoryName, serverName, DBMSType.MS_SQL);
//get list of available regions for the repository
GetRepositoryRegionListCommand regionListCommand = new GetRepositoryRegionListCommand(ac);
regionListCommand.setRepositoryIdentifier(repIdentifier);
try
{
regionListCommand.execute();
}
catch (Exception e)
{
e.printStackTrace();
}
RegionProperties[] regionProp = regionListCommand.getRegions();
//create a user session
CreateUserSessionCommand sessionCommand = new CreateUserSessionCommand(ac);
sessionCommand.setRepositoryIdentifier(repIdentifier);
sessionCommand.setDataRegion(regionProp[0]); // use the first region
try
{
sessionCommand.execute();
}
catch (Exception e)
{
e.printStackTrace();
}
String sessionId = sessionCommand.getUserSession();
//Authenticate the user session
AuthenticateUserSessionCommand authCommand = new AuthenticateUserSessionCommand(ac);
authCommand.setSession(sessionId);
authCommand.setUserName("Admin");
authCommand.setUserPassword("Admin");
try
{
authCommand.execute();
}
catch (Exception e)
{
e.printStackTrace();
}
GetRepositorySchemaCommand getRepSchemaCmd = new GetRepositorySchemaCommand(ac);
getRepSchemaCmd.setSession(sessionId);
try
{
getRepSchemaCmd.execute();
}
catch(Exception e)
{
e.printStackTrace();
}
RepositorySchema repSchema = getRepSchemaCmd.getRepositorySchema();
//The main table, hard-coded
TableId mainTableId = new TableId(1);
//Specify the result definition (what to retrieve); in this example, nothing
ResultDefinition rd = new ResultDefinition(mainTableId);
//Select all records
Search search = new com.sap.mdm.search.Search(mainTableId);
//Get fields
GetFieldListCommand getFieldListCommand = new GetFieldListCommand(ac);
getFieldListCommand.setSession(sessionCommand.getUserSession());
getFieldListCommand.setTableId(mainTableId);
try
{
getFieldListCommand.execute();
}
catch (Exception e)
{
}
FieldProperties[] fields = getFieldListCommand.getFields();
//Add fields to records to retrieve
rd.addSelectField(repSchema.getFieldId("Title","Title"));
rd.addSelectField(repSchema.getFieldId("Title","Material_Number"));
//Retrieve the records
RetrieveLimitedRecordsCommand retriveLimRecCommand = new RetrieveLimitedRecordsCommand(ac);
retriveLimRecCommand.setSession(sessionId);
retriveLimRecCommand.setResultDefinition(rd);
retriveLimRecCommand.setSearch(search);
try
{
retriveLimRecCommand.execute();
}
catch (Exception e)
{
e.printStackTrace();
}
Record[] records = retriveLimRecCommand.getRecords().getRecords();
for(int i=0;i<records.length;i++)
{
IPrivateTestAppView.ITestElement v1=wdContext.nodeTest().createTestElement();
v1.setMaterial(records<i>.getFieldValue(repSchema.getFieldId("Title","Material_Number")).toString());
v1.setTitle(records<i>.getFieldValue(repSchema.getFieldId("Title","Title")).toString());
wdContext.nodeTest().addElement(v1);
}
//Destroy the session
DestroySessionCommand destroySessionCommand = new DestroySessionCommand(ac);
destroySessionCommand.setSession(sessionId);
try
{
destroySessionCommand.execute();
}
catch (Exception e)
{
e.printStackTrace();
return;
}
//@@end
}
Please reward if found useful.
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sunil,
The way to access MDM Data is thru Web Services. You will have to use the MDM JAVA API and build web services(or use standard webservices provided by SAP) and then, import that as WEbservice model in Webdynpro for Java.
MDM Java API 2 an introductive series part I
/people/tobias.grunow/blog/2007/12/16/mdm-java-api-2-an-introductive-series-part-i
Please paste your code here.
Thanks,
Avinash.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.