on 07-09-2009 2:13 AM
Hello,
I have developed a webdynpro application to read and insert data into a R/3 Custom table.....the read works fine....but i need help to insert record once the user fills out the screen and hits submit button....what is the code required to be written in the view and the component controller and the appropriate bindings between the view,component controller and the model?
Any help would be highly appreicated.
Regards,
Anil
Hi Anil,
For inserting the record into the BAPI, you need to map the Corresponding nodes of BAPI to the Component Controller , i.e., if the BAPI name is Z_BAPI then
1) the parameters under Z_BAPI_INPUT should be mapped
2) In the Begin Others you must have created the object eg
Z_BAPI_Input object = new Z_BAPI_Input();
3) In the init part you must have bind the node to the BAPI, i.e.,
wdContext.nodeZ_BAPI_Input().bind(object);
4) Now in the method to execute the BAPI
try{ object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.execute();
}catch(exception e){
}
Hope this should help you.
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
As soon as the user fill the user data on the screen , you can fetch the data from the context ,
for example ,
you are filling the TWO INPUT FIELDS FIRSTNAME and LASTNAME ,
after fillimg this input fields you can get the data as \
String firstname= wdcontext.node<NODENAME>.current<nodeelementname>.getfirstname();
String lastname= wdcontext.node<NODENAME>.current<nodeelementname>.getlastname();
so if you are inserting it to the RFC , there are many structure present with CLASS NAME beside the strucure , you can find this in data modelor ,
suppose class name
RFCNAME rfc = new RFCNAME();
ZEmployee employee = new ZEmployee();
employee.setfirstname(firstname);
employee.setlastname(lastname)
rfc.addelement(emplopyee);
wdcontext.nodeEmployee.bind(rfc);
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks all for your replies...so this is the code i have written in the component controller:
Z_Bapi_<Insert Bapi> in = new Z_Bapi_<Insert Bapi>
Z<struct> zz = new Z<struct>();
zz.set<parameter>(wdContext.current<Currentnode>Element().get<parameter>());
in.set<input>(zz);
wdContext.node<bindednode>().bind(in);
wdContext.current<bindednode>tElement().modelObject().execute();
where Z_Bapi_<Insert Bapi> is the insert BAPI
Z<struct> is the structure used to insert
<parameter> is one of the fields to be inserted
<Currentnode> is the node holding current data binded to the node in the view controller.
<bindednode> is the node binded to the model object Z_Bapi_<Insert Bapi>
after executing this code there is nor error but the row is not getting inserted in the table...
Please help.
Regards,
Anil
Hi Anil,
follow this procedure,
1. first studdy the Import Parameters or Tables if any.
2. Then Implement the Model for the same. and then do the Field Mapping from Model Import Params/Tables to the Component.
3. Now Map the required fields from Component to your View.
4. Now write your logic to insert the data from UI (in View) to Model.
Regards,
Sunaina Reddy T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
For inserting the record into the FM, you need to map the Corresponding nodes of BAPI to the Component Controller , i.e., if the FM name is Z_Test then
1) the parameters under Z_Test_INPUT should be mapped
2) In the Begin Others you must have created the object eg
Z_Test_Input object = new Z_Test_Input();
3) in the action method of Submit you need to bind the FM object
wdContext.nodeZ_Test_Input().bind(object);
4) If there is a structure having the fields of the table to which you want to insert the data.
try{
Z_Test_Struct struct = new Z_Test_Struct ();
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
object.set<parameter name>(parameter value);
struct.setInput(object);
wdContext.currentZ_Test_InputElement().modelObject().execute();
wdContext.node<OutputNode>.invalidate();
}catch(exception e){
}
Hope this will help to insert data to the table.
Thanks
Ritushree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Let us consider the following context structure for your example
Z_bapi_input (Zbapi)(Bapi Node mapped to component controller(Class in the model)))
|
|-- ZTable(ZTabClass) (Node for table mapped from model (Class in the model))
Create a node with structure binding of ZTabClass say Table.
Map this node to the view Controller.
Create a method execute_Bapi()
public void execute_Bapi()
{
Zbapi obj = new Zbapi();
wdCopyService.copyCorresponding(wdContext.nodeTable,wdContext.nodeZTable);
wdContext.nodeZ_bapi_input.bind(obj);
try{
wdContext.currentZ_bapi_inputElement.execute();
}catch(Exception e)
{
}
}
Now in the view controller Click on the button .. Go to properties tab and in the property onClick go to the icon '...' and create a new action and event handler say 'SubmitData'
Write the code in the following method.
onSubmitData()
{
wdThis.wdGetComponentControllerName.execute_Bapi();
}
Best Wishes
Idhaya R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.