ABAP OO in your Custom Workflow – Part 2

Lets continue our exploration of ABAP OO and using it in SAP workflow. In this post, Bill will show us how to use ABAP Classes to streamline our code for an easier and elegant solution. Here is a little bit about Bill….

Bill Craig is the president of ASAP Consulting Inc., located in Centennial, Colorado. Bill has over 10 years of experience with SAP ECC systems and integration with SRM. His areas of expertise include SAP Business Workflow and ABAP development. He made his way into programming as a COBOL programmer, switching to SAP when the company he worked for migrated from mainframe programming to SAP. Prior to programming, Bill ran an upholstery shop in Denver, where he managed the workforce, payroll, sales, scheduling and delivery. You can reach him at bill.craig@asapconsultinginc.com

Using ABAP Object Oriented Coding in your Custom Workflow

In the first part of this blog regarding the use of ABAP OO with SAP Workflow, I explained some of the benefits of using ABAP OO with your custom workflows. In this part I will go into more detail about creating an ABAP OO class and using it within a workflow. This blog does not go into great detail about ABAP OO programming so learning some basics via other blogs or books is helpful.

Creating a class that can be used by workflow is a little more time consuming than creating a copy of a standard SAP Business Object and delegating your new object, but once you have done it a few times, it is rather simple and allows you to utilize ABAP OO.

Using SE24 I created a class ZCLZZ_WF_DEMO_CLASS which I will use in this example to represent a vendor. In order for workflow to be able to use this class you need to add the interface IF_WORKFLOW. The important part of this interface is called the Local Persistent Object Reference, which is used to convert the workflow object reference into the specific instance of the ABAP Class, as well as the reciprocal. This transformation is handled in the two interfaces included with IF_WORKFLOW; BI_PERSISTENT and BI_OBJECT.

The methods BI_PERSISTENT~FIND_BY_LPOR will convert the current object reference used by workflow into instance of the ABAP Class. The BI_PERSITENT~LPOR method will convert the ABAP instance into the workflow instance. While this communication was handled behind the scenes with BOR objects and workflow, a little bit of coding on your part is now needed.

Once the interface has been added, you need to open each method inherited from IF_WORKFLOW and activate the empty source code. As mentioned previously, the methods FIND_BY_LPOR and LPOR are the ones we need to concentrate on.

Below is the code that I added to the CONSTRUCTOR, FIND_BY_LPOR and LPOR methods, as well as the Class Attributes required.

Workflow Class Attributes:

Workflow Class Constructor:

Workflow Class – Method FIND_BY_LPOR:

Workflow Class – Method LPOR:

Next, I created a simple method DISPLAY_VENDOR which we can use in a task in our workflow for the user to execute with an exporting parameter of RETURN to match our BAPI call

The next step is to create an event which we will use to start our new workflow, as well as a method to raise the event. On the events tab I created an event START_WF. I did not include any event parameters but it is as simple as clicking on the PARAMETERS button and adding them if you need too.

Next I created a method that would raise our new event. The code for this is a little different than the function module calls we are used to using like SWE_EVENT_CREATE or SAP_WAPI_CREATE_EVENT. Instead you use a call to class CL_SWF_EVT_EVENT method RAISE or RAISE_IN_UPDATE_TASK.

If your event has parameters in an event container, call the method GET_EVENT_CONTAINER to return the definition from the event, and/or SET_EVENT_CONTAINER to populate the event container parameters.

OK – We are ready to use our new class in a Workflow!!

I have built a simple workflow that will start from our event defined in our ABAP OO class, as well as call a task using our DISPLAY_VENDOR method.

From the workflow builder screen (Part of Workflow Development Tools) click on the define workflow Triggering Events tab, and rather than selecting BOR Object Type, instead select ABAP Class as the object category. Enter the class and the event, and bindings, binding the event object to a workflow container defined as your class, and finally activate the event.

Next, create a task that calls the method within the class. A trick you need to know, is that after you save the task, you need to check the Synchronous object method box

Once you have inserted the task into your workflow and activated it you can test the process from SE24 and executing the method START_WF. If everything was done correctly you will see your workflow was started and by executing the work item in the Workflow INBOX, the vendor is displayed.

