Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

abap report issue using factory method

Former Member
0 Kudos

Hi All

i am working on a abap report using factory method.

In the initial run output works fine (with hyper links to columns on the report display).

But when i click on any custom button on application toolbar perform some action and come back to the output screen no other thing i.e. hyper link or any other button doesnt work.

looking for some inputs on this.

Thanks!

9 REPLIES 9

Sandra_Rossi
Active Contributor
0 Kudos

The usual problem is that you instantiate a new GUI control instead of reusing the existing one, and displaying it without freeing the previous GUI control.

0 Kudos

thanks for the reply!

how can i overcome this situation? this is the issue that i have only for popup. when i clear the isntance and trigger the report after the popup display it is navigating to the next level report output and when i click back i get  on to the list output but except hyper link other functionalities are working.

in the debug mode i see that instance of alv is not done properly.

0 Kudos

Sorry I don't understand the exact sequence of screens.

Screen 1 with ALV ---BUTTON---> popup ---BACK---> return to screen 1 ?

When you return to screen 1, it's not working? I think it's because you create a new instance of ALV but you should have kept the initial instance (you just need to refresh it).

0 Kudos

hi,

screen flow is-

first output screen---> clickbutton on toolbar-->open popup..>navigate to another report using submit program-->when i click back butte oon on the second output--> comes to the popup-->when i close the popup--->comes to firstoutput screen.

but the hotspot are not working after popup call.

0 Kudos

Thanks.

It's because you create a new instance of ALV but you should have kept the initial instance (you just need to refresh it). Add breakpoints on the constructor/factory method to make sure.

0 Kudos

hi,

please find the code snippet below:

1) to display first level output

cl_salv_table=>factory(

         IMPORTING

           r_salv_table = o_alv

         CHANGING

           t_table      = gt_output ).


  lo_events = o_alv->get_event( ).

   CREATE OBJECT lo_event_handler.

   SET HANDLER lo_event_handler->on_user_command FOR lo_events.

*   event handler

   SET HANDLER lo_event_handler->on_link_click FOR lo_events.

*call the DISPLAY method to get the output on the screen

   o_alv->display( ).

2) to display popup

METHOD on_user_command


TRY.

         cl_salv_table=>factory(

            IMPORTING

              r_salv_table   = o_popup_alv

           CHANGING

             t_table        = gt_check ).

       CATCH cx_salv_msg INTO lv_msg.

         lv_string = lv_msg->get_text( ).

         MESSAGE lv_string TYPE c_i.

     ENDTRY.


lo_events1 = o_popup_alv->get_event( ).

*   Instantiate the event handler object

     CREATE OBJECT lo_event_handler1.

*   event handler

     SET HANDLER lo_event_handler1->on_link_click1 FOR lo_events1.

*handler user command

     SET HANDLER lo_event_handler1->on_user_command1 FOR lo_events1.

*pf status


o_popup_alv->set_screen_popup(

     start_column = c_80

     end_column   = c_140

     start_line   = c_3

     end_line     = ci_10 ).

     o_popup_alv->display( ).

endmethod.


3) handling popup:

case  e_salv_function.

when 'ENTER'

LOOP AT gt_check ASSIGNING <fs_check> WHERE sel = c_x.

           IF lv_popup IS INITIAL.

             CALL FUNCTION 'POPUP_TO_CONFIRM'

               EXPORTING

                 text_question         = text-011

                 text_button_1         = 'Yes'

                 text_button_2         = 'No'

                 display_cancel_button = ' '

                 start_column          = 25

                 start_row             = 6

               IMPORTING

                 answer                = ans

               EXCEPTIONS

                 text_not_found        = 1

                 OTHERS                = 2.

           ENDIF.

           IF ans = '1'.


PERFORM download_data USING gv_type  gv_zzpos

o_popup_alv->close_screen( )..

ELSE."close the popup for other than answer - 1

                o_popup_alv->close_screen( ).

           o_alv->refresh( ).

endif.

endloop.

