on 11-27-2006 11:41 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.