This is just a very simple example, but as you can see using ABAP OO opens up a whole new dimension to workflow processes. As I stated in the first part of this blog, most of the workflows that I have done in recent years aren’t designed to deliver the work to the right people at the right time, but rather to automate as many processes as possible in an effort to minimize segregation of duty issues. With ABAP OO it is much easier to incorporate complex code and access standard SAP logic.

In the next part of this blog I will go into more details about work items using ABAP OO, how to create the equivalent of BOR attributes within the class, as well as some tips and tricks that I have learned and continue to learn as I expand my use and knowledge of SAP Workflow using ABAP OO.

If you enjoyed this blog, ABAP OO in your Custom Workflow – Part 2, please fill out the form below to sign up for our newsletter. We deliver SAP Technical tips & tricks, SAP news, and the current month’s BLOG right to your inbox!

The tools of the New ABAP Debugger are optimized for the different debugging situations you may have to deal with during the course of solving a problem. Some of the tools you will recognize from the Classic ABAP Debugger; others are brand new. Before we look at a few of the tools and how to use them, lets first get comfortable with the tools menu and how the tools are organized.

With all their new features, the latest versions of the ABAP Editor, I thought it best to appreciate the new features; we should first go back in time to see some of the limitations that were present in prior versions of the editor.

SAP NetWeaver 7.0 (formerly 2004s) offers the new Enhancement Framework that not only is intended to unify the modification and classic enhancement techniques, but also offers you almost the same flexibility as modifications without the limitations of modifications.

In contrast to enhancements in the Enhancement Framework, modifications are physically part of the object they modify. This means that every single modification gets lost in an upgrade and needs to be re-inserted even in cases where the underlying SAP object has not changed at all!

In all the aspects, enhancements are more powerful than modifications, even given all the modification support that transaction SPAU offers. The reason is due to an important difference between an enhancement and a modification that stems from the conceptual difference between the two technologies.

In addition to the new kernel-based BAdI, there are many other types of enhancement options that are part of the new Enhancement Framework. You implement these enhancements using the Enhancement Framework tools, which are integrated into the ABAP Workbench

No matter if you create an enhancement point or a BAdI as an enhancement option provider, or if you implement an existing enhancement option (be it implicit or explicit), what you create must fit into the structure of the Enhancement Framework in a way that enables you to collect and organize the enhancement options and their counterparts on the implementation side.

The Controls Technology Framework resides on the application server (the back-end), and the Automation Controller sits on the presentation server (the front-end). The integral component that optimizes the communication between the two is the Automation Queue.

The ALV Grid Control solves this problem. Its user interface provides a set of generic functions (e.g., sorting, filtering) for handling tabular data. It also confers the many benefits of controls technology to users, enabling more operations by mouse, and interaction with other controls, such as drag-and-drop. Developers simply plug the ALV Grid Control into their applications and the tool takes care of the rest. You do not need to do any further programming to offer users these functions. How you “plug” the control into an application is the first thing I will show you in this month’s blog. So lets get started!

he key to configuring the ALV Grid Control for your particular application is the structures that are passed by the application to an ALV Grid instance before or during list display. For some simple extensions of your ALV Grid instance, you only need to set the right parameter and pass the table or structure by using method set_table_for_first_display.

Adding new GUI elements to an ALV Grid instance is event-controlled and requires experience in ABAP Objects event handling. There is an event for each element type (toolbar push button, toolbar menu, and context menu). In the relevant event handler method, you define the properties of an element (such as its menu options) and assign a function code to each executable function.

What is web Dynpro? It’s SAP’s newest user interface (UI) development option for the SAP NetWeaver platform — has been designed to become the de facto option of choice for SAP development. Web Dynpro was created because, like every other software vendor in the Web space, SAP needed a longterm, strategic solution for the many problems faced by Web developers during the implementation of browser-based business applications.

Pin It on Pinterest

Share This

THIS WEBSITE USES COOKIES: By clicking "Accept", you agree to the use of cookies and similar technologies to enhance your browsing experience, and analyze your engagement with our content. Read our Privacy Policy.