cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any IDOC or event gets triggered when /SAPTRX/EH_HDR / /SAPTRX/EH_STAT table gets updated in ECC?

shardulphase
Explorer
0 Kudos

We need to send event details for some events to a third party application, when ever there is a change in sales order which changes and event data in above mentioned table.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Shardul,

If I understand your question correctly, you want to update the third party system when there will be a change in status when the SO change event has been posted.

There is no standard IDOC available in EM system which update the third party system. What you you do is to create new IDOC structure to update the third party system.

As Kevin mentioned, create new activity function to update the IDOC (Refer standard FM /SAPTRX/SEND_POD for reference).

Please let me know if you want more details on how to perform the this.

Hope this is helpful.

Regards,

Kinjal Rathod

Answers (4)

Answers (4)

shardulphase
Explorer
0 Kudos

I think I am not clear enough, I want to send following DATA from ECC system, whenever EH_STAT table is updated, and only need to send few maintained StatusAtt.Name in a Z table.

Event creation and change date

Sold to party code from sales order

Sales order and line item no.

Event details (StatusAtt.Name + St.Attr.Value)



Former Member
0 Kudos

Then why do you need IDOC route? I assume, you are doing status updates through ruleset. Isn't it?

If through ruleset, then add one more activity step after your status updates which will write the event name, date and the status you are going to update into a ZTable. This is better than IDOC in terms of performance of your ruleset.

If you need more info, let us know how and when your status attributes changes ( process ) and where do you have your ZTable? In ECC or EM? Are ECC and EM in a same box or different?

Thanks,

Vishnu

Former Member
0 Kudos

Hi Shardul,

There are two ways you can think to achieve:

First:

1.1. Trigger from SAP ECC itself without relying on SAP EM.

Example - 1. Event reation and change date (Available in Sales Order Order change date) , Sold to party code from sales order, Sales order and line item no (Sales Order) and Event details (Status Attribute Name and value) create customer table in SAP ECC and invoke the status send to match with SAP EM.

1.2 Create an custom IDOC (if you need to) or else create custom RFC program that can transfer only these data to middle-ware system with success/error acknowledgement.

Cons: If your event message fails in SAP EM side, then still the data to third party system.

Second:


2.1. Trigger from SAP EM through ruleset activity. Go to existing ruleset (IMG Define ruleset) on where status is setting for SO change, have a newline in multitask activity (after status setting activity) and create a new customer activity and assign custom RFC functional module or Functional module to create customer IDOC to send third party system.  This one we achieved in my previous project to integrate SAP EM and CRM to create a task through RFC.

Regards


GGOPII

shardulphase
Explorer
0 Kudos

Z table will have only status attribute names that needs to be communicated to third party system. When ever there is update in status attribute value (this will happen when something changes in SO, Delivery or Billing document) we need to get all updated status attributes, filter them on Z table values and send only necessary once. we have short listed two ways to do this,

1. /SAPTRX/BADI_EH_S, This BADI will be used to get status attribute and their status code and AFTER_SAVE method trigger custom IDOC to send above mentioned details 

2. Use IDOC EHPOST01 - This needs to be extended and we are still investigating on triggering point and process code related to this

Former Member
0 Kudos

Hi Shardul,

1. I can think off the best approach would be keep in ruleset instead of BADI to trigger custom IDOC.

2. Have you checked above link documents which I have mentioned, where it is shows below information in page number 21 for IDOC EHPOST01.

IDoc Type: EHPOST01

Message Type: EHPSTA

Process Code: /SAPTRX/EHPOST

Corresponding RFC: /SAPTRX/BAPI_EH_POST

Corresponding BAPI: EventHandler.PostEventHandler

Regards

GGOPII

.

Former Member
0 Kudos

Shardul,

Your option 1 ( /SAPTRX/BADI_EH_S-AFTER_EH_SAVE) might not work. You can test it out.

Your option 2 ( EHPOST01) will not work. Do not waste time on it.

As I said before, explore the option of writing the entries directly to Ztable from ruleset. If you are not sure of what ruleset is or how it works, please let us know or work with your team.

Thanks,

Vishnu

shardulphase
Explorer
0 Kudos

1. Can you please explain in detail about rule set activity? How to do it? in which system ECC SPRO or EM (we do not have EM access as of now)? where in SPRO?

2. Problem is I cant find that message type and process code details, in our system. I looked in we41 and WE64

