on 12-05-2007 9:21 AM
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();
Hi Rob,
The code looks to be fine. But can you check once the following?
1.The structure <b>Bapiadsmtp </b>is same of <b>input_crtbp</b>
If you can provide the architecture of the context. It is easy to analyze.
regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes the structure is identical.
Zbapi_Bupa_Create_Input input_crtbp;
to set the structure of input_crtbp.
Context Zbapi_Bupa_Create_Input
Table Node 'It_Email'
Cosnumber
E_Mail
Email_Srch
Encode
Errorflag
Flg_Nouse
Home_Flag
R_3_User
Std_no
Std_Recip
Tnef
Valid_From
Valid_To
This structure is exactly the same as the model class Bapiadsmtp
Hi Rob,
Add this code in first of your method.
try
{
wdContext.currentZbapi_Bupa_Create_InputElement().modelObject().getIt_Email().clear();
}
catch (Exception e1)
{
}
Change the code
// input_crtbp.addIt_Email(Email_table);
insted of this use the following.
<b>wdContext.currentZbapi_Bupa_Create_InputElement().modelObject().addIt_Email(Email_table);
</b>
And check this <u>wdContext.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail1());</u> whether this is giving correct values by printing the values in if condition.
regards
Siva
Hi Rob,
Change your code <i>current Element</i> with <i>getElementAt(index)</i> index starts from 0. And do null check, finally add model object
//Populate email table object
try
{
wdContext.currentZbapi_Bupa_Create_InputElement().modelObject().getIt_Email().clear();
}
catch (Exception e1)
{
}
if (wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail1()!=null
&&wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail1().length()
> 1) {
Bapiadsmtp Email_table = new Bapiadsmtp();
Email_table.setE_Mail
(wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail1());
//Verify Email1
wdComponentAPI.getMessageManager().reportException(Email_table.getE_Mail());
wdContext.currentZbapi_Bupa_Create_InputElement().modelObject().addIt_Email(Email_table);
}
if (wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail2()!=null
&&wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail2().length()> 1)
{
Bapiadsmtp Email_table = new Bapiadsmtp();
Email_table.setE_Mail(
wdContext.nodeE_Mail_List().getE_Mail_ListElementAt(index).getE_Mail2());
// Verify Email2
wdComponentAPI.getMessageManager().reportException(Email_table.getE_Mail());
wdContext.currentZbapi_Bupa_Create_InputElement().modelObject().addIt_Email(Email_table);
}
//Execute bapi
wdContext
.currentZbapi_Bupa_Create_InputElement()
.modelObject()
.execute();
Try with this code
regards,
Siva
Hi Rob,
After executing the model invalidate the output node.
wdContext.nodeE_Mail_List().invalidate();
Regards,
Mithu
Thank you all.
It now works.
Code below
try {
wdContext.currentZbapi_Bupa_Create_InputElement()
.modelObject()
.getIt_Email()
.clear();
} catch (Exception e1) {
e1.printStackTrace();
}
try {
if (wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail1()
!= null
&& wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail1()
.length()
> 1) {
Bapiadsmtp Email_table = new Bapiadsmtp();
Email_table.setE_Mail(
wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail1());
wdContext
.currentZbapi_Bupa_Create_InputElement()
.modelObject()
.addIt_Email(
Email_table);
}
if (wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail2()
!= null
&& wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail2()
.length()
> 1) {
Bapiadsmtp Email_table = new Bapiadsmtp();
Email_table.setE_Mail(
wdContext
.nodeE_Mail_List()
.currentE_Mail_ListElement()
.getE_Mail2());
wdContext
.currentZbapi_Bupa_Create_InputElement()
.modelObject()
.addIt_Email(
Email_table);
}
//Execute bapi
wdContext
.currentZbapi_Bupa_Create_InputElement()
.modelObject()
.execute();
wdContext.nodeOutput().invalidate();
} catch (Exception e2) {
e2.printStackTrace();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rob,
Have u tried debugging the application?? check what values are getting passed to bapi in debug mode in sap logon??
regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.