Skip to Content
0
Former Member
Feb 27, 2008 at 08:01 PM

Assign problem in the ME51N user-exit

206 Views

Hi experts!

I am using SAP version 4.6C..... =(

I have a problem in transaction ME51N, there is a field called "Promotion" in the Item Overview (table control) that has to work this way: when the user put a value, like number 1, 2 or 3, I have to select a description in a Z table and display it in the Promotion field (AKTNR).

Ex:

Promotion

1 (value typed and then I push enter)

With the value 1 I go to the Z table and bring this result:

Promotion

1-Industry

We are using a filed exit (element WAKTION) and a user exit (EXIT_SAPLMEREQ_005) to modify this field value but it only works when the Valuation tab is open, because there is the same Promotion field in there, that is the field treated in the field exit (I think we can't modify table control fields using field exits).

When other tab is open, the field exit doesn't work!

I was trying to use assign commands in field-symbols, after doing a call method im_req_item, and inside this method I found an object that has the item values of the table control, so if I could assign this object to a field-symbol, I could be able to change the value of the Promotion field whenever I want.

I tried this in the User Exit EXIT_SAPLMEREQ_005:

DATA: i_item type mmpur_requisition_items,

t_req type ref to IF_PURCHASE_REQUISITION,

wa_item like line of i_item,

lo_obj type ref to object,

v_state type string.

FIELD-SYMBOLS: <item> type mereq_item.

  • Get reference 1185<LCL_REQ_HEADER> into t_req

CALL METHOD im_req_item->get_requisition

receiving

re_requisition = t_req.

  • Get reference 1189<LCL_REQ_ITEM> into i_item

call method t_req->get_items

receiving

re_items = i_item.

  • Loop into work area to read the item <LCL_REQ_ITEM>

loop at i_item into wa_item.

lo_obj ?= wa_item-item. " attribute to a ref-to-object variable

v_state = 'MY_STATE->ITEM'.

assign lo_obj->(v_state) to <item>. "<----- my problem is here

endloop.

It gives me an error message when I check the syntaxe:

Field "" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

I think the code is OK...... =(

If I could do this assign I would attribute the value I want in ITEM-AKTNR (Promotion field).

If anyone has a better solution or a better way to do this assign command, please tell me!!! =)

Thank you in advance!

Eduardo