cancel
Showing results for 
Search instead for 
Did you mean: 

Change data using Bapi

Former Member
0 Kudos

Hi,

I know how to read data using bapi. How to change(update) data using bapi? For this i have created custom controller and added a modelnode which maps to the model of my change table/input. In the view controller i created the model node and mapped to custom controller model node. now how to pass data to custom controller. For your information i created instance and binded and wrote execute of bapi method and bapi_transaction as per pdf. when i try to set value for the model node of my view controller as per pdf(handling transaction using bapi) i get runtime error. i could't able to assing the value to the model directly.

Can any tell me what is the process of update actualy. Is my flow is right/wrong/

regards,

Ganesh.D

Accepted Solutions (1)

Accepted Solutions (1)

arun_srinivasan
Contributor
0 Kudos

hi

1. First create an instance for bapi and bind the instance to the bapi node.

Z<bapi name> zb=new Z<bapi name>();

wdContext.nodeZ<bapi name>. bind(zb);

2. Then if u have the import parameter u have to set them by using

The instance of the above bapi.

Zb.set<import parameters>;

3. If the bapi has a table parameters then the structure for the table parameters will also be imported

In the model class.

4. Set the table parameters by creating the instance for that structure and using this instance set it.

Z<Struct>itm tab=new Z<Struct>();

Tab.set<table parameters>

5. Then add the structure instance to the bapi instance.

Zb.add(Tab);

6. Then Execute the bapi after setting the import parameters.

7. If there is any export parameters, then get the values after execution.

hope this helps u,

Regards,

Arun S

Former Member
0 Kudos

Hi Arun,

Could you please giv any other solution relevant to question. I already read this in another thread. Read the question line bye line. How to set values to model node.

regards,

Ganesh.D

Dheerendra
Participant
0 Kudos

Hi Ganesh,

can u plz post ur Run time error stack,that ur getting.

Thanks

Former Member
0 Kudos

Hi,

In my view controller model node is ex: modone. which is mapped to custom controller. now i have to pass the value to custom controller. for this

wdContext.currentModOne.setSal(wdContext.currentContextElement.getSal());

I could't able to set the value in the model controller. Then only i can execute my custom controller to update.

Hope you got it.

regards,

Ganesh.D

former_member182294
Active Contributor
0 Kudos

Hi Ganesh,

With each model node there will be an associated model class exist. You need to create the instance of this model object and bind it to node. In your case your model node is <b>modnode</b> then there will be a class modnode.

modnode obj = new modnode();

obj.setSal(wdContext.currentContextElement.getSal());

wdContext.nodeModnode().bind(obj);

Regards

Abhilash

Former Member
0 Kudos

Hi,

Instead of Passing dat from view I would like to test by passing static values from cust controller itself. My Cust controler model is

ZBapi_Update(Bapi_UpdData)

---I_Data (Bapi_Data)

-


Desc

--I_Data_Upd(Bapi_Data_Upd)

-


Desc (boolean)

--I_Method (Bapi_Mehod)

-


Method

-


Key

ZBapi_Tranascation_Commit

now i created instance

Bapi_UpdData input = new Bapi_UpdData();

wdContext.nodeZBapi_Update().bind(input);

Bapi_Data dattab = new Bapi_Data();

dattab.setDesc("Hello");

inp.addI_Data(dattab);

Bapi_Data_Upd datupdtab = new Bapi_Data_Upd();

datupdtab.setDesc(true);

inp.addI_Data_Upd(datupdtab);

awaiting for your earlier reply, its urgent.

regards,

Ganesh.D

Bapi_Method methtab = new Bapi_Method();

methtab.setMethod("UPDATE");

methtab.setKey("1");

inp.addI_Method(methtab);

