Skip to Content
0

Language Dependent Element in Workflow Container

Jul 06, 2017 at 02:02 PM

146

avatar image
Former Member

Hi Experts,

I have create a new workflow with a decision item for a certain step. This item has the following text:

As you can see it uses several Tokens as placeholders. While CONTRACT_ID and LICENSEE are just numbers PERIOD should be language dependent text. To achieve this I added attributed PERIOD in the global workflow container and filled it programatically when the workflow is started:

Methode "GET_PERIOD_TOKEN" delivers an identifiert like "APR", "NOV" etc.

Now I was looking for a user exit during the query/read process of workflows (e.g. when the item is shown in Tx. SBWP) to replace that identifiert by the correct language dependent text. Unfortunately I could not find any appropriate place to do that.

Is this approach correct? Is there even a solution for such an issue? Thanks in advance!

Regards

Tobias

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

4 Answers

Mike Pokraka Jul 07, 2017 at 11:11 AM
0

Usually such methods have a language parameter, or at least they should.

If not, add it, or ask those responsible for /ascorpi/ namespace to do it.

Else you'll have to write some code to map it, or use a standard SAP calendar function to get the name of the month (don't know any offhand).

Or a dirty hack is to set sy-langu explicitly before the call:

data(current_language) = sy-langu. 
sy-langu = 'F'. 
<call method>
sy-langu = current_language.
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mike,

thanks for your answer. We have the /ascorpi/ namespace fully under our control. I am aware that I can add the language to that method call but it will not solve my problem. This logic is executed during the workflow creation by a technical user in the background (sy-langu is always "EN"). So the language to use is totally unkown in this context since different users (in different languages) have to process that workflow later. So an english user should see an english text and a german user should see a german text. So what I am looking for is a user-exit that can be used to replace technical tokens with language dependant text when the workflow item is read.

Does that make sense?

Regards

Tobias

0
Mike Pokraka Jul 10, 2017 at 10:09 PM
0

You could use classes with functional methods, which will generate your text on the fly. I don't know if they will work in a decision node in the WF builder (suspect not). If not then you will have to insert the decision as a regular step. In the task description you should be able to use things like &CONTRACT.GET_PERIOD( )&. But it won't work in the task body text, because that uses the ancient SapScript.

If that doesn't work, a more restricted fallback could be to generate it according to the recipient's language during binding.

&CONTRACT.GET_PERIOD( &AGENT.GET_LANGUAGE( )& )& ==> &PERIOD&

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mike,

thanks again for your help. I didn't know that such expressions can be used since I am not that familiar with workflow modelling. I think this is the right direction to go for my problem.

I still have one question. In the task of my decision item I already use the standard BOR Object "DECISION":

I guess this object has some decision specific logic that is needed and I cannot easily replace it with my own class. So, I tried to add a new element in my global workflow container of type class just to have some utility methods (I think you called it "functional methods" above). But it seems that this approach needs an implementation of the BI_PERSISTENT interface. I don't want to model a new object. I just want to have some utility access in my container. Isn't that simply possible by just adding static methods to my class that implements IF_WORKFLOW and add this class as a container element?

Another approach I could think of is indead replacing the DECISION Bor Object with my own class and use the standard object in my class as described in Jocelyn Dart's Blog:

https://blogs.sap.com/2007/07/16/referencing-bor-objects-in-abap-oo-classes/

Thanks for any help in advance.

Regards

Tobias

bor-decision.png (26.3 kB)
0
Mike Pokraka Jul 20, 2017 at 01:28 PM
0

Hi Tobias,

A functional method is not a workflow specific term, it is a method with a RETURNING parameter and can be used in operand positions within code. E.g.

data(test) = zcl_foo->bar( ).

And they can be used in most positions in workflow containers and data fields, as in

&user.get_email( )&

You only need the bi_persistent interface for instantiated objects (almost always a good idea). For static usage, just use % as with system variables. You can even nest expressions and mix and match BOR and OO. A good example is to use BOR objects to instantiate the corresponding OO objects in binding or assignment steps:

%zcl_order=>get_instance( &bor_order.purchaseorder& )%

I suggest to always build new functionality in classes and leave BOR for legacy functionality.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jul 20, 2017 at 02:03 PM
0

Hi Mike,

I tried the following. I created my own class implementing the IF_WORKFLOW interface and added it as an container element in the global container:

For testing purposes I added instance method "DO_SOMETHING" and static method "DO_SOMETHING_STATIC" to the class.

When I press F4 Valuehelp for Parameter 3 I can see my new class in the container but my methods are not listed. I just want to have a method that accepts the current value of Parameter "PERIOD" and translates this technical string to a language dependant human readable text. I guess it will be okay to use sy-langu for this since this expression for the workflow text is evaluated at runtime when a user opens the workflow inbox. So an english user would see the english text and a german user would see the german text.

You have any idea why my methods do not appear for my class in the value help?

Regards

Tobias


f4-help.png (65.1 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Only attributes and methods called get_* are listed in the F4 help. get_<stuff> is a nearly universal (ABAP, Java, C,...) naming convention for methods that return a single value for <stuff>. In the WF object browser and F4 help, it actually strips the GET_ and shows the method name (in some versions anyway). So USER.GET_NAME( ) will show as USER.NAME in the object browser.

Static classes and methods won't show up, you would have to search through the entire ABAP class repository if it did! So just type it in as I showed above.

This will work in binding, and possibly for the task generation from your definition above. I don't know if it will stay dynamic once it lands in different users' inboxes, and don't have time to check, sorry.

0