Sei sulla pagina 1di 2

DATA: LR_TABLE TYPE REF TO CL_SALV_TABLE,

LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST,


LR_DISPLAY TYPE REF TO CL_SALV_DISPLAY_SETTINGS,
LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
LR_COLUMN TYPE REF TO CL_SALV_COLUMN,
LR_SORTS TYPE REF TO CL_SALV_SORTS,
LR_LAYOUT TYPE REF TO CL_SALV_LAYOUT,
LR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE,
LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS,
LS_COLOR TYPE LVC_S_COLO,
LS_KEY TYPE SALV_S_LAYOUT_KEY,
LV_TITLE TYPE LVC_TITLE,
LV_TEXT TYPE SCRTEXT_M.

CHECK PT_DATA IS NOT INITIAL.

LV_TITLE = SY-TITLE.

TRY.
* Get new instance of alv table object
CL_SALV_TABLE=>FACTORY( IMPORTING R_SALV_TABLE = LR_TABLE
CHANGING T_TABLE = PT_DATA ). "GIT_DTLS ).

* Functions
LR_FUNCTIONS = LR_TABLE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( ABAP_TRUE ).

* Display settings
LR_DISPLAY = LR_TABLE->GET_DISPLAY_SETTINGS( ).
LR_DISPLAY->SET_STRIPED_PATTERN( CL_SALV_DISPLAY_SETTINGS=>TRUE ).
LR_DISPLAY->SET_LIST_HEADER( LV_TITLE ).

* Column settings
LR_COLUMNS = LR_TABLE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( ABAP_TRUE ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'PAGE_NO' ).


LR_COLUMN->SET_MEDIUM_TEXT( 'Page'(004) ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'LINE' ).


LR_COLUMN->SET_MEDIUM_TEXT( 'Line'(005) ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'LA_QTY' ).


LR_COLUMN->SET_MEDIUM_TEXT( 'LA Qty'(006) ).
LR_COLUMN->SET_LONG_TEXT( 'LA Qty'(006) ).
LR_COLUMN->SET_SHORT_TEXT( 'LA Qty'(006) ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'CASKS' ).


LR_COLUMN->SET_MEDIUM_TEXT( 'Casks'(007) ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'CASES' ).


LR_COLUMN->SET_MEDIUM_TEXT( 'Cases'(008) ).
LR_COLUMN->SET_LONG_TEXT( 'Cases'(008) ).
LR_COLUMN->SET_SHORT_TEXT( 'Cases'(008) ).

TRY.
LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'MANDT' ).
LR_COLUMN->SET_VISIBLE( ' ' ).
LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'LFGJA' ).
LR_COLUMN->SET_VISIBLE( ' ' ).

LR_COLUMN = LR_COLUMNS->GET_COLUMN( 'LFMON' ).


LR_COLUMN->SET_VISIBLE( ' ' ).
CATCH CX_SALV_NOT_FOUND.
ENDTRY.

* Layout
LR_LAYOUT = LR_TABLE->GET_LAYOUT( ).
LS_KEY-REPORT = SY-REPID.
LR_LAYOUT->SET_KEY( LS_KEY ).
LR_LAYOUT->SET_SAVE_RESTRICTION( CL_SALV_LAYOUT=>RESTRICT_NONE ).

* Display alv grid


LR_TABLE->DISPLAY( ).
CATCH CX_SALV_MSG.
CATCH CX_SALV_DATA_ERROR.
CATCH CX_SALV_EXISTING.
CATCH CX_SALV_NOT_FOUND.
ENDTRY.