Application Development 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: 

User exit in PP

Former Member
0 Kudos

Dear all,

Pl' give any examples of use exits used for PP modules, etc....

e.g. while production order confirmation (TCCO11) qty should be equal to & less than issued qty. ( CO27-- 261mvt) only , It should not accept order qty. greated than issue qty.

If order cancelled,teco... effects should be taken into consideration......

In QM also , it should accept production order confirmed qty. only which is issued by production people by MB31 ( mvt-101).

Thanks.

2 REPLIES 2

Former Member
0 Kudos

Hi Kishore,

I once implemented an exit for the second issue you have mentioned i.e to relese only the confirmed quantity from mb31 transaction.

I mention here the logic which i implemented and give the code to be implemented in the mentioned Customer exit.

Apart from implementing the code you will have to define appropriate messages as used in the code.

<b>****Logic***</b>

Transaction MB31 is entered to release the finished items.

Check1 ensures adequate goods have been issued or not.

Check2 ensures quantity being released for a material component is how much lesser that the total quantity.

Check3 & Check4 looks for new confirmations for the operations in an order, apart from the ones already released

Check5 Informs the qty confirmed has already been released.

Check6 allows only the left quantity to be released..

******

<b>***Additional details</b>

1) Checks if goods issue has been done or not for a material (For every unique material entry in RESB) by looking up for an entry in table AUFM for a particular material with movement type 261(good issue for order) and 262 (goods issue reversal for an order).

2) Another check is there for the quantity, to see that the quantity being released is equal to the amount being issued or not.

3) Check to find if the confirmation has been done for a particular order against a particular operation.

4) Check on the amount of quantity to be delivered is provided by checking the number of confirmations.

5) Check to see if any new confirmations have been done to release more number of items.

********

<b>****Code in exit MBCF0002**</b>

----


  • INCLUDE ZXMBCU02 *

----


IF sy-tcode = 'MB31'.

TABLES : afpo, aufm, afko, afvc, afru .

DATA : i_resb LIKE TABLE OF resb WITH HEADER LINE,

i_aufm LIKE TABLE OF aufm WITH HEADER LINE,

i_afru LIKE TABLE OF afru WITH HEADER LINE,

i_afvc LIKE TABLE OF afvc WITH HEADER LINE .

DATA : qty LIKE aufm-menge, qty1 LIKE afru-smeng, qty2 LIKE aufm-menge.

DATA : v_confirm(2) TYPE n, v_cancel(2) TYPE n, v_cnt_261(2) TYPE n,

v_cnt_else(2) TYPE n.

DATA : i_afko LIKE afko, wa_afru LIKE LINE OF i_afru, confirmation LIKE

afru-rueck.

SELECT SINGLE * FROM afko INTO i_afko WHERE aufnr = i_mseg-aufnr.

SELECT * FROM afru INTO TABLE i_afru WHERE aufnr = i_mseg-aufnr.

SELECT * FROM resb INTO TABLE i_resb WHERE aufnr = i_mseg-aufnr.

LOOP AT i_resb.

CLEAR : qty, v_cnt_261, v_cnt_else.

*Indicator: Phantom item indicator

IF i_resb-dumps = 'X' .

CONTINUE.

ENDIF.

*Indicator: Item is deleted

IF I_RESB-XLOEK = 'X'.

CONTINUE.

ENDIF.

*Indicator: bulk material

IF I_RESB-SCHGT = 'X' .

CONTINUE.

ENDIF.

  • clearing of aufm[] required

SELECT * FROM aufm INTO TABLE i_aufm WHERE matnr = i_resb-matnr AND

rsnum = i_resb-rsnum.

IF i_aufm[] IS INITIAL.

v_cnt_else = v_cnt_else + 1.

ENDIF.

LOOP AT i_aufm WHERE rspos = i_resb-rspos.

IF i_aufm-bwart = 261.

v_cnt_261 = v_cnt_261 + 1.

*addtion to check IF i_aufm-bwart = 262

ELSEIF i_aufm-bwart = 262.

v_cnt_else = v_cnt_else + 1.

ENDIF.

ENDLOOP.

IF v_cnt_else >= v_cnt_261.

MESSAGE ID 'ZSER' TYPE 'A' NUMBER '016' WITH i_mseg-aufnr i_resb-matnr

.

ELSE.

CLEAR qty.

LOOP AT i_aufm WHERE rspos = i_resb-rspos.

IF i_aufm-bwart = 261.

qty = qty + i_aufm-menge.

