2009 Aug 25 8:53 PM
I've been tasked with detecting whether or not the reference number is being repeated for a given vendor in any previous Entry Sheet during sheet creation in ML81N. If the reference number duplication is discovered the SAVE is supposed to be stopped so the user can potentially correct their data entry error or abort the save due to duplicate invoicing.
I'm new-ish to ABAP so I've been digging and discovered that user exit EXIT_SAPLMLSR_001 seems to best fit my needs; I get the EKKO and ESSR records for the transaction which allow me to implement my logic, and I can issue a message that the condition has been discovered.
My problem is stopping the SAVE. I've traced a little beyond the user exit but things get confusing so it's time to ask for help.
Is there convenient way to interrupt the action without quitting ML81N entirely? Should I be using another method, such as a different user exit or BAdI (but I don't know anything about BAdIs yet), to do this?
Thanks in advance,
Greg
Here's the logic I injected into EXIT_SAPLMLSR_001. I am hoping there's a simple change I can add to the middle to alert the tcode to stop saving. I'm also aware the loop iterates a few extra times given more than one duplicate found, but baby steps!
DATA: vendor LIKE ekko-lifnr,
purdocno LIKE ekko-ebeln.
if sy-tcode = 'ML81N' and sy-ucomm = 'YES'.
* Check for a Ref# match in existing sheets
SELECT ebeln INTO purdocno FROM essr WHERE xblnr = i_essr-xblnr AND loekz <> 'X' AND ebeln <> i_essr-ebeln.
* Having the match we now look at the vendor # to see if it is the same
SELECT lifnr INTO vendor FROM ekko WHERE ebeln = purdocno.
IF vendor = i_ekko-lifnr.
* abort!
MESSAGE ID 'RP' TYPE 'W' NUMBER '016' WITH 'Reference provided has been used by this vendor before!'.
* e_edit doesn't seem to do much for me...
e_edit = 'X'.
exit.
ENDIF.
ENDSELECT.
ENDSELECT.
ENDIF.
I've been tasked with detecting whether or not the reference number is being repeated for a given vendor in any previous Entry Sheet during sheet creation in ML81N. If the reference number duplication is discovered the SAVE is supposed to be stopped so the user can potentially correct their data entry error or abort the save due to duplicate invoicing.
I'm new-ish to ABAP so I've been digging and discovered that user exit EXIT_SAPLMLSR_001 seems to best fit my needs; I get the EKKO and ESSR records for the transaction which allow me to implement my logic, and I can issue a message that the condition has been discovered.
My problem is stopping the SAVE. I've traced a little beyond the user exit but things get confusing so it's time to ask for help.
Is there convenient way to interrupt the action without quitting ML81N entirely? Should I be using another method, such as a different user exit or BAdI (but I don't know anything about BAdIs yet), to do this?
Thanks in advance,
Greg
Here's the logic I injected into EXIT_SAPLMLSR_001. I am hoping there's a simple change I can add to the middle to alert the tcode to stop saving. I'm also aware the loop iterates a few extra times given more than one duplicate found, but baby steps!
DATA: vendor LIKE ekko-lifnr,
purdocno LIKE ekko-ebeln.
if sy-tcode = 'ML81N' and sy-ucomm = 'YES'.
* Check for a Ref# match in existing sheets
SELECT ebeln INTO purdocno FROM essr WHERE xblnr = i_essr-xblnr AND loekz <> 'X' AND ebeln <> i_essr-ebeln.
* Having the match we now look at the vendor # to see if it is the same
SELECT lifnr INTO vendor FROM ekko WHERE ebeln = purdocno.
IF vendor = i_ekko-lifnr.
* abort!
MESSAGE ID 'RP' TYPE 'W' NUMBER '016' WITH 'Reference provided has been used by this vendor before!'.
* e_edit doesn't seem to do much for me...
e_edit = 'X'.
exit.
ENDIF.
ENDSELECT.
ENDSELECT.
ENDIF.
2009 Aug 25 9:09 PM
Hi,
Did you try an error message inplace of warning message this should stop the dialog and the control should still be there in ML81N.
Regards,
Himanshu
2009 Aug 25 9:35 PM
I did try to use a "Type 'E'" Message but it errors right out of the transaction.
Message 'Reference provided has been used by this vendor before!' TYPE 'E'.Thanks for the suggestion, though.
2009 Aug 26 7:13 AM
Hi,
Why dont you try with enhancement spots there seems to be one avaliable in the line items screen ie. SAPLMLSP screen 400 Module ROW_INPUT.
Regards,
Himanshu
2009 Oct 01 10:55 PM
Just in case anyone else stumbles upon this thread, the solution was for me to learn more ABAP!
I spent some time learning about Enhancement Points and how to use them, and then solved my problem by creating three implicit EPs. One to create a new "global" flag in the TOP include, another to intercept and detect my desired condition at a convenient place where all the required fields were available and toss the message and "set" the global flag, and the final one in the SAVE function to fail out of it if the flag was set.
I'm sure there is a more graceful way to implement this, and I'll be cringing if I ever have to look back at it, but this got it done for now.
2011 Feb 08 10:49 AM
Hi,
Actually I am having the same problem.....will you please enlight the solutuion........
Thanks
Parikshit Bisht
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |