on 12-26-2013 1:48 AM
Hello Experts,
I'm trying to call a simple RFC from ERP backend in my java program. I did all the setup in my local eclipse tool and able to run sample programs provided by SAP (i.e StepByStepClient.java & StepByStepServer.java) and got familiar a little bit on how it works.
I'm having bit trouble in understanding JCo API and coding it appropriately. Would anyone please provide me the code for my requirement.
This is my RFC:
RFC Name: Z_ASTU_GET_SUBSCRIPTIONS
Export Parameters:
Parameter Name: ELIGIBLE_LIST
Typing: TYPE
Associated Type: ZSU_EXISTING_SUBSCRIPTIONS (Table Type)
Line type: ZSSU_EXISTINGSUBSCRIPTIONS
Structure: ZSSU_EXISTSUBS; again it has some 50 fields.
Tables:
BLANK
How do I read/iterate this RFC into my java code? Please help with some code snippet on iterating or looping through this Export parameters.
This is what I tried but No Luck.
System.out.println(" List Details: " + function.getExportParameterList().getListMetaData().);
OUTPUT:
ELIGIBLE_LIST,ZSU_EXISTING_SUBSCRIPTIONS,h,0,0,290,574,0, ,Existing Subscriptions Table Type,EXPORT,OPTIONAL
JCoTable exportTable1 = function.getTableParameterList().getTable("ELIGIBLE_LIST");
OUTPUT: NullPointerException. I suspect such as this might not be a tabletype or incompatiable type.
System.out.println("Export Table1 " + exportTable1.getMetaData() + ":\n");
JCoStructure exportStructure = function.getExportParameterList().getStructure("ZSU_EXISTING_SUBSCRIPTIONS");
OUTPUT: Cannot convert Table type to Structure Record. I suspect such as this also related to incompatiable types.
System.out.println("System info for " + exportStructure.getMetaData().getFieldCount() + ":\n");
Check attached screenshot of RFC. When I double click on ZSU_EXISTING_SUBSCRIPTIONS, It is opening a Dictionary screen with some info. Particularly a tab called "Line Type" is having "ZSSU_EXISTSUBS", when I double clik on it, then it is displaying a Structure screen with some fields info.
Thanks
VB
It seems very simple.Try the following and let me know.
JCoTable table = function.getExportParameterList().getTable("ELIGIBLE_LIST");
for (int i = 0; i < table.getNumRows(); i++)
{
table.setRow(i);
System.out.println(table.getValue(0) + '\t' + table.getValue(1)+..........); // Check & verify how many columns you have in each record and get it displayed accordingly.
}
Thanks
MSR
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Follow the steps in my blog to first create the proxy classes for your backend RFC.
Then, once the proxy classes are available it has the necessary getter and setter classes. Then, the main class has the method execute to trigger the RFC call and get the data into the variables.
If you are familiar with Java, then on execution you should be able to find your way through the setters and getters to view the resulting data.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you sharath for your response. I'm Java savvy and familiar with NWDS plug-in Enterprise connector. In current situation I have to use it in Eclipse only as there is other dependencies.
just I need technical logic in iterating the loop of blackend RFC as I quite did not understood this API on which getter's exactly needs to be used. I'm able to use setter's for IMPORT parameters as they are very simple fields/components in RFC. In case of EXPORT parameters, this RFC has combination of Table & Structure & within , fields/ components. I just need technical logic on using this RFC EXPORT fields.
Thanks
VB
RFC export parameters?
The example in this link explains in detail about setting the input and getting the output and looping through it.
Example: Using Generated Proxies to Call Function Modules (SAP Library - Development Manual)
Regards,
Sharath
Hello Experts,
Would anyone please help with some snippet? I'm getting followin error at JCoTable object codes. It seems I'm trying to intanitate the object with incorrect one.
Exception in thread "main" java.lang.NullPointerException
JCoTable codes = function.getTableParameterList().getTable("ZSU_EXISTING_SUBSCRIPTIONS ");
for (int i = 0; i < codes.getNumRows(); i++)
{
JCoStructure detail = codes.getStructure("ZSSU_EXISTSUBS");
System.out.println(detail.getString("CONTRACT_NUMBER") + '\t' +
detail.getString("MATERIAL_NUMBER") + '\t' +
detail.getString("MATERIAL_DESC"));
}
Regards
VB
P.S. Plz.,Refer attached screenshot.
I'm getting error at this line of code as mentioned in my previous thread. JCoTable object called "codes" is might be getting NULL value. so throwing NullPointerException.
JCoTable codes = function.getTableParameterList().getTable("ZSU_EXISTING_SUBSCRIPTIONS ");
RFC screenshot had been attached to the initial thread. However here with again I'm attaching.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.