*addtion to check IF i_aufm-bwart = 262

ELSEIF i_aufm-bwart = 262.

qty = qty - i_aufm-menge.

ENDIF.

ENDLOOP.

IF i_resb-bdmng <> qty.

qty = i_resb-bdmng - qty.

  • MESSAGE ID 'ZSER' TYPE 'W' NUMBER '016' WITH i_mseg-aufnr i_resb-matnr

  • 'QUANTITY' qty.

ENDIF.

ENDIF.

ENDLOOP.

*LOOP AT OPERATIONS WITHIN AN ORDER WITH ROUTING NO.

SELECT * FROM afvc INTO TABLE i_afvc WHERE aufpl = i_afko-aufpl.

LOOP AT i_afvc.

*CHECK CONFIMATION FOR AN OPERATION EXISTS IN ALL CONFIRMATIONS

READ TABLE i_afru WITH KEY rueck = i_afvc-rueck.

IF sy-subrc <> 0.

MESSAGE ID 'ZSER' TYPE 'A' NUMBER '017' WITH i_mseg-aufnr i_afvc-vornr.

ENDIF.

CLEAR : v_confirm, v_cancel.

*LOOP AT ALL CONFIRMED OPERATIONS FOR ALL OPERATION CONFIRMATIONS

LOOP AT i_afru WHERE rueck = i_afvc-rueck.

*CHECK FOR CANCEL CONFIRMATION FIELD (0/1 - CONFIRM/REVERSE)

IF i_afru-stzhl = 0 .

v_confirm = v_confirm + 1.

*QTY1 = QTY1 - I_AFRU-GMNGA.

ELSE.

v_cancel = v_cancel + 1.

*QTY1 = QTY1 + I_AFRU-GMNGA.

ENDIF.

ENDLOOP.

IF v_cancel => v_confirm .

MESSAGE ID 'ZSER' TYPE 'A' NUMBER '017' WITH i_mseg-aufnr i_afvc-vornr.

ENDIF.

confirmation = i_afvc-rueck .

ENDLOOP.

CLEAR : qty, qty1, qty2.

CLEAR : i_afru.

REFRESH i_aufm[].

SELECT * FROM aufm INTO TABLE i_aufm WHERE aufnr = i_mseg-aufnr.

*QTY2 IS DELIVERED QTY

LOOP AT i_aufm WHERE bwart = '101' OR bwart = '102' .

IF i_aufm-bwart = '101'.

qty2 = qty2 + i_aufm-menge .

ELSEIF i_aufm-bwart = '102'.

qty2 = qty2 - i_aufm-menge .

ENDIF.

ENDLOOP.

SORT i_afru BY rueck rmzhl.

LOOP AT i_afru INTO wa_afru WHERE rueck = confirmation.

*CALCULATE QUANTITY ALEADY CONFIRMED

IF wa_afru-stzhl <> 0 .

qty1 = qty1 - wa_afru-gmnga.

ELSE.

qty1 = qty1 + wa_afru-gmnga.

ENDIF.

*CLEAR WA_AFRU.

ENDLOOP.

*QTY1 --- CONFIRMED

*WA_AFRU-GMNGA --- TO BE CONFIRMED " i_afko-gamng --- total quantity

*I_MSEG-ERFMG -


TOTAL TO BE RELEASED CONFIRM

*QTY = I_AFKO-GAMNG - QTY.

IF qty2 = qty1.

MESSAGE ID 'ZSER' TYPE 'A' NUMBER '019' WITH wa_afru-gmnga i_mseg-erfmg.

ENDIF.

*qty = qty - qty2.

IF qty2 < qty1.

qty = qty1 - qty2.

ENDIF.

IF i_mseg-erfmg > qty .

MESSAGE ID 'ZSER' TYPE 'A' NUMBER '018' WITH qty i_mseg-erfmg.

ENDIF.

ENDIF.

*******

Also i recall putting a check on tcode in the begining of the code so probly this exit is being called in other transactions as well.

Check if it is being called in c011 as well and solves the purpose.

Also to search for exits go to transaction SMOD and from menu select

Utilities->find

and provide the package name for the main program of transaction MB31.

You will get a list of exits.

Put a break-point in the ones which you think can solve the purpose and see if anyone of these is getting called.

Hope this helps you.

regards,

Vikas

<b>Always rewards points to useful suggestions.</b>

0 Kudos

Dear Vikas,

Thanks.

But try for my other requirements considering effects like cancellation of orders, etc.....