/*i need to set two values/rows to get updated

methtab.setMethod("SAVE");

methtab.setkey("0");

inp.addI_Method(methtab);

wdContext.nodeI_Data().bind(dattab);

wdContext.nodeI_Data_Upd().bind(datupdtab);

wdContext.nodeI_Method().bind(methtab);

wdContext.currentZBapi_Update().modelobject().execute();

my bapi is working fine in se37(R/3).

that is to update data i need to pass two values in method structure one is specifiying update and another row is to pass save.

i also included the bapi_transaction_commit an executed. no errors are comming and data is not updated.

i dont know where i am mistake. since its not throwing any error i could't able to identify. i think i have missed some step. please summarize it. its very urgent.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Gothru this link

or otherwise post your entire code I will find where the error is .

Thanks,

Lohi.

Former Member
0 Kudos

Hi,

Hi this is the following code. when i check i_data_upd node the size is 0 inspite of adding static value. rest all fine. is bapi_transaction commit is necessary?

Instead of Passing dat from view I would like to test by passing static values from cust controller itself. My Cust controler model is

ZBapi_Update(Bapi_UpdData)---(...) are the structure name

---I_Data (Bapi_Data)

-


Desc

--I_Data_Upd(Bapi_Data_Upd)

-


Desc (boolean)

--I_Method (Bapi_Mehod)

-


Method

-


Key

ZBapi_Tranascation_Commit

now i created instance

Bapi_UpdData input = new Bapi_UpdData();

wdContext.nodeZBapi_Update().bind(input);

Bapi_Data dattab = new Bapi_Data();

dattab.setDesc("Hello");

inp.addI_Data(dattab);

Bapi_Data_Upd datupdtab = new Bapi_Data_Upd();

datupdtab.setDesc(true);

inp.addI_Data_Upd(datupdtab);

Bapi_Method methtab = new Bapi_Method();

methtab.setMethod("UPDATE");

methtab.setKey("1");

inp.addI_Method(methtab);

/*i need to set two values/rows to get updated

Bapi_Method methtab2 = new Bapi_Method();

methtab2.setMethod("SAVE");

methtab2.setkey("0");

inp.addI_Method(methtab2);

wdContext.currentZBapi_Update().modelobject().execute();

my bapi is working fine in se37(R/3).

that is to update data i need to pass two values in method structure one is specifiying update and another row is to pass save.

i also included the bapi_transaction_commit an executed. no errors are comming and data is not updated.

i dont know where i am mistake. since its not throwing any error i could't able to identify. i think i have missed some step. please summarize it. its very urgent.

awaiting for your earlier reply, its urgent.

regards,

Ganesh.D

former_member182294
Active Contributor
0 Kudos

Are you expecting some output after executing the BAPI?

Add invalidate() method to your output node, like

wdContext.nodeOutput().invalidate();

Regards

Abhilash

Former Member
0 Kudos

Hi,

No i want to update existing record by pulling static values into r/3.

I dont know where i am going wrong. i checked the bapi return but there is no error.

regards,

Ganesh.D

Former Member
0 Kudos

hi Ganesh

In my case of updating i have to get the data from the getBAPI and then modify it.

So I got the all the data from Backend , ,binded my update Bapi node to the View .To update i have to pass a list so i made a AbstractList of my update Bapi node and added my GetBapi data into this list.Like this i was able to display data on the view .Now whatever the user changed was reflected on my Modify

Node and passed to the database.

See my code of my getBapi:

public void executeGetDetail( )

{

//@@begin executeGetDetail()

IWDMessageManager msg1 = wdComponentAPI.getMessageManager();

AbstractList backupList;

boolean required =wdThis.checkRequired();

if(required)

{

input = new Z_Bapi_Get_Cash_Memo_Input();

input.setE_Accname(wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().currentZ_Bapi_Get_Cash_Memo_InputElement().getE_Accname());

input.setE_Dsart(wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().currentZ_Bapi_Get_Cash_Memo_InputElement().getE_Dsart());

input.setE_Valdate(wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().currentZ_Bapi_Get_Cash_Memo_InputElement().getE_Valdate());

try {

wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().currentZ_Bapi_Get_Cash_Memo_InputElement().modelObject().execute();

}

wdThis.setModTable();

} catch (WDDynamicRFCExecuteException e) {

// TODO Auto-generated catch block

e.printStackTrace();

msg1.reportSuccess("hi"+e);

See my method of setting the data into the mod :

public void setModTable( )

{

//@@begin setModTable()

IWDMessageManager msg1 = wdComponentAPI.getMessageManager();

modify = new Z_Bapi_Put_Memo_Record_Input();

wdContext.nodeZ_Bapi_Put_Memo_Record_Input().bind(modify);

IWDAttributeInfo dateinfo1 = wdContext.getNodeInfo().getChild("Z_Bapi_Put_Memo_Record_Input").getChild("Mod_It_Memo_Details").getAttribute("Datum");

ISimpleTypeModifiable simp1 = dateinfo1.getModifiableSimpleType();

simp1.setFormat("dd/MM/yyyy");

AbstractList getlist = new Zzf_Cfm_S_Cm_Details.Zzf_Cfm_S_Cm_Details_List();

//msg1.reportSuccess("list size"+wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().nodeGet_Output().nodeIt_Memo_Details().size());

for(int i =0;i<wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().nodeGet_Output().nodeIt_Memo_Details().size();i++){

getlist.add(wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().nodeGet_Output().nodeIt_Memo_Details().getIt_Memo_DetailsElementAt(i).modelObject());

//msg1.reportWarning("amt"+wdContext.nodeZ_Bapi_Get_Cash_Memo_Input().nodeGet_Output().nodeIt_Memo_Details().getIt_Memo_DetailsElementAt(i).getDmshb());

}

// msg1.reportSuccess("gelist size"+getlist.size());

modify.setIt_Memo_Details(getlist);

//@@end

Please ignore unnecssary code .Sorry for inconvienance

If any query plz post again

Regards

Nidhideep

Former Member
0 Kudos

Hi,

Thanks to all. I solved it. problem with input data only. it work fine now.

regards,

Ganesh.D