Skip to Content
avatar image
Former Member

How to get the clicked area when using ABAP Objects to WRITE?

Hi there,

I'm currently creating a classic ABAP report (No ALV. Just WRITE Statements) to list material numbers and other data. The program is very complex and has a ton of code, so it was created as a methods of an ABAP object (The instance is stored in "go_logic_class"). Those WRITE statements all happen in the methods of a local class.

The program basically looks like this:

TOP-OF-PAGE.
go_logic_class->display_headings(...).

START-OF-SELECTION.
CREATE OBJECT go_logic_class.
go_logic_class->read_all_the_data(...).
go_logic_class->display_all_the_data(...). " This is doing the WRITE statements

AT-LINE-SELECTION.
" I need to fill lv_matnr with the clicked material number here somehow.
SET PARAMETER ID 'MAT' FIELD lv_matnr.
CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.

I want the user to be able to click on a material number and go into into another transaction (Using "CALL TRANSACTION AND SKIP FIRST SCREEN"). But I need the material number to use the "SET PARAMETER" statement before.

Since the WRITE statements happen IN the method of the class (and not report itself) I'm not able to use the HIDE statement. (It requires a global object of the report, which I can't access in the instance of a class)

Switching from WRITE to ALV is also not possible.

Are there any ways left how I can identify what material number was clicked?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 13, 2017 at 09:57 AM

    The statement

    "It requires a global object of the report, which I can't access in the instance of a class"

    is apparently wrong.

    Of course you can access the global data objects of a program in the classes and methods of the same program. That's why they are called "global".

    https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenlifetime_and_visibility.htm

    The HIDE field is filled during the list events. The best way is to call an appropriate method when handling the list event and pass the hide field to a parameter instead of accessing the global field directly.

    DATA g_hide TYPE i.
    CLASS demo DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: write,
                       meth IMPORTING i_hide LIKE g_hide.
    ENDCLASS.
    
    CLASS demo IMPLEMENTATION.
      METHOD write.
        DATA number TYPE i VALUE 555.
        WRITE number.
        g_hide = number.
        HIDE g_hide.
      ENDMETHOD.
      METHOD meth.
        "access to g_hide and i_hide, the latter is recommended
      ENDMETHOD.
    ENDCLASS.
    
    START-OF-SELECTION.
      demo=>write( ).
    
    AT LINE-SELECTION.
      demo=>meth( g_hide ).
      CLEAR g_hide.
    
    Add comment
    10|10000 characters needed characters exceeded