‎2006 Mar 24 2:16 AM
Hi guys,
I have a case where I am modifying the quantity on a purchase order line item in Me22 or me22n.If this PO is tied to a nomination, I dont want the order quantity to be changed. Suppose I have Order quantity of 200 KG on item 10 and if item 10 is tied to nomination and if i try to change it to say 150 kg, I want my user exit to change it back to 200 KG when i click on save. So, I put my logic in an include file in EXIT_SAPMM06E_013 . Basically, I am trying to copy YEKPO-MENGE back to XEKPO-MENGE. But this doesn't seem to work. My quantity is still saved with 150 KG when i desire to have it unchanged as 200 KG. Here is the code below. Am i using the right user exit and the right Communication structure ? I am not sure if XEKPO and YEKPO are the ones I should look for. I even tried XEKET and YEKET. Did not work .Any help to solve this issue is greatly appreciated!
*----------------------------------------------------------------------
*
* INCLUDE ZSWI_NOMIT_PO_VALIDATION
*
*----------------------------------------------------------------------
DATA: i_wa_xekpo TYPE uekpo,
i_wa_yekpo TYPE uekpo,
i_oijnomi TYPE oijnomi.
DATA: i_wa_yeket TYPE ueket,
i_wa_xeket TYPE eket,
i_eket TYPE eket OCCURS 0 .
DATA :i_tabix TYPE sytabix.
CONSTANTS: c_char_i VALUE 'I',
c_char_e VALUE 'E',
c_char_f VALUE 'F',
c_char_p VALUE 'P',
c_char_v VALUE 'V',
c_bulk_order(2) VALUE 'ZB',
c_po_change(4) VALUE 'ME22',
c_pon_change(5) VALUE 'ME22N'.
IF i_ekko-bstyp = c_char_f AND " Purchase orders
i_ekko-bsart = c_bulk_order AND " Bulk orders
sy-batch IS INITIAL AND " In foreground
( sy-tcode = c_po_change OR " PO Change
sy-tcode = c_pon_change ) . " Enjoy PO Change
CLEAR: i_wa_msg .
REFRESH: i_message .
LOOP AT xekpo INTO i_wa_xekpo .
i_tabix = sy-tabix.
READ TABLE yekpo
INTO i_wa_yekpo
WITH KEY ebeln = i_wa_xekpo-ebeln
ebelp = i_wa_xekpo-ebelp .
IF sy-subrc EQ 0 .
CLEAR: i_oijnomi .
SELECT SINGLE * FROM oijnomi
INTO i_oijnomi
WHERE docnr = i_wa_xekpo-ebeln
AND docitm = i_wa_xekpo-ebelp
AND docind = c_char_p .
IF sy-subrc EQ 0. " TIED TO A NOMINATION
IF i_wa_xekpo-menge NE i_wa_yekpo-menge .
xekpo-menge = i_wa_yekpo-menge.
MODIFY xekpo FROM xekpo INDEX i_tabix
TRANSPORTING menge .
READ TABLE yeket INTO i_wa_yeket
WITH KEY ebeln = i_wa_xekpo-ebeln
ebelp = i_wa_xekpo-ebelp .
xeket-menge = i_wa_yeket-menge.
MODIFY xeket FROM xeket INDEX i_tabix
TRANSPORTING menge .
ELSEIF i_wa_xekpo-werks NE i_wa_yekpo-werks .
MODIFY xekpo FROM i_wa_yekpo INDEX i_tabix
TRANSPORTING werks.
ENDIF .
ENDIF .
ENDIF .
ENDLOOP .
ENDIF .Thanks,
SHK
‎2006 Mar 24 2:29 AM
Try include program ZXM06U43. This is an include in User Exit EXIT_SAPMM06E_012. This gets triggered when you save a Purchase Order. Here you can modify PO Qty. You will have to populate PO Item details from EKPO and modify internal table which contains PO Items details (after user modification).
To use this exit, you can do like this:
1. Run transaction CMOD.
2. Enter a project name. Create your own name. Check with your company naming range for user exit name.
3. Click on enhancement assignment
4. Select MM06E005
5. Doubleclick on EXIT_SAPMM06E_012
6. Doubleclick on include ZXM06U43
7. Inside this include you can start doing your Abap. Check on the fields you want to compare. And then you can modify data accordingly.
ashish
‎2006 Mar 24 2:29 AM
Try include program ZXM06U43. This is an include in User Exit EXIT_SAPMM06E_012. This gets triggered when you save a Purchase Order. Here you can modify PO Qty. You will have to populate PO Item details from EKPO and modify internal table which contains PO Items details (after user modification).
To use this exit, you can do like this:
1. Run transaction CMOD.
2. Enter a project name. Create your own name. Check with your company naming range for user exit name.
3. Click on enhancement assignment
4. Select MM06E005
5. Doubleclick on EXIT_SAPMM06E_012
6. Doubleclick on include ZXM06U43
7. Inside this include you can start doing your Abap. Check on the fields you want to compare. And then you can modify data accordingly.
ashish
‎2006 Mar 24 2:43 AM
I will try that Ashish. I have a quick question. Do i always have to create a project in CMOD ? Can I not open ZXM06U43 in se38 and add my include file with logic there ?
Thanks
Shareen
‎2006 Mar 24 2:47 AM
is any XEKPO and YEKPO structure avaiable in this user exit - EXIT_SAPMM06E_012 ? If yes, I will try to copy YEKPO-MENGE back to XEKPO-MENGE.
‎2006 Mar 24 2:48 AM
Hi Shareen,
You have to crate a project in CMOD. So that you can activate the enhancements you have done to the transaction.
Regards,
Wenceslaus.
‎2006 Mar 24 4:44 AM
I tried to use EXIT_SAPMM06E_012. It has a TEKPO internal table containing the new values. I replaced the Menge value here by the old value in EKPO-MENGE..But still the new value is saved Same thing happened in my exit above mentioned too. I was trying to copy the old value YEKPO-MENGE to XEKPO-MENGE, still the new one is getting saved , when i click on save.
‎2006 Mar 24 12:41 PM
Hi ashish,
I edit the fields of internal table TEKPO with whatever values, I need. But when saving, the PO is not getting updated with the desired values. Is this TEKPO getting refreshed or does it lose its scope when it comes out of the user exit ? Same is the problem with EXIT_SAPMM06E_013 too. I have both the old values and new values in YEKPO and XEKPO. I try to copy some fields of YEKPO to XEKPO..But somehow, its not getting updated.
THanks,
SHK
‎2006 Mar 24 1:03 PM
Hi Shareen,
In same EXIT_SAPMM06E_012, try to compare the old PO qty and changed PO qty if they are different then throw an error message. this stop the further processing of PO and will not allow user to save the changes.
then the original quantity will be retained.
regards
Rahul
‎2006 Mar 24 1:19 PM
Hi Rahul,
THis is what i am trying to avoid. I want the user not to change only the quantity field. All other changes he has made needs to be saved.So,I dont want to throw a hard error.
SHK
‎2006 Mar 24 1:32 PM
Hi Shareen,
According to my observation,
The User exits are provided for custom fields created on screen exit at header and item level, Quantity field is on standard screen. it has its own processors. custom sub screen can not control the process on standard screens. even if we try to assign data to standard fields at runtime, I found the value is lost in the execution and the chages doesn't reflect on screen.
regards
Rahul
‎2006 Mar 25 1:37 AM
Rahul,
I need to correct u. The Exit says Customer fields, not custom field 😛
rgds,
Shareen
‎2006 Mar 26 4:17 AM
I tried Ashish. Did not work..I have access for both old and new values . But when i copy the old value to new values, it loses it scope after couple of exits.
The i thought EXIT_SAPMM06E_017 might be the best one to use. Even that did not work.
Thanks,
Shareen
‎2006 Mar 31 6:00 PM
Shareen,
I am facing the same problem too. I have check the standard SAP code and found out that, whether you make changes to the data in the userexit for the EKKO, or EKPO, or EKET it doesn't reflect in the actual PO. Mainly all the PO userexits are there to show a custom error. The data which you can modify are only the customer (or custom) fields. I had to modify the delivery date for my requirement. What i did was modified the standard code by getting the object key? there is no other go, even checked with SAP.
Let me know if you need some help.
Naga
‎2006 Mar 24 1:17 PM
Hi Hegde,
Checkout which is the correct exit among these to put your code and tryout.
<b>Extension Name Exit Name
Description
Include</b>
MELAB001 EXIT_RM06ELAB_001
Customer Enhancement: Generate Sched. Agreement Releases: Creation Profile
ZXM06U26
MEVME001 EXIT_SAPLEINR_001
Calculation of Default GR Quantity and Over-/Underdelivery Tolerance
ZXM06U28
MM06E001 EXIT_SAPLEINM_001
Customer Enhancements for Control Record: Purchasing Document (Outbound)
ZXM06U01
MM06E001 EXIT_SAPLEINM_002
Customer Enhancements to Data Segments: Purchasing Document (Outbound)
ZXM06U02
Regards,
Raj
‎2006 Mar 24 1:22 PM
Dear Rajadeskhar,
None of the User exits your mentioned below. Most of them sound like they are for EDI.
I just want an user exit for Me22 or Me22n in 4.6 C which can alter certain fields like MENGE ( order quantity) during save, based on certain conditions,
Rgds,
Shareen
‎2006 Mar 24 1:58 PM
Hi,
These exits are in <b>ECC 5.0</b>
Try this program to know all userexits for a given transaction.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/abap-code-samples/userexits%20in%20a%20transaction.doc">Userexits for a given transaction</a>
Regards,
Raj
‎2006 Mar 25 1:41 AM
I know about that program to find user exits given a Tcode. I know all the available user exits for me22 and me22n. I just dont know why the changed i make to XEKPO, or TEKPO or XEKET are not getting reflected ? is any other process over writing it ? I tried to use field symbols so that i can retain its scope outside my include program. Doesnt help . Distress. SOS
‎2006 Apr 11 4:10 PM
Hi guys,
We succeed in solving partially the problem of modifyng the PO quantity (menge) using the SMOD exit MDR10001.
In this case, the FM EXIT_SAPLMDR1_004 can be used to trigger a modification in CH_S_RESULTS-menge e CH_S_RESULTS-lmenge. This modification is copied back in the PO item.
The only problem is that if the PO item is created with quantity zero, this exit is not alled.
Let me know your feed-back
Ugo Poddine