cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Badi - CRM_ORDERADM_H_MERGE only on saving of service request.

Former Member
0 Kudos

Hello CRM Experts,

I am trying to change value of a field - "object_id" of table "CRMD_ORDERADM_H" while creation of a service request. I am doing this by implemeting BADI - CRM_ORDERADM_H_BADI, method - CRM_ORDERADM_H_MERGE. In this method I am creating a new number and updating it in Object_id field of orderadmh table. This badi is getting called on every button click like - NEW, SAVE, even on pressing enter in service request creation page.

But I want to execute the code written in this method only on clicking SAVE button in web ui. But I am not able to find a way to do so.

Please suggest something.

Thanks,

Pooja

Accepted Solutions (1)

Accepted Solutions (1)

ceedee666
Active Contributor
0 Kudos

Hi Pooja,

have a look at the following thread:

It describes which BAdIs is triggered upon save.

However, why do you want to change the generated object ID? Can't you simply modify the the number range that is used to create the object ID instead of creating one yourself?

Christian

Answers (6)

Answers (6)

stephenjohannes
Active Contributor
0 Kudos

Actually another way of doing this would be to create a new BTE function module instead.  You can control the timing so that the function module will only fire once upon save if you configure the correct event timing.

To find out more on how to use this do a search here on CRMV_EVENT or run that transaction code in your system and click on "read this information".

For a bigger hint you would target:

Transaction Category - BUS20001 - or specific category that you need.

Execution TIme - 78 Before Saving

Object - ORDERADM_H

Event - BEFORE_SAVE

Attribute <*>

or perhaps

Execution TIme 88

Object ORDERADM_H

Event - INIT

or even:

Execution time - immediately

Object ORDERADM_H

Event AFTER_Create

In either case the call callback would be of type C call  once per transaction

I would do an CRMV_EVENT_TRACE to figure out where to put this, but that's my best ideas.

Take care,

Stephen

Former Member
0 Kudos

Hi Pooja,

1. Use badi order_save, in method check_before_save implement your logic.

2. Validate if field ZZXXXX (name of your field for new object id) is populated or not. (If you add the field with AET then you can use FM CRM_ORDER_H_READ_OW if you add the field in ORDER_H structure, if you add the field in CUSTOMER_H structure you can use FM CRM_CUSTOMER_H_READ_OW).

3. If field ZZXXXX is not populated then you generate your new number and maintain with FM CRM_ORDER_H_MAINTAIN_OW or CRM_CUSTOMER_H_MAINTAIN_OW

Hope this information helps you.

Regards,

Jorge G.

Former Member
0 Kudos

HI Faisal,

Thanks alot for your sugesstion

However, in Badi - CRM_ORDERADM_H_BADI, merge method, there is a chaging parameter of type structure - CRMT_ORDERADM_H_BADI, which contains object id as a field. So we can directly enhance object id value in table orderadmh by passing alpha numeric object id in this changing parameter. This badi is used for processing of orderadm only. That is why I thought of using this badi.

But by using order_save badi, do you have any idea, how can we enhance orderadmh table?

Thanks,

Pooja

Former Member
0 Kudos

Hi Faisal,

First, the Badi is getting called, then event handler of save button.

Thanks,

Pooja

faisal_pc
Active Contributor
0 Kudos

Hi Pooja,

Can you write the logic in event handler only?.

Or if you want to write in BADI, write in order_save badi. First set some static variable in event handler of save then check in order_Save badi whether this flag is set. If set, do your actions.

Thanks,

Faisal

Former Member
0 Kudos

Hi Pooja,

Check out following solution.

Reference  :

Cheers,

Aditya

faisal_pc
Active Contributor
0 Kudos

Hi Pooja,

If you want it to be triggered only when SAVE button is pressed, write the code in the button event handler instead of BADI. Why do you want to go for BADI in this case?.

Thanks,

Faisal

Former Member
0 Kudos

Hi Christian and Faisal,

My requirement was to generate an alpha numeric number on creating a service request. But alpha numeric number range is not present in SAP standards. So I implemented badi -CRM_ORDERADM_H_BADI to enhance table crmd_orderadm_h with alpha numeric object id.

So when I click on "New" button (to create a service request), this implementaion is getting called and alpha numeric service request number gets generated which I update in object_id field of orderadmh table. But after this, if I exit or cancel the page, the alpha numeric number that has been created has got wasted. So in order to avoid wasting of numbers, I want to execute the code written in badi implementation only on save action to get surity that the number which is getting generated is getting saved also.

But I am not able to find out a way of doing this. I can not put any check on event handler of save, as all these event handlers are getting called after badi.

I also tried calling badi manually in save method, but by doing this, no alpha numeric number is getting generated, rather standard object id is getting generated.

Please help me if you can.

Thanks,

Pooja

faisal_pc
Active Contributor
0 Kudos

Hi Pooja,

How come the event handler for save button is called after BADI?.

Thanks,

Faisal