WHEN c_cancel OR 'CANC'.

          o_popup_alv->close_screen( ).

o_alv->refresh( ).

endcase.

when ever i click on the popup then the hotspot functionality is vanished.

let me know if u need more details. would be great if u could give me sample program of calling a popup on salv list output.

0 Kudos

Thanks. Let's continue and build an example program on which we can discuss. Here is a fully functional program below, with a popup, of course it's not state-of-the-art (free are missing...) Could you modify it and tell us where the problem is?

REPORT.
* CLASS lcl_app DEFINITION.   PUBLIC SECTION.     CLASS-METHODS main.     CLASS-METHODS on_link_click FOR EVENT link_click OF cl_salv_events_table.     CLASS-METHODS on_user_command1 FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.     CLASS-DATA gt_output TYPE TABLE OF sflight.     CLASS-DATA gt_check TYPE TABLE OF scarr.     CLASS-DATA o_alv TYPE REF TO cl_salv_table.     CLASS-DATA o_popup_alv TYPE REF TO cl_salv_table. ENDCLASS." * CLASS lcl_app IMPLEMENTATION.   METHOD main.     DATA lo_events TYPE REF TO cl_salv_events_table.     SELECT * FROM sflight INTO TABLE gt_output.     cl_salv_table=>factory(            IMPORTING              r_salv_table = o_alv            CHANGING              t_table      = gt_output ).     lo_events = o_alv->get_event( ).     SET HANDLER on_link_click FOR lo_events.     DATA lo_columns TYPE REF TO cl_salv_columns.     DATA lo_column TYPE REF TO cl_salv_column_table.     lo_columns = o_alv->get_columns( ).     lo_column ?= lo_columns->get_column( 'PLANETYPE' ).     lo_column->set_cell_type( if_salv_c_cell_type=>hotspot ).     lo_column->set_long_text( 'PLANETYPE' ).     o_alv->display( ).   ENDMETHOD."   METHOD on_link_click.     DATA lo_events1 TYPE REF TO cl_salv_events_table.     SELECT * FROM scarr INTO TABLE gt_check.     cl_salv_table=>factory(        IMPORTING          r_salv_table   = o_popup_alv       CHANGING         t_table        = gt_check ).     lo_events1 = o_popup_alv->get_event( ).     SET HANDLER on_user_command1 FOR lo_events1.     o_popup_alv->set_screen_popup(          start_column = 80          end_column   = 140          start_line   = 3          end_line     = 10 ).     o_popup_alv->display( ).   ENDMETHOD."   METHOD on_user_command1.     DATA ans TYPE c.     CASE  e_salv_function.       WHEN 'ENTER'.         CALL FUNCTION 'POPUP_TO_CONFIRM'           EXPORTING             text_question         = 'text'(011)             display_cancel_button = ' '             start_column          = 25             start_row             = 6           IMPORTING             answer                = ans           EXCEPTIONS             text_not_found        = 1             OTHERS                = 2.         IF ans = '1'.           o_popup_alv->close_screen( ).         ELSE."close the popup for other than answer - 1           o_popup_alv->close_screen( ).           o_alv->refresh( ).         ENDIF.       WHEN 'CANC'.         o_popup_alv->close_screen( ).         o_alv->refresh( ).     ENDCASE.   ENDMETHOD." ENDCLASS." * START-OF-SELECTION.   lcl_app=>main( ).

0 Kudos

thanks for the code- i changed the alv instance to static and that worked.


But the popup has checkboxes for slection and when i select the checkbox and press Enter hyperlink is not working(when i close the popup and refresh alv output) but when i cancel the popup everythiing is working fine.

o_popup_alv->set_screen_popup(

     start_column = c_80

     end_column   = c_140

     start_line   = c_3

     end_line     = ci_10 ).

     o_popup_alv->display( ).

0 Kudos

So, it means that the issue is that you had used some local data objects. You must at least use a global or class-data internal table, and the ALV instance too. So, exactly what I said initially.

I don't understand your last question (?). Please do the same efforts I did for you, and paste a simple code as I did.