cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass table as input parameter of a BAPI ?

Former Member
0 Kudos

Hi Experts,

I am using one custom made z BAPI (Zbapi_Catimesheet_Update) to insert data in R/3 table. In this BAPI, we have to pass a table(WORKLIST_ACT) as Input parameter for the z Bapi.

I have done coding in following way:

String personalNo = "";

String WBS = "";

String Day1 ="";

String Day2 ="";

String Day3 ="";

String Day4 ="";

String Day5 ="";

String Day6 ="";

String Day7 ="";

Date workdate = new Date(System.currentTimeMillis());

String profile = "";

workdate = wdContext.currentZbapi_Catimesheet_Update_InputElement().getWork_Date();

Zbapi_Catimesheet_Update_Input timsheet_create = new Zbapi_Catimesheet_Update_Input();

wdContext.nodeZbapi_Catimesheet_Update_Input().bind(timsheet_create);

AbstractList timesheetList = new Zbapicatsd1.Zbapicatsd1_List() ;

Zbapicatsd1 itemInput = new Zbapicatsd1();

for (int i = 0; i < 1; i++) {

personalNo = "00000050";

WBS = "somevalue";

Day1 ="1";

Day2 ="1";

Day3 ="1";

Day4 ="1";

Day5 ="1";

Day6 ="1";

Day7 ="1";

profile = "someprofile";

itemInput.setWbs_Element(WBS);

itemInput.setPerson_No(personalNo);

itemInput.setDay1(Day1);

itemInput.setDay2(Day2);

itemInput.setDay3(Day3);

itemInput.setDay4(Day4);

itemInput.setDay5(Day5);

itemInput.setDay6(Day6);

itemInput.setDay7(Day7);

timsheet_create.addWorklist_Act(itemInput);

timsheet_create.setPersonalnumber(personalNo);

timsheet_create.setWork_Date(workdate);

timsheet_create.setProfile(profile);

}

wdThis.wdGetTimesheetCustController().executeZbapi_Catimesheet_Update_Input();

wdThis.wdGetTimesheetCustController().executeBapi_Transaction_Commit_Input();

However by doing coding in above way, data of table WORKLIST_ACT is not reaching the BAPI.

It looks like my approach of sending the data to BAPI is wrong. Can you please let me know what is going wrong here in the code.

Regards,

Brian

Accepted Solutions (0)

Answers (3)

Answers (3)

i827647
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello EP,

You need 2 steps to do this:

1 - In the wdInit() do only this:

wdContext.nodeXXXX_Input().bind(new Zwf_XXXXXX_Input());

2 - Create other method to submit. Ex.: executeRFC():

Zwf_XXXXXX_Input model = wdContext.currentZwf_XXXXXX_InputElement().modelObject();

for (int i = 0; i < wdContext.node << node bind in table >>.size(); i++) {

IPublic<<Name Controller>>.I<< node bind in table >>Element element = wdContext.node<< node bind in table >>().get<< node bind in table >>ElementAt(i);

Zco_XXXX_I sxsq_i = new Zco_XXXX_I();

//Set Attributes

// sxsq_i.setXXX(element.getXXX);

model.addT_XXXX_I(sxsq_i);

}

model.execute();

Regards,

Edson Thomaz

raja_thangamani
Active Contributor
0 Kudos

Statement

Zbapicatsd1 itemInput = new Zbapicatsd1();

should be inside FOR loop..

Raja T

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Thanks Raja,

Can you please let me know your tel no? I have used some logic to enter record in R/3 table using SAP supplied BAPI. The record is getting inserted. Using the same logic when I am trying to insert the data using ZBAPI, my data is not reaching R/3. What may be the possible reason.

Regards,

Brian

raja_thangamani
Active Contributor
0 Kudos

Did you debug the BAPI & see? Some time the code in BAPI will refer to header of the table.If so you wont get the table in BAPI. So make sure that BAPI is coded properly to refer the table not the table header.

Raja T

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi Raja,

I will request ABAPer to look into it. Meanwhile I am able to save record from R/3 screen. I am inserting data in Input Parameters and Table. Does this mean that ABAP code is correct?

Regards,

Brian

raja_thangamani
Active Contributor
0 Kudos

Unless until we see the ABAP code, I cant make any comments on ABAP code.

Raja T

Message was edited by:

Armin Reichert

former_member365727
Active Contributor
0 Kudos

Hi Brain,

Refer to this thread below...

You can easily find out whether the data is passed properly from WebDynpro to R/3 by setting an External break point in the Function module. If the external breakpoint is set, when the webdynpro application runs it will open the R/3 ABAP Debugger, here you can find the import params for the function module....chk the import params. In this way you can identify whether data is passed correctly to R/3.

Regards

Srikanth

Former Member
0 Kudos

Hi Srikanth,

I have done this. I can see that Import parameters have reached R/3. However I can see the tables parameters there. This means that table parameters have not reached there. I am wondering why these table parameters have not reached R/3? Any guess?

Regards,

Brian

former_member365727
Active Contributor
0 Kudos

Hi Brian,

If you are able to see the table Params, then there is no problem from webdynpro application. Get hold of an ABAPer and debug the code(External breakpoint).

If you are not able to see the table params in R/3 , try to insert the code

Zbapicatsd1 itemInput = new Zbapicatsd1();

inside for loop as mentioned by Raja.

Regards

Srikanth.

Former Member
0 Kudos

Hi Srikanth,

Thanks. For the sake of simplicity, I have removed the for loop. The new code looks like as below:

In View

Zbapi_Catimesheet_Update_Input Input = new Zbapi_Catimesheet_Update_Input();

wdContext.nodeZbapi_Catimesheet_Update_Input().bind(Input);

String dat="06/25/2007";

long date=new SimpleDateFormat("MM/dd/yyyy").parse(dat,new ParsePosition(0)).getTime();

java.sql.Date dbDate=new java.sql.Date(date);

wdContext.currentZbapi_Catimesheet_Update_InputElement().setProfile("somevalue");

wdContext.currentZbapi_Catimesheet_Update_InputElement().setPersonalnumber("somevalue");

wdContext.currentZbapi_Catimesheet_Update_InputElement().setWork_Date(dbDate);

wdContext.currentZbapi_Catimesheet_Update_InputElement().setText_Format_Imp("ITF");

Zbapicatsd xyz;

xyz = new Zbapicatsd();

xyz.setWbs_Element("somevalue");

xyz.setDay1("1.67");

xyz.setDay2("2");

xyz.setDay3("3");

xyz.setDay4("1");

xyz.setDay5("1");

xyz.setDay6("1");

xyz.setDay7("1");

xyz.setProjectdefination("");

xyz.setRec_Wbs("somevalue");

xyz.setReciever_Wbs_Element("");

xyz.setSend_Cctr("");

xyz.setSum_Hours("8");

xyz.setActtype("DE");

Input.addWorklist(xyz);

wdThis.wdGetJjkController().executeZbapi_Catimesheet_Update_Input();

wdThis.wdGetJjkController().executeBapi_Transaction_Commit_Input();

In comp controller:

wdContext.currentZbapi_Catimesheet_Update_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

wdContext.currentBapi_Transaction_Commit_InputElement().modelObject().execute();

wdContext.nodeOutput1().invalidate();

Using debugger, I can see that Import parameters have reached R/3. The table (WORKLIST) is empty. I am unable to figure out why the table is empty when it reaches. I am filling up table with data. But when it reaches it becomes empty.

Is there is any thing which is wrong in my code?

Regards,

Brian

raja_thangamani
Active Contributor
0 Kudos

Look at the below thread

Raja T

Message was edited by:

Armin Reichert