on 11-22-2007 7:24 AM
Hi,
My scenario is Idoc To file, in my idoc user who created a purchase order filed is not there but in xml file i want the user who create that PO, for this i am using RFC LooUp. I want the user who created a purchase order.
Graphical Mapping looks like below.
Belnr--
>UserName
Please find the code bloew:
String DBTABLE = "EKKO";
String lookUpField = "ERNAM";
String WHERE_CLAUSE = " EBELN "" = "" ' "a" ' " ;
JCO.Repository mRepository;
JCO.Client mConnection = JCO.createClient(
"500",
"RFCUSER",
"abc1234",
"EN",
"cxylo06",
"05");
// connect to SAP
mConnection.connect();
// create repository
mRepository = new JCO.Repository( "GenericRFCMappingLookup", mConnection );
// create function template to select data from any table
JCO.Function function = null;
IFunctionTemplate ft = mRepository.getFunctionTemplate("RFC_READ_TABLE");
function = ft.getFunction();
// Obtain parameter list for function
JCO.ParameterList input = function.getImportParameterList();
// Pass function parameters
// set import parameters table name and RFC
input.setValue( DBTABLE, "QUERY_TABLE");
input.setValue( "," , "DELIMITER");
//Fill the where clause of the table
JCO.ParameterList tabInput = function.getTableParameterList();
JCO.Table inputTable = tabInput.getTable("OPTIONS");
inputTable.appendRow();
inputTable.setValue(WHERE_CLAUSE,"TEXT");
mConnection.execute( function );
//Find the position of the field that has to be lookedUp
JCO.Table lookupFieldPos = function.getTableParameterList().getTable("FIELDS");
int pos = -1;
for (int i = 0; i < lookupFieldPos.getNumRows(); i++)
{
lookupFieldPos.setRow(i);
if (lookupFieldPos.getString("FIELDNAME").equals(lookUpField))
pos = i;
}
//Get the exact lookupvalue from the position obtained above
JCO.Table valueSet = function.getTableParameterList().getTable("DATA");
valueSet.setRow(0);
String resultSet = valueSet.getString("WA");
result.addValue(resultSet);
mConnection.disconnect();
I am not aware of java coding so kindly make necessary modifications.
Kindly suggest what changes i need to do to execute perfectly.
Your help will be greatly apprecited.
Regards,
Venkat
Hi Venkat,
If you use the JCO connection to get the value from RFC, it would be a problem in futherly like when you move this interface DEV to Q, then you need to change the connection parameters to establish the JCO connection.Same in Production environment too.It is not advisable to do JCO lookup. Go for RFC lookup as the link given by Farooq.
Create Reciever RFC communication channel and take the XML signature of u r RFC by importing that RFC under imported objects.Create an UDF, for this see the sample code which is exisitng in document to pass the Export parameter to RFC.
In this way u r RFC channel establish the connection to R3 and your RFC will execute and return the value.U just need to change the Reciever RFC channel parameters respective of environment.
Cheers
Veera
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By using the above mentioned code i could able to connect to sap system byt unable to retrieve the user name, kindly suggest what maodifications to be made.
Regards,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
why you are using JCO?
YOu can use RFC lookup API's..but it will work for SP14 or above.
Thanks
Farooq.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Refer this Article : by Michal.
Mapping lookups RFC API : https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...
Thanks
Farooq.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.