cancel
Showing results for 
Search instead for 
Did you mean: 

Example to insert / add a row using BAPI

former_member204370
Participant
0 Kudos

Hi

I am trying to write a program to insert record into PurchaseRequisition. I am using BAPI_PR_CREATE.

JCO3 help indicates that we should use table.appendRow(). I have tried writing a program but is not working or not giving any results and neither an exception.

Attached is the code i am trying with.

Can someone share any inputs?

Thanks, Ram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Table parameter is table type container for both input and output.

In your case it is used as input container, table.appendRow() should be written before executing bapi.

            //function.getImportParameterList().setValue(query_input_column1, query_input_column1_value);
            JCoTable table = function.getTableParameterList().getTable(targetTableUnderBAPI); //it is taken from the response value of metadata

            table.appendRow();
                table.setValue(query_input_column2,query_input_column2_value);
                //similarly for other columns 

            try{
                function.execute(destination);
            }
            catch(AbapException e){
                System.out.println(e.toString());
                return;
            }

Thanks

former_member204370
Participant
0 Kudos

Hi

This is really helpful. I just modified code. The return table says that i have to supply the inputs for two more columns. I am actually supplying these values (doc_type and plant).

Not able to understand what it is indicating. In fact, i am not able to insert a row using SE37 also (only for BAPI_PR_CREATE).

I get the same error message. What could be the issue?

Thanks, Ram

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Could you get successful return from SE37 ?

Some BAPI needs BAPI_TRANSACTION_COMMIT especially creation BAPI.

I'm not sure about your BAPI_PR_CREATE but you can test from SE37 and select Function Module=>Execute=>Test Sequences.

Thanks

former_member204370
Participant
0 Kudos

I am not able to insert from SE37 also.

Below is the return message i get when i try to insert row:

IDNUMMessage
ME083Enter Document Type 
BAPI001No instance of object type PurchaseRequisition has been created. External reference: # 1
ME083Enter Plant

MESSAGE_V4PARAMETERFIELD

PRHEADERBSART

PRHEADERBSART

PRITEMWERKS

I get the same message when i use JCo. How can we use BAPI_TRANSACTION_COMMIT while using se37 test sequence?

I have yet to explore how to use commit in JCo. I remember it as JCo context automatically takes care of it.

Any hints? Thanks.

Former Member
0 Kudos

Hi

Maybe you have to enter more parameters except document type and plant.

BAPI call is depend on application customization and error message is not enough kind.

Before using SE37 you had better create purchase requisition from application screen and collect data you have to enter.

Then try from SE37.

Regarding BAPI_TRANSACTION_COMMIT

Some BAPI need explicit commit operation.

for example BAPI_SALESORDER_CREATEFROMDAT2 needs BAPI_TRANSACTION_COMMIT after successful operation.

I'm not sure whether BAPI_PR_CREATE need it or not though.

You can find it as following way.

1) executing BAPI_PR_CREATE successfully from SE37

2) check from "Display Purchase Requisition" if you can find the PR which BAPI made, BAPI_TRANSACTION_COMMIT isn't need.

If you can't find it BAPI_TRANSACTION_COMMIT is need.

I hope this will help you.
Thanks

former_member204370
Participant
0 Kudos

Hi

The program is working for BAPI_REQUISITION_CREATE. But not working for BAPI_PR_CREATE.

As you said, i have to explore this better to make the program generic.

I will create a different thread for BAPI_PR_CREATE related issues.

Thanks for your responses.

vijay_kumar49
Active Contributor
0 Kudos

Ram,

Please go through this pdf, this pdf having how to add SalesOrderItem to BAPI.

http://monicaradytia.files.wordpress.com/2013/06/3-2-1-create-sales-order-in-java-web-dynpro-using-b...

Hope this helps!!

Regards

Vijay K