cancel
Showing results for 
Search instead for 
Did you mean: 

giving input to an internal table in database

Former Member
0 Kudos

hai all,

I have to give input to an internal table in the database from my web dynpro application to save them.Plz help me doing that.

Thanks n Regards

Sharanya.R

Edited by: Sharanya.R on Apr 2, 2008 1:21 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hai all,

Plz help me in doing the above given process.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Assuming that ArrayList a, b and c have same size


ArrayList a = wdContext.currentContextElement().getA();
ArrayList b = wdContext.currentContextElement().getB();
ArrayList c = wdContext.currentContextElement().getC();

Zmmin_Save_Input input = new Zmmin_Save_Input();

for(int i = 0 ;i<a.size();i++){

        IT_Data data = new IT_Data();
        data.setI_A(a.get(i));
        data.setI_B(b.get(i));
        data.setI_C(c.get(i));
        input.addIT_Data(data);
}

try {
	input.execute();
} catch (Exception e) {
	throw e;
}

Regards,

Gopal

Former Member
0 Kudos

hai Gopal,

I have some issues with the server right now.So once i check your coding ill let you know and close this issue.Thanks for the response.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hey try to accept the values of a column as import parameters to a BAPI and you can send the data.But this will work out for a single data.

In the BAPI insert the data making use of insert command.

ITAB-COLUMN1 = IMPORT PARAMETER 1.

ITAB-COLUMN2 = IMPORT PARAMETER 2.

ITAB-COLUMN3 = IMPORT PARAMETER 3.

INSERT INTO VALUES ITAB.

If you want to insert multiple records then you have to change the cardinality of the node.And add the node elements to the node.If any doubts then do reply.

Former Member
0 Kudos

Hai Gopal,

when i give

It_Data data=new It_Data() it gives error saying It_Data cannot be resolved.Plz give your Mail Address so that i can send a screen shot of my context of custom controller that is mapped with model.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

I am unable to post address. Please view my business card.

Regards,

Gopal

Edited by: Gopal on Apr 3, 2008 7:34 PM

Former Member
0 Kudos

hai Gopal,

I have sent the screen shot .plz check it out and provide me the solution.

Hai Srinivas,

for(int i=0;i< wdContext.currentContextElement().getCompanyName().size();i++)

{

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setProtection(wdContext.currentContextElement().getProtections().get(i).toString());

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setSub_Protection(wdContext.currentContextElement().getSubProtections().get(i).toString());

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setSpec(wdContext.currentContextElement().getCompanyName().get(i).toString());

}

when i try this way it gives null pointer exception.If you need ill provide the screen shot.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

hi,

Try this and let me known..

for(int i=0;i< wdContext.currentContextElement().getCompanyName().size();i++)

{

if(wdContext.currentContextElement().getProtections().get(i).toString()!=null)

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setProtection(wdContext.currentContextElement().getProtections().get(i).toString());

if(wdContext.currentContextElement().getSubProtections().get(i).toString()!=null)

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setSub_Protection(wdContext.currentContextElement().getSubProtections().get(i).toString());

if(wdContext.currentContextElement().getCompanyName().get(i).toString()!=null)

wdThis.wdGetSpecGenerationControllerCustController().wdGetContext().currentIt_DataElement().setSpec(wdContext.currentContextElement().getCompanyName().get(i).toString());

}

Thanks,

Srini

Former Member
0 Kudos

Create a public method say, save in Custom Controller. It must have three parameters. All three having data type ArrayList. Following is the code for method save:

public void save(ArrayList protections, ArrayList subProtections, ArrayList companyName){

	int size = wdContext.currentContextElement().getCompanyName().size();

	for(int i=0;i<size;i++){
		IPublicGetSpecGenerationControllerCustController.IIt_DataElement element = wdContext.nodeIt_DataElement().createIt_DataElement();
		element.setProtection((String) protections.get(i));
		element.setSub_Protection((String) subProtections.get(i));
		element.setCompanyName ((String) companyName.get(i));
		wdContext.nodeIt_DataElement().addElement(element);
	}

	try{
		wdContext.nodeZmmin_save-specification_Input().modelObject().execute();
}catch(Exception ex){
	wdConponentAPI.getMessageManager().reportException(ex.toString() + " : " + ex.getMessage());
}
}

Now call this public method from your view controller as follows:

