cancel
Showing results for 
Search instead for 
Did you mean: 

trying to use subclass in workflow, but superclass is instantiated

paul_bakker2
Active Contributor
0 Kudos

 

As time goes on, I'm gradually switching my new workflow developments to OO, just to see what the benefits are.

Not sure I've found any yet... 🙂

Anyway, I have just run into a strange problem. I have defined a superclass ZCL_CLASS and a subclass ZCL_SUB_CLASS.

The subclass inherits all the methods of the superclass, and you can redefine them, which is good. However I've noticed that you can't redefine the critical method BI_PERSISTENT~FIND_BY_LPOR, because it is a 'static' method.

This causes a big problem when I start a workflow containing a ZCL_SUB_CLASS object, because I've found that FIND_BY_LPOR instantiates an object of type ZCL_CLASS in the container!

The workflow therefore runs into an error when it tries to execute <SuperclassObject>->MY_SUBCLASS_METHOD... it reports that the method does not exist.

I must be doing something wrong.. but what is it?

merci,

Paul Bakker

Accepted Solutions (0)

Answers (1)

Answers (1)

bpawanchand
Active Contributor
0 Kudos

Hi,

Did you try to check by down type casting.. or What you can to is

  1. First try to get instantiate the subclass in FIND BY LPOR .
  2. Now in the subclass constructor you need to invoke the super class constructor. and you have to return the subclass object to the workflow.

Regards

Pavan

paul_bakker2
Active Contributor
0 Kudos

Hi,

Sorry , I don't understand your answer at all.

Are you suggesting that I instantiate each of the subclasses in the superclasses' FIND_BY_LPOR method? It can only return one object....

thanks

Paul

bpawanchand
Active Contributor
0 Kudos

Hi Paul,

I am asking you to try to TYPE CAST the super class object, I hope in your class now you would be having a super class object,  type cast this super class object to subclass.

Regards

Pavan

Former Member
0 Kudos

Hello there,

Im having the same problem, can you explain in which method you do this cast and how???

Doesn anyone found any solution to this?

Thank you for reading.

Best regards,

Nelson.

PS: There's another post similar to this one, but it seems theres no solution

Issue with Instantiation of a Class in Workflow | SCN

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Nelson.

This post is 2 years old. Please start a new discussion so we can help you.

You also might want to look at those arrow heads in the binding pop-up ... they hide a bunch of useful features that solve a multitude of problems such as casting.. and Paul himself might even answer.

Rgds,

Jocelyn

With my SCN moderator hat on..