cancel
Showing results for 
Search instead for 
Did you mean: 

RFC retrieve less records from PI in java

Former Member
0 Kudos

Dear experts,<br><br> In the snippet given below i use SXMB_GET_MESSAGE_LIST RFC first on my PI box to get messageids in a class implemented as CheckXISystem.class.<br>Till this point,i get correct no of messageids.<br>Now i put the hashtable of messageids retrieved as input to another RFC.<br>This RFC is SXM_GET_MESSAGES.I am referring here to a deep structure to get a field content as follows. <br>Exporting Struture (Internal table) EX_MSG_CONTENT_LIST-> (InternalTable) MSGVSERS_T->TPROP(InternalTable) with field CONTENT <br>My issue is that CheckXISystem.class gives me correct number of messageids <br>(For example between 01.01.2010 to 05.01.2010 i have 500 messageids of PID = 'CENTRAL') <br>Now i give messageids (500 in number) as input to an internal table of RFC (SXMB_GET_MESSAGES).<br>Ideally i should recieve 500 records of prop. Table prop though contains lots of categories of XI pipelining steps but i am referring to only 'Main' LCNAME values.<br>Which means every messageid will have one main xml content so i say 500 record input should give me 500 records .<br>But actually i get 121 records.Had it been 700 records of prop ,i would have got 180 records.In this way,retrieval happens but less than actual number of records. <br>Sending my snippet

,<br><br><pre>

import java.util.Properties;

import java.util.*;

import java.text.DateFormat;

import java.text.Format;

import com.sap.conn.jco.AbapException;

import com.sap.conn.jco.server.JCoServerContext;

import com.sap.conn.jco.JCoException;

import com.sap.conn.jco.JCoField;

import com.sap.conn.jco.JCoContext;

import com.sap.conn.jco.JCoFunction;

import com.sap.conn.jco.JCoFunctionTemplate;

import com.sap.conn.jco.JCoParameterList;

import com.sap.conn.jco.JCoFieldIterator;

import com.sap.conn.jco.JCoStructure;

import com.sap.conn.jco.JCoTable;

import com.sap.conn.jco.server.JCoServer;

import com.sap.conn.jco.ext.DestinationDataProvider;

import java.io.File;

import java.io.FileOutputStream;

import java.util.Properties;

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import custom.*;

