on 06-20-2005 11:25 AM
Hi,
First of all, I succeed calling a custom web service : I pass to this web service a table and retrieve a table.
Now, I am trying to do the same thing with the web service of BAPI_USER_GETLIST.
Here is the code in the Component Controller.
<i>
Request_BAPI_USER_GETLISTPortType_BAPI_USER_GETLIST input =
new Request_BAPI_USER_GETLISTPortType_BAPI_USER_GETLIST();
wdContext.nodeRequest_BAPI_USER_GETLISTPortType_BAPI_USER_GETLIST().bind(input);
ComplexType_BAPI_USER_GETLIST complex = new ComplexType_BAPI_USER_GETLIST();
complex.setMAX_ROWS(10);
complex.setWITH_USERNAME("X");
complex.addRETURN(new ComplexType_BAPIRET2());
complex.addSELECTION_EXP(new ComplexType_BAPIUSSEXP());
complex.addSELECTION_RANGE(new ComplexType_BAPIUSSRGE());
complex.addUSERLIST(new ComplexType_BAPIUSNAME());
input.setParameters(complex);
try {
wdContext.currentRequest_BAPI_USER_GETLISTPortType_BAPI_USER_GETLISTElement()
.modelObject().execute();
}catch(Exception e) {
wdContext.currentContextElement().setException(e.getMessage());
}
wdContext.nodeResponse().invalidate();
</i>
I do not get any results.
When debugging in the ABAP code, I get something strange.
For everyone who looks in the BAPI_USER_GETLIST source code, you can notice
that there is a refresh in the initialization function for the retrun and userlist
tables.
But, all the other tables (SELECTION_EXP and SELECTION_RANGE) has an empty line added!
And this cause the problem.
How do I know that this is the problem ? Because, when debugging in ABAP, I delete
those lines in thoses 2 tables and everything works good.
Is there a way to solve this problem ?
Thanks in advance.
Hi
The code should work fine. But looking at the lines of code written like
complex.addRETURN(new ComplexType_BAPIRET2());
complex.addSELECTION_EXP(new ComplexType_BAPIUSSEXP());
complex.addSELECTION_RANGE(new ComplexType_BAPIUSSRGE());
complex.addUSERLIST(new ComplexType_BAPIUSNAME());
input.setParameters(complex);
well when you are not passing any value to the input of the tables and blindly instantiating it for example in the line
complex.addSelection_EXP(new ComplexType_BAPIUSSEXP());
this will create a empty line in the internal table in R/3. If you take a look at the function module there is a statment like
IF NOT selection_range[] IS INITIAL.
which means that the table is checked without header. In this case the blank value will be a record in the internal table and so u will not be able to get any records.
But there is another check in the RFC which is something like
IF NOT userlist IS REQUESTED
here the Square brackets are not there. This makes a big difference. In this case the empty line will be a part of the header line. So even if you instantiate it should not make a difference.
So the above way of passing values like you have mentioned will not work if you just instantiate the objects. Moreover going by the BAPI i dont think passing any values to the table makes a effect. I guess it only retrieves data.
Anyway that is the problem. Hope that clarifies your doubt. Let me know if you require further clarifications
regards
ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
Thanks for the clarifications.
Do you mean that I cannot call this web service ?
I tried to do :
complex.addSELECTION_RANGE(new ComplexType_BAPIUSSRGE());
complex.addUSERLIST(new ComplexType_BAPIUSNAME());
input.setParameters(complex);
But, when I execute the WD, I get an exception that tells me that Return table is required and that Selection_EXP is required. This is strange because those tables are optional.
Thanks for all the explanations.
Hi again Ravi,
I did something not really beatifull but it works.
Here is the code :
complex.addRETURN(new ComplexType_BAPIRET2());
complex.addUSERLIST(new ComplexType_BAPIUSNAME());
ComplexType_BAPIUSSEXP d1 = new ComplexType_BAPIUSSEXP();
complex.addSELECTION_EXP(d1);
ComplexType_BAPIUSSRGE d2 = new ComplexType_BAPIUSSRGE();
complex.addSELECTION_RANGE(d2);
complex.removeSELECTION_EXP(d1);
complex.removeSELECTION_RANGE(d2);
input.setParameters(complex);
The 2 tables that arenot refreshed in the initialization in the ABAP code are SELECTION_EXP and SELECTION_RANGE.
So, I created and deleted an object for these 2 tables.
I tried to do complex.addSELECTION_EXP(null) but it doesn't work.
If you have a better idea, please tell me.
Thanks.
Hi
Again you are trying to add an empty line and then delete it. Well what i am saying is you dont have to do the lines
complex.addRETURN(new ComplexType_BAPIRET2());
complex.addUSERLIST(new ComplexType_BAPIUSNAME());
ComplexType_BAPIUSSEXP d1 = new ComplexType_BAPIUSSEXP();
complex.addSELECTION_EXP(d1);
ComplexType_BAPIUSSRGE d2 = new ComplexType_BAPIUSSRGE();
complex.addSELECTION_RANGE(d2);
complex.removeSELECTION_EXP(d1);
complex.removeSELECTION_RANGE(d2);
input.setParameters(complex);
Just write the following code and you are good to go.
Bapi_User_Getlist_Input complex = new Bapi_User_Getlist_Input();
wdContext.nodeBapi_User_Getlist_Input().bind(complex);
complex.setMax_Rows(10);
complex.setWith_Username("X");
try
{
wdContext.currentBapi_User_Getlist_InputElement().modelObject().execute();
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException ("Exception occured "+e,true);
}
Hope that helps you. You dont have to pass any values to the table structures. This specific bapi does not require data to be passed to the structures and by doing so empty lines are added and that is what i was saying when i explained in my previous post. Hope that clarifies your doubt. Do let me know in case u require further clarifications.
If you are getting a error saying Return and Selection_EXP are required check the mapping.
It is enough if you just select the nodes under
Bapi_User_List_Input
|_Output
| |_Return (Model Node)
| |_Selection_Exp (Model Node)
| |_Selection_Range (Model Node)
| |_Userlist (Model Node)
| |_Rows (Model Attribute)
|_Max_Rows (Model Attribute)
|_With_Username (Model Attribute)
and of course select the Model Attributes MAX_ROWS and With_Username
Let me know if you require any more information
regards
ravi
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.