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
Vallabhaneni

Hi,
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

Similar Messages

  • How to retrieve the data from SAP-BAPI by using VB Code

    Hi ,
    I am new to BAPI.
    V have created an application in Visual Basic with the following fields
    EmpNo , EmpName, Addr1, Addr2, City and Phone (Only for Test)
    We have written the code for SAVING the data into SAP. Already we have
    constructed a table with the respective fields in SAP.
    For that we ourself created our own BAPI Structure / Function Group /
    Function Module/ Business Object - RELEASED related elements.
    1)Established the connection successfully.
    2)Stored the data into SAP Successfully and v r in need of
    3)HOW TO RETRIEVE THE DATA FROM SAP (USING GETLIST.....GETDETAIL....)
    Following is the code :
    'BAPI Structure  : ZBAPIEMP
    'Function Group  : ZBAPIEMP
    'Function Module : ZBAPI_EMP_CREATEFROMDATA
    'Business Object : ZBAPIEMP
    'Function Module : ZBAPI_EMP_GETLIST
    Dim bapictrl As Object
    Dim oconnection As Object
    Dim boEmp As Object
    Dim oZEmp_Header As Object
    Dim oImpStruct As Object
    Dim oExpStruct As Object
    Dim oreturn As Object
    Dim x As String
    Private Sub Form_Load()
    Set bapictrl = CreateObject("SAP.BAPI.1")
    Set oconnection = bapictrl.Connection
    oconnection.logon
    Set boEmp = bapictrl.GetSAPObject("ZBAPIEMP")
    Set oZEmp_Header = bapictrl.DimAs(boEmp, "CreateFromData", "EmployeeHeader")
    Set oImpStruct = bapictrl.DimAs(boEmp, "GetList", "EmployeeDispStruct")
    End Sub
    Private Sub cmdSave_Click()
        oZEmp_Header.Value("EMPNO") = txtEmpNo.Text
        oZEmp_Header.Value("EMPNAME") = txtEmpName.Text
        oZEmp_Header.Value("ADDR1") = txtAddr1.Text
        oZEmp_Header.Value("ADDR2") = txtAddr2.Text
        oZEmp_Header.Value("CITY") = txtCity.Text
        oZEmp_Header.Value("PHONE") = txtPhone.Text
        boEmp.CreateFromData EmployeeHeader:=oZEmp_Header, Return:=oreturn
        x = oreturn.Value("Message")
        If x = "" Then
            MsgBox "Transaction Completed!..."
        Else
            MsgBox x
        End If
    End Sub
    Private Sub cmdView_Click()
    End Sub
    COULD ANYBODY GUIDE ME, HOW TO RETRIEVE THE DATA FROM BAPI, FOR THE WRITTEN CODE.

    I didn't seen any other answers but here's how it's been done previously in our organization for a custom BAPI. In this example, we give material and language to return the part description. It's not specific to your project but may give you ideas..
    -Tim
    Option Compare Database
    Dim SAPLOGIN As Boolean
    Dim FunctionCtrl As Object
    Dim SapConnection As Object
    Sub SAPLOGOUT()
    On Error GoTo LogoutFehler
        SapConnection.logoff
        SAPLOGIN = False
    Exit Sub
    LogoutFehler:
        If Err.Number = 91 Then
            Exit Sub
        Else
            MsgBox Err.Description, vbCritical, "Fehler-Nr." & CStr(Err.Number) & " bei SAP-Logout"
        End If
    End Sub
    Function SAPLOG() As Boolean
    'Verbindungsobjekt setzen (Property von FunctionCtrl)
       Set FunctionCtrl = CreateObject("SAP.Functions")
       Set SapConnection = FunctionCtrl.Connection
    'Logon mit Initialwerten
       SapConnection.Client = "010"
       SapConnection.Language = "EN"
       SapConnection.System = "PR1"
       SapConnection.SystemNumber = "00"
       'SapConnection.Password = ""
       SapConnection.GroupName = "PR1"
       SapConnection.HostName = "168.9.25.120"
       SapConnection.MessageServer = "168.9.25.120"
         If SapConnection.Logon(0, False) <> True Then  'Logon mit Dialog
             Set SapConnection = Nothing
             DoCmd.Hourglass False
             MsgBox "No connection to SAP R/3 !"
             SAPLOGIN = False
             SAPLOG = False
             Exit Function
          End If
        SAPLOG = True
    End Function
    Function MatDescr(MatNr As String)
    Dim func1 As Object
    Dim row As Object, X As Integer, ErsteNr As String
    Dim DatensatzZähler As Long
    Dim RowField(1 To 50, 0 To 1) As String, RowLine As Long
        If Not SAPLOGIN Then
            If Not SAPLOG() Then
                MsgBox "No connection  to SAP !", 16
                SAPLOGOUT
                Exit Function
            End If
        End If
    ' Instanziieren des Function-Objektes
    Set func1 = FunctionCtrl.Add("Z_BAPI_READ_MAKT")
    ' Export-Paramter definieren
    func1.exports("MATNR") = MatNr
    func1.exports("SPRAS") = "EN"
    DoEvents
    If Not func1.call Then
        If func1.exception <> "" Then
            MsgBox "Communication Error with RFC " & func1.exception
        End If
        DoCmd.Hourglass False
        SAPLOGOUT
        Exit Function
    Else
      MatDescr = func1.imports("MAKTX")
    End If
    If MatDescr = "" Then
        MatDescr = "PART NO. NOT FOUND"
    End If
    End Function

  • How to retrieve the data from Website and Upload it in SAP table?

    Dear ABAPers,
            I want to retrieve the data from website and upload the same in SAP Database Table is that possible.Please help me.It is very Urgent.
    Thanks & Regards,
    Ashok.

    Dear Abhishek,
                  Thanks for your reply.But my requirement is not met.
    If i execute the program it should retrieve the data from particular website.
    Thanks & Regards,
    Ashok.

  • How to get the data from a cluster table to BW

    Dear All,
    I want to extract the data from R/3 to BW by using 2 tables and one Cluster B2.
    Actually my report contains some fields from PA2001, PA2002 and one cluster table B2 (Table ZES). Can I create View by using these 3 tables? If it is not possible how can I get the data from the cluster? Can I create generic datasource by using cluster tables directly?
    In SE11 Transaction the Cluster (table ZES) is showing invalid table.
    I referred some Forums, but no use.
    Can any body tell me procedure to get the data from a cluster (table ZES) ?
    Waiting for you results.
    Thanks and regards
    Rajesh

    HI Siggi,
    Thank you for your reply..
    I am also planning to do FM to get the data. But it is saying that the Cluster table ZES does not exist (ZES is the the standard table, in SE11 also).
    How can I use the Fields from the that table.?
    What can I do now, can you please explain me about this point.
    Waiting for your reply.
    Thanks and Regards
    Rajesh
    Message was edited by:
            rajesh

  • How to pass the data from a input table to RFC data service?

    Hi,
    I am doing a prototype with VC, I'm wondering how VC pass the data from a table view to a backend data service? For example, I have one RFC in the backend system with a tabel type importing parameter, now I want to pass all the data from an input table view to the RFC, I guess it's possible but I don't know how to do it.
    I try to create some events between the input table and data service, but seems there is no a system event can export the whole table to the backend data service.
    Thanks for your answer.

    Thanks for your answer, I tried the solution 2, I create "Submit" button, and ser the mapping scope to  be "All data rows", it only works when I select at least one row, otherwise the data would not be passed.
    Another question is I have serveral imported table parameter, for each table I have one "submit" event, I want these tables to be submitted at the same time, but if I click the submit button in one table toolbar, I can only submit the table data which has a submit button clicked, for other tables, the data is not passed, how can I achieve it?
    Thanks.

  • How to recover the data from a  dropped table in production/archive mode

    How to recover the data/change on a table that was dropped by accident.
    The database is on archive mode.

    Oracle Version. ? If 10g.
    Try this Way
    SQL> create table taj as select * from all_objects where rownum <= 100;
    Table created.
    SQL> drop table taj ;
    Table dropped.
    SQL> show recyclebin
    ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
    TAJ              BIN$b3MmS7kYS9ClMvKm0bu8Vw==$0 TABLE        2006-09-10:16:02:58
    SQL> flashback table taj to before drop;
    Flashback complete.
    SQL> show recyclebin;
    SQL> desc taj;
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    OBJECT_NAME                                        VARCHAR2(30)
    SUBOBJECT_NAME                                     VARCHAR2(30)
    OBJECT_ID                                          NUMBER
    DATA_OBJECT_ID                                     NUMBER
    OBJECT_TYPE                                        VARCHAR2(19)
    CREATED                                            DATE
    LAST_DDL_TIME                                      DATE
    TIMESTAMP                                          VARCHAR2(19)
    STATUS                                             VARCHAR2(7)
    TEMPORARY                                          VARCHAR2(1)
    GENERATED                                          VARCHAR2(1)
    SECONDARY                                          VARCHAR2(1)
    SQL>M.S.Taj

  • How to retrieve the values from PL/SQL table types.

    Hi Every one,
    I have the following procedure:
    DECLARE
    TYPE t1 IS TABLE OF emp%ROWTYPE
    INDEX BY BINARY_INTEGER;
    t t1;
    BEGIN
    SELECT *
    BULK COLLECT INTO t
    FROM emp;
    END;
    This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
    Can anybody help me please!!!!!
    Thanks
    Ahmed.

    You mean, you can't add this
    for i in t.first..t.last loop
    dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
    end loop;or you can't add this
    set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
    You see, not able like very similar it is not working - both are too vague...
    Best regards
    Maxim

  • How to retrieve the data from SAP database.

    Hi Pals,
    How to retrieve data from SAP R/3 System to my third party software. I will make my query little bit more clear. There is a list of assets entered and stored in the SAP system. For example 3 mobile phones.
    1) Mobile 1- Nokia
    2) Mobile 2 - Samsung
    3) Mobile 3 u2013 Sony
    Now think I do not know what all assets is there. I have to retrieve the data and get it on my third party software. Just display the list of assets. Lets say SAP XI is also there. Now how will I map it and get the details.
    Please give me step by step method.
    N.B: Just to read the data from SAP database.
    Please make the flow clear step by step.
    Thanking you
    AK

    Hi,
    You can use RFC or ABAP Proxy to make synchronous call with SAP.
    Under RFC or ABAP Proxy Program you can get the data from SAP tables. Direct access to SAP Database is not preferrable even if its possible.
    The better way to go for RFC or PROXY.
    You will send the request from Third party system and the it will be as input parameters from RFC/ Proxy it will response based on it.
    This got it all..
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5474f19e-0701-0010-4eaa-97c4f78dbf9b
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    /people/stefan.grube/blog/2006/09/21/using-the-soap-inbound-channel-of-the-integration-engine
    /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit - File to RFC
    HTTP to RFC - A Starter Kit
    /people/community.user/blog/2006/12/12/http-to-rfc--a-starter-kit
    Refer
    Thanks
    Swarup
    Edited by: Swarup Sawant on Jun 4, 2008 9:32 AM

  • How to retrieve the data from a jsp page for print?

    i have a dynamic jsp file which will get the data at runtime.I have a print button in the jsp.When i chick the print button it should capture the data from the jsp and print it as LANDSCAPE mode. Now i am using Java Api for this
              Following code is a working sample which prints some data in LANDSCAPE mode..This is working fine....How can i modify this to get the data from a jsp?....I am using weblogic workshop for development
              package Awtjava;
              //working example
              import java.awt.*;
              import java.awt.print.*;
              public class testPrint implements Printable {
              private static String s[];
              private static Font f;
              private static int nLines;
              public static void main (String arg[]){
              s = new String[10];
              f = new Font("Arial", Font.PLAIN, 11);
              int i;
              s[0] = "This is a printer test";
              for (i=1; i<10; i++){
              s[i] = "The next line";
              nLines = 10;
              testPrint.printa();
              public static void printa(){
              System.out.println("public static void printa () ");
              PrinterJob pj=PrinterJob.getPrinterJob();
              Book b = new Book();;
              PageFormat pf = new PageFormat();
              pf = pj.defaultPage(pf);
              b.append(new testPrint(), pf, 2);
              pj.setPageable (b);
              try{
              if (pj.printDialog()){
              pj.print();
              catch (Exception e) { System.out.println ("Error"); }
              public int print (Graphics g1, PageFormat pf, int n){
              System.out.println("public int print");
              int x,y,i,fa,fh;
              FontMetrics fm;
              Graphics2D g = (Graphics2D) g1;
              pf.setOrientation(PageFormat.LANDSCAPE);
              fm = g.getFontMetrics (f);
              fa = fm.getMaxAscent();
              fh = fm.getHeight();
              x = (int)pf.getImageableX();
              y = (int)pf.getImageableY() + fa;
              g.setFont (f);
              g.setColor(Color.black);
              if (n==1){
              for (i=0; i<10; i++){
              g.drawString (s, x, y);
              y += fh;
              return PAGE_EXISTS;
              else {
              for (i=10;i<10; i++){
              g.drawString (s[i], x, y);
              y += fh;
              return PAGE_EXISTS;
              Hope you will reply soon...
              Thanks in advance
              Maria

    Hey, I got a doubt that who will call the print method in the same program and what about the g.drawString() it is showing any output effect. Finally how the variable n will get initializing to 0 and 1 for two times respectively. Can u please elaborate on this...

  • How to retrieve the data from the RT card after the host rebooted??

    Thank you for your answer!
    how to design my application to retrieve the data that was collected on RT Series hardware while the host PC was not in communication with the embedded LabVIEW RT application.

    I rember correctly, that may be one of the more challenging varieties to pull this stunt off.
    First, you are going to have to make sure you have enough memory to buffer the data while the host if doing something else.
    If you have enough memory you may want explicitly work up a comm scheem between the host and PC (probaly using VI server) that will let the host know there is data avaiailable and it should get it.
    So, doe sit seem like we may be getting closer?
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to retrieve the data from UME?

    Hi All,
    I have a problem with retriving data from UME.Here my problem is I have logged a pirticular user that user coming from sales-organization. I got that user But How to retrive the pirticular sales-org from UME.
    Please help me for this .
    Thanks
    Nageswara.

    Hi All,
    I have a problem with retriving data from UME.Here my problem is I have logged a pirticular user that user coming from sales-organization. I got that user But How to retrive the pirticular sales-org from UME.
    Please help me for this .
    Thanks
    Nageswara.

  • How to retrieve the data from 3 tables

    lifnr,land1,banks,bankl,bvtyp,bankn,bkont,banka,ort01,swift from LFA1,LFBK,BNKA................
    please  anybody can tell immediately.........

    Hi Ramesh,
    DATA:BEGIN OF itab OCCURS 0,
    lifnr LIKE lfa1-lifnr,
    land1 LIKE lfa1-land1,
    banks LIKE lfbk-banks,
    bankl LIKE lfbk-bankl,
    bvtyp LIKE lfbk-bvtyp,
    bankn LIKE lfbk-bankn,
    bkont LIKE lfbk-bkont,
    END OF itab.
    DATA:BEGIN OF itab2 OCCURS 0,
    banka LIKE bnka-banka,
    ort01 LIKE bnka-ort01,
    swift LIKE bnka-swift,
    END OF itab2.
    SELECT alifnr aland1 bbanks bbankl bbvtyp bbankn b~bkont INTO TABLE itab
    FROM ( lfa1 AS a INNER JOIN lfbk AS b ON blifnr = alifnr ).
    select banka ort01 swift from BNKA
    into table itab2
    for all entries in itab
    where banks = itab-banks
      and bankl = itab-bankl.
    Regards
    - Gopi

  • How to read the data from an internal table,when column names are known

    Hi All
    I have a specific requirement. I got an internal table with many fields (let it be my_tab).  Some of the fieldnames (column names in internal table my_tab) are stored in separate internal table(let it be my_fields).
    I need to store/read data corresponding to the fields (whose name is stored in my_fields) from my_tab.
    I am able to build dynamic table (referred by field-symbol) with respect to the given field names in my_fields.
    But i am unable to read the data corresponding to the fieldnames from my_tab.
    Please provide  me some pointer in this regard.
    Regards
    Swetabh Shukla

    HI All
    Thanks for the prompt response. I got solution for my question. Please check below thread. For quick reponse i posted my question in one more category. Thanks to all of you.
    How to read internal table w.r.t. fieldnames stored in other table

  • How to read the data from a sorted table

    Hi all,
    How to read data from the sorted tables. Please provide some examples.
    Thanks and regards,
    Lisa

    You can read like this :
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    CLEAR LINE.
    READ TABLE ITAB WITH TABLE KEY COL1 = 3
                    INTO LINE TRANSPORTING COL2.
    WRITE:   'SY-SUBRC =', SY-SUBRC,
           / 'SY-TABIX =', SY-TABIX.
    SKIP.
    WRITE: / LINE-COL1, LINE-COL2.

  • How to fetch the data from pl/sql table dynamically

    Hi All, I have the requirement of comparing two db views data in pl/sql. So, I have bulk collect the view into pl/sql table. But, the issue is, It is expecting to provide the column name for comparison. But, in my case, column name is dynamic. So, i cannot provide the column name directly for comparison.
    For eg: In my view t1_VW, i have 4 columns. stid, c1,c2,c3,c4 and similar structure for t2_vw
    my code
    TYPE v1_type IS TABLE OF t1_vw%ROWTYPE;
    l_data v1_type;
    TYPE v1_type1 IS TABLE OF t2_vw%ROWTYPE;
    l_data1 v1_type1;
    test varchar2(1000);
    test1 varchar2(1000);
    temp1 number;
    begin
    SELECT * Bulk collect into l_data
    FROM T1_VW;
    SELECT * Bulk collect into l_data1
    FROM T2_VW;
    select l_data(1).stid into temp1 from dual; -- It is working fine and gives me the value properly
    -- But, in my case, we are reading the column names from array, i am constructing the query dynamically and execute it.
    test :='select l_data(1).stid into temp1 from dual';
    execute immediate test into temp1;
    -- I am getting error as follows:
    Error report:
    ORA-00904: "L_DATA": invalid identifier
    ORA-06512: at "SYSTEM.BULKCOMPARISON", line 93
    ORA-06512: at line 2
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action
    end;
    - Please help me to get rid of this issue. Is it possible to construct the query dynamically and fetch the data?. If not, is there any other better approach to compare the data between two views?.

    Output should display what are all columns changed and its old value and new value.
    For eg., output should be
    COLUMNNAME OLD_VALUE NEW_VALUE STID
    C1 20 10 1
    C2 50 40 2
    C3 60 70 2
    C2 80 90 3Why no do this only via a simple sql ?
    create table a (STID number, C1 number,  C2 number, C3 number);
    insert into a values (1, 20, 30, 40)
    insert into a values (2, 40, 50, 60);
    insert into a values (3, 90, 80, 100);
    create table b as select *
    from a where 1 = 0;
    insert into b values (1, 10, 30, 40)
    insert into b values (2, 40, 40, 70);
    insert into b values (3, 90, 90, 100);
    commit;And now you can issue such a kind of select
    SELECT stid , c1, c2, c3                      
       FROM
      ( SELECT a.*,
             1 src1,
             to_number(null) src2        
       FROM  a   
       UNION ALL
       SELECT b.*,
             to_number(null) src1,
             2  src2        
        FROM b
       GROUP BY stid , c1, c2, c3
       HAVING count(src1) <> count(src2)
       order by stid;I would then create a new table a_b_difference having the same structure as a or b and insert into it like this
    create table a_b_diff as select * from a where 1 = 0;
    insert into a_b_diff
    SELECT stid , c1, c2, c3                      
       FROM
      ( SELECT a.*,
             1 src1,
             to_number(null) src2        
       FROM  a   
       UNION ALL
       SELECT b.*,
             to_number(null) src1,
             2  src2        
        FROM b
       GROUP BY stid , c1, c2, c3
       HAVING count(src1) <> count(src2)
       order by stid
       ;Then each time there is a difference between a column in a and its equivalente one in b (per unique stid ) a record will be inserted in this table.
    You can do more by adding the name of the table in front of each record in this table to see exactly where the data comes from
    Best Regards
    Mohamed Houri

Maybe you are looking for