0% found this document useful (0 votes)
638 views4 pages

ALV Com Hotspot - ABAP

This document defines a report to display accounts payable liquidation data in an ALV grid. It includes definitions for internal tables and structures to store the data, ALV grid objects and event handling classes. Forms are defined to select the data, build the output, and display the grid with hotspots on certain fields to launch transactions.

Uploaded by

Carlos Faria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
638 views4 pages

ALV Com Hotspot - ABAP

This document defines a report to display accounts payable liquidation data in an ALV grid. It includes definitions for internal tables and structures to store the data, ALV grid objects and event handling classes. Forms are defined to select the data, build the output, and display the grid with hotspots on certain fields to launch transactions.

Uploaded by

Carlos Faria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

*&---------------------------------------------------------------------*

*& Report ZFIR_LIQ_CONTAS_PAGAR


*&---------------------------------------------------------------------*
REPORT ZFIR_LIQ_CONTAS_PAGAR.

*&---------------------------------------------------------------------*
*& Tabela Interna
*&---------------------------------------------------------------------*
DATA: it_liq_contas_pagar TYPE TABLE OF zfist_liq_contas_pagar.

*&---------------------------------------------------------------------*
*& Estrutura
*&---------------------------------------------------------------------*
DATA: st_liq_contas_pagar TYPE zfist_liq_contas_pagar.

*&---------------------------------------------------------------------*
*& Variável
*&---------------------------------------------------------------------*
DATA: v_okcode TYPE sy-ucomm.

*&---------------------------------------------------------------------*
*& ALV
*&---------------------------------------------------------------------*
* Objeto
DATA: o_grid TYPE REF TO cl_gui_alv_grid,
* Tabela de definições da ALV
it_fieldcat TYPE lvc_t_fcat,
* Estrutura de definições da ALV
st_fieldcat LIKE LINE OF it_fieldcat.

* Classes
CLASS lcl_eventos_alv DEFINITION DEFERRED.

DATA o_eventos_alv TYPE REF TO lcl_eventos_alv.

*&---------------------------------------------------------------------*
*& CLASS lcl_eventos_alv DEFINITION
*&---------------------------------------------------------------------*
CLASS lcl_eventos_alv DEFINITION FINAL.

PUBLIC SECTION.

METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id.

ENDCLASS. "lcl_eventos_alv DEFINITION

*----------------------------------------------------------------------*
* CLASS lcl_eventos_alv IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_eventos_alv IMPLEMENTATION.

METHOD handle_hotspot_click.
PERFORM f_hotspot_click USING e_row_id e_column_id.
ENDMETHOD. "handle_hotspot_click

ENDCLASS. "lcl_eventos_alv IMPLEMENTATION


*&---------------------------------------------------------------------*
*& Tela
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
" Campos...
SELECTION-SCREEN END OF BLOCK b01.

*&---------------------------------------------------------------------*
*& Processo
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM seleciona_constante.
PERFORM selecionar_dados.
PERFORM monta_saida.

END-OF-SELECTION.
IF NOT it_liq_contas_pagar[] IS INITIAL.
CALL SCREEN '9000'.
ELSE.
MESSAGE 'Nenhum dado selecionado!' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.

*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.

SET PF-STATUS 'S9000'.


SET TITLEBAR 'T9000'.

PERFORM exibe_alv.

ENDMODULE. " STATUS_9000 OUTPUT

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.

CASE v_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

*&---------------------------------------------------------------------*
*& Form F_HOTSPOT_CLICK
*&---------------------------------------------------------------------*
FORM f_hotspot_click USING p_row_id TYPE lvc_s_row
p_column_id TYPE lvc_s_col.

DATA wa_dados LIKE LINE OF it_liq_contas_pagar.


* Fornecedor
IF p_column_id = 'LIFNR'.

READ TABLE it_liq_contas_pagar INTO wa_dados INDEX p_row_id-index.

IF sy-subrc = 0.
SET PARAMETER ID 'LIF' FIELD wa_dados-lifnr.
CALL TRANSACTION 'MK03' AND SKIP FIRST SCREEN.
ENDIF.

ENDIF.

* Documento contábil
IF p_column_id = 'BELNR'.

READ TABLE it_liq_contas_pagar INTO wa_dados INDEX p_row_id-index.

IF sy-subrc = 0.
SET PARAMETER ID 'BLN' FIELD wa_dados-belnr.
SET PARAMETER ID 'BUK' FIELD wa_dados-bukrs.
SET PARAMETER ID 'GJR' FIELD wa_dados-gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.

ENDIF.

ENDFORM. " F_HOTSPOT_CLICK

*&---------------------------------------------------------------------*
*& Form EXIBE_ALV
*&---------------------------------------------------------------------*
FORM EXIBE_ALV .

DATA wa_layout TYPE lvc_s_layo.

CREATE OBJECT o_grid


EXPORTING
i_parent = cl_gui_container=>screen0.

* Monta fieldcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZFIST_LIQ_CONTAS_PAGAR'
CHANGING
ct_fieldcat = it_fieldcat.

LOOP AT it_fieldcat INTO st_fieldcat.


CASE st_fieldcat-fieldname.
WHEN 'LIFNR'.
st_fieldcat-hotspot = 'X'.
MODIFY it_fieldcat FROM st_fieldcat.
WHEN 'BELNR'.
st_fieldcat-hotspot = 'X'.
MODIFY it_fieldcat FROM st_fieldcat.
ENDCASE.
ENDLOOP.
wa_layout-zebra = 'X'.
wa_layout-cwidth_opt = 'X'.

* Registra eventos
CREATE OBJECT o_eventos_alv.

IF o_eventos_alv IS BOUND.
SET HANDLER o_eventos_alv->handle_hotspot_click FOR o_grid.
ENDIF.

CALL METHOD o_grid->set_table_for_first_display


EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = it_liq_contas_pagar
it_fieldcatalog = it_fieldcat.

ENDFORM. " EXIBE_ALV

You might also like