Abapta Object Oriented ALV
Aşağıdan Object Oriented ALV örneğini inceleyebilirsiniz.
------------------------------------------------------------------*
REPORT zmk_object_alv.
TYPES: BEGIN OF ty_output,
ebeln TYPE ebeln,
aedat TYPE erdat,
ernam TYPE ernam,
ebelp TYPE ebelp,
matnr TYPE matnr,
werks TYPE werks_d,
menge TYPE bstmg,
meins TYPE bstme,
netwr TYPE bwert,
END OF ty_output.
DATA: lt_ekko TYPE TABLE OF ekko,
ls_ekko TYPE ekko,
lt_ekpo TYPE TABLE OF ekpo,
ls_ekpo TYPE ekpo,
lt_output TYPE TABLE OF ty_output,
ls_output TYPE ty_output,
lt_fieldcat TYPE lvc_t_fcat,
lw_fieldcat TYPE lvc_s_fcat,
lw_layout TYPE lvc_s_layo,
grid TYPE REF TO cl_gui_alv_grid,
container TYPE REF TO cl_gui_custom_container.
START-OF-SELECTION.
SELECT FROM ekko INTO TABLE lt_ekko UP TO 10 ROWS.
IF lt_ekko IS NOT INITIAL.
SELECT FROM ekpo INTO TABLE lt_ekpo FOR ALL ENTRIES IN lt_ekko
WHERE ebeln = lt_ekko-ebeln.
ENDIF.
LOOP AT lt_ekpo INTO ls_ekpo.
ls_output-ebeln = ls_ekpo-ebeln.
ls_output-ebelp = ls_ekpo-ebelp.
ls_output-aedat = ls_ekpo-aedat.
ls_output-matnr = ls_ekpo-matnr.
ls_output-werks = ls_ekpo-werks.
ls_output-menge = ls_ekpo-menge.
ls_output-meins = ls_ekpo-meins.
ls_output-netwr = ls_ekpo-netwr.
READ TABLE lt_ekko INTO ls_ekko WITH KEY ebeln = ls_ekpo-ebeln.
IF sy-subrc IS INITIAL.
ls_output-aedat = ls_ekko-aedat.
ls_output-ernam = ls_ekko-ernam.
ENDIF.
APPEND ls_output TO lt_output.
CLEAR ls_output.
ENDLOOP.
IF lt_output IS NOT INITIAL.
CALL SCREEN 100.
ENDIF.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'PF_100'.
SET TITLEBAR 'TIT_100'.
*build fieldcatalog
REFRESH lt_fieldcat.
CLEAR lw_fieldcat.
"Purchase Order
lw_fieldcat-fieldname = 'EBELN'.
lw_fieldcat-seltext = 'Purchase Order'.
lw_fieldcat-col_pos = 1.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Item
lw_fieldcat-fieldname = 'EBELP'.
lw_fieldcat-seltext = 'Item'.
lw_fieldcat-col_pos = 2.
lw_fieldcat-outputlen = 5.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Meterial
lw_fieldcat-fieldname = 'MATNR'.
lw_fieldcat-seltext = 'Meterial'.
lw_fieldcat-col_pos = 3.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Plant
lw_fieldcat-fieldname = 'WERKS'.
lw_fieldcat-seltext = 'Plant'.
lw_fieldcat-col_pos = 4.
lw_fieldcat-outputlen = 5.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Quantity
lw_fieldcat-fieldname = 'MENGE'.
lw_fieldcat-seltext = 'Quantity'.
lw_fieldcat-col_pos = 5.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Unit
lw_fieldcat-fieldname = 'MEINS'.
lw_fieldcat-seltext = 'Unit'.
lw_fieldcat-col_pos = 6.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Value
lw_fieldcat-fieldname = 'NETWR'.
lw_fieldcat-seltext = 'Value'.
lw_fieldcat-col_pos = 7.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Created Date
lw_fieldcat-fieldname = 'AEDAT'.
lw_fieldcat-seltext = 'Created Date'.
lw_fieldcat-col_pos = 8.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Created By
lw_fieldcat-fieldname = 'ERNAM'.
lw_fieldcat-seltext = 'Created By'.
lw_fieldcat-col_pos = 9.
lw_fieldcat-outputlen = 18.
APPEND lw_fieldcat TO lt_fieldcat.
CLEAR lw_fieldcat.
"Layout
lw_layout-cwidth_opt = 'X'.
CREATE OBJECT container
EXPORTING
container_name = 'CONTAINER'.
"Method to create grid
CREATE OBJECT grid
EXPORTING
i_parent = container.
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = lw_layout
CHANGING
it_outtab = lt_output
it_fieldcatalog = lt_fieldcat.
ENDMODULE.
&---------------------------------------------------------------------
& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------
text
*----------------------------------------------------------------------
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'UP' OR 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
Abapta object oriented Alv örneğiyle ilgili sorularınız olursa lütfen yorum olarak yazın.