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: 

User exit for IW31 after saving to update aufk custom fields after save

kavmp
Participant
0 Kudos
1,967

I have 2 custom fields in aufk table which I want to update with values after the user clicks on save in IW31 tcode. I want to find a user exit that can process after saving the order so that I can have the order details in the logic to update my values. EXIT_SAPLCOIH_009 is not apt for this as it does not have final order header. It has only buffer order data.

If there is any BAdI for the same also it would be great!

Thanks for your help

EDIT: I have tried WORKORDER_UPDATE BADI and its methods as well.

22 REPLIES 22

manfred_reinart
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,795

Please check Enhancement spot WORKORDER_UPDATE with BAdI interface IF_EX_WORKORDER_UPDATE

0 Kudos
1,795

Hi,

Thanks for your suggestion. I had checked WORKORDER_UPDATE but has only importing parameters for the AT_SAVE method. Please correct me if I am wrong. I would be needing an exporting or changing parameter to update aufk custom fields right?

kavmp
Participant
0 Kudos
1,795

Yes I tried that. But I thought I would need an exporting or changing parameter for my requirement. Would I be able to just update aufk without that?

raymond_giuseppi
Active Contributor
0 Kudos
1,795

Check Enhancement IWO10018 if your fields were appended in structure CI_AUFK (you may be required to use a dummy dynpro)

0 Kudos
1,795

Thanks for your suggestion. I had checked IWO10018. But it won't get triggered after saving the order in IW31 I guess.

0 Kudos
1,795

Problem is that the usual BAdI, WORKORDER_UPDATE, doesn't allow to change data (methods such AT_SAVE and BEFORE_UPDATE pass only read only parameters.

  • If those fields are not user input, how do you want to calculate them, why not in PAI logic of customer dynpro (my previous suggestion)
  • Else look at Enhancement Spots of main function group, ES_SAPLCOIH, and posting function group, ES_SAPLCOZV.

0 Kudos
1,795

The fields are updated by a logic does not need user input. And when the user creates the order, it fetches the previous order details for the custom fields and updates it at the time of save. I wont be able to use IWO10018 as the order gets released and printed by a batch job and it won't trigger the user exit in that case.

0 Kudos
1,795

As the previous order is already in the database and the new one is not yet, you can already load the data from the last order into the suggested customer exit, select the creation date (descending) or the maximum key value (subquery)

NB: You could also display those fields in the customer-exit in read-only mode.?

0 Kudos
1,795

Yes I can do that as well. But I won't be able to use the suggested customer exit as it does not get triggered at save. I want it to trigger at save so that it works when the processes are carried out by a batch job. That's why I am searching for an exit that let's be update the values at save.

fprokopiuk
Active Participant
0 Kudos
1,795

If provided customer exits and BAdIs are not enough you can try to use implicit enhancement at the end of form USER_EXITS_SAVE in include LCOIHF05. Just be cautious to only adjust your custom fields and it shouldn't influence standard processing.

0 Kudos
1,795

Thanks for your suggestion, will look into this.

0 Kudos
1,795

This form also has only buffer order details and not order header.

0 Kudos
1,795

It's normal for document creation that number is not yet assigned and changed later on. You can just try to adjust your fields and see if they are saved in most cases it should work. If not then you need to debug it and find other spot after it's called. However this place is pretty safe because user-exits are called here.

0 Kudos
1,795

But based on the current order number and current erdat only my logic to populate the custom fields is coded. So I would need access to the current order number to execute the update of the custom fields. Any idea where I would be able to get the order header after save?

0 Kudos
1,795

I don't have option to debug the process from code it looks like either some ehnacement point or badi in CO_ZV_ORDER_POST FM should work. For example EAM_MRS_ORDER_POST badi method POST_BEFORE_COMMIT. However you need to debug it and check by yourself, it can also depend on your system version what you can do there. Good luck!

thkolz
Contributor
0 Kudos
1,795

0 Kudos
1,795

The user exits mentioned in this blog don't trigger on clicking save in IW31. So I could not use those.

0 Kudos
1,795

Can you use EXIT_SAPLCOIH_019 (include ZXWOCU16)?

aufk-zzfield = 'Test'.
MOVE-CORRESPONDING aufk TO coci_aufk_exp.

0 Kudos
1,795

No, it doesn't trigger on save right, so when I am executing through a batch job this code won't get executed. That's why I have to search for after save events

0 Kudos
1,795

What about BAdI WORKORDER_UPDATE (method IN_UPDATE)?

0 Kudos
1,795

That method did not trigger at save somehow.

kavmp
Participant
0 Kudos
1,795

Thanks for all the replies. I had used the below statement in EXIT_SAPLCOIH_009 to update the caufvd_imp structure even before I had order number of the current order getting created. This perform effectively lets you to update the fields of aufk even if you have only the buffer order number.

PERFORM caufv_upd(saplcobh) USING caufvd_imp.