cancel
Showing results for 
Search instead for 
Did you mean: 

'BAPI_PRODORDCONF_CANCEL" for cancelling confirmation

former_member321825
Active Participant
0 Kudos

Hi,

We are using customized report for Production order confirmation . Below are steps

1. Goods issue

2. Calling transaction Co11 for confirmation (BDC)

3 Goods receipt using BAPI_GOODSMVT_CREATE

while running the program , it throws the "Order processed by RFC_USER" . We have tried enquque, dequeue , wait  but error pops up randomly.

We have carried out few steps but still we are getting error sometimes.

The issue is that goods issue & confirmation is happening but not goods receipt hence we are  are now trying to revert the goods issue & confirmation through "BAPI_PRODORDCONF_CANCEL" .  i have pasted my code , please  suggest if by using "BAPI_PRODORDCONF_CANCEL"

will it  revert goods issue & confirmation .

*****************************************************************************************************************************

SELECT RUECK RMZHL

   from AFRU

   INTO IT_AFRU

  WHERE   AUFNR = zaufnr

AND ERNAM = Sy-uname

AND ERSDA = sy-datum


SORT IT_AFRU descending RUECK RMZHL.

 

   DO N Times.                                                                                                    " N=2

               CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

                 EXPORTING

                   goodsmvt_header  = ls_goodsmvt_header

                   goodsmvt_code    = ls_goodsmvt_code"'02' "ls_goodsmvt_code

                 IMPORTING

                   goodsmvt_headret = ls_goodsmvt_headret

                   materialdocument = lv_materialdocument1

                 TABLES

                   goodsmvt_item    = lt_goodsmvt_item1

                   return           = lt_return.

*

               CLEAR : IT_ENQ, IT_ENQ[],wa_enq.                

               READ TABLE lt_return INTO lwa_return WITH KEY type = 'E'.

               If sy-subrc  = .

                 Count = Count + 1.

                 IF Count < N .

                   CLEAR : ls_goodsmvt_headret,lv_materialdocument2.

                   CLEAR : lt_return, lt_return[].

                 ELSE.

  

   READ TABLE IT_AFRU into WA_AFRU index 1.

              

                  CALL FUNCTION 'BAPI_PRODORDCONF_CANCEL'

                    EXPORTING

                      CONFIRMATION              = WA_AFRU-RUECK

                      CONFIRMATIONCOUNTER       = WA_AFRU-RMZHL

*                    POSTG_DATE                =

*                    CONF_TEXT                 =

                   IMPORTING

                     RETURN                    =   ZRETURN

                     LOCKED                    ZLOCKED

                     CREATED_CONF_NO           ZCREATED_CONF_NO

                     CREATED_CONF_COUNT        ZCREATED_CONF_COUNT

  

              

                   

                ENDIF.

               

               else .

                 EXIT.

               ENDIF.

*              READ TABLE lt_return INTO lwa_return WITH KEY type = 'E'.

*              If sy-subrc  NE 0  .

*                EXIT.

*              ENDIF.

             ENDDO.

Accepted Solutions (1)

Accepted Solutions (1)

former_member321825
Active Participant
0 Kudos

while doing confirmation through Co11, goods issue used to happen but during goods receipt  we used to get error " Order processed by RFC_USER" .

We resolved this issue by using wait statement for longer duration during error

rupesh_brahmankar3
Active Contributor
0 Kudos

Hello Rachel,

Please use WAIT UPTO XXXX Seconds after BAPI commit.

Thanks for the info, please close the discussion.

Best Regards,

R.Brahmankar

former_member321825
Active Participant
0 Kudos


Just wanted to update you all before closing this discussion that we had resolved this issue by looping through "BAPI_GOODSMVT_CREATE.  if it gets error during  first iteration then wait for 20 secs. when it goes through loop for second time , doesnt throw error "order processed by RFC_USER".


Thank you all for your suggestions.




Answers (7)

Answers (7)

former_member321825
Active Participant
0 Kudos

POST_WRONG_ENTRIES  is commented  inside " BAPI_PRODORDCONF_CANCEL"

rupesh_brahmankar3
Active Contributor
0 Kudos

Hello Rechel,

The POST_WRONG_ENTRIES parameter controls which confirmations are transferred into the error pool.

You can correct and re-post the error pool entries via the post-processing of confirmations.

Value range

0: No confirmations

1: Only incorrect confirmations

2: Incorrect confirmations and confirmations that cannot be processed due to a lock situation.

Best Regards,

R.Brahmankar

former_member321825
Active Participant
0 Kudos

I am getting error while cancelling the confirmation "Order Processed by RFC_USER"