public class PayloadExtractor {

ConnectSAP ob_c ;

JCoFunction function_p;

PayloadExtractor ()

{

System.out.println ("Fetching System information of connected SAP -


wait " );

}

public void execute_payload()

{

try {

ob_c = new ConnectSAP(); //We are using everytime a new connection and function to assure that issue of less record retrieval is not due to existing objects

ob_c.connect();

ob_c.function = ob_c.destination.getRepository().getFunction("SXMB_GET_MESSAGES");

JCoContext.begin(ob_c.destination);

ISO8601DateParser obj = new ISO8601DateParser();

Date d_a = obj.parse("20100101000000");

Date d_b= obj.parse("20100813000000");

String s_a = obj.toString(d_a); //Timestamp from

String s_b = obj.toString(d_b); //Timestamp To

System.out.println(s_a.toString());

System.out.println(s_b.toString());

Hashtable messageids = new Hashtable (new CheckXISystem(s_a,s_b).getMessageids());

JCoParameterList tables = ob_c.function.getImportParameterList();

JCoTable table = tables.getTable("MSG_LIST");

int nr = messageids.size();

table.appendRows(nr);

for (int i=0; i<=messageids.size()-1;i++) {

table.setValue("MSGGUID",messageids.get(i));

table.setValue("PID","CENTRAL");

table.nextRow();

}

System.out.println("Input rows to table as parameter: "+table.getNumRows());

table.setRow(0);

ob_c.function.execute(ob_c.destination);

JCoContext.end(ob_c.destination);

JCoParameterList tables_out = ob_c.function.getExportParameterList();

JCoTable tableresout= tables_out.getTable("EX_MSG_CONTENT_LIST");

System.out.println("Number of messageids for which contents are fetched = "+tableresout.getNumRows());

if ( tableresout.getNumRows() > 0 ) {

ArrayList<PayLoadType> payloads = new ArrayList<PayLoadType>(fetchmessagepayloads(tableresout));

System.out.println("Number of payloads = "+payloads.size());

try {java.lang.Thread.sleep(2000);}catch(Exception jh) {jh.printStackTrace();}

for (int i= 0 ; i<=payloads.size()-1;i++) {

PayLoadType obp = new PayLoadType();

obp = payloads.get(i);

System.out.println("************************************************************************");

System.out.println(obp.msgid);

System.out.println(obp.payload);

System.out.println();

System.out.println("************************************************************************");

System.out.println();

System.out.println();

}

JCoTable tableres = tables_out.getTable("EX_ERR_MSG_LIST");

if ( tableres.getNumRows() > 0 ) {

for (int i=0;i <=tableres.getNumRows()-1;i++) {

String res ="Tables:""\n""EX_ERR_MSG_LIST""\n""\n"tableres.getString(0)","tableres.getString(1)","tableres.getString(2)"\n"+"\n";

System.out.println(res);

}

System.exit(1);

}

}

}

catch(Exception gg) { gg.printStackTrace();}

}

public static void main(String[] args) throws JCoException

{

PayloadExtractor ob = new PayloadExtractor();

ob.execute_payload();

}

public ArrayList<PayLoadType> fetchmessagepayloads (JCoTable tableobj)

{

int count = 0;

ArrayList<PayLoadType> oba = new ArrayList<PayLoadType> ();

while (count < tableobj.getNumRows()) {

PayLoadType obj = new PayLoadType();

JCoTable subtab1 = tableobj.getTable("MSG_VERS_T");

count = count + 1;

int rec = subtab1.getNumRows();

int numrecs = 0;

while ( numrecs < rec )

{

subtab1.nextRow();

numrecs = numrecs + 1;

}

JCoTable subtab2 = subtab1.getTable("TPROP");

numrecs = 0;

rec = subtab2.getNumRows();

while (numrecs < rec )

{

numrecs = numrecs + 1;

if (subtab2.getString("LCNAME").trim().equals("Main")) {

obj.msgid = subtab2.getString("MSGGUID");

obj.payload = subtab2.getString("CONTENT");

oba.add(obj);

}

subtab2.nextRow();

}

tableobj.nextRow();

}

return oba;

}

}

</pre>,<br><br>

Edited by: Matt on Aug 20, 2010 10:12 AM - fixed formatting a bit

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

Write messages to the trace as described in online help.

System.out.println does not help you.

Former Member
0 Kudos

Thanx stefan , but i am not getting any exception.I am getting output but with less records so what trace i should print.


try {
ob_c = new ConnectSAP();   //We are using everytime a new connection and function to assure that issue of less record retrieval is not due to existing objects
ob_c.connect();
ob_c.function = ob_c.destination.getRepository().getFunction("SXMB_GET_MESSAGES");
JCoContext.begin(ob_c.destination);
ISO8601DateParser obj = new ISO8601DateParser();
Date d_a = obj.parse("20100101000000");
Date d_b= obj.parse("20100813000000");
String s_a = obj.toString(d_a);  //Timestamp from
String s_b = obj.toString(d_b); //Timestamp To
System.out.println(s_a.toString());
System.out.println(s_b.toString());
Hashtable messageids = new Hashtable (new CheckXISystem(s_a,s_b).getMessageids());       <---- retrieve correctno of records
JCoParameterList tables = ob_c.function.getImportParameterList();
JCoTable table = tables.getTable("MSG_LIST");
int nr = messageids.size();
table.appendRows(nr);
for (int i=0; i<=messageids.size()-1;i++) {
table.setValue("MSGGUID",messageids.get(i));
table.setValue("PID","CENTRAL");
table.nextRow();
}

System.out.println("Input rows to table as parameter:  "+table.getNumRows());
table.setRow(0);
ob_c.function.execute(ob_c.destination);   <---------- retrieve less number of records 

I hope someone will help me .I want to break this myth that complex parameters are not supported in java for RFC.

Thanx a lot Matt for format Fixing.

Edited by: aditya sharma on Aug 20, 2010 10:17 AM

stefan_grube
Active Contributor
0 Kudos

> Thanx stefan , but i am not getting any exception.I am getting output but with less records so what trace i should print.

Are you sure that your RFC request is correct?

You could write that call into trace.

Former Member
0 Kudos

How,plz guide me.

Former Member
0 Kudos

I am adding about 290 rows to input table.I confirmed that rows are added.Still i get less records

Former Member
0 Kudos

Stefan i activated RFC trace on my PI system.What i found that there were two red colors indication duration which meant minimum threshold time exceeded.

Select trace showed me the last record same as in can see in console.Which means SAP got complete input for RFC but could manage only some few execution.

I remember once i tried to make a nested structure while coding a RFC and got several warnings that using tablelline has a performance effect.I dropped the idea and instead used TableType parameter.This output is also to be fetched from nested structure.

I also checked input record are exact 295 in number which is correct.But in output in get only 66 records which is wrong .Logically i should get only 295.

I could not relate now what to do next ?

Edited by: aditya sharma on Aug 20, 2010 2:04 PM

Edited by: aditya sharma on Aug 20, 2010 2:07 PM

Former Member
0 Kudos

My analysis plainly reveals that SAP JCO is a lot buggy.

Where it comes running simple RFCs ,it works ok.

But incase RFC takes little extra load or data goes in complex structures,it fails.

End result is it has a lot of scope of improvement.