cancel
Showing results for 
Search instead for 
Did you mean: 

Returns o rows from sap table

Former Member
0 Kudos

Hi

I am new to sap.

I want to pull data from sap table .I have wriiten following code

  JCO.ParameterList input = function.getImportParameterList();

  input.setValue(partner.getProject(), "I_PROJECT_DEFINITION");

             log.info("New nessie partner details:populating import parameters"+partner.getProject());

 

  // Execute function

  client.execute(function);

  JCO.Table partnerDef = function.getTableParameterList().getTable("ET_PARTNER_DETAIL");

  for (int i = 0; i < partnerDef.getNumRows(); i++) {

  partnerDef.setRow(i);

  partner.setPartner(partnerDef.getString("PARTNER"));

  partner.setPartnerfunction(partnerDef.getString("PARTN_ROLE"));

  partner.setPartneraddress(partnerDef.getString("ADRESSE"));

  partner.setPartneraddrflag(partnerDef.getString("ADRESSS_FLAG"));

  partner.setPartnername(partnerDef.getString("NAME_LIST"));

  partner.setPartnertext(partnerDef.getString("DEVISION_TEXT"));

  retPartner.getCodes().add(partner);

  }

But i am getting 0 rows,even though table has records .

please help me on this

Accepted Solutions (1)