But it goes to BAPI_TRANSACTION commit but the problem is confirmation is not cancelled(commit does not happen) .

when i try putting breakpoint in bapi_transaction_commit , may be while debugging it gets more time and

then confirmation is cancelled only during debugging . Please help me with below code to cancel confirmation




CALL FUNCTION 'BAPI_PRODORDCONF_CANCEL'

                          EXPORTING

                            CONFIRMATION              = WA_AFRU-RUECK

                            CONFIRMATIONCOUNTER       = WA_AFRU-RMZHL

                 POSTG_DATE                = sy-datum

*                    CONF_TEXT                 =

                         IMPORTING

                           RETURN                    =   ZRETURN

                           LOCKED                    ZLOCKED

                           CREATED_CONF_NO           ZCREATED_CONF_NO

                           CREATED_CONF_COUNT        ZCREATED_CONF_COUNT.



If SY-SUBRC = 0 .

                         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

                           EXPORTING

                             wait = 'X'.

                       ENDIF.

rupesh_brahmankar3
Active Contributor
0 Kudos

Hello Rachel,

What is the value for POST_WRONG_ENTRIES is value not equal to '2' when the confirmation is called up ?

Best Regards,

R.Brahmankar

former_member321825
Active Participant
0 Kudos

I have carried out below steps

Call function modules ENQUEUE_ESORDER (with parameter AUFNR) and ENQUEUE_EMRKPF (with parameter RSNUM) before calling the BAPI's to check for locks on the order header and the reservation header, respectively

Looping through BAPI_GOODSMVT_CREATE and using wait statement  . In case of error ,then cancelling of goods issue & confirmation using BAPI_PRODORDCONF_CANCEL.

But still getting RFC error hence I am not able to rollback goods issue.

I want to know if there is any tcode  incase of  error i can ask user to run tcode for goods receipt.

Is there way to automate goods receipt

former_member321825
Active Participant
0 Kudos

call function modules ENQUEUE_ESORDER (with parameter AUFNR) and ENQUEUE_EMRKPF (with parameter RSNUM) before calling the BAPI's to check for locks on the order header and the reservation header, respectively

Looping through BAPI_GOODSMVT_CREATE and using wait statement  . In case of error ,then cancelling of goods issue & confirmation using BAPI_PRODORDCONF_CANCEL.

But still i am getting RFC error hence I am not able to rollback goods issue.

I want to know if there is any tcode  incase of  error i user to run tcode for goods receipt.

former_member321825
Active Participant
0 Kudos

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'


I have looped the above BAPI , Incase if i get error for second time i have used

CALL FUNCTION 'BAPI_PRODORDCONF_CANCEL'

                          EXPORTING

                            CONFIRMATION              = WA_AFRU-RUECK

                            CONFIRMATIONCOUNTER       = WA_AFRU-RMZHL

*                    POSTG_DATE                =

*                    CONF_TEXT                 =

                         IMPORTING

                           RETURN                    =   ZRETURN

                           LOCKED                    ZLOCKED

                           CREATED_CONF_NO           ZCREATED_CONF_NO

                           CREATED_CONF_COUNT        ZCREATED_CONF_COUNT.



If SY-SUBRC = 0 .

                         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

                           EXPORTING

                             wait = 'X'.

                       ENDIF.

Please suggest if this will work ,

rupesh_brahmankar3
Active Contributor
0 Kudos

Hello Rachel,

Please use WAIT UPTO XXXX Seconds after BAPI commit.

Best Regards,

R.Brahmankar

rupesh_brahmankar3
Active Contributor
0 Kudos

Hello Rechel

The goods movements in the BAPI are mainly posted in the update program,

It is recommended to set the WAIT parameter in the BAPI - BAPI_TRANSACTION_COMMIT or to use the statement 'COMMIT WORK AND WAIT'

in your own customer program.

Please refer SAP OSS consulting note 744403

Best Regards,

R.Brahmankar

Caetano
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello

If you are posting the goods receipt using BAPI_GOODSMVT_CREATE, it would not be cancelled by BAPI_PRODORDCONF_CANCEL because you did not post the goods movement during the confirmation.


You can use the control key PP03 on your operation, so that the goods receipt is posted during the confirmation. This way it can be cancelled by BAPI_PRODORDCONF_CANCEL .

Otherwise, you will have to cancel the goods movement individually using BAPI_GOODSMVT_CANCEL.

BR
Caetano

dejoy
Active Contributor
0 Kudos

Hello Rachel,

Yes this perform goods movement and confirmation  cancellation both. You can try with SE37 and put there test sequence with BAPI_PRODORDCONF_CANCEL & BAPI_TRANSACTION_COMMIT. Now run and check the result.

Regards,