Skip to Content

Introduction: –


This document is to show how to make a simple interactive report in OOPS by using event ‘HOTSPOT_CLICK‘ present in standard sap class ‘CL_GUI_ALV_GRID‘.

               I have taken a scenario of displaying the PO (Header and Item) data for a vendor by creating event driven interactive report. The program is created in ALV+OOPS. The interaction will be done on vendor number and PO document number.


The flow will be: – Vendor Details -> PO (Header) -> PO (Item)

For code snippet please check the attached file.

Steps:-


  Create a program in SE38 and SE51. The names of the programs should be same and keep on saving the progress with time to time.  In the screen painter add the 3 custom containers which will show the data in ALV GRID format. Here we will add two fields which will take the vendor number as input from user.

yalv_oops11.JPG

       Declare the internal tables and the object for the custom container in ABAP editor.

yalv_oops1.PNG

yalv_oops2.JPG

       As it is an event driven program we need to create a local class for creating a method which will be registered as an event for our interactive working. Save it.

yalv_oops3.JPG

Un-comment the PBO and PAI modules from SE51 and navigate to ABAP editor.

Here in the methods we will declare the working of our program, i.e. registering the event, putting select query and creating field catalogues for ALV output.

Our program is created in SE51 i.e. it is already having 4 events of its own so we have to be careful while writing code and creating the program flow.

yalv_oops10.JPG

Double click on STATUS_0011 method and it will switch to the ABAP editor. Here we will create our objects which we declared for custom containers previously. Just like for lfa1_container, create the remaining two for EKKO and EKPO. We will register the method which we created as event handle in status_0011 as that event will trigger at runtime.

yalv_oops5.JPG

yalv_oops6.JPG

After this save it, go back and double click on method under PROCESS AFTER INPUT.

It will again switch to editor. In this we will declare the select query which will select the initial vendor data according to the user input and we will also declare the button command triggering.

yalv_oops9.JPG

Above we declared and implemented our local class for event handling. There we created a subroutine in the method. After declaring as shown  create the ‘FORM’ part of that subroutine.

yalv_oops7.JPG

yalv_oops8.JPG

  Declare the field catalogs for the internal tables and activate everything. While creating field catalogs, declare the property ‘HOTSPOT’ as ‘X’ for the field on which the interactive will work.  Create a t-code in SE93 for our program.  Give the input in the fields which we declared and click on display.

Output:-

yalv_oops12.JPG


yalv_oops13.JPG

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Jelena Perfiljeva

    To be honest, you lost me here:

    Create a program in SE38 and SE51. The names of the programs should be same

    Yeah, because it is the same program. Or, to be accurate, one ABAP report (let’s use the SAP terminology). SE51 is just Screen Painter. Actually one does not even need to go there because you can add a screen from SE38 (ABAP Editor), just open the object list. Although most developers probably moved on to SE80 a while ago.

    And why is it necessary to create a transaction? Someone without a clue might assume this is a vital step while the report can be simply executed from the Editor.

    There are quite good demo reports for all possible ALV functionality already available in SAP, just search in SE38 by SALV*. For example, SALV_DEMO_HIERSEQ_EVENTS is specifically for the events.

    Not saying there should be no blogs on this on SCN but they should (a) be accurate; (b) offer the readers something more than a demo program does. E.g. are there any specific design considerations? Any OOP theory you’d like to share? Is there some peculiar business requirement that can be satisfied by using this? What compelled you to write this blog? Were you not aware of the demo programs? Did you have any difficulties? Simple “do these steps because I said so” doesn’t add the whole lot of value IMHO.

    There are some good blogs with suggestions for other bloggers, this one is a good start:

    http://scn.sap.com/community/about/blog/2013/06/13/build-a-better-blog-step-1-tell-the-story-you-want-to-tell

    (0) 
    1. Ashish Gupta Post author

      Hello Jelena,

          I tried to keep it as simple as I could, so that the one who is freshman can understand it. I agree with you that most developers are probably moved to SE80 and I am one of them too.

      And I also agree that there are many good demo reports in ALV, like the one which you suggested, but is it possible for all to understand.? There is just coding and no explanation I guess.

      (0) 
      1. Jelena Perfiljeva

        The demo reports have all the explanations at the beginning and one can use the paragraph marks to find the corresponding piece of code. And there are additional comments in the program’s body. If someone finds this difficult to understand then they might want to revisit a decision to pursue an SAP career – it won’t get any easier than that.

        Unfortunately the demo programs only offer a technical description of the steps, without any design background or an explanation why all those steps are necessary. But, as noted above, this post doesn’t offer any additional information either.

        (0) 

Leave a Reply