on 10-22-2007 6:43 AM
Hi
Scenario - File - RFC LOOKup- SAP
File has got 2 fields (Zprod and Zoffer) .When these fields are empty,material number from the file is sent as an input parameter in RFC lookup such that it woud fetch the value ZZprod and Zoffer from the SAP table and populate it in the file fields which is parsed and sent to the target .
<b>Where do i go wrong in this code</b>
imports java.io.;com.sap.aii.mapping.lookup.;
public String getProductOffering(String e,Container container){
MappingTrace importanttrace;
importanttrace = container.getTrace();
{
String content = "";
String m = "<?xml version=\"1.0\"encoding=\"UTF-8\"?><ns0:Z_SD_LOOKUP_SNS xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"> <MATNR/> ns0:Z_SD_LOOKUP_SNS>";
RfcAccessor accessor = null;
importanttrace.addInfo(m);
try
{
String BSName = "";
java.util.Map map;
map = container.getTransformationParameters();
BSName = (String)map.get(StreamTransformationConstants.RECEIVER_SERVICE);
// 1. Determine a channel (Business system, Communication channel)
Channel channel = LookupService.getChannel(BSName,"TSGD_TSD_RFC_IN");
// 2. Get a RFC accessor for a channel.
accessor = LookupService.getRfcAccessor(channel);
// 3. Create a xml input stream representing the function module request message.
InputStream inputStream = new ByteArrayInputStream(m.getBytes());
// 4. Create xml payload
XmlPayload payload = LookupService.getXmlPayload(inputStream);
// 5. Execute lookup.
Payload resultPayload = accessor.call(payload);
InputStream in = resultPayload.getContent();
BufferedInputStream bis = new BufferedInputSream(in);
int i;
while((i = bis.read()) != -1)
{
content = content + i;
}
bis.close();
}
catch(LookupException e)
{
importanttrace.addWarning("Error while lookup " + e.getMessage() );
}
catch(IOException e)
{
importanttrace.addWarning("Error " + e.getMessage() );
}
finally
{
// 7. close the accessor in order to free resources.
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
importanttrace.addWarning("Error while closing accessor " + e.getMessage() );
}
}
}
return content;
}
Help in this is highly appreciated .Thanks.
Hi Anusha,
I think the problem might be due to the closing tag.
You haven't closed the tag </ns0:Z_SD_LOOKUP_SNS>";
Thanks
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think you need to have some value for MATNR in the UDF as it seems it is empty in the String. Either add an argument in the UDF to get the value of MATNR or specify a value in the String.
String m = "<?xml version=\"1.0\"encoding=\"UTF-8\"?><ns0:Z_SD_LOOKUP_SNS xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"> <MATNR/> </ns0:Z_SD_LOOKUP_SNS>";
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
use this peace of code
String headerField;
java.util.Map map;
String Sender_Service = "";
String comm_channel = "";
Sender_Service= "";
JCO.Repository mRepository;
JCO.Client mConnection = JCO.createClient( "" , "", "", "" , "" , "" );
// connect to SAP
mConnection.connect();
//Repository = new JCO.Repository( "SAPLookup", mConnection );
JCO.Function function = null;
IFunctionTemplate ft = mRepository.getFunctionTemplate("UR FUNCTION MODULE NAME");
function = ft.getFunction();
JCO.ParameterList input = function.getImportParameterList();
input.setValue ( , "" );
input.setValue ( , "" );
input.setValue ( , "" );
String ret1 ="";
String ret2 ="";
String ret3 ="";
mConnection.execute(function);
{
ret1 = function.getExportParameterList().getString( "OUTPUT OF FUNCTION MODULE");
ret2 = function.getExportParameterList().getString( "OUTPUT OF FUNCTION MODULE");
}
mConnection.disconnect();
Vector vector = new Vector();
{
vector.add(ret1);
vector.add(ret2);
vector.add(ret3);
}
//GlobalContainer glCont = container.getGlobalContainer();
//glCont.setParameter("OUTBOUND PARAMETER",vector);
Alos use the bpm for this.
1) use global variable for using the responce of lookup.
Thanks
sudhir sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sudhir
we need only mapping API's not jco's.
What would be the <b>content</b> that is returned ..
When i give my material number from file as input to RFC ,RFC should pick up the corresponding Zprod and Zoffer from the table and update in Mapping for the fields in file ..
So would the content be a string of these 2 values ?If yes How to spilt it up in UDF ?
<b>U cannot use try- catch block in UDF</b>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what sort of Error u are getting if u paste that it will help us to get in more details.
Reagrds
Farooq.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
"<?xml version=\"1.0\"encoding=\"UTF-8\"?><ns0:Z_SD_LOOKUP_SNS xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"> <MATNR/> </ns0:Z_SD_LOOKUP_SNS>";
I had closed the tags properly sry that was a typo and the error message is
"Ilegal start of expression public static void main(String[] args) throws expression"
<b>imports</b> java.io.;com.sap.aii.mapping.lookup.;
it should be import java.io.;com.sap.aii.mapping.lookup.;
import is the keyword not the imports..typo error...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.