shardulphase
Explorer
0 Kudos

1. SAPTRX/BADI_EH_S-AFTER_EH_SAVE - We have tested this BADI, and it triggers every time there is an insert, update or delete activity on table /SAPTRX/EH_STAT and /SAPTRX/EH_HDR though transaction for sales order or delivery. Hence this should work, why do you think it will not work?


2. Why EHPOST01 will not work


3. If I have to go by ruleset can you please give in detail how to achieve this solution.

Former Member
0 Kudos

Shardul,

>>1. SAPTRX/BADI_EH_S-AFTER_EH_SAVE - We have tested this BADI, and it triggers every time there is an insert, update or delete activity on table /SAPTRX/EH_STAT and /SAPTRX/EH_HDR though transaction for sales order or delivery. Hence this should work, why do you think it will not work?


Depends on how you are inserting data into /SAPTRX/EH_STAT. Make sure you are able to hit this badi method during event posting. If you have custom solution to manipulate  /SAPTRX/EH_STAT entries which is taking you into this badi, then you might be good to go.



>>2. Why EHPOST01 will not work

This IDOC is used to create/modify EHs. You can only set initial statuses by default but cannot update the statuses and that's why it will not work.

>>3. If I have to go by ruleset can you please give in detail how to achieve this solution.

Start reading these blogs especially the Guide #3.






shardulphase
Explorer
0 Kudos

1. This BADI, this particular method is hit after save event of event handler in above table and after posting of data to EM  through FM /SAPTRX/BAPI_EH_POST and it is getting hit every time. above action happens.

2. We are exploring rule set activity. thanks a lot

shardulphase
Explorer
0 Kudos

We just created rule set, but when I put a break point in activity function module it is not reaching there from VA02, Can you please guide? Rule set is based on condition

&Event Msg.Int. Event Code& = Z_YN_OTE_RE_SCHL_FST (This is a status attr)

So when ever this status attribute is changed activity should trigger right?

Former Member
0 Kudos

Shardul,

I guess before I hep you with ruleset, you need to have little understanding of EM. Through your questions, I long figured that you haven't done EM before or no clue.

Please read the following blogs which will help you in understanding EM and how it works. Once you read it, let's work on helping you with building the ruleset for your scenario.

Also, I would like to know what kind of Z objects are there in your current EM design. This knowledge will help us in helping you better.

Configuring an End-to-end SCEM scenario (2/3)

Configuring an End-to-end SCEM scenario (3/3)

Thanks,

Vishnu

former_member190756
Active Contributor
0 Kudos

Hi Shardul,

if BP is not triggered please check in ECC system in transaction /N/SAPTRX/ASC0TS if communication is set to synchronous and check the communication user in SM59 for the EM connection.

If you put then an external  BP in your activity for that user it should be triggered.

Best regards,
Steffen

shardulphase
Explorer
0 Kudos

Hello Vishnu,

Yes you are right I have never worked on EM before, and after studying EM for last 2 days I realized meaning of your first reply with Rule Set . Now I can also see how all rules are linked to change in status attribute value.

Now we have finally decided to go through rule set, after every STATUS_SET activity (Method ACT_SET_STATUS) we will add our custom activity (IF STATUS_SET returns true i.e. result of previous activity, we will execute our custom function module).

I have following questions though,

1. Is above approach is correct? 

2. How can I get Event Handler: Globally Unique ID ? This is needed to get status attribute code, value, sales order, item no, change date, sold to party details etc.

3. If I need to test by adding a break-point, Can I do that?

If you can provide these details it will be very helpful

Former Member
0 Kudos

Hi Shardul,

If you look at our solution, we are suggesting to go with ruleset.

1. Is above approach is correct?

Yes it is correct.

Check this ruleset for reference OBP10_PACKED, how to do it and add last line your custom functional module.

2. How can I get Event Handler: Globally Unique ID ? This is needed to get status attribute code, value, sales order, item no, change date, sold to party details etc.

Structure - /SAPTRX/EH_HDR_DYN-EH_GUID (Ref /SAPTRX/CL_EH_PROCESS_MODEL -> Method GET_ACTIVITY_META_DATA) Ref Activity method SHPMT_ENDDATE_UPDATE - functional module /SAPTRX/SET_SHIPMENT_ENDDATE

3. If I need to test by adding a break-point, Can I do that?

