Introduction
Trying to find a solution for the RFQ rejection I came across multiple threads but could not find a solution which will close the issue for me. So once I found a solution decided to share it.
Problem
In standard SAP system the RFQ release strategy does not cover rejection; it only has two options that is Release and Cancel Release.
Solution
The solution targets RFQ release using transaction ME45. The standard transaction provides user with two options.
- RFQ Release
- Cancel RFQ Release
To solve the rejection problem, I use the implicit enhancement option technique.
Finding the place to put my code:
When the user clicks the (Release/Cancel Release) ICON in the ALV grid, system triggers an ALV callback function. Tracing the code I reached to a METHOD rel_resetrel in include LMEREPI20. Here based on the ICON system decides to call the BAPI for Release or Cancel Release. I placed my code here
Enhancement Point:
The implicit enhancement point is created at the start of the METHOD rel_resetrel in include LMEREPI20.
As soon as the user clicks the ICON to release the RFQ, standard program triggers the callback function and finally lands in the above mentioned method. Here the enhancement checks if the action is to Release the RFQ, then a POPUP_TO_CONFIRM function is called and user is asked if he wants to Release or Reject the RFQ.
If the user selects the Release button, the enhancement doesnot proceed and leaves it to the standard system to trigger the release BAPI.
In case the user selects the Reject button, the enhancement calls a custom function Z_MM_DEL_RFQ, which through a BDC deletes all the line items of the RFQ. If the funciton returns with success, it deletes the line from the ALV table gt_outtab_purchdoc_rel, so that the line disappears once the control is returned back to the user. In case of an error system displays it.
Code Extract
<pre>
METHOD rel_resetrel."""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Class LCL_REPORTING_CNT_PURCHDOC_REL, Method REL_RESETREL, Start A*$*$-Start: (1)---------------------------------------------------------------------------------$*$*ENHANCEMENT 1 ZMM_RELEASE_ME45. "active version*If transaction code is ME45 and icon is not released yet the ask user to confirm is he wants to approve or reject
DATA ls_me45outtab TYPE merep_outtab_purchdoc_rel.
DATA lv_me45_ans TYPE c.
FIELD-SYMBOLS: <ME45_line> LIKE LINE OF gt_outtab_purchdoc_rel.
IF sy-tcode = 'ME45' .
MOVE-CORRESPONDING im_wa TO ls_me45outtab.
IF ls_me45outtab-icon_release = lcl_datablade_purchdoc_rel=>my_icon_allowed. "This means not relased yet*Ask user if he wants to release or reject(delete item)
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Decision'
text_question = 'Please select the required action'
text_button_1 = 'Release'* ICON_BUTTON_1 = ' '
text_button_2 = 'Reject'* ICON_BUTTON_2 = ' '
display_cancel_button = ' '
IMPORTING
answer = lv_me45_ans
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF lv_me45_ans = 2. "If Reject button is selected then delete the RFQ line item other wise continue so the standard BAPIs are called
CALL FUNCTION 'Z_MM_DEL_RFQ'
EXPORTING
ebeln = ls_me45outtab-ebeln
EXCEPTIONS
err_message = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.* update output table
LOOP AT gt_outtab_purchdoc_rel ASSIGNING <ME45_line> WHERE
ebeln = ls_me45outtab-ebeln.
DELETE gt_outtab_purchdoc_rel.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDIF.ENDENHANCEMENT.*$*$-End: (1)---------------------------------------------------------------------------------$*$*
Rest is standard
.
.
.
.
.
</pre>
Funciton Z_MM_DEL_RFQ
<pre>
FUNCTION z_mm_del_rfq.*"----------------------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(EBELN) TYPE EBELN*" EXCEPTIONS*" ERR_MESSAGE*"----------------------------------------------------------------------
DATA: lt_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
PERFORM bdc_dynpro USING 'SAPMM06E' '0305'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-ANFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RM06E-ANFNR'
ebeln."'2500011940'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EKKO-ANGDT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=MALL'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EKKO-ANGDT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=DL'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-ANFPS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'ME42' USING gt_me45_bdcdata MODE 'N' UPDATE 'S' MESSAGES INTO lt_messtab.
LOOP AT lt_messtab WHERE msgtyp = 'E'.
MESSAGE ID lt_messtab-msgid TYPE lt_messtab-msgtyp NUMBER lt_messtab-msgnr
WITH lt_messtab-msgv1 lt_messtab-msgv2 lt_messtab-msgv3 lt_messtab-msgv4 RAISING err_message.
EXIT.
ENDLOOP.ENDFUNCTION. </pre>