Create User in OID using Java API

I read the documentation, read javadoc for Java API for OID, but still am not clear "how can I create a user in OID using Java API for OID."
It tells us how to create a java object User, but then how do we write this object to OID ?
I searched every where, metalink, forums, google...and am still looking for answere...
Thanks in Advance
Cheers
Puneet

I did it using the Novell LDAP java api:
import com.novell.ldap.*;
public class LdapAdmin {
public static final String ldap_base = "dc=your,dc=company,dc=com";
public static final String ldap_user_base = "cn=Users," + ldap_base;
public static final String ldap_portal_base = "cn=PORTAL_GROUPS,cn=Groups," + ldap_base;
public static final String ldap_extended_base = "cn=Extended Properties,cn=OracleContext," + ldap_base;
public static final String ldap_dbdomain_base = "cn=OracleDefaultDomain,cn=OracleDBSecurity,cn=Products,cn=OracleContext," + ldap_base;
public static final String ldap_context_base = "cn=COMMON,cn=OracleDBAppContext," + ldap_dbdomain_base;
private static final String default_ldap_host = "infrastructure.your.company.com";
private static final int default_ldap_port = 4032;
private static final String default_ldap_login = "cn=orcladmin," + ldap_user_base;
private static final String default_ldap_pwd = "welcome1";
private static final String default_user_pwd = "secret";
private static final String[] personclass_values = { "top", "person", "organizationalPerson", "inetOrgPerson", "orcluser", "orcluserv2" };
public static LDAPConnection getConnection (String host, int port, String user, String pwd) {
LDAPConnection lc = new LDAPConnection();
try {
lc.connect(host,port);
lc.bind(user,pwd);
} catch (LDAPException lex) {
System.out.println("LDAP Error in getConnection: "+lex.getResultCode()+"-"+lex.getLDAPErrorMessage());
     return lc;
public static LDAPConnection getConnection (String host, int port) {
LDAPConnection lc = new LDAPConnection();
try {
lc.connect(host,port);
} catch (LDAPException lex) {
System.out.println("LDAP Error in getConnection: "+lex.getResultCode()+"-"+lex.getLDAPErrorMessage());
     return lc;
public static LDAPConnection getConnection (String user, String pwd) {
LDAPConnection lc = new LDAPConnection();
try {
lc.connect(default_ldap_host,default_ldap_port);
lc.bind(user,pwd);
} catch (LDAPException lex) {
System.out.println("LDAP Error in getConnection: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
lex.printStackTrace();
     return lc;
public static LDAPConnection getConnection () {
return getConnection(default_ldap_host,default_ldap_port);
public static void bind (LDAPConnection conn, String user, String pwd) {
try {
conn.bind(user,pwd);
} catch (LDAPException lex) {
System.out.println("LDAP Error in bind: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
lex.printStackTrace();
private static void bind (LDAPConnection conn) {
bind(conn,default_ldap_login,default_user_pwd);
public static void modifyAttribute (LDAPConnection conn, String dn, String attr, String val, int mod) {
LDAPAttribute attribute = new LDAPAttribute(attr,val);
LDAPModification[] modification = new LDAPModification[] { new LDAPModification(mod,attribute) };
try {
conn.modify(dn,modification);
} catch (LDAPException lex) {
System.out.println("LDAP Error in modifyAttribute: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
public static void modifyAttribute (LDAPConnection conn, String dn, String attr, String val) {
modifyAttribute(conn,dn,attr,val,LDAPModification.REPLACE);
public static void addAttribute (LDAPConnection conn, String dn, String attr, String val) {
modifyAttribute(conn,dn,attr,val,LDAPModification.ADD);
public static void deleteAttribute (LDAPConnection conn, String dn, String attr, String val) {
modifyAttribute(conn,dn,attr,val,LDAPModification.DELETE);
public static void deleteEntry (LDAPConnection conn, String dn) {
try {
conn.delete(dn);
} catch (LDAPException lex) {
System.out.println("LDAP Error in deleteEntry: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
public static boolean isValidDn(LDAPConnection conn, String dn) {
try {
LDAPSearchResults res = conn.search(dn);
} catch (LDAPException lex) {
System.out.println("LDAP Error in deleteEntry: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
return false;
public static void createPerson (LDAPConnection conn, String net_id, String lname, String fname, String office, String email, String id, String fullname) {
     LDAPAttributeSet attributeSet = new LDAPAttributeSet();
attributeSet.add(new LDAPAttribute("cn", net_id));
attributeSet.add(new LDAPAttribute("sn", lname));
attributeSet.add(new LDAPAttribute("objectclass", personclass_values));
attributeSet.add(new LDAPAttribute("l", office));
attributeSet.add(new LDAPAttribute("mail", email));
attributeSet.add(new LDAPAttribute("employeeNumber", id));
attributeSet.add(new LDAPAttribute("givenName", fname));
attributeSet.add(new LDAPAttribute("uid", net_id));
// attributeSet.add(new LDAPAttribute("fullName", fullname));
attributeSet.add(new LDAPAttribute("orclpkcs12hint", default_user_pwd));
attributeSet.add(new LDAPAttribute("orclpassword", VerifyPassword.getHash(net_id,default_user_pwd)));
attributeSet.add(new LDAPAttribute("userpassword", default_user_pwd));
attributeSet.add(new LDAPAttribute("orcldefaultprofilegroup", "cn=DEFAULT,"+ldap_portal_base));
LDAPEntry entry = new LDAPEntry("cn="+net_id+","+ldap_user_base,attributeSet);
try {
conn.add(entry);
} catch (LDAPException lex) {
System.out.println("LDAP Error in createPerson: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
public static void updatePerson (LDAPConnection conn, String net_id, String lname, String fname, String office, String email, String id, String fullname) {
LDAPModification[] mod = new LDAPModification[8];
mod[0] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("cn", net_id));
mod[1] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("sn", lname));
mod[2] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("l", office));
mod[3] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("mail", email));
mod[4] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("employeeNumber", id));
mod[5] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("givenname", fname));
mod[6] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("fullName", fullname));
mod[7] = new LDAPModification(LDAPModification.REPLACE,new LDAPAttribute("uid", net_id));
try {
conn.modify("cn="+net_id+","+ldap_user_base,mod);
} catch (LDAPException lex) {
System.out.println("LDAP Error in updatePerson: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
public static void main (String[] args) {
try {
LDAPConnection conn = getConnection(default_ldap_login,default_ldap_pwd);
// updatePerson(conn,"ID1","Somebody","Joe","CLE","[email protected]","1","Joe Somebody 2");
// modifyAttribute(conn,"cn=ID1,"+ldap_user_base,"fullName","Joe Somebody",LDAPModification.REPLACE);
// modifyAttribute(conn,"cn=ID1,"+ldap_user_base,"displayName","Joe Somebody");
createPerson(conn,"ID1","Somebody","Joe","CLE","[email protected]","1","Joe Somebody");
// deleteEntry(conn,"cn=ID1,"+ldap_user_base);
conn.disconnect();
} catch (LDAPException lex) {
System.out.println("LDAP Error in main: ("+lex.getResultCode()+") - "+lex.getLDAPErrorMessage());
}

Similar Messages

  • Create group in OID using java api

    Hi all!
    I need to create group in OID using java api. Java api documentation contains examples for creating users but not for groups. I search oracle.com (and google) and didn't find any hint.
    Anybody know the way?
    thank you.

    Andrew,
    a group is created like any other entry in OID. You need to specify the dn, objectclass(es) and (mandatory) attributes.
    e.g.
    objectclass=groupOfUniqueNames
    with
    uniquemember=cn=orcladmin, cn=Users, dc=de,dc=oracle,dc=com
    as an example take a look at
    cn=iASAdmins, cn=Groups,cn=OracleContext,dc=de,dc=oracle,dc=com
    to see the schema (data) for groupofuniquenames you can either use ODM or query the directory server
    ldapsearch -p 3060 -b "cn=subschemasubentry" -s base "objectclass=*"
    regards,
    --Olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to create the groups in OID Using Java API.

    Hi,
    I need to create the group in OID Using Java API's only(i.e., javax.naming.* only).
    I need to achieve it without using any oracle specific jars.
    Is there any way to achieve it?.If there's a option to achieve it,do let me know.
    I also need to create the users in that group ,after creating it.
    If you share any useful link or ideas for the same would be great.
    Thanks
    Balaji

    bobws wrote:
    Hi,
    I want to find the installed JREs in windows using java. I couldn't fine any java API. So I am using the below code to fetch the JRE list from windows registries & parse the returned collection to know the installed JRE.Why? If you are running java you already have a JRE. So why not just use it?
    >
    String key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment";
    Runtime.getRuntime().exec(
    "reg query " + "\"" + key + "\"");
    Is it legal to retrieve the installed JREs in this way? Legal? It is OS specific, and to a certain extent dependent on vendor and what the vendor wants to do. Could also be impacted by permissions. Other than that it is ok.
    I am feeling like its a type of hacking. So I couldn't decide whether this is legal (recommended) way of using. Does anybody can answer me. I can see the similar posts in google. Somebody suggests this way & somebody suggests to use preference API which is similar to this. Appreciate your help.Preferences won't work. It doesn't allow access to the registry in general, only a part of it. There are discussions in the JNI forum about retrieving VM versions. Prior to actually using the VM though.

  • Error while creating user id from MDM JAVA API in 7.1 SP7

    Hi,
    We are trying to create user id in MDM 7.1 SP7 using JAVA API in SAP Portal. When trying to create user id, we are getting below error. If you have any solution please let us know.
    com.sap.mdm.commands.CommandException: MDM repository data is out-of-date or is locked by another MDM Server. Refresh the data and try the operation again. If the error persists, contact the system administrator
    Thanks,
    Vinit Pugaliya

    URGENT** How to change  OIM user password from outside OIM

  • Unable to raise password expiry warning exception in OID using JAVA API

    Hi,
    We are maintaing the user information for our application in OID(9.2). During logon, it is required that a warning is given to the user according to the value set in "Password Expiration Warning" parameter.
    A pl/sql program (using DBMS_LDAP/DBMS_LDAP_UTL packages) written to test password expiry raises the PWD_EXPIRE_WARN exception as expected. However we are unable to simulate the same using the JAVA APIs.
    We did try some thing like the following:
    public class SampleExpire {
    public static void main(String argv[])
    throws NamingException {
    // Create InitialDirContext
    InitialDirContext ctx = ConnectionUtil.getDefaultDirCtx( "TCS-UUODC4",
    "4032",
    "cn=orcladmin",
    "welc0me" );
    System.out.println("Hello");
    // Create User Objects
    User myuser = null,
    try {
    // Create User using a subscriber DN and the User DN
    myuser = new User ( ctx,
    Util.IDTYPE_DN,
    "uid=C100013, ou=People, o=UUSD",
    Util.IDTYPE_DN,
    "ou=People, o=UUSD",
    false );
    catch ( UtilException e ) {
    * Exception encountered in User object constructor
    System.out.println("User creation failed");
    // Authenticate User
    try {
    myuser.authenticateUser(ctx,User.CREDTYPE_PASSWD,"Z100013");
    catch ( UtilException e ) {
    * Authenticate fails
    System.out.println("Authentication failed");
    } // End of SampleExpire.java
    The authenticate user does not raise any exception.
    Am I missing something ?
    Regards -
    Adhiraj

    Hi,
    did you manage to solve this problem? Please let me know

  • How to create users in Weblogic using an API

    Hi All,
    I have a requirement where i need to add the users in security realm without using Weblogic Console.Is there any API or program which lets us to create the users and set it in realm.
    Please suggest!!
    Thanks.

    Hi,
    You can follow the blog written by Middleware magic team
    Creating Users And Groups
    http://middlewaremagic.com/weblogic/?p=4981
    Deleting Users And Groups
    http://middlewaremagic.com/weblogic/?p=5234
    Users List from Security Realm
    http://middlewaremagic.com/weblogic/?p=6678
    Hope this will be helpful
    Regards
    FAbian

  • Problem while creating a custom document using JAVA API in the current Folder

    I am trying to create an instance of a custome type from the API. I have created a custom type via XML. I have associated a JSP with the custom type thru iFS manager. This jsp provides an interface for the user to enter various data. On submit I call some other jsp also loaded into the /ifs/webui/jsps which calls a method in the java class to create an instance of the above mentioned type. This instance needs to be created in the current directory and not in the home directory of the user. I have written a java program which when run from JDeveloper connects to the repository and creates the object, but not as a foldered object. If I load this class into custom_classes directory, I get an exception. I am attaching the code also here which does the actual processing.
    package cms;
    import oracle.ifs.agents.common.*;
    import oracle.ifs.agents.manager.*;
    import oracle.ifs.agents.server.*;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    public class ContentModule extends Object {
    public static final String CLASSNAME = "CONTENT";
    public static final String TOPICID_ATTRIBUTE = "TOPICID";
    public static final String SITEID_ATTRIBUTE = "SITEID";
    LibrarySession m_session;
    public ContentModule() {
    connectToRepository();
    createDocument("AM5","s");
    public void connectToRepository(){
    try{
    LibraryService l_service=new LibraryService();
    CleartextCredential l_credential = new CleartextCredential("system","manager");
    ConnectOptions l_options=new ConnectOptions();
    l_options.setServiceName("IfsDefault");
    l_options.setServicePassword("ifssys");
    m_session=l_service.connect(l_credential,l_options);
    }catch(IfsException ex){
    ex.setVerboseMessage(true);
    ex.printStackTrace();
    public void createDocument(String p_docName,String p_docContent){
    try{
    DocumentDefinition l_doc=new DocumentDefinition(m_session);
    l_doc.setClassname(CLASSNAME);
    long newId1=5;
    long newId2=5;
    FolderPathResolver l_currentPath=new FolderPathResolver(m_session);
    Folder l_currentFolder=l_currentPath.getCurrentDirectory();
    l_doc.setAddToFolderOption(l_currentFolder);
    l_doc.setName(p_docName);
    l_doc.setContent(p_docContent);
    AttributeValue av1 = AttributeValue.newAttributeValue(newId1);
    l_doc.setAttribute(TOPICID_ATTRIBUTE,av1);
    AttributeValue av2 = AttributeValue.newAttributeValue(newId2);
    l_doc.setAttribute(SITEID_ATTRIBUTE,av2);
    Document l_document=(Document) m_session.createPublicObject(l_doc);
    }catch(IfsException ex){
    ex.setVerboseMessage(true);
    ex.printStackTrace();
    public static void main(String[] args) {
    ContentModule contentModule = new ContentModule();
    Any help will be highly appreciated.
    Thanks

    Please print out the Verbose Stack Trace generated when you run this application.
    I suspect that you FolderPathResolver is not pointed at the directory you think it is. You might want to try printing out
    I_CurrentFolder.getAnyFolderPath();
    and I_CurrentFolder.getName();
    null

  • Code to Create and Populate Lookup using Java API

    Hi All,
    I wish to write a java code to first create a lookup in OIM and then populate with some custom values.
    For creating Lookup, I used the following function and it worked:
    tcLookupOperationsIntf useLookup=(tcLookupOperationsIntf)factory.getUtility
    ("Thor.API.Operations.tcLookupOperationsIntf");
    useLookup.addLookupCode("Lookup.Custom");
    However, If I try using the following function to populate this lookup:
    useLookup.addLookupValue("value1","value2",value3",value4");
    I got this error:
    Thor.API.Exception.tcInvalidLookupException
    Please help.
    Cheers,
    Sunny

    You are using the correct API
    ("value1","value2",value3",value4");
    The values which you are providing are wrong.
    TRY THIS
    addLookupValue("Lokkup.Test", codeValue,decodevalues, "en", "US")
    Lookup.Test should be there.

  • Image not displayed in pdf generated using Java API for Forms service

    Hi,
    I am creating a pdf document using Java API for Forms Service.
    I am able to generate the pdf but the images are not visible in the generated pdf.
    The image relative path is coming in the xml as defined below. The images are stored dynamically in the Livecycle repository each time a request is fired with unique name before the xml is generated.
    <imageURI xfa:contentType="image/png" href="../Images/logo.png"></imageURI>
    Not sure if I need to specify specify specific URI values that are required to render a form with image.
    The same thing is working when I generate pdf document using Java API for Output Service.
    As, I need to generate interactive form, I have to use Forms service to generate pdfs.
    Any help will be highly appreciated.
    Thanks.

    Below is the code snippet:
                //Create a FormsServiceClient object
                FormsServiceClient formsClient = new FormsServiceClient(myFactory);
                //Specify URI values that are required to render a form
                URLSpec uriValues = new URLSpec();
                                  // Template location contains the whole rpository path for the form
                uriValues.setContentRootURI(templateLocation);
               // The base URL where form resources such as images and scripts are located.  Whole Image path is passed in BaseUrl in the http format.
                      String baseLocation = repositoryPath.concat(serviceName).concat(imagesPath);   
                                  uriValues.setBaseURL(baseLocation);                                        
                // Set run-time options using a PDFFormRenderSpec instance
                PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();
                pdfFormRenderSpec.setCacheEnabled(new Boolean(true));           
                pdfFormRenderSpec.setAcrobatVersion(com.adobe.livecycle.formsservice.client.AcrobatVersio n.Acrobat_8);
                                  //Invoke the renderPDFForm method and write the
                //results to a client web browser
                String tempTemplateName =templateName;
                FormsResult formOut = formsClient.renderPDFForm(tempTemplateName,
                                              inXMDataTransformed,pdfFormRenderSpec,uriValues,null);
                //Create a Document object that stores form data
                Document outputDocument = formOut.getOutputContent();
                InputStream inputStream = outputDocument.getInputStream();

  • Modifying record in MDM using JAVA API

    hello all
    I have created record in MDM using JAVA API now I want to update record using API. I used ModifyRecordCommand. But this requires input as Record but I have RecordID of the record to be modified. How do I get Record value from RecordID.

    Hi,
                      You can use RetrieveRecordsByIdCommand to get the record by Record Id.
                RetrieveRecordsByIdCommand recordbyidcom = new  RetrieveRecordsByIdCommand(con);
                recordbyidcom.setSession(session);
                recordbyidcom.addId(recordid);
                recordbyidcom.setResultDefinition(resultdefinition);
                recordbyidcom.execute();
                RecordResultSet rs = recordbyidcom.getRecords();
                Record record = rs.getRecord(0);
                //Modify the record
                record.setFieldValue(fieldid,value);
                ModifyRecordCommand modify = new ModifyRecordCommand(con);
                modify.setSession(session);
                modify.setRecord(record);
                modify.execute();
    Regards,
    Sreenivasulu Thimmanapalli.
    Edited by: Sreenivasulu Thimmanapalli on Dec 8, 2008 2:36 AM

  • GetSelectedFields()  for time stamp and user stamp using java api

    using Java API's
    getSelectedFields() returns NULL  value if values presented also, for Time stamp and User stamp
    properties in Flat tables , is there any other alternative way to get the SelectedFields values ?
    Edited by: Vijaya Sekhar Reddy Alla on Mar 19, 2008 3:16 PM

    Well, I can't say I solved the problem, because I got another one afterwards.
    As usually I created a GetFieldListCommand, set its needed attributes and executed it. Then I read all the field properties out:
    FieldProperties[] fieldProp = getFieldListCommand.getFields();
    Afterwards it is possible to do what you want. Using a for-loop.
    for (FieldProperties fp : fieldProperties) {
        UserStampFieldProperties usfp = (UserStampFieldProperties) fp; // <= Cast error
        FieldId[] fieldIDs = usfp.getSelectedFields();
    And this is what I get now:
    Exception in thread "main" java.lang.ClassCastException: com.sap.mdm.schema.fields.FixedWidthTextFieldProperties cannot be cast to com.sap.mdm.schema.fields.UserStampFieldProperties
    Why this happens, I don't know. But it should somehow be solveable.

  • User defined Metadata for XML DB using Java API

    I have been looking through and reading the documentation for Oracle XML DB. I am trying to find out if there is a way to create user define metadata using a Java API. when I look in the XML "Java API Reference (Javadoc)" setProperty(java.lang.String name, java.lang.String value, int type) it states: Sets the specified (single-value) property to the specified value. If the property does not yet exist, it is created. I have tried several ways to do this and have not been successful. I have looked for java examples in the XML DB Developer's Guide, XML Developer's Kit Programmer's Guide.
    Is there a good example out there as to how to create user-defined metadata that can be populated using the JCR API.
    Thanks in advance.

    We need to create the 2 xml schemas, one for request and the other for response of selected operation in the WSDL.
    This we need to do dynamically. There will not be any java classes generated, the xsd files need to be created on the fly.
    Please suggest xml schema creation in this sequence.

  • Can i create more than one attributes for the custom class created using java API

    Hello everyone,
    I have been creating class and its attributes programatically using java APIs, I want to know that is there any way to create multipal attributs for the same class in just one call of API with all the options for each attributes,
    thanks

    You can create a new class and define all of the Attributes at the time the class is created - this is the preferred way of creating classes. Use the addAttributeDefinition() method on ClassObjectDefinition. If you need to add attributes to existing classes, you can only add them one at a time (using the addAttribute() method on ClassObject).
    (dave)

  • How to create a mail user agent by using JAVA...

    my lecturer has asked me to create a mail user agent by using JAVA , i have no idea how to start this assignment......

    What part are you stuck on? Creating a GUI (look at the Swing tutorials), or writing the talk-to-mail-server bit? Look at Java Mail, or the email RFCs.

  • Need Sample Code for Vendor creation using JAVA API

    Hi,
    I have a scenario like Vendor creation using <b>Java API</b>.
    1.I have Vendors (Main) Table.
    2.I have <b>look up</b> tables like Account Group.
    3.Also <b>Qualifier table</b>(Phone numbers) too.
    Could you please give me the sample code which helps me to create Vendor records using Java API?
    <b>I need Code samples which should cover all of the above scenario.</b>
    <b>Marks will be given for the relevent answers.</b>
    Best Regards
    PK Devaraj

    Hi Devraj,
    I hope the below code might solve all your problem:-
    //Adding Qualified field
    //Creating empty record in Qualifed table 
    //Adding No Qualifiers
    Record qualified_record = RecordFactory.createEmptyRecord(new TableId(<TableId>));
    try {
    qualified_record.setFieldValue(new FieldId(<fieldId of NoQualifier), new StringValue(<StringValue>));//Adding No Qualifier
    catch (IllegalArgumentException e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
    catch (MdmValueTypeException e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
    //Creating Record in Qualified table
    CreateRecordCommand create_command = new CreateRecordCommand(connections);
    create_command.setSession(sessionId);
    create_command.setRecord(qualified_record);
    try
    create_command.execute();
    catch(Exception e)
    System.out.println(e.toString());
    RecordId record_id = create_command.getRecord().getId();
    //Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers
    QualifiedLookupValue lookup_value = new QualifiedLookupValue();
    int link = lookup_value.createQualifiedLink(new QualifiedLinkValue(record_id));
    //Adding Yes Qualifiers
    lookup_value.setQualifierFieldValue(0 , new FieldId(<FieldID of Yes Qualifier>) , new StringValue(<StringValue>));
    //Now adding LookUP values
    //Fetch the RecordID of the value selected by user using the following function
    public RecordId getRecordID(ConnectionPool connections , String sessionID , String value , String Fieldid , String tableid)
    ResultDefinition rsd = new ResultDefinition(new TableId(tableid));
    rsd.addSelectField(new FieldId(Fieldid));
    StringValue [] val = new StringValue[1];
    val[0] = new StringValue(value);
    RetrieveRecordsByValueCommand val_command = new RetrieveRecordsByValueCommand(connections);
    val_command.setSession(sessionID);
    val_command.setResultDefinition(rsd);
    val_command.setFieldId(new FieldId(Fieldid));
    val_command.setFieldValues(val);
    try
         val_command.execute();
    catch(Exception e)
    RecordResultSet result_set = val_command.getRecords();
    RecordId id = null;
    if(result_set.getCount()>0)
         for(int i = 0 ; i < result_set.getCount() ; i++)
         id = result_set.getRecord(i).getId();     
    return id;
    //Finally creating the record in Main table
    com.sap.mdm.data.Record empty_record = RecordFactory.createEmptyRecord(new TableId("T1"));
    try {
         empty_record.setFieldValue(new FieldId(<FieldId of text field in Main table>),new StringValue(<StringValue>));
         empty_record.setFieldValue(new FieldId(<FieldId of lookup field in Main table>), new LookupValue(<RecordID of the value retrieved using the above getRecordID function>));
    empty_record.setFieldValue(new FieldId(<FieldId of Qualified field in Main table>), new QualifiedLookupValue(<lookup_value>));//QualifiedLookUp  value Retrieved above
    } catch (IllegalArgumentException e1) {
    // TODO Auto-generated catch block
         e1.printStackTrace();
    } catch (MdmValueTypeException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
    //Actually creating the record in Main table
    CreateRecordCommand create_main_command = new CreateRecordCommand(connections);
    create_main_command.setSession(sessionId);
    create_main_command.setRecord(empty_record);
    try
         create_main_command.execute();
    catch(Exception e)
         System.out.println(e.toString());
    Thanks
    Namrata

Maybe you are looking for

  • I would like to buy an app not available in India.how can I buy it

    I need to buy an app on decisions of golf which is not available in iTunes India.there has to be another way of purchasing it.when I registered there was no iTunes India and I could use an international credit card.why should this change now.

  • Sales orders by batch

    Is there a standard SAP report where I can pull sales orders by a specific batch.  If we need to do a recall on a particular batch we would need to find all sales of this batch.  If there is no standard report to accomplish this, is there a sales rep

  • Fcpx with magic bullet green and pink flash frames

    Hi I'm using fcpx with magic bullet. all recent updates. an imac 3.4ghz 32gb ram 512ssd drive and 512mb card. I keep getting pink and green flash frames whenever i colour grade in magic bullet. first 22 secs of project were fine, next day I added to

  • Tags/flags for songs - feature request

    Hello everybody, I've been using itunes for years now and am pretty happy with it, except for slow performance in .7 - also becasue of a large library. What would you think about a feature that allows to set flags/tags for each song, like in blogs or

  • Help needed on text variable.

    Hi experts, I have to write a report that requires text variable. My scenario is as follows: 1. User have to key in posting period into variable 0P_PER3. 2. The text variable has to translate posting period into calendar month. However, since I am no