Skip to Content
0

ALV OOPS interactive report issue

Nov 30, 2017 at 05:54 AM

42

avatar image

Hi everyone,

I am new to oops alv. I was practising an interactive alv report which has the following basic list:

On double clicking the Material number (first time), I am calling a subscreen below the basic list and some data from MARA table is being shown:

But, when I am clicking another line of the material number, the screen is displaying the result behind the initial secondary list (which I am obtaining after I scroll down with the scroll bar)!

I am pasting the code for the secondary list . Screen 9000 is the basic list screen and screen 9003 is the subscreen that I am calling

PROCESS BEFORE OUTPUT.

  MODULE status_9000.

  CALL SUBSCREEN  REF1 INCLUDING sy-repid l_dynpro.

PROCESS AFTER INPUT.

  MODULE user_command_9000.

  CALL SUBSCREEN ref1.

In the flow logic of screen 9003:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_9003.


PROCESS AFTER INPUT.
 MODULE USER_COMMAND_9003.

Inside MODULE status_9003 OUTPUT:

MODULE status_9003 OUTPUT.
REFRESH lt_fcat3.
l_obj->fill_mara_fcat( ).
l_obj->disp_mara_list( ).

ENDMODULE.

The logic inside methods "fill_mara_fcat" and "displ_mara_list" is given below:

METHOD fill_mara_fcat.

    lw_fcat3-fieldname = 'MATNR'.
    lw_fcat3-tabname = 'LT_MARA'.
    lw_fcat3-coltext = 'Material Number'.
    lw_fcat3-tooltip = 'Material Number'.
    lw_fcat3-hotspot = 'X'.
    lw_fcat3-col_opt = ''.
    APPEND lw_fcat3 TO lt_fcat3.
    CLEAR lw_fcat3.

    lw_fcat3-fieldname = 'ERSDA'.
    lw_fcat3-tabname = 'LT_MARA'.
    lw_fcat3-coltext = 'Created On'.
    lw_fcat3-tooltip = 'Created On'.
    lw_fcat3-col_opt = ''.
    APPEND lw_fcat3 TO lt_fcat3.
    CLEAR lw_fcat3.

    lw_fcat3-fieldname = 'MTART'.
    lw_fcat3-tabname = 'LT_MARA'.
    lw_fcat3-coltext = 'Material Type'.
    lw_fcat3-tooltip = 'Material Type'.
    lw_fcat3-col_opt = ''.
    APPEND lw_fcat3 TO lt_fcat3.
    CLEAR lw_fcat3.
  ENDMETHOD.                    "fill_mara_fcat
METHOD disp_mara_list.

 CREATE OBJECT l_cont3
      EXPORTING
        container_name              = 'L_CONTAINER3'
  EXCEPTIONS
       cntl_error                  = 1
       cntl_system_error           = 2
       create_error                = 3
       lifetime_error              = 4
       lifetime_dynpro_dynpro_link = 5
       OTHERS                      = 6.

    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CREATE OBJECT l_grid3
      EXPORTING
        i_parent          = l_cont3
      EXCEPTIONS
       error_cntl_create = 1
       error_cntl_init   = 2
       error_cntl_link   = 3
       error_dp_create   = 4
       OTHERS            = 5.
   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CALL METHOD l_grid3->set_table_for_first_display
      EXPORTING
      is_layout                     = lw_layout
     CHANGING
        it_outtab                     = lt_mara[]
        it_fieldcatalog               = lt_fcat3[]
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

  ENDMETHOD.                    "display_mara_data

Please let me know how to solve the issue. I have debugged my code and the data is populating fine. The only problem I have is the way its getting displayed.

Regards,

Matt

capture.png (18.2 kB)
capture.png (30.9 kB)
capture.png (34.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Raymond Giuseppi
Nov 30, 2017 at 07:05 AM
1

Something like

IF l_cont3 IS INITIAL.
  CREATE OBJECT l_cont3...
ENDIF.
IF l_grid3 IS INITIAL.
  CREATE OBJECT l_grid3...
ELSE.
  l_grid3->refresh_table_display...
ENDIF.
Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
Nov 30, 2017 at 06:35 AM
1

Don't create new instances of class that already exists at frontend like container and ALV grid. Better reuse the current ones, e.g. continue (do nothing) with current customer container and use method REFRESH_TABLE_DISPLAY with grid ALV.

If (when) you have time to improve

  • Use some TRY/CATCH/ENDTRY to handle exceptions.
  • Use method IS_VALID to insure those not cleared/freed objects are currently valid frontend objects.
  • Use lifetime parameters.
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Raymond,

Can u send me a code snippet as to what exactly I need to do in this case ? Where in my code do I need to make the changes ?

Regards,

Matt

0