wdThis.wdGetSpecGenerationControllerCustController().save(wdContext.currentContextElement().getProtections(),wdContext.currentContextElement().getSubProtections(), wdContext.currentContextElement().getCompanyName());

Answers (1)

Answers (1)

Former Member
0 Kudos

Hai all,

To make my question more clear,Iam using adaptive rfc model.

I have Zmmin_save_input in which i have a table IT_data.This table has 3 fields and i need to pass input for that table in a loop.Plz guide me doing that.Any help will be greatly appreciated.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi ,

Hope the below code will help you....

ArrayList IT_dataArr = new ArrayList();

IPrivate<View>.<IT_data>IPersonsTreatedElement tele=null;

for(int i=0;i<3.size();i++)

{

tele = wdContext.create<IT_data>Element();

tele.set<X>("XX");

tele.set<Y>("YY");

tele.set<Z>("ZZ");

IT_dataArr.add(tele);

}

wdcontext.node<it_data>().bind(IT_dataArr);

Regards,

Sunitha Hari

Former Member
0 Kudos

hai sunitha,

Thanks for the response.

Iam not getting values from database.I need to set the values from user to a table in database.I have the Bapi

Zmmin_Save_Input under which i have a node called IT_Data under which i have 3 fields in my custom controller which is mapped to the model.

Plz ensure the code for doing that.

Thanks n Regards

Sharanya.R

Edited by: Sharanya.R on Apr 2, 2008 2:02 PM

Edited by: Sharanya.R on Apr 2, 2008 2:03 PM

Former Member
0 Kudos

Hi ,

what i understood is u have a table where user enters some values and u have update these values to R/3.

1)Create a Valuenode with same structure of ur Internal Table i.e It_data.

2)Bind ur table to the value node.

3)When u r executing the RFC populate data from value node to model node .

z<rfc>_input input = new z<rfc>();

IPrivate<View>.<IT_data>IPersonsTreatedElement tele=null;

for(int i=0;i<wdcontext.node<it_valuenode>.size();i++)

{

tele = wdContext.create<IT_data>Element();

wdocontext.node<it_valuenode>.setLeadSelect(i);

tele.set<att1>(wdcontext.node<it_valuenode>.currentnode<it_value>.get<attr1>());

// repeate the same code for other 2 attributes.

input.add(tele);

}

// Insert Execute RFC line

Regards,

Sunitha Hari

Former Member
0 Kudos

hai Sunitha,

Thanks once again.

Let me make my requirement more clear.

I have 3 attribute in the context of a view of type arraylist which contains a set of values.consider it as attribute A,B,C all of type arraylist containing set of values each.Now i have a table in r/3 with 3 fields.now i need to pass the values in arraylist attribute (A,B,C) one after the other where A goes for 1st field of table in database and B -2nd field and C thrid field in database table.I have the bapi in my custom controler mapped with my model.Now plz do provide the coding that i should use to pass these arraylist attribute values to the table in database.Plz provide step by step procedure which will be very helpful for me.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi ,

Your Function Module has to update three fields , say A,B,C of a table . That means u can pass three input parameters

it can take .

1) Assuming your backend Function module : Z_YourTable_createRecord

Import Parameters :

A type text30

B type text30

C type text30

Source :

data : val like Z_YourTable

val-FieldA = A.

val-FieldB = B.

val-FieldC = C.

INSERT INTO Z_YourTable Values val.

2) In WebDynpro java :

When you do modeling , you will get the node .

supppose the node is :

Z_Your_Table_createrecord

\

A

B

C

And u have a context say :

UpdateTable

\

A1

B1

C1

( suppose updateTable have more number of elements , than u have to create multiple records , so run a loop)

for ( int i=0;i<wdContext.nodeUpdateTable().size();i++)

{

wdContext.currentZ_Your_Table_createrecord().setA(wdContext.nodeUpdateTable().UpdateTableElementAt(i).getA1());

wdContext.currentZ_Your_Table_createrecord().setB(wdContext.nodeUpdateTable().UpdateTableElementAt(i).getB1());

wdContext.currentZ_Your_Table_createrecord().setC(wdContext.nodeUpdateTable().UpdateTableElementAt(i).getC1());

// execute the method as you are passing three values

wdThis.wdGet<..> Controller().executeZ_YourTable_createRecord();

}

This for loop every time takes A1,B1,C1 and updates in the table .

Thanks,

Srini