cancel
Showing results for 
Search instead for 
Did you mean: 

Populate a bapi table object in Java Web Dynpro

Former Member
0 Kudos

Hi,

How can I populate/manipulate the data in a table object in a model which has been passed from a bapi?

For example I am creating a customer who can have up to 3 telephone numbers.

The create bapi passes a table object 'Telephone' I need to add all three telephone numbers into the table and pass it back?

Any help appreciated.

Rob

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182374
Active Contributor
0 Kudos

HI Rob,

When you say "passing back" I think you need to run another BAPI for updating...

You fetch the data from R3 (You call BAPI1).

You manipulate the data in Web Dynpro (add, delete, update)

You update the data in R3 (You call BAPI2)

Regards,

Omri

Former Member
0 Kudos

Hi

This is a create.

A user fills in 2 Inputfields with 2 e-mail addresses. I now need to pass this into the table and then execute the bapi.

How do I iterate through rows of the table to populate each e-mail?

//Populate email table object

Bapiadsmtp Email_table = new Bapiadsmtp();

input_crtbp.addE_Mail(Email_table);

Email_table.setE_Mail(wdContext.nodeE_mail_List().currentE_mail_ListElement().getE_mail1());

//Iterate code..............????????????????

Email_table.setE_Mail(wdContext.nodeE_mail_List().currentE_mail_ListElement().getE_mail2());

Former Member
0 Kudos

Hi,

you don't use an Iterator for that.

you can do it in a simple for loop like:




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

   Bapiadsmtp Email_table = new Bapiadsmtp();
   input_crtbp.addE_Mail(email_table);

   email_table.setE_Mail(
       wdContext.nodeE_Mail_List().getE_mail_ListElementAt(i).getE_Mail1());
   //and so on...
}

you are now looping through all rows of your table.

Regards,

Dennis

Former Member
0 Kudos

Hi Dennis,

I need to iterate through the Email_table object not the E_mail_List. I need to set both addresses 1 and 2 in the table and then execute the bapi.

Rob

Former Member
0 Kudos

Hi,

I've managed to populate the table and execute the bapi but my code is not behaving as I expected...

When I execute this if I populate E_Mail1 and not E_mail2 then the bapi is not executed.

If I populate both E_Mail1 and E_Mail2 then the value in E_Mail2 is written out twice to the table

Any help appreciated

			//Populate email table object
			Bapiadsmtp Email_table = new Bapiadsmtp()			
                          if (wdContext
				.nodeE_Mail_List()
				.currentE_Mail_ListElement()
				.getE_Mail1()
				.length()
				> 1) {
				Email_table.setE_Mail(
					wdContext
						.nodeE_Mail_List()
						.currentE_Mail_ListElement()
						.getE_Mail1());
				input_crtbp.addIt_Email(Email_table);
			}
			if (
				wdContext
						.nodeE_Mail_List()
						.currentE_Mail_ListElement()
						.getE_Mail2()
						.length()
						> 1) {
				Email_table.setE_Mail(
					wdContext
						.nodeE_Mail_List()
						.currentE_Mail_ListElement()
						.getE_Mail2());
				input_crtbp.addIt_Email(Email_table);
			}
			
			//Execute bapi
			wdContext
				.currentZbapi_Bupa_Create_InputElement()
				.modelObject()
				.execute();

Former Member
0 Kudos

Hi Rob

i think the prob with ur code is that you are using same Bapiadsmtp object for both E_Mail1 and E_Mail2. which is why i think u r getting two values for E_Mail2.actually the duplicate which u r getting is of E_Mail1 and not that of E_MAIL2.

//Populate email table object

Bapiadsmtp Email_table = new Bapiadsmtp()

if (wdContext.nodeE_Mail_List().currentE_Mail_ListElement().getE_Mail1().length()> 1)

{

Email_table.setE_Mail(wdContext.nodeE_Mail_List().currentE_Mail_ListElement().getE_Mail1());

input_crtbp.addIt_Email(Email_table);

}

if (wdContext.nodeE_Mail_List().currentE_Mail_ListElement().getE_Mail2().length()> 1)

{

Email_table.setE_Mail(wdContext.nodeE_Mail_List().currentE_Mail_ListElement().getE_Mail2());

input_crtbp.addIt_Email(Email_table);

}

Deeps

Former Member
0 Kudos

Hi,

look at this, it may help you solving your Issue:

Regards,

Dennis