How to read JCO Table parameter

Hello
I am calling Java function from ABAP side (JCO outbound call). Right now, in the java program I can get the import parameter data, but not the table parameter data. I am using the famous example5.java and the ABAP code is like below:
PARAMETERS: requtext LIKE sy-lisel.
DATA: echotext LIKE sy-lisel,
      resptext LIKE sy-lisel,
      rfctest TYPE TABLE OF rfctest,
      wa_rfctest TYPE rfctest.
wa_rfctest-rfcdata1 = requtext.
wa_rfctest-rfcdata2 = 'Hello World'.
APPEND wa_rfctest TO rfctest.
CALL FUNCTION 'STFC_CONNECTION'
  DESTINATION 'JCO'
  EXPORTING
    requtext = requtext
  IMPORTING
    echotext = echotext
    resptext = resptext
  TABLES
    rfctest  = rfctest.
In the java side it is defined as:
JCO.MetaData fmeta = new JCO.MetaData("STFC_CONNECTION");
        fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 16,   0,     0,       JCO.IMPORT_PARAMETER, null);
        fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255,   255,     0,       JCO.EXPORT_PARAMETER, null);
        fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255,   512,     0,       JCO.EXPORT_PARAMETER, null);
        fmeta.addInfo("RFCTABLE",     JCO.TYPE_TABLE,     144, 0, 0, 0,                    "RFCTEST");