Accepted Solutions (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Manali,

You are still using JCo 2.1, which has been out of support for more than three years now. Switch to JCo 3.0 for your project. Furthermore, it's likely that you experience a behavior that is very common: The import parameter has language dependent inputs when being used in the SAP Gui, but when being used in JCo via RFC, you need to provide the internal language-independent value for it. Simply check this via the debugger in ABAP.

Best regards,

Markus

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Markus ,Hi Stefan

Thank you all for your suggestion .somehow i have managed to pull correct data...

once again Thanks for your help..

Regards,

Manali

Former Member
0 Kudos

Hi Markus,

Thanks for this information..i will try to use this clear option

we are running this interface on tomcat 6.Already existing functionality uses 2.1 API

Regards,

Manali

Former Member
0 Kudos
function.getImportParameterList().setValue(projectCode,"I_PROJECT_DEFINITION");
// Execute function
client.execute(function);

log.info("Function " + name + " executed ok...");
//Connecting to ET_PARTNER_DETAIL Table
JCO.Table partnerDef = function.getTableParameterList().getTable("ET_PARTNER_DETAIL");
 

log.info("New nessie partner details:setting parameters from ET_PARTNER_DETAIL no of rows: " + partnerDef.getNumRows()+ "\t no of columns:" + partnerDef.getNumColumns());

            

//fetching data from ET_PARTNER_DETAIL and setting that information
     
       
       
for (int i = 0; i < partnerDef.getNumRows()  ; i++) {
if(i <21)
{
partnerDef.setRow(i);
NessieProjectsPartnerIntf partner= new NessieProjectsPartnerIntf();
partner.setProject(project);
partner.setBusinessArea(1);
partner.setPartner(partnerDef.getString("PARTNER"));
log.info("PARTNER-----"+partnerDef.getString("PARTNER"));
partner.setPartnerfunction(partnerDef.getString("PARTN_ROLE"));
//log.info("PARTN_ROLE---"+partnerDef.getString("PARTN_ROLE"));
retPartner.getCodes().add(partner);
}
 
}

partnerDef.clear();

still its appending data ...please see the log

30.06.2016 12:31 INFO  - New nessie partner details:setting parameters from ET_PARTNER_DETAIL no of rows: 1 no of columns:6

30.06.2016 12:31 INFO  - PARTNER-----10001833

30.06.2016 12:31 INFO  - Got the BAPI_BUS2001_PARTNER_GETDETAIL function object  (New nessie partner details)

30.06.2016 12:31 INFO  - coverted project code new  :GB026480000

30.06.2016 12:31 INFO  - Function BAPI_BUS2001_PARTNER_GETDETAIL executed ok...

30.06.2016 12:31 INFO  - New nessie partner details:setting parameters from ET_PARTNER_DETAIL no of rows: 5 no of columns:6

30.06.2016 12:31 INFO  - PARTNER-----10001833---//repeated from previous data

30.06.2016 12:31 INFO  - PARTNER-----10005829

30.06.2016 12:31 INFO  - PARTNER-----10005829

30.06.2016 12:31 INFO  - PARTNER-----10139808

30.06.2016 12:31 INFO  - PARTNER-----10139808

dont know what i need to use?

Please help

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Manali,

When running on Tomcat 6, this means you are really using JCo 2.1. Migrate as soon as possible to JCo 3.0. JCo 2.1 is no longer supported and if you run into issues, you will have to ressolve them on your own.

Best regards,

Markus

Former Member
0 Kudos

Thanks Markus ...I can not change it i have to use the same ..so there is no solution?that means

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

JCo 3.0 and JCo 2.1 can run simultaneously in the same process.

They do not interfere with each other.

So even if some other legacy application still uses JCo 2.1 there is no justification that another application would not be able to use JCo 3.0.

Besides, Markus did not say that there won't be a solution for your issue but only that there is no official support from SAP anymore. The maintenance and support period for JCo 2.1 ended on March 31, 2013.

Best regards,

Stefan

Former Member
0 Kudos

Hi Thank you
now i am able to get the data..but i am getting overridden values from previous rows.

  1. 28.06.2016 06:51 INFO  - project code 2 : project1
  2. 28.06.2016 06:51 INFO  - New nessie partner details:setting parameters from ET_PARTNER_DETAIL no of rows: 1            no of columns:6
  3. 28.06.2016 06:51 INFO  - PARTNER-----10001833

Correct entry returned for project1

  1. 28.06.2016 06:51 INFO  - project code 2 : project2
  2. 28.06.2016 06:51 INFO  - New nessie partner details:populating import parameters
  3. 28.06.2016 06:51 INFO  - BAPI2001
  4. 28.06.2016 06:51 INFO  - New nessie partner details:setting parameters from ET_PARTNER_DETAIL no of rows: 6            no of columns:6
  5. 28.06.2016 06:51 INFO  - PARTNER-----10001833 – these are invalid rows – stored in memory from previous call
  6. 28.06.2016 06:51 INFO  - PARTNER-----10001833– these are invalid rows – stored in memory from previous call
  7. 28.06.2016 06:51 INFO  - PARTNER-----10005829
  8. 28.06.2016 06:51 INFO  - PARTNER-----10005829
  9. 28.06.2016 06:51 INFO  - PARTNER-----10139808
  10. 28.06.2016 06:51 INFO  - PARTNER-----10139808

each time the issue is the field is not being cleared hence i am retaining records from previous call. can you please guide me

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Manali,

when considering seomthing helpful, you should also signal this in the forum so that others can learn from it as well.

What you are now asking is not really fully clear to me, but I have a guess. Are you re-using the same JCoFunction instance? If so, ET_PARTNER_DETAIL will send the previously received rows to the ABAP system and obviously, it is not disturbing the logic, but simply appending to the existing table. Table parameters are always bi-directional, just like Changing parameters. If you like to re-use a function object, you need to clear all tables. Or create a new JCoFunction instance from the JCoFunctionTemplate.

Best regards,

Markus

Former Member
0 Kudos

Hi Markus

Thanks a lot.I tried to create a new JCOFunction instance ,but still its appending data from previous rows.

In your comment,you also mentioned about clearing table

and I got this information

voidclear()
          Clears the table, i.e. deletes all rows

does that mean it will actually delete table from sap end?or how it is?

i am doing this for production ..so just for safety, need to confirm 

check this.. is this correct?


function.getImportParameterList().setValue(projectCode,"I_PROJECT_DEFINITION");

  // Execute function

  client.execute(function);

  log.info("Function " + name + " executed ok...");

  //Connecting to ET_PARTNER_DETAIL Table

  JCO.Table partnerDef = function.getTableParameterList().getTable("ET_PARTNER_DETAIL");

  //partnerDef.clear();

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Manali,

the table wuill be cleared in the Java program - not remotely in the ABAP system. BTW, it seems that you are still using the 2.1 API. Is your application run on top of NetWeaver AS Java?

Best regards,

Markus