ABAP OO Super/SubClass Event triggering

Dart, Jocelyn jocelyn.dart at sap.com
Thu Jun 16 09:24:12 EDT 2011


Hi Mark,
Don't stress about breakpoints... workflow is not a program... a lot of what is happening is happening in different logical units of work. Which is why there is a special option for running the event synchronously from SWUE for the purpose of debugging.  But even then a lot is happening in system code and that may be your problem.

Ok so...

1.       Triple check you have set the Object Category to class before you enter your class name.  If it still says "object type" you are probably still in BOR mode.

2.       Go to SE24 and test your class - run your constructor method and double check the contents of your M_POR attribute.  It should contain the correct object category "CL", your class name, and your class key.  Watch out for extra spaces, dates in wrong formats, etc. Especially with multipart keys.  Material number has a nasty little ALPHA conversion exit on it which can cause problems if you haven't taken that into account.   If the M_POR value is not correct then your LPOR method won't return the right result.   Check especially the class name is correct when the ZSUB1 is instantiated, vs instantiation of ZSUPER.

3.       Your FIND_BY_LPOR code does not look quite correct.   Because RESULT is a much more generic class reference the safe way is to create your object first, and then use the  ?=  casting function to assign it to RESULT.  It may be this that is causing the problem - you could try this in a little test program ... but this is how I would usually code this to avoid unnecessary failures:

Data: lo_zsub1 type ref to zsub1.
...
    when 'ZSUB1'.
      try.
          create object lo_zsub1 type zZSUB1
             exporting
               i_matnr = l_matnr.
         Result ?= lo_zsub1.
        catch ......
      endtry.

Regards
Jocelyn

From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf Of Mark Daley
Sent: Thursday, 16 June 2011 8:51 PM
To: sap-wug at mit.edu
Subject: RE: ABAP OO Super/SubClass Event triggering

Hi Mike/Jocelyn.

I think I'm doing what you've said Mike, but the event is not appearing in SWEL.

Here's what I've tried in SWUE :
Object Type 'ZSUB1'
Event : CREATE

I put in object key etc and then click create event, message says 'Event Created - at least one receiver found'..... BUT no event in SWEL and doesn't hit breakpoint in ZSUPER.FIND_BY_LPOR or ZSUPER.LPOR

If I try ZSUPER with CREATE, I rightly get error saying event does not exist as the event is on ZSUB1 not ZSUPER.

Note I can trigger an event of the superclass fine eg ZSUPER.SUPERCREATE, breakpoint is hit and event is created in SWEL.


My code is like this...
method bi_persistent~find_by_lpor.
  data : l_matnr type matnr.

  l_matnr = lpor-instid.
  case lpor-typeid.
    when 'ZSUPER'.
      try.
          create object result type ZSUPER
             exporting
               i_matnr = l_matnr.
        catch ....
      endtry.

    when 'ZSUB1'.
      try.
          create object result type zZSUB1
             exporting
               i_matnr = l_matnr.
        catch ......
      endtry.

    when 'ZSUB2'.
      try.
          create object result type ZSUB2
             exporting
               i_matnr = l_matnr.
        catch .....
      endtry.
  endcase.
endmethod.


  method BI_PERSISTENT~LPOR.
result = me->m_por.
endmethod.

I fill m_por in the constructor

ZSUPER.CONSTRUCTOR
...
...
   me->m_por-catid = 'CL'.
  me->m_por-typeid = 'ZSUPER'.
  me->m_por-instid = me->matnr.
...
...
...

ZSUB1.CONSTRUCTOR
  super->constructor( i_matnr ).
 me->m_por-typeid = 'ZSUB1'.



But none of this code seems to be executed as my breakpoint is NOT being hit!!

Mark











From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf Of Dart, Jocelyn
Sent: 16 June 2011 10:02
To: SAP Workflow Users' Group
Subject: RE: ABAP OO Super/SubClass Event triggering

Mark,
Can you send through your code for the FIND_BY_LPOR and LPOR classes please?
They are usually only a few lines long.
Should be easy to spot the problem.
Regards,
Jocelyn


From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf Of Mike Pokraka
Sent: 15 June 2011 17:39
To: SAP Workflow Users' Group
Subject: Re: ABAP OO Super/SubClass Event triggering

Hi Mark,

It's certainly possible, what precisely does "having problems" entail? If
you raise an event ZSUB.CREATED, that's exactly what you should see in
SWEL. If this is the case then your problem is elsewere.

You're probably on the right track looking at FIND_BY_LPOR, as that can be
tricky to get right. Bear in mind that FIND_BY_LPOR is static and thus
cannot be redefined, thus you will need to ensure that the correct class
(TYPEID) is retained in your LPOR structure for each instance.

Breakpoints are a bit fluffy at times, make sure your breakpoint debugs by
just using ZSUPER everywhere, then move the trigger back to ZSUB.

Hope that helps,
Mike


From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf Of Mark Daley
Sent: Thursday, 16 June 2011 12:44 AM
To: sap-wug at mit.edu
Subject: ABAP OO Super/SubClass Event triggering

Hi all,

I have an abap object class that is workflow enabled ie using IF_WORKFLOW interface.

I want to create several 'flavours' of this class (ZSUB1) using the original abap class (ZSUPER) as the superclass.

My understanding from what I've read in Workflow book and blogs, is that I need to reference the ZSUB1 instance in my workflow and I will have access to methods of the super class.

This all seems fine, but I'm having problems trying to trigger an event of the subclass eg ZSUB.CREATE? Is it possible to do this?

I've tried to debug whats happening using SWUE by puting  a breakpoint in the FIND_BY_LPOR method of ZSUPER but it does not even get executed?

What am I missing?


Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20110616/6b498335/attachment.htm


More information about the SAP-WUG mailing list