Retrieving lookup field values from a main table using MDM JAVA APIs
Hi all,
am trying to retrieve the main table data...., i could able to retrieve all the data except lookup field values..., iam facing some runtime exceptions and i dont know why exactly it is throwing this exception..., i pasted piece of code where exactly the error is and the exception also.
in the below sode i set some result set definitions and passing them to retrieveLimitedRecordsCommand. it is showing some exception at retrieveLimitedRecordsCommand.execute(); command.
//*** Code ***//
supportingMainResultDefinitions = new ResultDefinition[] { rdQual ,rdFlat, rdqFlat };
retrieveLimitedRecordsCommand.setResultDefinition(rd);
retrieveLimitedRecordsCommand.setSearch(new Search(tableId));
retrieveLimitedRecordsCommand.setSession(sessionId);
retrieveLimitedRecordsCommand.setSupportingResultDefinitions(supportingMainResultDefinitions);
try {
retrieveLimitedRecordsCommand.execute();
PrintRecords.toConsole(retrieveLimitedRecordsCommand.getRecords());
} catch (CommandException e) {
e.printStackTrace();
//*** Below is the Exception raised ***//
java.lang.UnsupportedOperationException: Unexpected field type -1
at com.sap.mdm.internal.schema.PropertiesHelper.createField(PropertiesHelper.java:274)
at com.sap.mdm.internal.schema.PropertiesHelper.convertFrom(PropertiesHelper.java:281)
at com.sap.mdm.internal.data.RecordMetadata.<init>(Unknown Source)
at com.sap.mdm.internal.data.RecordsLoader.<init>(Unknown Source)
at com.sap.mdm.internal.data.RecordsLoader.<init>(Unknown Source)
at com.sap.mdm.internal.data.RecordResultSetHelper.convertFrom(Unknown Source)
at com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand.execute(Unknown Source)
at com.sap.mdm.apitutorial.lesson2.RecordsDisplay.getDisplayRecords(RecordsDisplay.java:303)
at org.apache.jsp.Sample_jsp._jspService(Sample_jsp.java:190)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
If anyonw worked on this concept..., please provide me the solution
Regards
Praveen k
Which version are you using? Can you please try and narrow down to the offending field? You can do this by limiting the fields you provide to ResultDefinition.
Similar Messages
-
How to retrieve the data from MDM hierarchy table using MDM Java API
Hi,
I had a hierarchy table in MDM. This table had some column say x. I want to retrieve the values of this x column and need to show them in a drop down using MDM Java API.
Can anyone help me to solve this?
Regards
VallabhaneniHi,
Here is your code...
TableId Hier_TId = repository_schema.getTableId(<hierarchy table id>);
java.util.List list = new ArrayList();
ResultDefinition Supporting_result_dfn = null;
FieldProperties[] Hier_Field_props =rep_schema.getTableSchema(Hier_TId).getFields();
LookupFieldProperties lookup_field = null;
TableSchema lookupTableSchema = null;
FieldId[] lookupFieldIDs = null;
for (int i = 0, j = Hier_Field_props.length; i < j; i++) {
if (Hier_Field_props<i>.isLookup()) {
lookup_field = (LookupFieldProperties) Hier_Field_props<i>;
lookupTableSchema =repository_schema.getTableSchema(lookup_field.getLookupTableId());
lookupFieldIDs = lookupTableSchema.getFieldIds();
Supporting_result_dfn = new ResultDefinition(lookup_field.getLookupTableId());
Supporting_result_dfn.setSelectFields(lookupFieldIDs);
list.add(Supporting_result_dfn);
com.sap.mdm.search.Search hier_search =new com.sap.mdm.search.Search(Hier_TId);
ResultDefinition Hier_Resultdfn = new ResultDefinition(Hier_TId);
Hier_Resultdfn.setSelectFields(rep_schema.getTableSchema(Hier_TId).getDisplayFieldIds());
ResultDefinition[] supportingResultDefinitions =
(ResultDefinition[])list.toArray(new ResultDefinition [ list.size() ]);
RetrieveLimitedHierTreeCommand retrieve_Hier_tree_cmd =
new RetrieveLimitedHierTreeCommand(conn_acc);
retrieve_Hier_tree_cmd.setResultDefinition(Hier_Resultdfn);
retrieve_Hier_tree_cmd.setSession(Auth_User_session_cmd.getSession());
retrieve_Hier_tree_cmd.setSearch(hier_search);
retrieve_Hier_tree_cmd.setSupportingResultDefinitions(supportingResultDefinitions);
try {
retrieve_Hier_tree_cmd.execute();
} catch (CommandException e5) {
// TODO Auto-generated catch block
e5.printStackTrace();
HierNode Hier_Node = retrieve_Hier_tree_cmd.getTree();
print(Hier_Node,1);
//method print()
static private void print(HierNode node, int level) {
if (!node.isRoot()) {
for (int i = 0, j = level; i < j; i++) {
System.out.print("\t");
System.out.println(node.getDisplayValue());
HierNode[] children = node.getChildren();
if (children != null) {
level++;
for (int i = 0, j = children.length; i < j; i++) {
print(children<i>, level);
//end method print()
Best regards,
Arun prabhu S
Edited by: Arun Prabhu Sivakumar on Jul 7, 2008 12:19 PM -
How to add record in Qualified table using MDM Java API
Hi experts,
I am trying to add a record into a Table.
but I am facing the problem in setFieldValue method.
//Getting Field-ID to pass in setFieldValue() method.
FieldId[] fields = new FieldId[6];
fields[0] = repSchema.getFieldId("GTINs", "Description");
fields[1] = repSchema.getFieldId("GTINs", "Unit_Descriptor");
fields[2] = repSchema.getFieldId("GTINs", "GTIN");
fields[3] = repSchema.getFieldId("GTINs", "Alternate_Item_Classifications");
fields[4] = repSchema.getFieldId("GTINs", "Country_Of_Origin");
fields[5] = repSchema.getFieldId("GTINs", "Bar_Coded");
Record rec = RecordFactory.createEmptyRecord(mainTableId);
rec.setFieldValue(fields, );
but I am not getting how to assign the value to these fields using MDMvalue Interface.
Can anyone provide me the code sample or Code flow so that I can do this.
Plz help me it'll be great help for me.
Thanks
Tarun
Edited by: Tarun Sharma on Feb 4, 2008 11:39 AM
==========================================================================================
Hi Gurus
I found the way to add the MDMValue in setFieldValue Method.
we can set like this:
setFieldValue(<fieldId object like fieldId[], <MdmValue like this> new StringValue("ABC"));
Now I am facing problem in adding value to lookup flat table.
According to the setFieldValue method we can assign the loookup like this:
setFieldValue(<fieldId[0]>, new LookpValue(<here we have to pass the recordID of lookup table>);
so I want to know how I can pass the recordId of lookup table here.
Please suggest.
Thanks
Tarun Sharma
Edited by: Tarun Sharma on Feb 4, 2008 3:15 PM
Edited by: Tarun Sharma on Feb 4, 2008 3:25 PM
Edited by: Tarun Sharma on Feb 8, 2008 6:58 PMHi Andrea,
I tried your suggestion but now i am getting Type Mismatch Error.
Please suggest me what I can do?
//TableId for Lookup[Flat].
TableId lookupTableId = repSchema.getTableId("Return_Goods_Policies");
FieldId[] ReturnGoodsPolicyTableIdFields = new FieldId[1];
ReturnGoodsPolicyTableIdFields[0] = repSchema.getFieldId("Return_Goods_Policies", "Name");
Record recLookup = RecordFactory.createEmptyRecord(lookupTableId);
try{
recLookup.setFieldValue(ReturnGoodsPolicyTableIdFields[0], new StringValue("New_Brand"));
}catch(Exception ex){
System.out.println(ex);
//Creating Record in Qualified Table - Request Details
CreateRecordCommand createLookupcommand = new CreateRecordCommand(simpleConnection);
createLookupcommand.setSession(session);
createLookupcommand.setRecord(recLookup);
createLookupcommand.execute();
//Getting the recordId of Lookup record.
RecordId lookupRecordId = createLookupcommand.getRecord().getId();
//Table Id for Qualified table.
TableId qualifiedTableId = repSchema.getTableId("Ext_Hardlines");
FieldId[] ExtHardlinesFields = new FieldId[3];
ExtHardlinesFields[0] = repSchema.getFieldId("Ext_Hardlines", "Name");//Text
ExtHardlinesFields[1] = repSchema.getFieldId("Ext_Hardlines", "Pieces_Per_Trade_item");//Integer
ExtHardlinesFields[2] = repSchema.getFieldId("Ext_Hardlines","Return_Goods_Policy");
Record recQualified = RecordFactory.createEmptyRecord(qualifiedTableId);
try{
recQualified.setFieldValue(ExtHardlinesFields[0], new StringValue("Qualified Value"));
recQualified.setFieldValue(ExtHardlinesFields[1], new StringValue("Qualified Description"));
recQualified.setFieldValue(ExtHardlinesFields[2], new LookupValue(lookupRecordId));
}catch(Exception ex){
System.out.println(ex);
//Creating Record in Qualified Table - Request Details
CreateRecordCommand createQualifiedCommand = new CreateRecordCommand(simpleConnection);
createQualifiedCommand.setSession(session);
createQualifiedCommand.setRecord(recQualified);
createQualifiedCommand.execute(); I am getting this Type match here, but i m not getting what mistake i did.
RecordId qualifiedRecordId = createQualifiedCommand.getRecord().getId();
//Adding to Main Table
TableId mainTableId = repSchema.getTableId("GTINs");
FieldId[] gtinsFields = new FieldId[1];
gtinsFields[0] = repSchema.getFieldId("GTINs","Ext_Hardlines");
Record recMain = RecordFactory.createEmptyRecord(mainTableId);
//Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers
QualifiedLookupValue qualifiedLookupValue = new QualifiedLookupValue();
qualifiedLookupValue.createQualifiedLink(qualifiedRecordId);
try{
recMain.setFieldValue(gtinsFields[0], new QualifiedLookupValue(qualifiedLookupValue));
}catch(Exception ex){
System.out.println(ex);
CreateRecordCommand createCmd = new CreateRecordCommand(simpleConnection);
createCmd.setSession(session);
createCmd.setRecord(recMain);
createCmd.execute();
Could you help me out?
Thanks
Tarun -
Retrieve Title field values from multiple lists and add into another list
Hi , Iam trying to retrieve Title field value from multiple lists. and add them into another list. using Javascript. Can any one help me in doing this. Below is the code.. function save() { clientContext = new SP.ClientContext.get_current(); oWebsite = clientContext.get_web(); oList = clientContext.get_web().get_lists().getByTitle('MainList'); clientContext.load(oList); clientContext.executeQueryAsync(OnSucceeded, onQueryFailed); } function GetListItemValue(listName, fieldName) { var list = oWebsite.get_lists().getByTitle(listName); var eventValue = document.getElementById(fieldName).value; eventValue = eventValue.replace(",", ""); var camlQuery = new SP.CamlQuery(); var filterdata = '<view><query><where><eq><fieldref name="Title/"><value type="Text">' + myreqValue.trim() + '</value></fieldref></eq></where></query></view>'; camlQuery.set_viewXml(filterdata); listItems = list.getItems(camlQuery); clientContext.load(list); clientContext.load(listItems, 'Include(Id)'); clientContext.executeQueryAsync(Succeeded,Failed); } function OnSucceeded() { itemCreateInfo = new SP.ListItemCreationInformation(); oListItem = oList.addItem(itemCreateInfo); oListItem.set_item('Title', 'My New Title'); var deptItemLookupField = new SP.FieldLookupValue(); //Problem in below line...I was unable to get ID var getId = GetListItemValue("Listname1", "txtboxname1"); alert("ID" + getId); if (getId != undefined) { deptItemLookupField.set_lookupId(getId); } var getId12 = GetListItemValue("Listname12", "txtboxname12"); alert("ID" + getId12); if (getId12 != undefined) { deptItemLookupField.set_lookupId(getId12); } oListItem.update(); clientContext.executeQueryAsync(itemadded, itemFailed); } function itemadded() { alert('Item added successfully'); } function itemFailed(sender, args) { alert('Item added itemFailed' + args.get_message() + '\n' + args.get_stackTrace()); }
RajHi,
For this requirement, you will need to retrieve all the lists objects you want firstly, then execute the requests one by one to get the value of the Title column using CAML or
LINQ.
How to: Retrieve Lists Using JavaScript
http://msdn.microsoft.com/en-us/library/office/hh185009(v=office.14).aspx
About
retrieve list items:
http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
You can use
Promise in your script to make your requests sequentially:
http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx
http://www.learningsharepoint.com/2013/08/13/using-deferred-and-promise-to-handle-async-calls-in-sharepoint-client-object-model/
Best regards
Patrick Liang
TechNet Community Support -
Read data from MDM For Lookup and Flat table using MDM ABAP API
Hi,
I have requriment to read data from MDM from FLAT and Lookup table using MDM ABAP API. My design is like this ,
I have one ITEMS (Main table in MDM) and inside that i have one Lookup flat table ITEM_TYPE , my requriment is to read Item number and its related Item type.
From ABAP.
Please help if any body has any idea.
Regards,
ShyamHI Guys,
I found my solution by myself. Below is the solution , hope this will help others:-
Retrieve data from MDM using MDM ABAP API.
Step- 1. Create structure in SAP with the same name as that of MDM field code for MDM Main table.
Step-2. Create another structure in SAP having all lookup fields of MDM , fieldname in ECC must be same as that of MDM field
code.
Step-3.Create structure in SAP for individual lookup field(Single Field only) with the same name as MDM Field code.
Step-4.
DATA: IT_QUERY TYPE STANDARD TABLE OF MDM_QUERY, "MDM_QUERY_TABLE,
WA_QUERY TYPE MDM_QUERY,
WA_CDT_TEXT TYPE MDM_CDT_TEXT,
IT_RESULT_SET_KEY TYPE MDM_SEARCH_RESULT_TABLE,
WA_RESULT_SET_KEY TYPE MDM_SEARCH_RESULT,
WA_STRING TYPE STRING.
DATA:<Internal table> TYPE STANDARD TABLE OF <SAP Str Having all LOOKup Fields>
DATA: :<Internal table>TYPE STANDARD TABLE OF <SAP Str one LOOKup field>,
<Workarea> LIKE LINE OF :<Internal table>.
*PASS LOGICAL OBJECT NAME.
V_LOG_OBJECT_NAME = 'Logical object name defined in Customization'.
Define logon language, country & region for server
WA_LANGUAGE-LANGUAGE = 'eng'.
WA_LANGUAGE-COUNTRY = 'US'.
WA_LANGUAGE-REGION = 'USA'.
TRY.
CREATE OBJECT LR_API
EXPORTING
IV_LOG_OBJECT_NAME = V_LOG_OBJECT_NAME.
ENDTRY.
CONNECT to repository. Apply particular logon language info
CALL METHOD LR_API->MO_ACCESSOR->CONNECT
EXPORTING
IS_REPOSITORY_LANGUAGE = WA_LANGUAGE.
*NOW PASS ITEM NO AND GET KEY FROM MDM.
CLEAR WA_QUERY.
WA_QUERY-PARAMETER_CODE = <MDM FIELD CODE>. "Field code
WA_QUERY-OPERATOR = 'EQ'. "Contains
WA_QUERY-DIMENSION_TYPE = 1. "Field search
WA_QUERY-CONSTRAINT_TYPE = 8. "Text search
WA_STRING = <Field Value>.
GET REFERENCE OF WA_STRING INTO WA_QUERY-VALUE_LOW.
APPEND WA_QUERY TO IT_QUERY.
CLEAR WA_QUERY.
*PASS ITEM NUMBER AND GET RELATED KEY FROM MDM.
TRY.
CALL METHOD LR_API->MO_CORE_SERVICE->QUERY
EXPORTING
IV_OBJECT_TYPE_CODE = <MDM Main Table>
IT_QUERY = IT_QUERY
IMPORTING
ET_RESULT_SET = IT_RESULT_SET_KEY.
CATCH CX_MDM_COMMUNICATION_FAILURE .
CATCH CX_MDM_KERNEL .
CATCH CX_MDM_NOT_SUPPORTED .
CATCH CX_MDM_USAGE_ERROR .
CATCH CX_MDM_PROVIDER .
CATCH CX_MDM_SERVER_RC_CODE .
ENDTRY.
Pass record id into keys.
LOOP AT IT_RESULT_SET_KEY INTO WA_RESULT_SET_KEY.
WA_KEYS = WA_RESULT_SET_KEY-RECORD_IDS.
ENDLOOP.
WA_RESULT_SET_DEFINITION-FIELD_NAME = <Look field name>.
APPEND WA_RESULT_SET_DEFINITION TO IT_RESULT_SET_DEFINITION.
CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE
EXPORTING
IV_OBJECT_TYPE_CODE = <MDM Main Table>
IT_RESULT_SET_DEFINITION = IT_RESULT_SET_DEFINITION
IT_KEYS = WA_KEYS
IMPORTING
ET_RESULT_SET = IT_RESULT_SET.
LOOP AT IT_RESULT_SET INTO
WA_RESULT_SET.
*PASS KEYS INTO MAIN TABLE TO GET Structure for FALT or Look up Table
TRY.
CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE_SIMPLE
EXPORTING
IV_OBJECT_TYPE_CODE = <MDM Main Table>
IT_KEYS = WA_KEYS
IMPORTING
ET_DDIC_STRUCTURE =<SAP Strct having all Look up fileds of MDM>
ENDTRY.
LOOP AT <SAP Strct having all Look up fileds of MDM> INTO <Work area>.
CLEAR WA_KEYS.
APPEND <Work area>-field name TO WA_KEYS.
CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE_SIMPLE
EXPORTING
IV_OBJECT_TYPE_CODE = <MDM Lookup table name>
IT_KEYS = WA_KEYS
IMPORTING
ET_DDIC_STRUCTURE = <Single Structure in SAP For Lookup field>.
READ TABLE <Single Structure in SAP For Lookup field>. INTO <Work Area> INDEX 1.
Here you can get the value of realted lookup fields associated with main table data.
ENDLOOP.
ENDLOOP.
LR_API->MO_ACCESSOR->DISCONNECT( ).
Edited by: Shyam Babu Sah on Nov 24, 2009 4:52 AM -
How to update field values in a database table using module pool prg?
hi
how to update field values in a database table using module pool prg?
we created a customized table, and we put 2 push buttons in screen painter update and display.
but update is not working?
data is enter into screen fields and to internal table, but it is not updated in database table.
thanks in adv
vidyaHI,
we already used the update statement. but its not working.
plz check this.
*& Module Pool ZCUST_CALL_REC
PROGRAM ZCUST_CALL_REC.
TABLES: ZCUST_CALL_REC,ZREMARKS.
data: v_kun_low like ZCUST_CALL_REC-kunnr ,
v_kun_high like ZCUST_CALL_REC-kunnr,
v_bud_low like ZCUST_CALL_REC-budat,
v_bud_high like ZCUST_CALL_REC-budat.
ranges r_kunnr for ZCUST_CALL_REC-kunnr .
ranges r_budat for zcust_call_rec-budat.
DATA: ITAB TYPE STANDARD TABLE OF ZCUST_CALL_REC WITH HEADER LINE,
JTAB TYPE STANDARD TABLE OF ZREMARKS WITH HEADER LINE.
*data:begin of itab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of itab.
*data:begin of Jtab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of Jtab.
CONTROLS:vcontrol TYPE TABLEVIEW USING SCREEN '9001'.
CONTROLS:vcontrol1 TYPE TABLEVIEW USING SCREEN '9002'.
*start-of-selection.
*& Module USER_COMMAND_9000 INPUT
text
MODULE USER_COMMAND_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'ENQUIRY'.
perform multiple_selection.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9001'.
WHEN 'UPDATE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
perform update on commit.
WHEN 'DELETE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*& Module STATUS_9000 OUTPUT
text
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE USER_COMMAND_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
endcase.
ENDMODULE. " USER_COMMAND_9001 INPUT
*& Module STATUS_9001 OUTPUT
text
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9002 INPUT
text
module USER_COMMAND_9002 input.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'UPDATE'.
perform move_data.
UPDATE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE UPDATED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT UPDATED'.
ENDIF.
WHEN 'DELETE'.
perform move_data.
DELETE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE DELETED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT DELETED'.
ENDIF.
endcase.
endmodule. " USER_COMMAND_9002 INPUT
*& Module STATUS_9002 OUTPUT
text
module STATUS_9002 output.
SET PF-STATUS 'ZCUSTOMER1'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_9002 OUTPUT
*& Module update_table OUTPUT
text
module update_table output.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
endmodule. " update_table OUTPUT
***Selection Data
FORM SELECT_DATA.
SELECT mandt kunnr budat code remarks FROM zcust_call_rec INTO
table itab
WHERE kunnr IN r_kunnr AND BUDAT IN R_BUDAT.
ENDFORM.
****append vendor code
FORM APPEND_CUSTOMER_CODE.
clear r_kunnr.
clear itab.
clear r_budat.
refresh r_kunnr.
refresh itab.
refresh r_kunnr.
IF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_high
IMPORTING
OUTPUT = r_kunnr-high.
r_kunnr-option = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I003(0) WITH 'ENTER CUSTOMER NUMBER'.
CALL SCREEN '9000'.
ENDIF.
PERFORM V_BUDAT.
ENDIF.
ENDFORM.
FORM V_BUDAT.
IF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'BT'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-HIGH = v_bud_HIGH.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I002(0) WITH 'ENTER POSTING DATE'.
CALL SCREEN '9000'.
r_budat-low = ''.
r_budat-option = ''.
r_budat-sign = ''.
ENDIF.
ENDIF.
ENDFORM.
*& Form update
text
--> p1 text
<-- p2 text
form update .
commit work.
endform. " update
*& Form move_data
text
--> p1 text
<-- p2 text
form move_data .
clear itab.
refresh itab.
move-corresponding zcust_call_rec to itab.
MOVE ZCUST_CALL_REC-MANDT TO ITAB-MANDT.
MOVE ZCUST_CALL_REC-KUNNR TO ITAB-KUNNR.
MOVE ZCUST_CALL_REC-BUDAT TO ITAB-BUDAT.
MOVE ZCUST_CALL_REC-CODE TO ITAB-CODE.
MOVE ZCUST_CALL_REC-REMARKS TO ITAB-REMARKS.
APPEND ITAB.
delete itab where kunnr is initial.
endform. " move_data
thanks in adv
vidya -
How to populate boolean fields using MDM Java API's
Hi Experts!
I am trying to populate Boolean fields in main table of my repository using MDM JAVA API SP 05 patch 2.
Problem is i am geting syntax error for any value that i try to put in.
Please provide me sample code for the purpose.
Thanks in advance!Hi,
Here is the code snippet to populate boolean values from Main Table in the Repository:
Populating boolean values from Main Table in the Repository:
wdContext.currentNodeElement().setABC(Boolean.valueOf((strABC).toString()).booleanValue());
Putting boolean values in the main table:
Record objEmptyRecord = RecordFactory.createEmptyRecord(new TableId(strTableId));
boolean bFieldValue = ((Boolean)strABC).booleanValue();
objEmptyRecord.setFieldValue(new FieldId(strFieldId),new
BooleanValue(bFieldValue));
Hope this helps.
Regards
Neha Sharma -
How to retrieve a column field value from an ADF table ?
All,
I have a backing bean where I have bounded a field of an ADF table.
I would like, in the bean, to read the value of that field so that I can use it inside a task flow router.
The question: how to read a value from a ADF table column field ?
In the bean I have the getter and setter of the RichInputText ADF table field. But when I type:
System.out.println("the name is: " + this.getName().getValue());
or
System.out.println("the name is: " + this.Name().getValue());
I get a null pointer exception.
Thanks in advance,
Sergio.Thanks Marvin, but this is not really what I'm looking for. Or at least, it does not sounds like to be :)
I need to get the value contained in a row cell of an ADF table.
Let's say the table (two rows, three cells) contains these values:
"table_A", "123", "John"
"table_B", "456", "Peter"
When I click on the first row, I need the value: "table_A". Once I got that value, I extract the last char, in this case: "A", and then I call a specific task flow from a task flow router (specified in the task flow router Cases property).
When I click on the second row, the same process applies, only the router now points to another flow view.
So to summarize, I need to get the value of a row cell in an ADF table. How to do that from within a javaBean in JDeveloper 11g Release 2 ?
This is what I have in the bean; so far I've bounded the related row cell (herkunft) to the bean. Each time I select a row on the ADF table, the function setHerkunft() runs - I see that from within the JDeveloper console - but when I try to get its value, I get a null value - hence the surrounding if statement.
package bean;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import oracle.adf.view.rich.component.rich.input.RichInputText;
+public class taskFlowBean {+
public RichInputText herkunft;
public static String taskFlowView = "C";
+public taskFlowBean() {+
System.out.println("taskFlowBean constructor call");
+}+
+public void setHerkunft(RichInputText herkunft) {+
System.out.println("set herkunft");
this.herkunft = herkunft;
if (this.getHerkunft().getValue() != null )
System.out.println("herkunft is: " + this.getHerkunft().getValue());
+//here taskFlowView will set accordingly with the herkunft value.+
+}+
+public RichInputText getHerkunft() {+
System.out.println("get herkunft");
return herkunft;
+}+
+public String getTaskFlowView() {+
System.out.println("get taskFlowView ! : " this.taskFlowView);+
return this.taskFlowView;
+}+
+}+
Regards,
Sergio. -
How to map lookup main table field in another main table using MDM 7.1?
We created a new SAP MDM 7.1 repository with multiple main tables. The first main table is called ProductMaster table which contains Products information. The ProductCode is the primary key and the only display field for the table during data loading process. The second main table is ProductByRegion table which has a main table lookup field ProductCode and a RegionId field. These two fields (ProductCode and RegionId) combine as the PK for this main table. Both main tables have key mapping enabled.
I was able to load ProductMaster table using Import Manager. But Iu2019m having trouble to load data into ProductByRegion table using MDM Import Manager. Although I have met all the 5 requirements below (excerpted from MDM Import Manager Reference Guide P.222), the ProductCode wonu2019t show up on the destination value pane. If I mapped all productCode to NULL field, ProductCode wonu2019t load. If I u2018Addu2019 all ProductCode to Destination Value pane, the Import Manager added duplicated rows to Product Master table while only loading 1 record to ProductByRegion table. I canu2019t get ProductCode show up in Matching Destination Field list. When I checked ProductMaster records in MDM Data Manager, I right-clicked on one of records, chose Edit Key Mappings, it didnu2019t show anything. However, if I right-clicked on one of those duplicated rows, Edit Key Mapping shows remote system and key correctly.
Where did I do wrong? How can I fix the problem?
Thank you for help in advance.
From: SAP MDM Import Manager Reference Guide:
Mapping to Main Table Lookup Destination Fields
Import Manager handles main table lookup fields (Lookup [Main])
differently than other MDM lookup fields. Specifically, Import Manager
does not display the complete set of display field values of the records
of the underlying lookup table. Instead, the values it displays for a main
table lookup field are limited by both the key mappings for the lookup
table and the values in the source file.
Also, Import Manager does not automatically display the values of a
Lookup [Main] destination field in the Destination Values grid when you
select the field in the Destination Fields grid. Instead, for a main table
lookup field value to appear in the Destination Values grid, all of the
following conditions must be met:
u2022 The lookup table must have key mapping enabled
u2022 The lookup field must be mapped to a source field
u2022 The source field must contain key values for the lookup table
u2022 The destination value must have a key on the current remote system
u2022 The destination valueu2019s key must match a source field value
NOTE ►► The current remote system is the remote system that was
selected in Import Manageru2019s Connect to Source dialog (see
u201CConnecting to a Remote Systemu201D on page 416 for more information).
VickyHi Michael,
Thank you very much for your response. I'm new to SAP MDM, I need some clarification and help regarding your solution.
I did use two maps to load ProductMaster and ProductByRegion separately. Here were my steps:
1. create main table ProductMaster with key mapping enabled at the table level and set ProductCode as unique and writable once (primary key).
2. create a map to load ProductMaster record from a staging table located an oracle database. But Key mapping didn't show anything when I looked at them using Data Manager.
3. create main table ProductByRegion with a lookup field looking at ProductMaster table. This field and RegionId combines as a unique field for ProductByRegion table.
4. create a map to load ProductByRegion table. But ProductCode records only shows on the source pane not destination pane and can't be mapped properly.
My questions:
1. How can I "Ensure that you add key mapping info for all ProductMaster records" besides enabling Key Mapping on the table level?
2. How can I define a concatenation of ProductCode and RegionId as a REMOTE KEY"?
Thanks a lot for your help!
Vicky -
Use MDM java Api for saving an image to mdm image table
Hi experts
I want to save an image from web dynpro java to MDM image table using java Api's
Can anyone provide a code snippet .
I am using MDM 7.1 sp6.
Thanks and regards
SureshHello Suresh
Unfortunatly, this is no possible, i mean, to load images to mdm repository through JAVA API.
Sure you can do it directly to database ( but for that you need to do saome investigation)
Here you can found JAVA API classes for MDM:
http://help.sap.com/javadocs/MDM71/
Next two classes are working with BLOBs (pdf, images, video, etc.) in MDM repository:
com.sap.mdm.blobs
com.sap.mdm.blobs.commands
Regards
Kanstantsin chernichenka
Edited by: kanstantsin_ch on Sep 8, 2011 2:36 PM -
Unable to read field value from main table - unexpected socket read error
Hi Friends,
While executing the below code, I am able to get the value of the field 'id' but i am unable to get the value for the 'materialnumber' field. i am getting the below exception
+com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read. Result is -1.
at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:158)
at com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand.execute(RetrieveLimitedRecordsCommand.java:157)
at updaterecords.main(updaterecords.java:126)
Caused by: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read. Result is -1.
at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:100)
at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:146)
... 2 more
Caused by: java.io.IOException: Unexpected socket read. Result is -1.
at com.sap.mdm.internal.net.DataSocket.receiveData(DataSocket.java:59)
at com.sap.mdm.internal.net.ConnectionImpl.readInt(ConnectionImpl.java:417)
at com.sap.mdm.internal.net.ConnectionImpl.nextMessage(ConnectionImpl.java:501)
at com.sap.mdm.internal.net.ConnectionImpl.receiveMessage(ConnectionImpl.java:472)
at com.sap.mdm.internal.net.ConnectionImpl.send(ConnectionImpl.java:209)
at com.sap.mdm.internal.net.ReservedConnection.send(ReservedConnection.java:105)
at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:97)
... 3 more+
import com.sap.mdm.commands.AuthenticateUserSessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateUserSessionCommand;
import com.sap.mdm.commands.DestroySessionCommand;
import com.sap.mdm.commands.GetRepositoryRegionListCommand;
import com.sap.mdm.data.Record;
import com.sap.mdm.data.RegionProperties;
import com.sap.mdm.data.ResultDefinition;
import com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand;
import com.sap.mdm.ids.TableId;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.schema.FieldProperties;
import com.sap.mdm.schema.RepositorySchema;
import com.sap.mdm.schema.commands.GetFieldListCommand;
import com.sap.mdm.schema.commands.GetRepositorySchemaCommand;
import com.sap.mdm.search.Search;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
public class updaterecords {
public static void main(String[] args) {
try {
String serverName = "159.112.6.26";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(serverName);
} catch (ConnectionException e) {
e.printStackTrace();
return;
// specify the repository to use
// alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
String repositoryName = "DEMO";
String dbmsName = "MDMD";
RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.ORACLE);
// get list of available regions for the repository
GetRepositoryRegionListCommand regionListCommand = new GetRepositoryRegionListCommand(connections);
regionListCommand.setRepositoryIdentifier(reposId);
try {
regionListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
RegionProperties[] regions = regionListCommand.getRegions();
// create a user session
CreateUserSessionCommand sessionCommand = new CreateUserSessionCommand(connections);
sessionCommand.setRepositoryIdentifier(reposId);
sessionCommand.setDataRegion(regions[0]); // use the first region
try {
sessionCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
String sessionId = sessionCommand.getUserSession();
// authenticate the user session
String userName = "meter1";
String userPassword = "meter1";
AuthenticateUserSessionCommand authCommand = new AuthenticateUserSessionCommand(connections);
authCommand.setSession(sessionId);
authCommand.setUserName(userName);
authCommand.setUserPassword(userPassword);
try {
authCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
GetRepositorySchemaCommand cmd=new GetRepositorySchemaCommand(connections);
cmd.setSession(sessionId);
try{
cmd.execute();
}catch(CommandException e){
System.out.println(e.getLocalizedMessage());
RepositorySchema repsch=cmd.getRepositorySchema();
// the main table, hard-coded
TableId mainTableId = new TableId(1);
// specify the result definition (what to retrieve); in this example, nothing
ResultDefinition rd = new ResultDefinition(mainTableId);
// select all records
Search search = new com.sap.mdm.search.Search(mainTableId);
//get fields
GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);
getFieldListCommand.setSession(sessionCommand.getUserSession());
getFieldListCommand.setTableId(mainTableId);
try {
getFieldListCommand.execute();
} catch (CommandException e) {
System.out.println(e);
FieldProperties[] lookupFields = getFieldListCommand.getFields();
// add fields to records to retrieve
rd.addSelectField(repsch.getFieldId("Products","Id"));
rd.addSelectField(repsch.getFieldId("Products","MaterialNumber"));
// retrieve the records
RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(connections);
limitingCommand.setSession(sessionId);
limitingCommand.setResultDefinition(rd);
limitingCommand.setSearch(search);
//limitingCommand.setPageSize(2000);
try {
limitingCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
System.out.println("Record count is " + limitingCommand.getRecords().getCount()+"\n");
Record[] records=limitingCommand.getRecords().getRecords();
System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","Id"))+ " \n");
System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","MaterialNumber"))+ " \n");
// finally destroy the session
DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connections);
destroySessionCommand.setSession(sessionId);
try {
destroySessionCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
Kindly let me know where i am going wrong. MaterialNumber field is a TEXT not a lookup table field. Above fields are from the main table.
Thanks,
RaagsHi Friends,
I got the solution. It was the error because of not having a the below statement.
limitingCommand.setPageSize(1);
As i havent used that statement, it was trying to get 1000 records, and i dont know exactly what makes this to get that error. Anyhow., As i want to use for updation, i cn live with one record.
Thanks,
Raags -
Retrieve values from a HTML table !!!
Hi.
How can i retrieve values from a HTML table using javascript ?
I´m trying to use the command "document.getElementsByTagName" without success.
Thanks in advance.
EduardoHi, Deepu.
I´m still with trouble in retrieving the value in HTML.
In debug the C_CELL_ID seems to be correctly updated but
when using the command "document.getElementById" the value is always "null".
I implemented in the method DATA_CELL the code :
if i_x = 3 and i_y = 2.
C_CELL_ID = 'zs'.
C_CELL_CONTENT = 10.
endif.
And in HTML :
var ztest = document.getElementById('zs');
alert(ztest);
Could you help me please.
Many regards
Eduardo S.
Message was edited by: Eduardo Silberberg -
MDM java api search on Main table
Hi All,
I am developing MDM Web dynpro custom application using MDM java API 2. I am having difficulty while searching on main table by date field. The fields type in MDM as u201CTime Stampu201D how I make my search constraints. Please point me if there is any tutorial or sample code.
Thanks
John.Hi John,
Try using the following code snippet.
TableId tableId = schema.getTable("Products").getId();
FieldId fieldId = schema.getField("Products", "Update_Date").getId();
FieldSearchDimension searchDimension = new FieldSearchDimension(fieldId);
Calendar cal = Calendar.getInstance();
cal.set(2009, 11, 24);
DateTimeSearchConstraint dateConstraint = new DateTimeSearchConstraint(cal, DateTimeSearchConstraint.GREATER_THAN);
Search search = new Search(tableId);
search.addSearchItem(searchDimension, dateConstraint);
Here "Products" is the name of the table on which the search is done. "Update_Date" is a field of type Timestamp. I've hard-coded the date currently. You can use the various Date constructors to set the date dynamically.
Regards,
Anil Madhavan -
MDM Java API (Creation of table)
Hi,
can anyone help me for creation of tables in repository using MDM java API .
Can u Provide sample code for this.
Edited by: Srikanth Josyula on Jun 26, 2008 8:52 AMHi Srikanth,
Check with this code.It may be useful.
createflattable.java
Created on June 25, 2008, 5:08 PM
To change this template, choose Tools | Options and locate the template under
the Source Creation and Management node. Right-click the template and choose
Open. You can then make changes to the template in the Source Editor.
package tabletype;
import com.sap.mdm.commands.AuthenticateRepositorySessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateRepositorySessionCommand;
import com.sap.mdm.commands.GetRepositoryRegionListCommand;
import com.sap.mdm.data.MultilingualString;
import com.sap.mdm.data.RegionProperties;
import com.sap.mdm.data.RegionalString;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.schema.TableProperties;
import com.sap.mdm.schema.commands.CreateTableCommand;
import com.sap.mdm.schema.commands.GetFieldListCommand;
import com.sap.mdm.schema.commands.GetTableListCommand;
import com.sap.*;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
import java.util.Locale;
public class createflattable {
/** Creates a new instance of createflattable */
public createflattable() {
private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString)
MultilingualString mlString = new MultilingualString();
for (int i = 0; i < regionPropertiesList.length; i++)
Locale locale = regionPropertiesList<i>.getLocale();
//Locale locale = regionPropertiesList<i>.getLocale();
String regionCode = regionPropertiesList<i>.getRegionCode();
String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry();
RegionalString regionalstring = new RegionalString(string, regionCode);
mlString.set(regionalstring);
return mlString;
private static TableProperties createFlatTable(RegionProperties[] regionPropertiesList)
//MultilingualString tableName = createMultilingualString(regionPropertiesList, "NewTable" + System.currentTimeMillis());
MultilingualString tableName = createMultilingualString(regionPropertiesList, "first"+System.currentTimeMillis());
System.out.println("table is" +tableName);
TableProperties table = new TableProperties(TableProperties.FLAT);
table.setName(tableName);
table.setCode("NewCode" + System.currentTimeMillis());
table.setKeyMappable(true);
table.setDescription("");
return table;
public static void main(String[] args) {
// System Name
String tag = "";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(tag);
catch (ConnectionException e)
e.printStackTrace();
return;
//////////////// specify the repository to use
//RepositoryName
String repositoryName = "";
//DataBase Name
String dbmsName = "";
RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL);
/////// create a repository session
CreateRepositorySessionCommand sessionCommand = new CreateRepositorySessionCommand(connections);
sessionCommand.setRepositoryIdentifier(reposId);
try {
sessionCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
System.out.println("Currently connected to "+reposId);
String sessionId = sessionCommand.getRepositorySession();
/////////// authenticate the repository session
String userName = "";
String userPassword = "";
AuthenticateRepositorySessionCommand authCommand = new AuthenticateRepositorySessionCommand(connections);
authCommand.setSession(sessionId);
authCommand.setUserName(userName);
authCommand.setUserPassword(userPassword);
try {
authCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
//////////////////// retrieve the list of tables
GetTableListCommand tableListCommand = new GetTableListCommand(connections);
tableListCommand.setSession(sessionId);
try {
tableListCommand.execute();
catch (CommandException e) {
e.printStackTrace();
return;
// get change stamp
// this is required when we make any kind of changes to the repository
int changeStamp = tableListCommand.getChangeStamp();
//////get repository regionlist
//A command for retrieving the list of regions supported by the repository.
// retrieve the available regions (languages) for the repository
// we need this to set up the table name for each region
GetRepositoryRegionListCommand gm = new GetRepositoryRegionListCommand(connections);
gm.setRepositoryIdentifier(reposId);
try {
gm.execute();
catch (CommandException e) {
e.printStackTrace();
return;
// RegionProperties[] rs = gm.getRegions();
RegionProperties[] regionPropertiesList = gm.getRegions();
TableProperties newtable = createFlatTable(regionPropertiesList);
CreateTableCommand c = new CreateTableCommand (connections);
c.setSession(sessionId);
c.setTable(newtable);
c.setInChangeStamp(changeStamp);
try {
c.execute();
System.out.println("sdf");
catch (CommandException e) {
e.printStackTrace();
return; -
Get Field Values from Table using Java api
I am using the example java code "RetrieveLimitedRecords" that can be found at :
https://help.sap.com/javadocs/MDM71/current/API/index.html
The code give the expected result and retrieves the record count for the main table
Now I want to get the values of the fields for one record
I added the lines:
Record[] records = recordResultSet.getRecords() ;
FieldId[] fields = records[0].getFields();
System.out.println ("Field Length = "+fields.length);
and the output is::
Field Length = 0
How can I get the fields of the record and read their values?
Thanks
NicolasAssuming you want every field, the equivalent of "SELECT *" in SQL, you can use the RepositorySchema object to get a TableSchema, and with that get all FieldIds for the table.
If your RepositorySchema variable is rs it would be something along the lines of:
TableSchema mainTableSchema = rs.getTableSchema(mainTableId);
ResultDefinition rd = new ResultDefinition(mainTableId);
rd.setSelectFields(mainTableSchema.getFieldIds());
Hope this helps,
Greg
Maybe you are looking for
-
Hi, How do i get opening balance and closing balances in reports? where i have the time chars 0fiscper3 and 0fiscyear and the values for the 0fiscper3 are 1 to 16. Thanks, Venu.
-
Func Module : LDB_PROCESS and Logical Database ADA
Hi All, How to get 'ANLB' data from logical database 'ADA' using the function module 'LDB_PROCESS'? Is there any other way to done this without getting into SELECTION SCREEN of this LOGICAL DATABASE? With Thanls & Regards, R.Nagarajan. We can -
-
Can I open two files in photoshop cc?
I've been using Ph for years and just purchased the Creative Cloud. Upon opening Ph, I see the file taking up the whole screen with no apparent way to reduce the size and display other files side by side. I need the ability to drag a jpg onto another
-
Why is there a data type NUMC?
Hi ABAP masters, working in database support for several years I've very often seen the problems that arise from the awkward data type NUMC. A numeric type stored as characters. What I always wondered is: what is this data type really good for? The l
-
Hi Guys, My scenarios are Idoc to EDI. My Doubt is What type of public SSL certificate needs to be purchased for production EDIINT/AS2? What type of private SSL certificate needs to be purchased for production EDIINT/AS2? I am not sure this belongs