Application Development and Automation 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: 
Read only

Problem while saving PR in ME51N

former_member209770
Participant
0 Likes
1,823

dear Gurus,

i'm coding in userexit "EXIT_SAPLMEREQ_010"

When i try to save the ME51N transaction all the fields gets disabled or greyed out and there is an error message that i write it. BUT I want that the fields should be enabled so that he can make the corrections.

I found that when we click the save button the user exit is activated.

Can anyone help me?

Thanks in advance, and i really appreciate it.

12 REPLIES 12
Read only

madhu_vadlamani
Active Contributor
0 Likes
1,641

Hi,

Did not understand the requirement. Explain more.

When i try to save the ME51N transaction all the fields gets disabled or greyed out and there is an error message that i write it.

Regards,

Madhu.

Read only

0 Likes
1,641

Dear Madhu,

The Userexit I use: EXIT_SAPLMEREQ_010

In the first half of my code, I write some code to select the information I want to check.

But in the screen of ME51N, if it is wrong data, it will appear an error msg that i write.(as following code)

IF SY-SUBRC = 0.

MESSAGE E999(CK) WITH 'TEST MESSAGE'.

ENDIF.

but after that, i can't change the fields directly in PR anymore, the fields gets disabled or greyed out.

I have to re-enter the order instead.

Can you understand what I mean?

Edited by: Ya-Chun Liou on Aug 9, 2011 7:37 AM

Read only

0 Likes
1,641

hello,

why you are using user exit when there is BADI ME_PROCESS_REQ_CUST which works perfectly (your code will be assembled in one place )?

Implement that BADI and add your code into CHECK method.



INCLUDE mm_messages_mac.

 IF sy-subrc = 0.
      mmpur_message 'E' 'CK' '999' 'TEST MESSAGE' '' '' ''.
      ch_failed = mmpur_yes.
  ENDIF.

br,

dez_

Read only

0 Likes
1,641

Hi Liou,

Sorry little late reply. I did this a long back. Check this link.

Post if need help.

Regards,

Madhu.

Edited by: madhurao123 on Aug 9, 2011 2:40 PM

Read only

0 Likes
1,641

Dear Dez,

Thanks for your reply, but i still have some question.

With the BADI, how can I restrict the user not to choose the asset number (ANLN1) that have already exist in the system when they create new PR (account assignment: A)?

Users must create new asset instead.

I'm not familiar with Badi, and I really appreciate your help.

Read only

0 Likes
1,641

hello,

read this article about BADI:

[http://wiki.sdn.sap.com/wiki/display/ABAP/ConceptsandWorkingwithBADI]

you could use the same check method for asset number validation. Just use asset number which is entered into anla1 field and write a simple select from anla table if select returns 4

(sy-subrc eq 4)

then asset does not exist if zero - it exists.

INCLUDE mm_messages_mac.

  DATA: t_items TYPE mmpur_requisition_items.
  DATA: wa_item TYPE mmpur_requisition_item.
  DATA: ls_mereqitem TYPE mereq_item.

  CALL METHOD im_header->get_items
    RECEIVING
      re_items = t_items.

  LOOP AT t_items INTO wa_item.

    CLEAR ls_mereqitem.

    CALL METHOD wa_item-item->get_data
      RECEIVING
        re_data = ls_mereqitem.

    "here should be your select

    IF sy-subrc = 0.
      mmpur_message 'E' 'ME' 'Message' '' '' ''.
      ch_failed = mmpur_yes.
    ENDIF.

  ENDLOOP.

br,

dez_

Read only

0 Likes
1,641

Dear Dez,

I don't understand why select return number have to equal 4 ?

Read only

0 Likes
1,641

if select returns 4 - such entry does not exits or you could write

sy-subrc ne 0

br,

dez_

Read only

0 Likes
1,641

I select ANLN1 from the table ANLA to compare the data with ls_mereqitem.

But when I execute ME51N, it still doesn't work.

Is there any problem?


INCLUDE mm_messages_mac.

  DATA: t_items TYPE mmpur_requisition_items.
  DATA: wa_item TYPE mmpur_requisition_item.
  DATA: ls_mereqitem TYPE mereq_item.
  DATA: IT_ANLA TYPE ANLA.

  CALL METHOD im_header->get_items
    RECEIVING
      re_items = t_items.

  LOOP AT t_items INTO wa_item.

    CLEAR ls_mereqitem.

    CALL METHOD wa_item-item->get_data
      RECEIVING
        re_data = ls_mereqitem.

  SELECT ANLN1 FROM ANLA INTO IT_ANLA.
CHECK IT_ANLA-ANLN1 = ls_mereqitem.  "IF THE USER SELECT EXISTED ASSET NUMBER
  ENDSELECT.

    IF sy-subrc = 0.
      mmpur_message 'E' 'ck' '999' 'Message' '' '' ''.
      ch_failed = mmpur_yes.
    ENDIF.

  ENDLOOP.

Read only

0 Likes
1,641

Hi Liou,

Can you tell me what is happening here.

SELECT ANLN1 FROM ANLA INTO IT_ANLA.

CHECK IT_ANLA-ANLN1 = ls_mereqitem. "IF THE USER SELECT EXISTED ASSET NUMBER

ENDSELECT.

mereq_item this is item record. IT_ANLA-ANLN1 this is a field

Regards,

Madhu.

Edited by: madhurao123 on Aug 9, 2011 3:15 PM

Read only

0 Likes
1,641

Dear Madhu,

I am so sorry about my poor programming skill...

Now I have changed my code as following...

but i have no idea how to set the account assignment must = 'A'


INCLUDE MM_MESSAGES_MAC.

DATA LTO_ITEMS TYPE MMPUR_REQUISITION_ITEMS.
DATA L_ITEM TYPE MMPUR_REQUISITION_ITEM.

DATA LTO_ITEMS_ACCOUNTING_LIST TYPE MMPUR_ACCOUNTING_LIST.
DATA L_ACC_ITEM TYPE MMPUR_ACCOUNTING_TYPE.

DATA LRE_EXKN TYPE EXKN.

LTO_ITEMS = IM_HEADER->GET_ITEMS( ).   " Get PR items

LOOP AT LTO_ITEMS INTO L_ITEM.   " Loop at each item

  CLEAR: LTO_ITEMS_ACCOUNTING_LIST, L_ACC_ITEM, LRE_EXKN.

  LTO_ITEMS_ACCOUNTING_LIST = L_ITEM-ITEM->IF_ACCT_CONTAINER_MM~GET_ITEMS( ).

  READ TABLE LTO_ITEMS_ACCOUNTING_LIST INTO L_ACC_ITEM INDEX 1.

  IF SY-SUBRC = 0.

    LRE_EXKN = L_ACC_ITEM-MODEL->GET_EXKN( ).   " Get the EXKN structure.

    IF LRE_EXKN-ANLN1+0(6) NE 'INTERN'.   " Filter the new entry

      MMPUR_MESSAGE 'E' 'CK' '999' 'u8ACBu5EFAu7ACBu4E00u7D44u65B0u7684u8CC7u7522...u4E0Du5F97u9078u53D6u5DF2u5B58u5728u7684u8CC7u7522u865Fu78BC' '' '' ''.
      CH_FAILED = MMPUR_YES.
      CLEAR LRE_EXKN-ANLN1.

    ENDIF.

  ENDIF.

ENDLOOP.

Could anybody tell me what can I do?

I really appreciate that!

Read only

0 Likes
1,641

I have solved my problem.

Thanks for any help~