Difference between revisions of "SAP ABAP ALV OM"

From SapWiki
(Created page with "==Función para desplegar un LOG usando ALV OM== * ----- Output in Log -------------------------------------------------- TYPES: BEGIN OF ty_news, icon(4),...")
 
Line 13: Line 13:
 
  ..
 
  ..
 
  ..
 
  ..
 
 
  CALL FUNCTION 'Z_DISPLAY_LOG'
 
  CALL FUNCTION 'Z_DISPLAY_LOG'
 
     EXPORTING
 
     EXPORTING
Line 80: Line 79:
 
  *... Display table
 
  *... Display table
 
   gr_table->display( ).
 
   gr_table->display( ).
 
 
 
 
 
  ENDFUNCTION.
 
  ENDFUNCTION.

Revision as of 18:29, 26 March 2020

Función para desplegar un LOG usando ALV OM

* ----- Output in Log --------------------------------------------------
TYPES: BEGIN OF ty_news,
         icon(4),
         pernr   TYPE zhr_solicitudes-pernr,
         begda   TYPE zhr_solicitudes-begda,
         endda   TYPE zhr_solicitudes-endda,
         subty   TYPE zhr_solicitudes-subty,
         text    LIKE bapiret2-message,
       END OF ty_news.

DATA: news TYPE TABLE OF ty_news.
..
..
CALL FUNCTION 'Z_DISPLAY_LOG'
   EXPORTING
    START_COLUMN       = 8
    END_COLUMN         = 120
    START_LINE         = 3
    END_LINE           = 15
  CHANGING
    i_news = news.
FUNCTION Z_DISPLAY_LOG.
*"----------------------------------------------------------------------
*"*"Interfase local
*"  IMPORTING
*"     REFERENCE(START_COLUMN) TYPE  I DEFAULT 8
*"     REFERENCE(END_COLUMN) TYPE  I DEFAULT 120
*"     REFERENCE(START_LINE) TYPE  I DEFAULT 3
*"     REFERENCE(END_LINE) TYPE  I DEFAULT 15
*"  CHANGING
*"     REFERENCE(I_NEWS) TYPE  TABLE
*"----------------------------------------------------------------------
* SALV Data
  DATA: gr_table  TYPE REF TO cl_salv_table.
  DATA: gr_functions TYPE REF TO cl_salv_functions_list.
  DATA: lr_columns TYPE REF TO cl_salv_columns_table,
        lr_column  TYPE REF TO cl_salv_column.

  try.
* SALV Create Instance
  CALL METHOD cl_salv_table=>factory
  IMPORTING
    r_salv_table = gr_table
  CHANGING
    t_table      = i_news.           "internal table

    CATCH cx_salv_msg.      "#EC NO_HANDLER
  ENDTRY.

* setting default ALV generic funtions
  gr_functions = gr_table->get_functions( ).
*  gr_functions->set_detail( IF_SALV_C_BOOL_SAP=>TRUE ).

  gr_functions->set_all( ).
*... §4.1 set the size and position of the Popup via coordinates
  gr_table->set_screen_popup(
  start_column = start_column
  end_column   = end_column
  start_line   = start_line
  end_line     = end_line ).

* edit ALV columns
  lr_columns = gr_table->get_columns( ).
* optimize output
  lr_columns->set_optimize( 'X' ).

  TRY.
    lr_column = lr_columns->get_column( 'ICON' ).
    lr_column->set_long_text( 'Status' ).
    lr_column->set_medium_text( 'Status' ).
    lr_column->set_short_text( 'Status' ).
  CATCH cx_salv_not_found.   "#EC NO_HANDLER
  CATCH cx_salv_existing.    "#EC NO_HANDLER
  CATCH cx_salv_data_error.  "#EC NO_HANDLER
  ENDTRY.

*... Display table
  gr_table->display( ).
ENDFUNCTION.