Also RFCTEST structure is defined ( omitted here)
In the handleRequest(JCO.Function function), the following code:
if (function.getName().equals("STFC_CONNECTION")) {
                output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
                JCO.Table tab = tables.getTable("RFCTABLE");
                System.out.println("RFCTABLE rows = " + tables.getTable("RFCTABLE").getNumRows());
I always get 0 rows in the table RFCTABLE. I checked the trace file in the Java side, I can see the table data are indeed passed to Java side, the JCO just can't pass the data through the API.
Any one has idea of it?
Thank you very much.
Jayson

Andre 
I have read the function Structure of J_1B_NFE_XML_OUT and i don't find the TableParameter or ExportParameter for this FM.
How do you actually get your return parameter?
I don't think here the table type is JCO.Table.
And  i don't know how to use this Function . So i can't test my assumption.
JCO.Table tab = function.getImportParameterList().getTable( "XML_ITEM_TAB" );
normally people use the JCO.Table tab=function.getTableParameterList().getTable();
But XML_ITEM_TAB is not a Table parameter.
I don't know if table type from importParmeter can convert themself like that.But you still can try it.
hope that be helpful!

Similar Messages

  • How to read a table from one host to other host

    Hi Everybody,
    How to read a table from one host to other host.
    For Example,
    a/a@abcd - host 1
    b/b@xyz - host 2
    suppose im having a table called emp in a/a@abcd
    i want to read the table emp in b/b@xyz
    how to do this.??
    I know that we have to create a dblink...after that how to proceed.
    Plz help..
    Thanks in Advance,
    Gita

    connected as scott/tiger@test
    SQL>
    CREATE DATABASE LINK local
    CONNECT TO admin IDENTIFIED BY pinnet
    USING 'pinnet';
    Database link created.
    sql>
    select count(*) from
    users@local;
    COUNT(*) 
    16
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to set  JCO.Table as input parameter

    RunTest.java
    Reservation reservation=new InvReservation();
              reservation.setRSNUM("0001");
              reservation.setMATNR("cellphone");
              reservation.setMENGE(1.0);
              reservation.setLGORT("MAINWH");
              reservation.setWERKS("HQ");
              reservation.setSERNR("AP");
              reservation.setVBELN("SD");
              try{
              Collection col=reservation.confirmReservation();
              for(Iterator it=col.iterator();it.hasNext();){
                   InvReservation invRes=(InvReservation)it.next();
                   System.out.println(invRes.getRSNUM()+"  "+invRes.getMBLNR()+"  "+invRes.getMATNR() +" "
                              +invRes.getMENGE()+" " +invRes.getSERNR()+"  " +invRes.getDMBTR() +"  "
                              +invRes.getZSUBRC()+"  "+invRes.getZEMSG());
              }catch(Exception ex){
                   System.out.println("main: " +ex );
    Reservation.java
    public Collection confirmReservation() throws CustomException{
              Reservation outgoingRes = new InvReservation();
              Collection col=new ArrayList();
                   JCO.Function function = null;
                   JCO.Client client = null;
                   String functionName = "ZMM_OSB_CONFIRM_RESERVATION";
                   try{
                        function = con.createFunction(functionName);
                        client = JCO.getClient(con.getConnectionPool());
                                            if (function != null) {
                             Table codes=function.getTableParameterList().getTable("ZOSB");
              int j=codes.getNumRows();  //it did not enter the for loop
                             for(int i=0;i<codes.getNumRows();i++){
                                  Reservation incomingRes1=new InvReservation();
                                  codes.setRow(i);
                                  incomingRes1.setRSNUM(codes.getString("RSNUM"));
                                  incomingRes1.setMATNR(codes.getString("MATNR"));
                                  incomingRes1.setMENGE(codes.getDouble("MENGE"));
                                  incomingRes1.setLGORT(codes.getString("LGORT"));
                                  incomingRes1.setWERKS(codes.getString("WERKS"));
                                  incomingRes1.setSERNR(codes.getString("SERNR"));
                                  incomingRes1.setVBELN(codes.getString("VBELN"));
                                  col.add(incomingRes1);
                                   System.out.println("RSNUM:" +codes.getString("RSNUM") + 't' +
                                        "MATNR:"+ codes.getString("MATNR") + 't' +
                                        "MENGE:" +codes.getDouble("MENGE") + 't' +
                                        "LGORT:" +codes.getString("LGORT") + 't' +
                                        "WERKS:" +codes.getString("WERKS") + 't' +
                                        "SERNR:" +codes.getString("SERNR") + 't' +
                                        "VBELN:" +codes.getString("VBELN"));
                              System.out.println("after set successful");
                              client.execute(function);     
                              int  count= function.getExportParameterList().getFieldCount();
                             JCO.Field ZSUBRCField=function.getExportParameterList().getField("ZSUBRC");
                             JCO.Field ZEMSGField=function.getExportParameterList().getField("ZEMSG");
                              for(int i=0; i<count; i++) {
                                if(ZSUBRCField.getName().equals("ZSUBRC")){
                                       outgoingRes.setZSUBRC(ZSUBRCField.getString()); 
                                  }else if(ZEMSGField.getName().equals("ZEMSG")){
                                       outgoingRes.setZEMSG(ZEMSGField.getString()); 
                             System.out.println(ZSUBRCField.getName() + ":t" + ZSUBRCField.getString());
                             System.out.println(ZEMSGField.getName() + ":t" + ZEMSGField.getString());
                              Table excodes = function.getTableParameterList().getTable("ZOSBMSEG");
                              for(int i=0;i<excodes.getNumRows();i++){
                                   Reservation outgoingRes1 = new InvReservation();
                                   excodes.setRow(i);
                                   outgoingRes1.setRSNUM(excodes.getString("RSNUM"));
                                   outgoingRes1.setMBLNR(excodes.getString("MBLNR"));
                                   outgoingRes1.setMATNR(excodes.getString("MATNR"));                              
                                   outgoingRes1.setMENGE(excodes.getDouble("MENGE"));
                                   outgoingRes1.setSERNR(excodes.getString("SERNR"));
                                   outgoingRes1.setDMBTR(excodes.getDouble("DMBTR"));
                                   outgoingRes1.setZSUBRC(ZSUBRCField.getString());
                                   outgoingRes1.setZEMSG(ZEMSGField.getString());
                                   col.add(outgoingRes1);
                                   System.out.println("RSNUM:" +excodes.getString("RSNUM") + 't' +
                                              "MBLNR:" +excodes.getString("MBLNR") + 't' +
                                        "MATNR:" +excodes.getString("MATNR") + 't' +
                                        "MENGE:" +excodes.getDouble("MENGE")+ 't' +
                                        "SERNR:" +excodes.getString("SERNR") + 't' +
                                        "MENGE:" +excodes.getDouble("DMBTR") + 't' +
                                        "ZSUBRC:" +ZSUBRCField.getString() + 't' +
                                        "ZEMSG:" +ZEMSGField.getString());
                             System.out.println("all ok");
                   }catch(Exception ex){
                        System.out.println("Caught an exception: n" + ex);
                        throw new CustomException(ex);
                   }finally{
                        if (client != null) {
                             System.out.println("Connection Closed");
                             JCO.releaseClient(client);
                   return col;
    everytime , when i debug, i found that it didnot enter the for loop and the j value always equals =0
    int j=codes.getNumRows();
    and always come up with this
    JCO_ERROR_RESOURCE: Trying to access row values in a table which does not have any rows yet
    Result:
    AFTER CREATEFUNCTION:Name:   ZMM_OSB_CONFIRM_RESERVATION
    Input: 
    null
    Output:
    | PARAMETERS 'OUTPUT'
    ZEMSG
    ZSUBRC
    01234567890123456789012345678901234567890123456789
    0   1
    as stated the input is null...i dunno why i cant set the input table parameter
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme

    new code
    public Collection confirmReservation() throws CustomException{
              // TODO Auto-generated method stub
              Reservation outgoingRes = new InvReservation();
              Collection col=new ArrayList();
                   JCO.Function function = null;
                   JCO.Client client = null;
                   String functionName = "ZMM__CONFIRM_RESERVATION";
                   try{
                        function = con.createFunction(functionName);
                        client = JCO.getClient(con.getConnectionPool());
                        System.out.println("AFTER CREATEFUNCTION:" + function );
                        if (function != null) {
                             JCO.ParameterList tabInput = function.getTableParameterList();
                             JCO.Table inputTable = tabInput.getTable("ZOSBIMSEG");
                             inputTable.appendRow();
                             System.out.println("checking table input:" +this.getRSNUM()+"  " +this.getMATNR()+ ""
                                                 +this.getMENGE()+" " +this.getLGORT()+" " +this.getWERKS() +" "
                                                 +this.getSERNR()+" " +this.getVBELN());
                                                      inputTable.setValue(this.getRSNUM(),"RSNUM");
                             inputTable.setValue(this.getMATNR(),"MATNR");
                             inputTable.setValue(this.getMENGE(),"MENGE");
                             inputTable.setValue(this.getLGORT(),"LGORT");
                             inputTable.setValue(this.getWERKS(),"WERKS");
                             inputTable.setValue(this.getSERNR(),"SERNR");
                             inputTable.setValue(this.getVBELN(),"VBELN");
                                                       System.out.println("after set successful");
                              client.execute(function);     
                              int  count= function.getExportParameterList().getFieldCount();
                             JCO.Field ZSUBRCField=function.getExportParameterList().getField("ZSUBRC");
                             JCO.Field ZEMSGField=function.getExportParameterList().getField("ZEMSG");
                              for(int i=0; i<count; i++) {
                                if(ZSUBRCField.getName().equals("ZSUBRC")){
                                       outgoingRes.setZSUBRC(ZSUBRCField.getString()); 
                                  }else if(ZEMSGField.getName().equals("ZEMSG")){
                                       outgoingRes.setZEMSG(ZEMSGField.getString()); 
                             System.out.println(ZSUBRCField.getName() + ":t" + ZSUBRCField.getString());
                             System.out.println(ZEMSGField.getName() + ":t" + ZEMSGField.getString());
                              Table excodes = function.getTableParameterList().getTable("ZOSBMSEG");
                              for(int i=0;i<excodes.getNumRows();i++){
                                   Reservation outgoingRes1 = new InvReservation();
                                   excodes.setRow(i);
                                   //add here
                                   outgoingRes1.setRSNUM(excodes.getString("RSNUM"));
                                   outgoingRes1.setMBLNR(excodes.getString("MBLNR"));
                                   outgoingRes1.setMATNR(excodes.getString("MATNR"));                              
                                   outgoingRes1.setMENGE(excodes.getDouble("MENGE"));
                                   outgoingRes1.setSERNR(excodes.getString("SERNR"));
                                   outgoingRes1.setDMBTR(excodes.getDouble("DMBTR"));
                                   outgoingRes1.setZSUBRC(ZSUBRCField.getString());
                                   outgoingRes1.setZEMSG(ZEMSGField.getString());
                                   //outgoingRes.setMENGE(java.lang.Double.parseDouble(codes.getString()));
                                   col.add(outgoingRes1);
                                   System.out.println("RSNUM:" +excodes.getString("RSNUM") + 't' +
                                              "MBLNR:" +excodes.getString("MBLNR") + 't' +
                                        "MATNR:" +excodes.getString("MATNR") + 't' +
                                        "MENGE:" +excodes.getDouble("MENGE")+ 't' +
                                        "SERNR:" +excodes.getString("SERNR") + 't' +
                                        "MENGE:" +excodes.getDouble("DMBTR") + 't' +
                                        "ZSUBRC:" +ZSUBRCField.getString() + 't' +
                                        "ZEMSG:" +ZEMSGField.getString());
                             System.out.println("all ok");
                   }catch(Exception ex){
                        System.out.println("Caught an exception: n" + ex);
                        throw new CustomException(ex);
                   }finally{
                        if (client != null) {
                             System.out.println("Connection Closed");
                             JCO.releaseClient(client);
                   return col;
    Just to let's you know something here...
    the input parameter is a table structure...so when i execute this.
    Caught an exception:
    java.lang.NullPointerException
    JCO.ParameterList list = function.getImportParameterList();
                              list.setValue(this.getRSNUM(),"RSNUM");
                              list.setValue(this.getMATNR(),"MATNR");
                              list.setValue(this.getMENGE(),"MENGE");
                              list.setValue(this.getLGORT(),"LGORT");
                              list.setValue(this.getWERKS(),"WERKS");
                              list.setValue(this.getSERNR(),"SERNR");
                              list.setValue(this.getVBELN(),"VBELN");
    so i changed to ....
    it get what i want....
    but again the result of the input is still null
         JCO.ParameterList tabInput = function.getTableParameterList();
                             JCO.Table inputTable = tabInput.getTable("ZOSBIMSEG");
                             inputTable.appendRow();
                             System.out.println("checking table input:" +this.getRSNUM()+"  " +this.getMATNR()+ ""
                                                 +this.getMENGE()+" " +this.getLGORT()+" " +this.getWERKS() +" "
                                                 +this.getSERNR()+" " +this.getVBELN());
                                                      inputTable.setValue(this.getRSNUM(),"RSNUM");
                             inputTable.setValue(this.getMATNR(),"MATNR");
                             inputTable.setValue(this.getMENGE(),"MENGE");
                             inputTable.setValue(this.getLGORT(),"LGORT");
                             inputTable.setValue(this.getWERKS(),"WERKS");
                             inputTable.setValue(this.getSERNR(),"SERNR");
                             inputTable.setValue(this.getVBELN(),"VBELN");
    AFTER CREATEFUNCTION:Name:   ZMM_OSB_CONFIRM_RESERVATION
    Input: 
    null
    Output:
    | PARAMETERS 'OUTPUT'
    | ZEMSG                                            | ZSUBRC |
    |01234567890123456789012345678901234567890123456789|   0   1|
    |                                                  |00000000|

  • How to display JCO.Table in jsp, CRM ISA

    Hi,
    I have got a JCO.Table with results from teh CRM system and now want to display this in ISA.
    Is there any templates, or code, that could guide me as to how to transfer the table to jsp.
    thanks,
    sunil

    Hi Sunil,
    The code from bean class is here,
    public void listDetails(String releaseGroup,String releaseCode)                                 
    throws Exception
                    try
                         if (mRepository == null )
                              System.out.println("NuLL");
                         try
    IFunctionTemplate                                         ft=mRepository.getFunctionTemplate("BAPI_REQUISITION_GETITEMSREL");
    myFunction=ft.getFunction();
                   catch (Exception ex)
                   throw new Exception(ex + "Problem retrieving JCO.Function object.");
          if (myFunction == null)
         System.exit(1);
    mConnection.execute(myFunction);
                   JCO.ParameterList input = myFunction.getImportParameterList();
                           input.setValue(releaseGroup,"REL_GROUP");
                           input.setValue(releaseCode,"REL_CODE");
                           input.setValue(releaseFlag,"ITEMS_FOR_RELEASE");
                             System.out.println("Imported");
                         catch (Exception ex)
                              ex.printStackTrace();
                              System.exit(1);
                          mConnection.execute(myFunction);
                JCO.Table codes = null;
               codes =myFunction.getTableParameterList().getTable("REQUISITION_ITEMS");
               size =codes.getNumRows();
               if (size == 0)
                  System.out.println("No value matches the selection cretaria");
               purchaseRequisitionNo = new String[size];
               item   = new String[size];
               requestorName = new String[size];
               description = new String[size];
               creatorName = new String[size];
               purchaseRequisitionDate = new String[size];
               plant = new String[size];
              // getter methods
         public int  getSize() { return size; }
         public String getPurchaseRequisitionNo(int i){return                                                        purchaseRequisitionNo<i>; }
          public String getItem(int i) { return item<i>; }
         public String getDescription(int i) { return description<i>; }
         public String getCreatorName(int i) { return creatorName<i>; }
         public String getPurchaseRequisitionDate(int i)
                                             {return purchaseRequisitionDate<i>; }
         public String  getplant(int i) { return plant<i>; }
    Now in the JSP page get the number of entries in the table and try to get row by row from the bean class using the row number.
    <%
    int count = PR.getSize() ; // This method will return the number of
    rows in the table.
    for ( int i = 0; i < count ; i++ ) {
    %>
    <TR><TD ALIGN = "center"><%= PR.getPurchaseRequisitionNo(i) %> </TD>
    <TD ALIGN = "center"><%= PR.getItem(i) %> </TD>
    <TD ALIGN = "center"><%= PR.getDescription(i) %></TD>
    <TD ALIGN = "center"><%= PR.getCreatorName(i)%> </TD>
    <TD ALIGN = "center"><%= PR.getPurchaseRequisitionDate(i)%> </TD>
    <TD ALIGN = "center"><%= PR.getplant(i)%> </TD>
    <% } %>
    Hope this is a simple way to get your requirement.
    Let me know if this does not help you.
    Thanks
    Kathirvel.

  • How to set the tables parameter to a BAPI using adaptive RFC model

    Hi,
    I have a BAPI ZBAPI that has a tables parameter ZPernr of type ZTable with two elements pernr and name.
    I used adaptive RFC model and created model classes for the BAPI.
    My question how do i set list of pernr and name to the tables parameter in the webdynpro for java.
    I have the following methods available
    ZBAPI input = new ZBAPI();
    1.ZTable table = new ZTable();
    table.setPernr(pernr);
    table.setname(name);
    input.addZPernr(table);
    how do i set the table parameter for multiple pernr and name
    2.
    add all the pernr and name to list and set that list to input in the following way
    input.setZPernr(list) and list of typecom.sap.aii.proxy.framework.core. AbstractList
    out of two methods mentioned which one is correct.
    Please let me know the solution
    Thanks
    Bala Duvvuri

    Hi Bala,
                In your code:
    List pernrList = new ArrayList();
    pernrList  should be declared as the  type of class HROBJECT   ( The structure name in the model  e.g. the node PERFWARN type is Zhrecmfm_002_Perfrat_Warning_Input )
    Try this:
    HROBJECT  pernrList = new HROBJECT();
    pernrList.setPernr(pernr);
    input.setPernr_List(pernrList);
    // call BAPI execute method
    If you want to pass list of pernrs, you can pass in alternate way
    IPrivate<viewname>.I<nodeame>Node prNode = wdContext.node<node>();
    IPrivate<viewname>.I<nodeame>Element prEle;
    for (int i = 0; i < table.size(); i++) {
    HROBJECT  pernrList = new HROBJECT();
    pernrList.setPernr(pernr); // Set the pernr from current record
    prEle = prNode.create<nodeame>Element(pernrList);
    prNode.addElement(prEle);     
    // call BAPI execute method
    Once I execute the BAPI how do i iterate thru second table parameter PERNR_PERFRAT to get pernr and performance rating text
    Say your node name is  PERNR_PERFRAT
    for (int i = 0; i < wdContext.nodePERNR_PERFRAT().size(); i++) {
    wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPernr();
    wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPerfrat();
    Regards,
    Siva

  • How to read a table from a word file, using HWPF

    How can I read a table from a Word file using HWPF?
    I looked in API and Table class doesn't seem to have a constructor... very very strange for me. pls help

    the constructor is HWPFDocument = new HWPFDocument(/*file*/)
    Here is the API for that
    http://poi.apache.org/apidocs/org/apache/poi/hwpf/HWPFDocument.html
    Also here is another link to something that might help you more with tables
    http://www.aspose.com/Community/forums/thread/79182.aspx

  • JCO Table Parameter whith 2 lines...

    Hello all.
    How to send 2 lines parameters in the same table to call a BAPI.
    This is my code ...but not work !
    JCO.Table ItemDocCont = function.getTableParameterList().getTable("T_DOCITE");
                     ItemDocCont.setRow(1);
         ItemDocCont.appendRow();
              //item 1
              ItemDocCont.setValue("XXX", "BUKRS");
              ItemDocCont.setValue("1", "BELNR");
              ItemDocCont.setValue("2009", "GJAHR");
              ItemDocCont.setValue("001", "BUZEI");
              ItemDocCont.setValue("TESTE SGTXT ITEM 001", "SGTXT");
              ItemDocCont.setValue("100,00", "WRBTR");
              ItemDocCont.setValue("6154110199", "HKONT");
              ItemDocCont.setValue("0000000000", "AUFPL");
         ItemDocCont.appendRow();
                                               //item 2
              ItemDocCont.setValue("XXX", "BUKRS");
              ItemDocCont.setValue("1", "BELNR");
              ItemDocCont.setValue("2009", "GJAHR");
              ItemDocCont.setValue("002", "BUZEI");
              ItemDocCont.setValue("TESTE SGTXT ITEM 002", "SGTXT");
              ItemDocCont.setValue("100,00-", "WRBTR");
              ItemDocCont.setValue("2113110001", "HKONT");
              ItemDocCont.setValue("0000000000", "AUFPL");
                        mConnection.execute(function);     
    thanks in Advance.
    Regards.
    Taylor

    Hey Taylor,
    Two small issues: Before changing the data you must set the right row. You did this for the first row, but this is incorrect, because row numbers start with 0. I'd do the following:
    ItemDocCont.appendRows(2);
    //item 1
    ItemDocCont.setRow(0);
    ItemDocCont.setValue("XXX", "BUKRS");
    ItemDocCont.setRow(1);
    //item 2
    ItemDocCont.setValue("XXX", "BUKRS");
    mConnection.execute(function);
    In general it's better to create all the new rows at the same time. In your case with two rows that won't make any difference, but in general the one time allocation provides better performance.
    cheers, harald

  • How to read cluster tables

    Hi ,
    I have a requirement  to read cluster tables data using import statement . I have to access cluster tables data based on selection criteria . Any body help me regarding this isuue .
    Regards
    Uday

    Hi Uday,
    Check this one:
    [Extraction from cluster tables through function module|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33]
    Re: BW extractor for ERP cluster tables
    Regards,
    Chandra Sekhar

  • How to read a table and transfer the data into an internal table?

    Hello,
    I try to read all the data from a table (all attribute values from a node) and to write these data into an internal table. Any idea how to do this?
    Thanks for any help.

    Hi,
    Check this code.
    Here i creates context one node i.e  flights and attributes are from SFLIGHT table.
    DATA: lo_nd_flights TYPE REF TO if_wd_context_node,
            lo_el_flights TYPE REF TO if_wd_context_element,
            ls_flights TYPE if_main=>element_flights,
            it_flights type if_main=>elements_flights.
    navigate from <CONTEXT> to <FLIGHTS> via lead selection
      lo_nd_flights = wd_context->get_child_node( 'FLIGHTS' ).
    CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
      IMPORTING
        TABLE  = it_flights.
    now the table data will be in internal table it_flights.

  • How to read internal table data and use to retrive from other table.

    Hi all,
        I am trying to generate a report using ooabap.
    In this scenario, I retrieved data from one standard table (zcust) and successfully displayed using structure 'i_zcust_final' ( i_zcust_final is similar structure of zcust).  
        Now I want to get some other data from other standard table  (zpurch) using the data in i_zcust_final. How....???? I am unable to read data from i_zcust_final even i kept in loop.
        I am attaching the code here.. even it too long, please look at the code and suggest me what to do.
    code  **************************
    REPORT  ZBAT_OOPS_REPORT1.
    TABLES: ZCUST.
        D E F I N I T I O N     *****
    CLASS BATLANKI_CLS DEFINITION.
      PUBLIC SECTION.
      DATA : ITAB_ZCUST TYPE STANDARD TABLE OF ZCUST,
             I_ZCUST_FINAL LIKE LINE OF ITAB_ZCUST,
             ITAB_ZCUST1 TYPE STANDARD TABLE OF ZCUST.
      TYPES: BEGIN OF IT_ZPURCH,
              CUSTNUM   TYPE ZPURCH-CUSTNUM,
              PURC_DOC  TYPE ZPURCH-PURC_DOC,
              VENDOR    TYPE ZPURCH-VENDOR,
              STATUS    TYPE ZPURCH-STATUS,
              PURC_ORG  TYPE ZPURCH-PURC_ORG,
            END OF IT_ZPURCH.
      DATA : ITAB_ZPURCH TYPE TABLE OF IT_ZPURCH,
             I_ZPURCH_FINAL LIKE LINE OF ITAB_ZPURCH.
      METHODS: GET_ZCUST,
               PRINT_ZCUST,
               GET_ZPURCH.
    ENDCLASS.
    I N I T I A L I Z T I O N   *****
        SELECT-OPTIONS:S_CUSNUM FOR ZCUST-CUSTNUM.
    INITIALIZATION.
    S_CUSNUM-LOW = '0100'.
    S_CUSNUM-HIGH = '9999'.
    S_CUSNUM-OPTION = 'BT'.
    S_CUSNUM-SIGN   = 'I'.
    APPEND S_CUSNUM.
    CLEAR S_CUSNUM.
    I M P L E M E N T A T I O N *****
    CLASS BATLANKI_CLS IMPLEMENTATION.
      METHOD GET_ZCUST.
      SELECT * FROM ZCUST
        INTO TABLE ITAB_ZCUST
       WHERE CUSTNUM IN S_CUSNUM.
    ENDMETHOD.
      METHOD PRINT_ZCUST.
       LOOP AT ITAB_ZCUST INTO I_ZCUST_FINAL.
       WRITE:/ I_ZCUST_FINAL-CUSTNUM,
               I_ZCUST_FINAL-CUSTNAME,
               I_ZCUST_FINAL-CITY,
               I_ZCUST_FINAL-EMAIL.
       ENDLOOP.
      ENDMETHOD.
       METHOD GET_ZPURCH.
    LOOP AT ITAB_ZCUST INTO ITAB_ZCUST1.
      SELECT CUSTNUM
             PURC_DOC
             VENDOR
             STATUS
             PURC_ORG
        FROM ZPURCH
        INTO CORRESPONDING FIELDS OF TABLE ITAB_ZPURCH
        WHERE CUSTNUM EQ I_ZCUST_FINAL-CUSTNUM.
    ENDLOOP.
         LOOP AT ITAB_ZPURCH INTO I_ZPURCH_FINAL.
         WRITE:/ I_ZPURCH_FINAL-CUSTNUM,
                 I_ZPURCH_FINAL-PURC_DOC,
                 I_ZPURCH_FINAL-VENDOR,
                 I_ZPURCH_FINAL-STATUS,
                 I_ZPURCH_FINAL-PURC_ORG.
         ENDLOOP.
    ENDMETHOD.
    ENDCLASS.
      O B J E C T   *****
    DATA: BATLANKI_OBJ TYPE REF TO BATLANKI_CLS.
    START-OF-SELECTION.
    CREATE OBJECT BATLANKI_OBJ.
    CALL METHOD:
                 BATLANKI_OBJ->GET_ZCUST,
                 BATLANKI_OBJ->PRINT_ZCUST,
                 BATLANKI_OBJ->GET_ZPURCH.
    Can anyone suggest me..
      Thanks in advance,
      Surender.

    Hi Surendar..
    There is mistake in the Work area specification in this method.
    METHOD GET_ZPURCH.
    LOOP AT ITAB_ZCUST INTO ITAB_ZCUST1.
    SELECT CUSTNUM
    PURC_DOC
    VENDOR
    STATUS
    PURC_ORG
    FROM ZPURCH
    INTO CORRESPONDING FIELDS OF TABLE ITAB_ZPURCH
    <b>WHERE CUSTNUM EQ      ITAB_ZCUST1-CUSTNUM.</b>           
                                   "Instead of  I_ZCUST_FINAL-CUSTNUM.
    ENDLOOP.
    LOOP AT ITAB_ZPURCH INTO I_ZPURCH_FINAL.
    WRITE:/ I_ZPURCH_FINAL-CUSTNUM,
    I_ZPURCH_FINAL-PURC_DOC,
    I_ZPURCH_FINAL-VENDOR,
    I_ZPURCH_FINAL-STATUS,
    I_ZPURCH_FINAL-PURC_ORG.
    ENDLOOP.
    ENDMETHOD.
    Now it should work..
    One more thing : From performance point of view you have to Replace that loop using FOR ALL ENTRIES . And avoid CORRESPONDING FIELDS. it will be slow.
    This is the code.
    LOOP AT ITAB_ZCUST INTO ITAB_ZCUST1.
    if ITAB_ZCUST[] IS NOT INITIAL.
    SELECT CUSTNUM
    PURC_DOC
    VENDOR
    STATUS
    PURC_ORG
    FROM ZPURCH
    INTO TABLE ITAB_ZPURCH
    <b>for all entries in ITAB_ZCUST1</b>
    <b>WHERE CUSTNUM EQ      ITAB_ZCUST1-CUSTNUM.</b>           
                                   "Instead of  I_ZCUST_FINAL-CUSTNUM.
    ENDIF.
    ENDLOOP.
    <b>Reward if Helpful.</b>

  • How to read internal table other program (assign?)

    Hello techies,
    The problem >
    I have 2 Sap standard programs A & B
    I'm editing a userexit in program B but I need to read
    data from program A that is also running.
    While using the debugger, I can ask for the folowing
           (A)internaltable
            example : (SAPLMEPO)pot
    this shows the content of internal table "pot" of the program "SAPLMEPO".
    The question>
    How can I copy the content of a table(ex. pot) in program "A"(ex. SAPLMEPO) to a internal table pot2 of program "B"?
    Possible sollution (does not work in 5.0)
    CODE SAMPLE *************
    Fields          **
    data: w_name type char50,"help field
          w_recpot like ekpo."help structure
    Internal tables **
    data: Begin of it_pot2 occurs 0.
       include structure it_pot2.
    data: End of it_pot2
    field-symbols <fs_pot> type any table.
    w_structure_name = '(SAPLMEPO)pot'.
    assign (w_structure_name) to <fs_pot>.
    loop at <fs_pot> into w_recpot.
    it_pot2 = w_recpot.
    append it_pot2
    Endloop.
    END CODE SAMPLE *************
    Thanks in advance,
    Frederik

    Hi again,
    1. Simple.
    2. In your case, u should use
      <b>[]</b>
      DATA : myitab LIKE TABLE OF t001 WITH HEADER LINE.
      DATA : w_struct_name(100) TYPE c.
      BREAK-POINT.
      FIELD-SYMBOLS <fs_pot> TYPE ANY TABLE.
    <b>  w_struct_name = '(ZAM_TEMP0)ITAB[]'.</b>
      ASSIGN (w_struct_name) TO <fs_pot>.
    3. No need to use Loop etc.
    4. *----
    In your case
    CODE SAMPLE *************
    Fields **
    data: w_name type char50,"help field
    w_recpot like ekpo."help structure
    Internal tables **
    data: Begin of it_pot2 occurs 0.
    include structure it_pot2.
    data: End of it_pot2
    field-symbols <fs_pot> type any table.
    w_structure_name = '<b>(SAPLMEPO)POT[]</b>'.
    assign (w_structure_name) to <fs_pot>.
    NOT REQUIRED
    *loop at <fs_pot> into w_recpot.
    *it_pot2 = w_recpot.
    *append it_pot2
    *Endloop.
    END CODE SAMPLE *************
    regards,
    amit m.

  • How to read a table/structure value in a container from a Z program

    Experts,
    I have a WF with one of the container element is a multiline table element of the strucuture BSEG. Now I have a report where given a WID, i need to read the contents of this structure from the workflow container and display in ALV grid.
    I'm using the FM SAP_WAPI_READ_CONTAINER or SWW_WI_CONTAINER_READ to read the container. No issues till here now.
    I'm able to read the contents of the attributes that are simple without being in a structure/table.
    But, how do i read the values from the table/structure in the container from this FM?
    I see lots of threads talking about SWC_GET_TABLE or something like that. But I don't know whether and how to use it in my scenario. Any sample programs will be greatly appreciated.
    Thanks,
    Sam

    Hey,
    No issues. I sorted out myself. Glory to God in the Heavens!
    -Sam

  • HOW TO READ A TABLE CONTROL IN BDC

    hi
    how to know the field position..which row in table control before edit it...
    for exaample:
    position of table control: mm02>enter matnr>basic view1-->click additional data..
    depending on the sy-langu required language position changes.
    if sy-langu = en.
    in table control..
    en english descritption.
    sv swedish desc
    if sy-langu = sv.
    sv swedish desc
    en english disc
    if sy-langu = de
    sv swedish desc
    en english desc
    i how can i know the position of sv in table control to update it's discription . it would not be depended on sy-langu..
    any idea???
    urgent plzzz

    BDC XK01 using Table control: see the loop and field with  index
    REPORT Y730_BDC5 .
    *HANDLING TABLE CONTROL IN BDC
    DATA : BEGIN OF IT_DUMMY OCCURS 0,
           DUMMY(100) TYPE C,
           END OF IT_DUMMY.
    DATA : BEGIN OF IT_XK01 OCCURS 0,
           LIFNR(10) TYPE C,
           BUKRS(4)  TYPE C,
           EKORG(4)  TYPE C,
           KTOKK(4)  TYPE C,
           NAME1(30) TYPE C,
           SORTL(10) TYPE C,
           LAND1(3)  TYPE C,
           SPRAS(2)  TYPE C,
           AKONT(6)  TYPE C,
           FDGRV(2)  TYPE C,
           WAERS(3)  TYPE C,
           END OF IT_XK01,
           BEGIN OF IT_BANK OCCURS 0,
           BANKS(3)  TYPE C,
           BANKL(10) TYPE C,
           BANKN(10) TYPE C,
           KOINH(30) TYPE C,
           LIFNR(10) TYPE C,
           END OF IT_BANK.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
           IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = 'C:VENDOR.TXT'
       FILETYPE                      = 'ASC'
    TABLES
       DATA_TAB                      = IT_DUMMY.
    LOOP AT IT_DUMMY.
      IF IT_DUMMY-DUMMY+0(2) = '11'.
        IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
        IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
        IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
        IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
        IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
        IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
        IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
        IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
        IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
        IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
        IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
        APPEND IT_XK01.
      ELSE.
        IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
        IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
        IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
        IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
        IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
        APPEND IT_BANK.
      ENDIF.
    ENDLOOP.
    LOOP AT IT_XK01.
    REFRESH IT_BDCDATA.
    perform bdc_dynpro      using 'SAPMF02K' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-REF_LIFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                                  IT_XK01-LIFNR.
    perform bdc_field       using 'RF02K-BUKRS'
                                  IT_XK01-BUKRS.
    perform bdc_field       using 'RF02K-EKORG'
                                  IT_XK01-EKORG.
    perform bdc_field       using 'RF02K-KTOKK'
                                  IT_XK01-KTOKK.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-TELX1'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  IT_XK01-NAME1.
    perform bdc_field       using 'LFA1-SORTL'
                                  IT_XK01-SORTL.
    perform bdc_field       using 'LFA1-LAND1'
                                  IT_XK01-LAND1.
    perform bdc_field       using 'LFA1-SPRAS'
                                  IT_XK01-SPRAS.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-KOINH(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    DATA : FNAM(20) TYPE C,
           IDX      TYPE C.
    LFBK-BANKS(3)
      MOVE 1 TO IDX.
    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
      CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKS.
      CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKL.
      CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKN.
      CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-KOINH.
      IDX = IDX + 1.
    ENDLOOP.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-FDGRV'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFB1-AKONT'
                                  IT_XK01-AKONT.
    perform bdc_field       using 'LFB1-FDGRV'
                                  IT_XK01-FDGRV.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0310'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFM1-WAERS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFM1-WAERS'
                                  IT_XK01-WAERS.
    perform bdc_dynpro      using 'SAPMF02K' '0320'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'WYT3-PARVW(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    CALL TRANSACTION 'XK01' USING IT_BDCDATA
                            MODE  'A'
                           UPDATE 'S'
                         MESSAGES INTO IT_BDCMSGCOLL.
    ENDLOOP.
    FORM BDC_DYNPRO USING PROG SCR.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-PROGRAM = PROG.
      IT_BDCDATA-DYNPRO  = SCR.
      IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDCDATA.
    ENDFORM.
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-FNAM = FNAM.
      IT_BDCDATA-FVAL  = FVAL.
      APPEND IT_BDCDATA.
    ENDFORM.

  • How to read ABAP return parameter into java code

    Hi all,
    How JAVA environment can trap an error returned from abap code?
    E.g.:
    From a BAPI wrapper written like this:
    "function zpm_gi_create .
    ""Interfaccia locale:
    *"  IMPORTING
    *"     VALUE(ZBAPIGOODSMVT) TYPE  ZBAPIGOODSMVT
    *"  EXPORTING
    *"     VALUE(RETURN) TYPE  BAPIRET2
    *"     VALUE(PO_NUMBER_ES) TYPE  ZBAPIEKKO-PO_NUMBER
    *"  TABLES
    *"      GOODSMVT_ITEM STRUCTURE  ZGOODSMVT_ITEM
      data: goodsmvt_header type bapi2017_gm_head_01,
            return2         type bapiret2 occurs 0 with header line,
      call function 'BAPI_GOODSMVT_CREATE'
        exporting
          goodsmvt_header             = goodsmvt_header
          goodsmvt_code               = zbapigoodsmvt-gm_code
          testrun                     = 'X'
    importing
      GOODSMVT_HEADRET   GM         =
        materialdocument              = matdoc
        matdocumentyear               = matyear
    tables
        goodsmvt_item                 = gm_item
      GOODSMVT_SERIALNUMBER       =
          return                      = return2.
    Our return (for istance is):
    "EBM                  312The (internal) unit xx has not been maintained in
    the unit table"
    How JAVA environment can trap this error or interpret the BAPIRET2 structure?
    Is there something to do in the corresponding syncBO?
    regards,
    eliana

    Hi elina ,
    these topic is already discussed in forum.
    Jo has replied to this doubt in these links.
    Re: Return messages in SyncBo
    Can't see RETURN parameter in SyncBO
    Return messages in SyncBo
    just note this..
    have to change like this , when u follow the help.
    if (messageReply.getType() == MessageReplyType.SYNC_BEGIN) {
              if (messageReply.getType() == MessageReplyType.SYNC_END) {
                Regards
                  Kishor Gopinathan

  • How to read I$ table using ODI procedure

    Hi
    Can any one help me how to drop a I$ table from out sie of interface.
    I have tried below approches but no luck
    I have created ODI procedure with technology oracle and target logical schema (I$ tables are creating on target DB) with and with out begin and end;
    Approch 1:
    Given below code in ODi procedure
    drop table <%=odiRef.getTable("L", "INT_NAME", "W")%> <% if (new Integer(odiRef.getOption( "COMPATIBLE" )).intValue() >= 10 ) { out.print( "purge" ); }; %>
    Approch 2:
    drop table I$_<%=odiRef.getTable("L", "TARG_NAME", "A") %>;
    Approch 3:
    drop table <%=odiRef.getTable("L", "INT_NAME", "W")%> (but it is fetching target dtabase schema anme not I$ table)
    Please help me any other alternative way to drop a I$ table, more over this code should be unique for all interface
    Regards,
    Phanikanth

    Thanks bhabani,
    Actaul my requirement is some time my scenario is stoping due some issue at Merge Rows Step (I am using IKM Oracle Incremental Update(Merge) KM) when the next iteration starts it is thwoing and error at create flow table I$ step and error is table name is already exists, so i am doing is if the interface went failed I am storing those information in one table using ODI procedure (INF--ko-->ODI procedure) in same ODI procedure I want to call a I$ table to drop.
    Can you please provide the steps so it will very useful for me using Java variable.
    I have gievn a step as below on create I$ table step (after create I$ statement)
    <@ java.lang.String Idollertable = <%=odiRef.getTable("L", "INT_NAME", "W")%> ; @>
    I am calling Idollertable variable in ODI procedure which is ko>* of INF as <@=Idollertable@>
    Note: I have followed below approch
    ODI Procedure Code:
    drop table <@=Idollertable@>; --> *2nd approch*
    begin
    insert into ODI_EXECUTION_ERROR_DETAILS
    (SESSION_NO,
    SCENARIO_NAME,
    CONTEXT_NAME,
    ERR_MESSAGE,
    INSERT_COUNT,
    ERROR_COUNT)
    values
    <%=snpRef.getSession("SESS_NO")%>,
    '<%=odiRef.getPrevStepLog("STEP_NAME")%>',
    '<%=odiRef.getContext( "CTX_NAME" )%>',
    '<%=odiRef.getPrevStepLog("MESSAGE")%>',
    '<%=odiRef.getPrevStepLog("INSERT_COUNT")%>',
    '<%=odiRef.getPrevStepLog("ERROR_COUNT")%>'
    commit;
    drop table <@=Idollertable@>; --> * first approch *
    end;
    Please help me
    Regards,
    Phanikanth
    Edited by: Phanikanth on Mar 3, 2013 9:52 PM
    Edited by: Phanikanth on Mar 3, 2013 9:52 PM

Maybe you are looking for

  • Java heap size error Work manager

    Hi,   We are working with Work Manager 6.0 running on SMP 2.3 SP03. The application was working fine, but after the data load that has happened in the UAT System, we are getting the below error: 2014/08/08 00:48:56.142: setImportParameters::STORAGE_R

  • Fonts in Library/Fonts are disabled after restart

    On every sytem start/restart I have all fonts in Library/Fonts folder disabled. Safe boot, cache cleaning etc. didn't help. Any help, please? It's quite annoying.

  • Reason to use Aperture or iPhoto library?

    A few months ago I purchase Aperture, on install I selected the option to let is use my iPhoto library. While "learning" to use Aperture, I didn't want to totally abandon iPhoto in case I wasn't pleased with it. Now I will be using Aperture solely, s

  • How many computers/iPods can a song be on?

    I have a computer and a laptop and want to buy an iPod. I think you're limited to the number of computers/iPods you can play songs on. Does anyone know what it is? Is it only for computers or do iPods count too?

  • [SOLVED] Radeon, black border (doesn't fill entire screen)

    Updated yesterday. Now I have a black border of unused screen space along the edges of my monitor. It's an AMD system using the integrated card (785G (RS880, Radeon HD 4200)) and it's connected to a TV. I've tried DVI to HDMI as well as HDMI to HDMI,