0% found this document useful (0 votes)
43 views2 pages

Blocking PR

This code block checks purchase requisition documents for specific rejection reasons in the VBAP and VBAK tables before allowing the document to be posted. It loops through the EBKN table, fetches data from VBAP and VBAK where applicable, and checks the ABGRU and AUGRU fields for rejection reasons. If a rejection reason is found, an error message is displayed stating the document or document item is blocked from being posted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Blocking PR

This code block checks purchase requisition documents for specific rejection reasons in the VBAP and VBAK tables before allowing the document to be posted. It loops through the EBKN table, fetches data from VBAP and VBAK where applicable, and checks the ABGRU and AUGRU fields for rejection reasons. If a rejection reason is found, an error message is displayed stating the document or document item is blocked from being posted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Requirement:

Purchase Requisition to be blocked by checking the ABGRU(Reason for rejection of quotations and sales
orders) in VBAP and AUGRU(Order reason (reason for the business transaction)) in VBAK tables and then
block the document to be posted .

BADI - ME_REQ_POSTED
Method POSTED

Code:
IF sy-tcode EQ 'ME51N'.
DATA: im_wa_ebkn LIKE LINE OF im_ebkn.

** Structure declaration for VBAP table


TYPES: BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln, " Sales Document
posnr TYPE vbap-posnr, " Sales Document Item
abgru TYPE vbap-abgru, " Reason for rejection of quotations and sales
orders
END OF ty_vbap,
** Structure declaration for VBAK table
BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln, " Sales Document
augru TYPE vbak-augru, " Order reason (reason for the business transaction)
END OF ty_vbak.

DATA:
** Work area declaration for VBAP table
wa_vbap TYPE ty_vbap,
** Work area declaration for VBAK table
wa_vbak TYPE ty_vbak.

DATA: g_string TYPE string. " String declaration to display error message

** Read table data from EBKN table


loop at im_ebkn into im_wa_ebkn.
** Condition to get the values of vbeln and vbelp
IF im_wa_ebkn-vbeln IS NOT INITIAL AND im_wa_ebkn-vbelp IS NOT INITIAL.

** Fetching the data from VBAK table


SELECT SINGLE
vbeln
augru
FROM vbak
INTO wa_vbak
WHERE vbeln = im_wa_ebkn-vbeln.

IF wa_vbak-augru = 'CL' OR wa_vbak-augru = 'HL'.


MESSAGE 'Sales order is blocked' TYPE 'I' display like 'E'.
leave to current transaction.
ELSE.
** Fetching the data from VBAP table
SELECT SINGLE
vbeln
posnr
abgru
FROM vbap
INTO wa_vbap
WHERE vbeln = im_wa_ebkn-vbeln
AND posnr = im_wa_ebkn-vbelp.
IF wa_vbap-abgru eq 'CL' or wa_vbap-abgru eq 'HL'.
** Concatenation in a string to display Sales document and Sales document item details
CONCATENATE 'Sales order line item is blocked for' im_wa_ebkn-vbeln im_wa_ebkn-vbelp
INTO g_string separated by space.
MESSAGE g_string TYPE 'I' display like 'E'.
leave to current transaction.
ENDIF.
ENDIF.
ENDIF.
endloop.
ENDIF.
ENDMETHOD.

You might also like