cancel
Showing results for 
Search instead for 
Did you mean: 

Get Original Record Id for Results Set iview

Former Member
0 Kudos

Hello,

I want to retrieve the Original Record id of the record selected in the Results Set iview in the Webdynpro java application using MDM Java API. I am using the following links for the same :

http://help.sap.com/saphelp_mdm71/helpdata/en/49/6bc4e153a03e90e10000000a42189c/content.htm

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/12195312-0e01-0010-a392-debbd32e3...

But when I try to print the value of the Original Record Id, it gives a value of -1. In the same way when I send the Material ID value from the iview using the same method , the correct value is displayed. Do we need to do anything else to display the Original RecordID.

Any help would be highly appreciated.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try this command -

public class RetrieveOriginalsByCheckoutRecordCommand

extends AbstractRecordsByIdCommand

A command to retrieve the original record Ids given the checked out record Ids are known.

http://help.sap.com/javadocs/mdm/sp06p2/com/sap/mdm/data/commands/RetrieveOriginalsByCheckoutRecordC...

Thanks,

Shambhu.

Former Member
0 Kudos

Hello Shambhu,

Thanks for the reply. I wrote the following code below to retrieve the Original Record Id :

try

{

usc = new UserSessionContext(servername,repositoryname,username);

// Create a Session Manager.

SessionManager sessionManager = SessionManager.getInstance();

// Authenticate user to the Session.

sessionManager.createSession(usc,SessionTypes.USER_SESSION_TYPE,password for the user);

retorig = new RetrieveOriginalsByCheckoutRecordCommand(usc);

}

catch(ConnectionException ce)

{

ce.printStackTrace();

}

GetTableListCommand tableListCommand = new GetTableListCommand(connections);

tableListCommand.setSession(sessionId);

try

{

tableListCommand.execute();

}

catch (CommandException e)

{

e.printStackTrace();

wdComponentAPI.getMessageManager().reportException(e.getMessage(), true);

}

TableProperties[] tables = tableListCommand.getTables();

retorig.setSession(sessionId);

retorig.setRecordIds(new RecordId[]{new RecordId(recordid)});

retorig.setTableId(tables[0].getId());

try

{

retorig.execute();

wdComponentAPI.getMessageManager().reportSuccess("Success for Original");

}

catch(CommandException e)

{

e.printStackTrace();

wdComponentAPI.getMessageManager().reportException(e.getMessage(), true);

}

RecordId[] rids = retorig.getOriginalRecords(new RecordId(recordid));

wdComponentAPI.getMessageManager().reportSuccess(rids.length+"");

}

Where recordid is the RecordId returned from the iview from the Parameters -Mapped Fields section which is coming fine as a number. But when I try to print the value for the length for the Record Ids Array rids , it returns a value of 0.

Please help.

Edited by: PortalPerson on Sep 12, 2011 6:18 PM

Former Member
0 Kudos

Refer this link pg 8 and see if the logic used here can be of any help to you - http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d09eaa01-f941-2c10-8d88-be7e05a85...

Thanks,

Shambhu.

Former Member
0 Kudos

The code I see on Page 8 is to get the RegionProperties , so I got the Region name ,added it as a parameter while creating the UserSession Context but still I get the same output.

Pls help.

Former Member
0 Kudos

If this is working then try to use the variable "i" for length -

for(int i=0;i<regionProp.length;i++){

if(regionProp<i>.getName().equalsIgnoreCase("English [US]")){

regionProperties = regionProp<i>;

break;

Former Member
0 Kudos

The RegionProperties code is separate from the Original Records Ids code ,right? Rather than just the length I need the Original Record Ids in the Array rids as in the previous code .

Thanks

Former Member
0 Kudos

You said that you were able to get the Original Record ID but not able to print the length of the array.

So I showed you an example where you can get the length of the array. Use this logic and enhance your code and not replace your code.

Include both the codes, the one with which you are getting Record ID and the other with which you are getting length.

Thanks,

Shambhu.

Former Member
0 Kudos

Shambhu,

I said that the RecordId retrieved from the iview is coming fine which is not the Original Record, so when I use that recordid as parameter in the Command RetrieveOriginalsByCheckoutRecordCommand I get an array of length 0 , as it does not have any Original Record Ids in it , so I am not able to get any Original recordIds.

Thanks

Former Member
0 Kudos

Please paste your fix in the post, so other users can be benefitted.

Thanks,

Shambhu.

Former Member
0 Kudos

The Record Id returned from the iview is the Original Record Id and then use command RetrieveCheckoutRecordsByOriginalCommand using that Id as a parameter.

Thanks