cancel
Showing results for 
Search instead for 
Did you mean: 

need to insert some value in lookup flat table usinf MDM java apis

NarendraChandel
Contributor
0 Kudos

Hi experts,

i required to insert a text value from web dynpro java screen to a MDM look up table.

can you please help me with your suggestions or code snippet to do it.

regards

Narendra

Accepted Solutions (1)

Accepted Solutions (1)

nitin_mahajan2
Contributor
0 Kudos

Use the create Record command

- Create an Empty Record using the following API of RecordFactory

public static Record createEmptyRecord(TableId table)


Record lookUpRecord = RecordFactory.createEmptyRecord(TableId table)

- Get Field Ids of all the fields and set appropriate values


FieldId fi1 = repositorySchema.getFieldId( TableCode, FieldCode )

MDMValue mdmVal1 = new MDMValue(String) ;

lookupRecord.setFieldValue( fi1, mdmVal1) ;

do similarly for all the fields

Use Create Record Command with Connect

ion Object, Set the user Session string into it.


try{
CreateRecordCommand command = new CreateRecordCommand (Conneciton Object ) ;
command.setUserSession( UserSession ) ;
command.setRecord(lookupRecord) ;
command.execute( ) ;
//if successful, you can get the recordId from the above command.
command.getRecord().getId( ) ;
}
catch( Exception e)
{ } 

PS: I just wrote this code as i was replying to assist you and is not a copied lines of code from my project. There may be some typing mistakes.

Regards,

Nitin

Edited by: Nitin Mahajan on Jun 4, 2009 8:03 PM

Answers (4)

Answers (4)

nitin_mahajan2
Contributor
0 Kudos

Hello Narendra, please mark the query answered if it is resolved.

~Nitin

nitin_mahajan2
Contributor
0 Kudos

Just for the logic,

Create / update a record in the lookup table as you would create record in the main table.

No change in execution,

After this, get the record Id if the record in the lookup table is new and set it to the lookup field value of the main table to do the mapping.

If you need i can send you the code.

Regards,

Nitin

Former Member
0 Kudos

Hi Narendra,

For inserting a new value to the lookup table you can do the following:

Use CreateRecordCommand to create a nw record in Lookup Table. Only difference here will be the TableId that you will pass. Pass the table Id of the lookup table instead of Main Table.

Pseudo code:

1. Create the user Session

2. create an object of CreateRecordCommand

3. Create an Empty Record with the required values for the fields

4. Execute the command after setting the required parameters

Hope this helps!!

Cheers,

Arafat

Former Member
0 Kudos

Hi Narendra,

Check the below link. Code would be same just in the place of table name pass the code of lookup table.

Since you are using WebDynpro. You need to create the context elements and bind them with the screen or ui elements. On click of button say Save, you will get the valyes from ui elements into the context elements, just type cast these values in the format MDM expects and use the code shown in the below link.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70a7afe4-9e3e-2b10-de8d-b105d0b8...

Regards,

Jitesh Talreja