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: 

How to change the value of Purchasing group while saving in ME21N

0 Kudos

Hi Guys,

I have a requirement wherein i need to check the value of purchasing group(field EKGRP) on pressing save ie creation of a purchase order. If the EKGRP value is not a specific value say 110 i have to default it to 110 on saving

That is upon saving(in Me21N) the code should check these

1 - Value of EKGRP

2 - Change the value to 110 if it's anything else.

I have gone through EXIT_SAPMM06E_013 and BAPI ME_PROCESS_PO_CUST. The problem with the EXIT_SAPMM06E_013 is that it's tables have no value of EKGRP during runtime.

The BAPI ME_PROCESS_PO_CUST method PROCESS_HEADER does not get called while saving the PO,hence it does not solve my purpose.

Could anyone help me out?

1 ACCEPTED SOLUTION

0 Kudos

Hi everyone,

I have solved the requirement by means of an implicit enhancement in the include LMEGUICI5. Inside this include there is a method transport_from_dynp.All i have to do is change the value of purchasing group based on my condition inside the structure mepo1222.

This enhancement gets triggered whenever user presses enter or save.

Thanks everyone for your valuable help and inputs.Iam marking Raymond's answer as helpful

16 REPLIES 16

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Hari,

If you are not able to find the internal table/structure in BADI/Exit, I hope you can try the value using field symbol concept.


"Data Declaration

field-symbol <f_ekgrp> like ekgrp.

"Get the Ekgrp value using Program and Variable name

assign ('(program_name)varible_name') to <f_ekgrp>.

"Change the value

if <f_ekgrp> is assigned.

<f_ekgrp> = 'new value'.

endif.

Regards

Rajkumar Narasimman

raymond_giuseppi
Active Contributor
0 Kudos

The BAPI ME_PROCESS_PO_CUST method PROCESS_HEADER does not get called while saving the PO,hence it does not solve my purpose.

So better use a method CHECK, this one is called both when saving or when user execute a check, and allows change of data. (Method POST should not allow change of data, only execution of other updates. Just call im_header->get_data and set_data.)

NB: But why do you want to wait until save to change the value, if you don't need some information only available at save time, you could use PROCESS_HEADER, so user would be aware of the change?

Regards,

Raymond

0 Kudos

Mr Raymond,

The only changing parameter in the method CHECK is of type abap_bool.Rest all are importing parameters.So this method cannot be used though it gets called while saving.

And regarding using PROCESS_HEADER. This method gets triggered whenever user presses the enter button after say making some change(s). But what if the user doesn't press enter and instead gives all values and presses save directly?. That is why iam waiting until save to change the value.

0 Kudos
  1. You could noticed that other methods as PROCESS_HEADER/ITEM also have only an input parameter, so read the documentation and implementation example of the BAdI and look for samples at SCN, you have to execute some methods as GET_DATA (read info) and SET_DATA (update info) on the received parameter (which is a class instance reference) in the method to change the values.
  2. Perform some test, if user press SAVES, PROCESS_HEADER will be executed as soon if user has input any data (and if no input from user, some error message should raise...)

Regards,

Raymond

0 Kudos

Hi Hari -

When some header data get changed with respect to the old header data in PO then the method PROCESS_HEADER should get called during SAVE as well as while pressing 'enter' from the key board. Let us know, if its not working.

0 Kudos

Hi Atul,

You mention that "when some header data get changed". So i must assume this gets triggered in ME22N and not while saving in ME21N. So cannot solve my purpose.

0 Kudos

Hi Raymond,

I have placed a break point in the method PROCESS_HEADER. The problem is that while saving in ME21N,the control does not go to the breakpoint meaning that the BADI method is not triggered while saving.

0 Kudos

Sorry Raymond,

You seem to be right.The check method gets triggered while saving and it has reference to methods like get data,set data.I believe i can use the set_data method to change the value.Let me check and will update

0 Kudos

Did you activate the implementation ?

Regards,

Raymond

0 Kudos

Ofocurse i activated the implementation.

0 Kudos

I set the header data in Check method but it's not getting reflected after saving.Iam lost now

0 Kudos

Hi Hari -

What I mean here is that it triggers also in ME21N. When ever you enter some data or change the data (even in ME21N say you change vendor / purchase org etc) , it also get triggered.

1. Go to BADI Implementation method (PROCESS_HEADER) and put a break point on ENDMETHOD (if you have not written any code yet)

2. Go to ME21N, choose the PO Type and you will reach the break point

3. Then enter Purchase org and press 'enter', you will reach the break point.

3. Again change the Purchase org from what you entered in step 3 above and press 'enter', you will reach the break point

Please check, let us know.

Regards,

Atul Mohanty

0 Kudos

Try to add a im_header->set_changed() after the GET_DATA()/MOVE xxx TO mepoheader-ekgrp/SET_DATA() code.

Also, for testing, execute the CHECK function and not the SAVE function, are some messages raised in "Doc. Header Messages (Error), is the change executed.

Regards,

Raymond

Former Member
0 Kudos

Hi,

use, as Raymond has mentioned, BADI ME_PROCESS_PO_CUST with

method PROCESS_HEADER.

In this method you have to use:

CALL METHOD IM_HEADER->GET_DATA

and than

CALL METHOD IM_HEADER->SET_DATA

Regards, Dieter

Former Member
0 Kudos

Hi,

i'm a litte bit confused, there are a lot of answers which will help.

Can you please show us what do you have tried.

Did you tried PROCESS_HEADER? When yes show the code.

Regards, Dieter

0 Kudos

Hi everyone,

I have solved the requirement by means of an implicit enhancement in the include LMEGUICI5. Inside this include there is a method transport_from_dynp.All i have to do is change the value of purchasing group based on my condition inside the structure mepo1222.

This enhancement gets triggered whenever user presses enter or save.

Thanks everyone for your valuable help and inputs.Iam marking Raymond's answer as helpful