cancel
Showing results for 
Search instead for 
Did you mean: 

MDM JAVA API to enter value into field of type date

Former Member
0 Kudos

Hi All,

I am having an input field in a typical Dynpro application where a date would be entered.I want to enter the date in my MDM table in a field of type "Date".Do you have any idea about MDM JAVA API's I need to do this.Also how can I do this ?

Thanks

Vinay

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Vinay,

How I see you already developed a WebDynpro using MDM API do you know how is the best aproach of doing this? we would like to use the API as the model do you see this as a best practice or do you know the best aproach??

Thanx in Advanced and Kind Regards!

Gerardo J

Former Member
0 Kudos

An example of Date data type usage, for the legacy API (MDM4J):

// Input String in YYYYMMDD format (example)

String dateString = "20070131";

// Parse the effective date into YMD components

int year = Integer.parseInt(dateString.substring(0, 4));

int month = Integer.parseInt(dateString.substring(4, 6));

int day = Integer.parseInt(dateString.substring(6, 8));

SystemTime systemTime = new SystemTime(year, month, day, 0, 0, 0, 0); // a2i.core.SystemTime

Value dateValue = new Value(systemTime); // a2i.core.Value

A2iField dateField = new A2iField("Your MDM Date Field Name");

dateField.SetValue(dateValue);

// Array & fields to store information for one record - standard stuff

A2iFields allFields = new A2iFields();

allFields.Add( dateField );

.

.

catalogData.AddRecord("Your MDM Table Name", allFields, 0, 0);

Former Member
0 Kudos

Hi,

Web Dynpro shall return you a type Date field. For Value, you shall have to pass SystemTime Object.

Just get the substring of Date.toString() and convert them to Integer ..

So a typical date would look like yyyy-mm-dd (eg: 2006-10-19) and not yyyymmdd.

SystemTime st = new SystemTime();

st.setYear( Integer.parseInt(Date.toString().substring(0,4));

st.setMonth ( Integer.parseInt(Date.toString().substring(5,7));

st.setDate ( Integer.parseInt(Date.toString().substring(8,10));

A2iField date = new A2iField("fieldname", new Value(st));

Hope that helps..

Regards,

Tanveer.

<b>Please mark helpful answers</b>

Note: The above mentioned code is not pasted from any editor..So might contain syntax error..

Former Member
0 Kudos

com.sap.mdm.data.<b>Record</b> interface has this following method:

public void setFieldValue(FieldId fieldId,

MdmValue value)

throws java.lang.IllegalArgumentException,

MdmValueTypeException

Use this method to set the field values.

For the MdmValue, you have to pass a <b>java.util.Calendar</b> object.

For updating records, refer to the JavaDoc on

com.sap.mdm.data.commands.ModifyRecordCommand

Hope this helps,