Tuesday, December 8, 2015

SALV handle Exceptions

  data lt_makt type standard table of makt.
  data lo_salv type ref to cl_salv_table.

  select * from makt into corresponding fields of table lt_makt
    where matnr = iv_matnr.
  try.
      " setup SALV
      cl_salv_table=>factory(
         importing r_salv_table = lo_salv
         changing t_table = lt_makt
       ).

      " prepare SALV
      lo_salv->get_functions( )->set_all( ). " activate toolbar
      lo_salv->get_columns( )->get_column( 'MANDT' )->set_technical( ).
      lo_salv->get_columns( )->get_column( 'SPRAS' )->set_output_length( 8 ).
      lo_salv->get_columns( )->get_column( 'MAKTGX' )->set_visible( abap_false ).
      lo_salv->get_sorts( )->add_sort( 'MATNR' ).
      lo_salv->get_sorts( )->add_sort( 'SPRAS' ).

      " Display SALV
      lo_salv->display( ).
    catch
      cx_salv_msg
      cx_salv_not_found
      cx_salv_data_error
      cx_salv_existing into data(lo_x).

      message lo_x type 'E'.
  endtry.

No comments:

Post a Comment

Working with the session Id // ID für den Modus

Sometimes it can be helpful to know the id of the current session     CALL FUNCTION 'TH_GET_CONTEXT_ID'       IMPORTING         cont...