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:Β 

Assign problem in the ME51N user-exit

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

how about this:

loop at i_item into wa_item.

assign wa_item-item to <item>.

endloop.

/wg

8 REPLIES 8

Former Member
0 Kudos

how about this:

loop at i_item into wa_item.

assign wa_item-item to <item>.

endloop.

/wg

0 Kudos

Thank you Gasiorowski, but this doesn't solve my problem.

When I change the values of wa_item-item in the user exit, the values in the table control are still the same, they don't change.

So, the values I have to change are inside the object loaded in wa_item, that is:

wa_item-item = 536<LCL_REQ_ITEM>

Inside object 536<LCL_REQ_ITEM> , there is an attibute called MY_STATE:

536<LCL_REQ_ITEM>-MY_STATE

Inside MY_STATE, there is another object:

536<LCL_REQ_ITEM>-MY_STATE = 908<LCL_REQ_ITEM_STATE>

And finally, inside this object, it's the ITEM I want to reach:

908<LCL_REQ_ITEM_STATE>-ITEM

More precisely, the field AKTNR: 908<LCL_REQ_ITEM_STATE>-ITEM-AKTNR

I'm trying to assign this last field....

Thank you and I hope someone can help me with this....

Eduardo

0 Kudos

Hi,

How about that:

data: LR_REQ_ITEM type ref to LCL_REQ_ITEM.
data: LR_REQ_ITEM_STATE type ref to LCL_REQ_ITEM_STATE.
....
loop at i_item into wa_item.
assign wa_item-item to <item>.
LR_REQ_ITEM ?= <item>.
LR_REQ_ITEM_STATE ?= LR_REQ_ITEM-MY_STATE.
* I don't know if here ITEM is an internal table so I 
* have assumed that is 
LR_REQ_ITEM_STATE-ITEM-AKTNR = 'VALUE'.
<item> = LR_REQ_ITEM .
endloop.

Please check it because I'm eager to help you.

Best regards,

Wojciech

0 Kudos

Gasiorowski,

That was a nice suggestion, but in the user-exit it's giving me this error message:

The type "LCL_REQ_ITEM" is unknown.

Do you know why?

Thank you,

Eduardo

0 Kudos

have you checked that interface: IF_PURCHASE_REQUISITION_ITEM maybe there will be a promotion.

/wg

0 Kudos

Hi,

I think that I've got it. Maybe you will have to replace object->method( ) with call method:

data: LR_REQ_ITEM type ref to IF_PURCHASE_REQUISITION_ITEM.

data: s_MEREQ_ITEM type MEREQ_ITEM.

....

loop at i_item into wa_item.

assign wa_item-item to <item>.

LR_REQ_ITEM ?= <item>.

s_MEREQ_ITEM = LR_REQ_ITEM->GET_DATA( ).

s_MEREQ_ITEM-AKTNR ='some value'.

LR_REQ_ITEM->SET_DATA( s_MEREQ_ITEM ).

<item> = LR_REQ_ITEM .

endloop.

/wg

0 Kudos

In the interface you mencioned, there is a method (get_data) that returns the item line values of the table control, including Promotion field, but the changes I do there, doesn't apply to the screen field, unless the Valuation tab is open. =(

0 Kudos

Dear experts ,

I am through with saving custom textfields of customers in PR by following the guidelines from here.

But still i couldnot make out

i_mereq_item type mereq_item

how,we are able to conclude the structure where data goes.