Skip to Content
0

C4C: Declaration of Global Variables possible?

Aug 15, 2017 at 10:50 AM

159

avatar image

Dear all,

when you make changes, C4C calls the various events defined in Cloud Application Studio. Depending on the change, the number of events can be large, for instance if you change the reference between a quote and an opportunity, the system will call (if defined):

  • BusinessTransactionDocument-BeforeSave
  • Opportunity-Root-BeforeSave
  • CustomerQuote-Root-BeforeSave

Now, if in any of those BeforeSaves I modify another business document (e.g. another quote), the Root-BeforeSave of that document will also be called.

In ABSL itself, it is not possible to access the stack trace to see in what context an event is called (Is the event called because the user simply change a field in the quote? Or is the event called because an opportunity change this quote?)

So, my question: Is it possible to declare global variables of any sort in C4C that I can access in all events through the entire roundtrip? For instance, in the BusinessTransactionDocument-BeforeSave I would set a variable origin = "FromBTR" and in all Event calls in the same roundtrip (e.g. in CustomerQuote-Root-BeforeSave) I could access this global variable.

As a workaround, I've been considering setting a temporary variable e.g. at the CustomerQuote-Root level that I could access from all instance. However, the problem is to determine from which roundtrip this variable comes. In the Root-BeforeSave I cannot know which other Events the standard calls - and even if I knew, once I reset the root variable in an event other than the Root-BeforeSave, the system would merrily call the Root-BeforeSave event again.

I've also thought about using a custom BO to store the variable and access that custom BO from every event to identify the context. However - what would I use as an identifier that is the same in all event calls in this roundtrip? I can't use the Root.UUID, b/c it might be the starting point is another business object. The last change time also does not seems like a reliable indicator.

If global variable declaration is not possible (which I fear), are there any creative workarounds for this situation?

Thanks for any suggestions!
Stefan

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Saurabh Kabra
Aug 15, 2017 at 05:23 PM
0

Hi,

Please make use of "TRANSIENT" keyword in the BO field Declaration to use it as Global Variable.

Thanks

Saurabh


Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Saurabh,

thanks for your answer. I didn't quite understand. How do you suppose transient fields can be of help with my problem?

Best regards
Stefan

0
Former Member

Transient Fields are not Global and only in scope for that specific Object and Session

0
avatar image
Former Member Aug 18, 2017 at 10:30 PM
0

The only real way I have found to do this is creating a "Variable" BO (only has a single Instance). the issue with it is.. that any changes to that BO will not persist till the Parent document activating them saves. and you get some locking issues some times.

Re-reading your question, Why not only focus on the documents you care changed... And make the "Downstream" adjustments "Before" SAP does.. then you do not have to worry about the events in the downstream objects.

Without knowing your exact case it is hard to tell what exactly you are looking to do

Share
10 |10000 characters needed characters left characters exceeded
E89 External Group Accounting E89 Nov 16, 2017 at 04:40 PM
0

Hi all,

to follow up on this one, I have come up with a workaround and posted a blog post: https://blogs.sap.com/?p=576365

Best regards
Stefan

Share
10 |10000 characters needed characters left characters exceeded