Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Runtime error in implementing a BADI.

Former Member
0 Kudos
405

Hello Experts,

                     I have requirement to incorporate certain logic by creating an implementation in BADI "workorder_update" . I have coded the logic but i get a runtime error stating that "Invalid COMMIT WORK in an update function module."   When i explored further I found that this error is arising from function module "  BAPI_MATERIAL_PLANNING " for which I have coded as below ,

   CALL FUNCTION 'BAPI_MATERIAL_PLANNING'
            EXPORTING
              material       = it1-matnr
              plant          = it1-werks
*            MRP_AREA       =
*            PLAN_SCENARIO  =
             MRP_PLAN_PARAM = it_mrp_list
*            MATERIAL_EVG   =
            IMPORTING
*             MRP_STATISTIC  =
              return         = t_return
*            TABLES
*              mrp_lists      = iit_mrp_list
*             EXTENSIONOUT   =
            .


*checking if  return result from BAPI_MATERIAL_PLANNING  was success.
          IF l1_return-type = 'S'.

           CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*            EXPORTING
*              WAIT          =
           IMPORTING
              RETURN        = t_return
                    .




          ELSE.
          CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
         IMPORTING
             RETURN        = t_return
                    .

endif.

Thanks & regards ,

Prakrita Kapoor.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
250

Hi all ,

        I could find the solution  for the above problem .  I created a function module  and called it  in IN_UPDATE  method as follow .

   CALL FUNCTION 'Zxxxxx' STARTING NEW TASK 'UPDATE'.

Inside it , I  added the above mentioned  code and it worked without the commit work error.

Thank you all for the replies .

Hope I will get your support in my future discussions .

Thanks & regards ,

Prakrita Kapoor.

6 REPLIES 6

former_member1716
Active Contributor
0 Kudos
250

Hi Prakrita,

Please ask your basis team to refresh the system, since the code is from standard FM.

This have worked in certain cases.

Also try removing the badis that you have used for rollback and commit statements. This will work.

Thanks,

Satish

Former Member
0 Kudos
250

Hi Prakrita,

Go through the function module documentation which clearly states

COMMIT control

For the single- and multi-level planning, the planning results are posted by
materials. The COMMIT WORK command is executed after every planned
material.

This means there is no need to explicility to do another commit by

'BAPI_TRANSACTION_COMMIT'

So remove the commit and rollback statements.

Hope this helps.

Thanks,

Tooshar Bendale

0 Kudos
250

Hi Tooshar,

                  Inspite of removing the commit and rollback  statements ,still I am getting the same runtime error. Could you please let me know where I am going wrong or if there is any  alternative ways of doing it ?

Thanks & regards,

Prakrita Kapoor.

Former Member
0 Kudos
250


Yes I agree with Tushar.

We can see there is in an implicit COMMIT WORK done by the system.

SAP Notes in the Function Module Documentation:

COMMIT control

For the single- and multi-level planning, the planning results are posted by materials. The COMMIT WORK command is executed after every planned material.

Regards,

Tanmoy

Former Member
0 Kudos
251

Hi all ,

        I could find the solution  for the above problem .  I created a function module  and called it  in IN_UPDATE  method as follow .

   CALL FUNCTION 'Zxxxxx' STARTING NEW TASK 'UPDATE'.

Inside it , I  added the above mentioned  code and it worked without the commit work error.

Thank you all for the replies .

Hope I will get your support in my future discussions .

Thanks & regards ,

Prakrita Kapoor.

0 Kudos
250

Nice that you posted the answer prakrita

This will really be helpful for all other members who go through this thread Good work

and also glad that you found the solution

thanks,

Satish