Check this recent discussion where we advised and you can put breakpoint in ruleset to check whether it is returning and trigger your functional module.

Regards

GOPII

Former Member
0 Kudos

Hi Shardul,

Yes, you can add your custom FM after each status_set activity. If you need to debug, just put in system breakpoint( not user breakpoint) on your custom FM and it should stop. To retrieve the global unique id ( EH_GUID ), Kevin has guide on how to code in this blog

screen shot from the guide here:

Former Member
0 Kudos

Let me know if you struggle with the code. I can send you a code for copy/paste.

shardulphase
Explorer
0 Kudos

Thanks a lot Vishnu, Gopi and Kevin. You guys are great.

I just tried this in sandbox server, as I am not authorized to do this config. I wrote on Z FM to update one Z table. and it worked.

Only problem is I am still not able to debug this.

@Vishnu external breakpoint / system break point does not work as it calls from some RFC user, and you can set external breakpoint to dialog user.

@Gopi I did not understand what you have mentioned regarding debugging this

Former Member
0 Kudos

Hi Shardul,

Manually post the event from EM itself using BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02 from SE37 and put the breakpoint. It should stop and you can debug. You need to add commit bapi in sequence as well to post the event.

Other way after posting the event is to goto EH_LIST -> goto detail overview and reprocess the event and it should trigger breakpoint.

Thanks,

Vishnu

Former Member
0 Kudos

Hi Shardul,

When you done with your coding and config on your new ruleset, you can put the breakpoint on /SAPTRX/CL_EH_RULE_ACTIVITY -> Method CALL FUNCTION and  PERFORM_ACTIVITY or  /SAPTRX/CL_RULES_PROCESSOR_40 -> MethodProcess_Rules to check whether your activity calls successfully through debugging (You have to manually enter all relevant parameters in BAPI /SAPTRX/BAPI_EH_ADDEVENTMSG_02 and post the event through Tcode SE37). 

Regards


GGOPII

Former Member
0 Kudos

Gopi,

To debug a activity code why do you need to put break point in those classes. Directly putting the breakpoint in the code will suffice. Your advice will help to check the sequence of rules and activities and for sure the code too but it's a not a good way to debug the logic of the code and complicated for someone who is new to ruleset.

Thanks,

Vishnu

Former Member
0 Kudos

Hi Vishnu,

ABAPer would know how to do that and it is not complicated.  Yes this would help them to check a sequence and determine the root cause.

Regards


GGOPII

Former Member
0 Kudos

Hello Gopi,

It is always better to provide specific point where they can debug rather going generalize approach.

In such scenario, finding an issue in one of the user exit in Sales order creation, you can not ask ABAPer to do debugging from VA01 screen itself.

Let's try to be specific on the solution we are providing as it will help SCN folks resolve their issues.

Hope this helps!

Regards,

Kinjal

Former Member
0 Kudos

Hi Kinjal,

If you look at previous discussion, we have given specific for many scenario but end up not working and again coming up with few questions.  When you reply again you have to tell do this and do that, so it would be a good way to tell some areas to be generic and some areas specific but not everywhere.

Regards


GGOPII

Former Member
0 Kudos

Hi Shardul,

Your question is not clear. Do you want to send event to EM based on SO changes in ECC or do you want to do some followup activity after posting Event to EM like send the event details to some third party system?

Also, is IDOC only your preferred option?

Please clarify to help you better.

Thanks,

Vishnu

shardulphase
Explorer
0 Kudos

I want to do some follow up activity from ECC on SO changes. Activity is sending changes of STATUS_TYPE from /SAPTRX/EH_STAT table...

Former Member
0 Kudos

Hi Shardul,

Yes SAP EM has two IDOCS EHPOST01 Event Handler & EVMSTA02 Event Message.  You can find in detail technical document in following links about EH POST and EVM Message.

Let's us know the detail flow what you want to achieve, we can guide you.

Regards


GGOPII

shardulphase
Explorer
0 Kudos

EHPOST01 if I use this IDOC what will be process code for this and is triggering point is function module EH_POST? and how do I get details like Status attribute name and sold to party and ship to party details?

kevin_wilson2
Contributor
0 Kudos

Check out function module /SAPTRX/SEND_POD - It's a rule set activity function that shows how to create an IDoc based on data in SAP Event Management. Write your own Activity function and call it from the rule set when you receive events that you want to pass to the 3rd party app.