REPORT zlayout_alv.
*&---------------------------------------------------------------------*
" Hoje nós vamos aprender a usar o layout no ALV, sabe deixar cada linha
" com uma cor diferente, tamanho das colunas, das linhas, tudo que tenha
" a ver com o layout do nosso ALVzinho rs.
" Include contendo todas as declarações default.
"http://abapjuniores.blogspot.com/2011/07/include-zincldeclaradefault.html
INCLUDE z_incl_declara_default.
" Include contendo os forms da seleção de dados default.
"http://abapjuniores.blogspot.com/2011/07/include-zinclfeeddefault.html
INCLUDE z_incl_feed_default.
" Declarações ...
" type-pools ....
TYPE-POOLS : slis
.
" Tabelas internas ....
DATA : it_fieldcat TYPE slis_t_fieldcat_alv
.
" Estruturas ....
DATA : st_fieldcat TYPE slis_fieldcat_alv,
" Aqui está a estrutura que irá informar como deverá estar o layout.
st_layout TYPE slis_layout_alv
.
" Start of selection .....
START-OF-SELECTION.
PERFORM : z_selecao, " Form do Include de seleção default.
z_all_alv
.
*&---------------------------------------------------------------------*
*& Form Z_ALL_ALV
*&---------------------------------------------------------------------*
FORM z_all_alv .
PERFORM : z_fieldcat, " Cria o fieldcat para o ALV
z_layout, " Cria o Layout do ALV.
z_alv " Cria o ALV
.
ENDFORM. " Z_ALL_ALV
*&---------------------------------------------------------------------*
*& Form Z_FIELDCAT
*&---------------------------------------------------------------------*
FORM z_fieldcat .
"--------------------------------"Fname Seltext check Edit Col_pos
PERFORM z_feed_fieldcat USING : 'CHECK' ' ' 'X' 'X' 0 ,
'MATNR' 'Material' ' ' ' ' 1 ,
'ERSDA' 'Data de criação' ' ' ' ' 2 ,
'MAKTX' 'Descrição' ' ' ' ' 3 ,
'WERKS' 'Centro' ' ' ' ' 4 ,
'LGORT' 'Depósito' ' ' ' ' 5 ,
'PSTAT' 'Status de atualização' ' ' ' ' 6
.
ENDFORM. " Z_FIELDCAT
*&---------------------------------------------------------------------*
*& Form Z_FEED_FIELDCAT
*&---------------------------------------------------------------------*
FORM z_feed_fieldcat USING fname
seltext
check
edit
col_pos .
st_fieldcat-fieldname = fname.
st_fieldcat-seltext_m = seltext.
st_fieldcat-checkbox = check.
st_fieldcat-edit = edit.
st_fieldcat-col_pos = col_pos.
APPEND st_fieldcat TO it_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " Z_FEED_FIELDCAT
*&---------------------------------------------------------------------*
*& Form Z_LAYOUT
*&---------------------------------------------------------------------*
FORM z_layout .
" mexe no tamanho da coluna conforme a qtde de caracter da Informação.
st_layout-colwidth_optimize = 'X'.
" huahuahuahua, simples,,... deixa zebrado.
st_layout-zebra = 'X'.
" tem mais esse monte de parametros mas eu naum sei mexe na maioria,
" mas está aih pra vcs mexerem, ow se quiserem ir mais fundo cliquem
" duas vezes no tipo da estrutura 'st_layout'
* st_layout-no_colhead = c_x. " no headings
* st_layout-no_hotspot = c_x. " headings not as hotspot
* st_layout-zebra = c_x. " striped pattern
* st_layout-no_vline = c_x. " columns separated by space
* st_layout-no_hline = c_x. "rows separated by space B20K8A0N5D
* st_layout-cell_merge = c_x. " not suppress field replication
* st_layout-edit = c_x. " for grid only
* st_layout-edit_mode = c_x. " for grid only
* st_layout-numc_sum = c_x. " totals for NUMC-Fields possib.
* st_layout-no_input = c_x. " only display fields
* st_layout-f2code = sy-ucomm,
* st_layout-reprep = c_x., " report report interface active
* st_layout-no_keyfix = c_x., " do not fix keycolumns
* st_layout-expand_all = c_x., " Expand all positions
* st_layout-no_author = c_x., " No standard authority check
* st_layout-def_status = c_x., " default status space or 'A'
* st_layout-item_text = 'texto do item'., " Text for item button
ENDFORM. " Z_LAYOUT
*&---------------------------------------------------------------------*
*& Form Z_ALV
*&---------------------------------------------------------------------*
FORM z_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* i_callback_pf_status_set = ' '
* i_callback_user_command = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout = st_layout
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
" o 'i_save serve pra grava as alterações que vc fizer SOMENTE no layout
i_save = 'X'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_outtab
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " Z_ALV