Eyl 18 2011
Sap programlama dili abap ile alv yazmak? Sap ALV nasıl yazılır ? Abap ile alv ? howto write prgraming alv abap language for sap system.
Sap sistemine özel programlama dili olan ABAP ile alv (ABAP LIST VIEWER) nasıl yazılıra bakacağız .
öncelikle abap nedir bakalım Dünya liderleri arsında yer alan sap sistemine üzerinde geliştirme yapmaya olanak sağlayan ABAP WROKBENCH programı üzerinde abap dili ile sap sisteminde sizi tatmin etmeyen geliştirmeleri (rapor, program, var olan bir programda değişiklik, sistem funsiyonuna eklenti yapmak, user exit, vs) yapabilmenize olanak sağlayan bu dili kullanacağız.
seviye oalrak c diline syntax olarak biraz benzemektedir, mantik biraz farklıdır, native sql kullanılabilir. en çok sevdiğim özelliği ise Db ve table ayrıca connection string yazmamamızdır.
open source kaynaklı sap sistemi gnu gibi olmasada, sonuçta ticari bir yazılımdır ticari sahiibine yani lisans ücretini ödeyene open source dur diyebiliriz. Sistemdeki tüm standart uygulamaların kodları görünmetdir bu kodlarda herhangi bi değişiklik yapılmamaktadır aslında yapılabilmektedir şöyleki,
sap sistemi geliştiricileri bazı yerleri açık bırakmıştır yani bazı functionlara ek geliştirmeler ülke değişiklikleri, şirket kültürüne uymayan standart modül geliştimelerini user exit denen erişim sağlanan kod function class larında yapabilirsiniz.
Şimdi ALV nedir? alv visual programlama icadı ile gelen Grid database deki bazı bilgileri izgara grid aslında burdna gelir bir düzen içinde excel deki gibi hücreler ile gösterimesini ve bazı yerlere tıklanarak action ile başka bir event tetikleme gibi işlemleri bize kolayca sağlayan güçlü bir bileşendir (componenttir) grid böyle iken aslında tablodan bazı filedlari veririz sql sorgusu ile o bize dinamik bir yapıda akıllıca oluşması gerkeen tüsün ve kayıt sayısı kadar satır oluşturur. işte grid budur ya alv.
Alv tam anlamıyla gridi sap programlama abap tarafında tamamlayan componet dir diye bilirz aslında
Bu almanlar çok milliyetçi olduklarında kendileri kendi literatorlerini içat ederler kafa karıştırırlar grid desen ne olurdu hans efendi diyorum ve almanları kendilerine havale ediyorum 🙂 yeri gelmiş ken söyliyeyim adamlar ters adam 🙂
ortada bir visual programlama olmadığından componet yoktur bu componentin class ve functionları vardır bu function ve classlar bize dinamik alv yi (yani giridi) oluşturmamıza yardımcı olacak edit,delete, actin hyper to link gibi event metodlarını yapmızda kolaylaştıracakdır.
işte size bir örnek alv kodu :
DESCRIPTION: ALV grid example - Using SAP
Control Technology
YOURCODE:
*&---------------------------------------------------------------------*
*& Report ZTRPSD110 *
*& *
*&---------------------------------------------------------------------*
* TITLE: Statement of Export Report for Tata Tetley *
* *
* PURPOSE:Statement of Export Report for Tata Tetley *
* *
*----------------------------------------------------------------------*
* A. Start-of-selection: *
* 1. In get_billing_data using the selection screen parameters get the *
* billing data from billing header(VBAK) and Item (VBAP) *
* 2. Get the SHIP-TO partner data from VBPA using Customer number as *
* one condition and store in it_vbpa_sh
* 9. Popultae the ALV display table
*
* B. End-of-selection:
* Call screen 9000 and display data in ALV
*----------------------------------------------------------------------*
REPORT ztrps110 MESSAGE-ID zttl LINE-SIZE 130.
TABLES: vbrk.
* CONSTANTS
CONSTANTS :
c_x(1) TYPE c VALUE 'X',
c_zxto TYPE vbak-auart VALUE 'ZXTO',
c_e TYPE spras VALUE 'E',
c_000000 TYPE posnr VALUE '000000',
c_ship_to TYPE parvw VALUE 'WE'. "Ship To Party
* Table Types
TYPES: BEGIN OF ty_vbrk_vbrp,
vbeln TYPE vbrk-vbeln, "Billing doc
posnr TYPE vbrp-posnr, "Billing item
aubel TYPE vbrp-aubel, "Sales order
waerk TYPE vbrk-waerk, "Doc currency
mvgr1 TYPE vbrp-mvgr1, "Material group 1
mvgr3 TYPE vbrp-mvgr3, "Material group 3
mvgr4 TYPE vbrp-mvgr4, "Material group 4
matnr TYPE vbrp-matnr, "Material no
ntgew TYPE vbrp-ntgew, "Net wt
gewei TYPE vbrp-gewei, "Wt unit
kzwi1 TYPE vbrp-kzwi1, "Subtotal 1
kursk TYPE vbrp-kursk, "Exchange rate
END OF ty_vbrk_vbrp.
TYPES: BEGIN OF ty_data,
land1 TYPE vbpa-land1,
landx TYPE t005t-landx,
mvgr3 TYPE vbrp-mvgr3,
mvgr4 TYPE vbrp-mvgr4,
bezei3 TYPE tvm3t-bezei,
bezei4 TYPE tvm4t-bezei,
ntgew_tea_bag TYPE vbrp-ntgew,
ntgew_pkt_tea TYPE vbrp-ntgew,
ntgew_bulk_tea TYPE vbrp-ntgew,
kzwi1_tea_bag TYPE vbrp-kzwi1, "Subtotal 1 Tea Bag
kzwi1_pkt_tea TYPE vbrp-kzwi1, "Subtotal 1 Pkt Tea
kzwi1_bulk_tea TYPE vbrp-kzwi1, "Subtotal 1 Bulk Tea
ntgew_tot TYPE vbrp-ntgew,
kzwi1_tot TYPE vbrp-kzwi1,
line_color(4) TYPE c, "For line color
END OF ty_data.
TYPES: BEGIN OF ty_vbpa,
vbeln TYPE vbpa-vbeln,
land1 TYPE vbpa-land1,
END OF ty_vbpa.
TYPES: BEGIN OF ty_t005t,
land1 TYPE t005t-land1,
landx TYPE t005t-landx,
END OF ty_t005t.
TYPES: BEGIN OF ty_tvm3t,
mvgr3 TYPE tvm3-mvgr3,
bezei TYPE tvm3t-bezei,
END OF ty_tvm3t.
TYPES: BEGIN OF ty_tvm4t,
mvgr4 TYPE tvm4-mvgr4,
bezei TYPE tvm4t-bezei,
END OF ty_tvm4t.
DATA: it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp,
wa_vbrk_vbrp TYPE ty_vbrk_vbrp,
it_vbpa TYPE STANDARD TABLE OF ty_vbpa,
wa_vbpa TYPE ty_vbpa,
it_data TYPE STANDARD TABLE OF ty_data,
wa_data TYPE ty_data,
it_t005t TYPE STANDARD TABLE OF ty_t005t,
wa_t005t TYPE ty_t005t,
it_tvm3t TYPE STANDARD TABLE OF ty_tvm3t,
wa_tvm3t TYPE ty_tvm3t,
it_tvm4t TYPE STANDARD TABLE OF ty_tvm4t,
wa_tvm4t TYPE ty_tvm4t.
* Global data for grand total
DATA:
w_tot_ntgew_tea_bag TYPE vbrp-ntgew,
w_tot_ntgew_pkt_tea TYPE vbrp-ntgew,
w_tot_ntgew_bulk_tea TYPE vbrp-ntgew,
w_tot_ntgew_tot TYPE vbrp-ntgew,
w_tot_kzwi1_tea_bag TYPE vbrp-kzwi1,
w_tot_kzwi1_pkt_tea TYPE vbrp-kzwi1,
w_tot_kzwi1_bulk_tea TYPE vbrp-kzwi1,
w_tot_kzwi1_tot TYPE vbrp-kzwi1.
* Global data definitions for ALV
DATA :
* ALV Grid container
w_alv_container TYPE REF TO cl_gui_custom_container,
* ALV Grid
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_layo TYPE lvc_s_layo, "For layout
wt_fieldcat TYPE lvc_t_fcat, "For field catalog
okcode TYPE okcode, "OK Code
w_to(2) TYPE c,
w_title TYPE string.
*-------------- START OF SELECTION SCREEN ----------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
* Billing Date
SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat MEMORY ID vf OBLIGATORY NO-EXTENSION.
SELECTION-SCREEN:SKIP 1.
SELECTION-SCREEN: END OF BLOCK b1.
*-------------- END OF SELECTION SCREEN ------------------------------*
*------------- EVENT START-OF-SELECTION -------------------------------*
START-OF-SELECTION.
* Get billing data from Delivery header(VBRK) and item (VBRP)
PERFORM get_billing_data.
* Get ship-to country
PERFORM get_ship_to_data.
* Get material group description 3
PERFORM get_material_group_3.
* Get material group description 4
PERFORM get_material_group_4.
* Form the ALV Grid title
PERFORM form_title.
* Process data
PERFORM process_data.
* Populate text descriptions
PERFORM populate_description.
*------------- EVENT END-OF-SELECTION -------------------------------*
END-OF-SELECTION.
* Set the text to when date high is there
IF NOT s_fkdat-high IS INITIAL.
w_to = 'to'(c16).
ENDIF.
* Call the scren 9000 for ALV Display
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Form get_billing_data
*&---------------------------------------------------------------------*
* Get billing data from Delivery header(VBRK) and item (VBRP)
* & store in internal table it_vbrk_vbrp
*----------------------------------------------------------------------*
FORM get_billing_data .
REFRESH: it_vbrk_vbrp.
* Select Billing data by joining VBRK & VBRP and store in it_vbrk_vbrp
SELECT a~vbeln
b~posnr
b~aubel
a~waerk
b~mvgr1
b~mvgr3
b~mvgr4
b~matnr
b~ntgew
b~gewei
b~kzwi1
b~kursk
FROM vbrk AS a INNER JOIN vbrp AS b
ON a~vbeln = b~vbeln
INTO TABLE it_vbrk_vbrp
WHERE a~fkdat IN s_fkdat
* Consider only non-deleted document
AND fksto = space
* Billing doc type should be ZXTB
AND fkart = 'ZXTB'
AND pstyv = c_zxto.
IF sy-subrc <> 0.
MESSAGE i999(zttl) WITH 'No data is there'(m06).
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " get_billing_data
*&---------------------------------------------------------------------*
*& Form get_ship_to_data
*&---------------------------------------------------------------------*
* Get Ship-To party data
*----------------------------------------------------------------------*
FORM get_ship_to_data .
DATA: l_it_vbpa TYPE STANDARD TABLE OF ty_vbpa.
REFRESH: it_vbpa, it_t005t.
IF NOT it_vbrk_vbrp[] IS INITIAL.
SELECT vbeln
land1
FROM vbpa
INTO TABLE it_vbpa
FOR ALL ENTRIES IN it_vbrk_vbrp
WHERE vbeln = it_vbrk_vbrp-aubel
AND posnr = c_000000
AND parvw = c_ship_to.
IF sy-subrc <> 0.
MESSAGE i999(zttl) WITH 'Exporter country not maintained'(m02).
LEAVE LIST-PROCESSING.
ELSE.
SORT it_vbpa BY vbeln.
* Create an unique and sorted driver table
l_it_vbpa[] = it_vbpa[].
SORT l_it_vbpa BY land1.
DELETE ADJACENT DUPLICATES FROM l_it_vbpa COMPARING land1.
IF NOT l_it_vbpa[] IS INITIAL.
* Get the country description from T005t table
SELECT land1
landx
FROM t005t
INTO TABLE it_t005t
FOR ALL ENTRIES IN l_it_vbpa
WHERE spras = c_e
AND land1 = l_it_vbpa-land1.
IF sy-subrc = 0.
SORT it_t005t BY land1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " get_ship_to_data
*&---------------------------------------------------------------------*
*& Form get_material_group_3
*&---------------------------------------------------------------------*
* Get material group 3
*----------------------------------------------------------------------*
FORM get_material_group_3 .
DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
REFRESH: it_tvm3t.
* Create an unique and sorted driver table
l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
SORT l_it_vbrk_vbrp BY mvgr3.
DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr3.
IF NOT l_it_vbrk_vbrp[] IS INITIAL.
SELECT mvgr3
bezei
FROM tvm3t
INTO TABLE it_tvm3t
FOR ALL ENTRIES IN l_it_vbrk_vbrp
WHERE mvgr3 = l_it_vbrk_vbrp-mvgr3.
IF sy-subrc = 0.
SORT it_tvm3t BY mvgr3.
ENDIF.
ENDIF.
ENDFORM. " get_material_group_3
*&---------------------------------------------------------------------*
*& Form get_material_group_4
*&---------------------------------------------------------------------*
* Get material group 4
*----------------------------------------------------------------------*
FORM get_material_group_4 .
DATA: l_it_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
REFRESH: it_tvm4t.
* Create an unique and sorted driver table
l_it_vbrk_vbrp[] = it_vbrk_vbrp[].
SORT l_it_vbrk_vbrp BY mvgr4.
DELETE ADJACENT DUPLICATES FROM l_it_vbrk_vbrp COMPARING mvgr4.
IF NOT l_it_vbrk_vbrp[] IS INITIAL.
SELECT mvgr4
bezei
FROM tvm4t
INTO TABLE it_tvm4t
FOR ALL ENTRIES IN l_it_vbrk_vbrp
WHERE mvgr4 = l_it_vbrk_vbrp-mvgr4.
IF sy-subrc = 0.
SORT it_tvm4t BY mvgr4.
ENDIF.
ENDIF.
ENDFORM. " get_material_group_4
*&---------------------------------------------------------------------*
*& Form process_data
*&---------------------------------------------------------------------*
* Process the data and do summation and populate final display table
*----------------------------------------------------------------------*
FORM process_data .
LOOP AT it_vbrk_vbrp INTO wa_vbrk_vbrp.
CLEAR: wa_data, wa_vbpa.
READ TABLE it_vbpa INTO wa_vbpa WITH KEY
vbeln = wa_vbrk_vbrp-aubel
BINARY SEARCH.
IF sy-subrc = 0.
wa_data-land1 = wa_vbpa-land1.
ENDIF.
wa_data-mvgr3 = wa_vbrk_vbrp-mvgr3.
wa_data-mvgr4 = wa_vbrk_vbrp-mvgr4.
* Do an unit conversion of the quamtity
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = wa_vbrk_vbrp-ntgew
* NO_TYPE_CHECK = 'X'
* ROUND_SIGN = ' '
unit_in = wa_vbrk_vbrp-gewei
unit_out = 'TO' "Metric tonn
IMPORTING
output = wa_vbrk_vbrp-ntgew
EXCEPTIONS
conversion_not_found = 1
division_by_zero = 2
input_invalid = 3
output_invalid = 4
overflow = 5
type_invalid = 6
units_missing = 7
unit_in_not_found = 8
unit_out_not_found = 9
OTHERS = 10.
IF sy-subrc <> 0.
wa_vbrk_vbrp-ntgew = wa_vbrk_vbrp-ntgew.
ENDIF.
* Convert the currency from Customer currency to local
* currency by multiplying with kursk
wa_vbrk_vbrp-kzwi1 = wa_vbrk_vbrp-kzwi1 * wa_vbrk_vbrp-kursk.
* Convert the amount to Lacks by dividing with 100000
wa_vbrk_vbrp-kzwi1 = wa_vbrk_vbrp-kzwi1 / 100000. "DV1K905028
* When MVGR1 is between A to F use the amount as TEA_BAG
IF wa_vbrk_vbrp-mvgr1 BETWEEN 'A' AND 'F'.
wa_data-ntgew_tea_bag = wa_vbrk_vbrp-ntgew.
wa_data-kzwi1_tea_bag = wa_vbrk_vbrp-kzwi1.
ENDIF.
* When MVGR1 is between G to L use the amount as TEA_BAG
IF wa_vbrk_vbrp-mvgr1 BETWEEN 'G' AND 'L'.
wa_data-ntgew_pkt_tea = wa_vbrk_vbrp-ntgew.
wa_data-kzwi1_pkt_tea = wa_vbrk_vbrp-kzwi1.
ENDIF.
* When MVGR1 is between G to L use the amount as TEA_BAG
IF wa_vbrk_vbrp-mvgr1 = 'M'.
wa_data-ntgew_bulk_tea = wa_vbrk_vbrp-ntgew.
wa_data-kzwi1_bulk_tea = wa_vbrk_vbrp-kzwi1.
ENDIF.
COLLECT wa_data INTO it_data.
ENDLOOP.
ENDFORM. " process_data
*&---------------------------------------------------------------------*
*& Form populate_description
*&---------------------------------------------------------------------*
* Populate the description fields
*----------------------------------------------------------------------*
FORM populate_description .
LOOP AT it_data INTO wa_data.
CLEAR: wa_t005t.
READ TABLE it_t005t INTO wa_t005t WITH KEY land1 = wa_data-land1
BINARY SEARCH.
IF sy-subrc = 0.
wa_data-landx = wa_t005t-landx.
ENDIF.
* Read description of Material group 3
CLEAR wa_tvm3t.
READ TABLE it_tvm3t INTO wa_tvm3t WITH KEY
mvgr3 = wa_data-mvgr3
BINARY SEARCH.
IF sy-subrc = 0.
wa_data-bezei3 = wa_tvm3t-bezei.
ENDIF.
* Read description of Material group 4
CLEAR wa_tvm4t.
READ TABLE it_tvm4t INTO wa_tvm4t WITH KEY
mvgr4 = wa_data-mvgr4
BINARY SEARCH.
IF sy-subrc = 0.
wa_data-bezei4 = wa_tvm4t-bezei.
ENDIF.
* Get the grand totals
wa_data-ntgew_tot = wa_data-ntgew_tea_bag
+ wa_data-ntgew_pkt_tea
+ wa_data-ntgew_bulk_tea.
wa_data-kzwi1_tot = wa_data-kzwi1_tea_bag
+ wa_data-kzwi1_pkt_tea
+ wa_data-kzwi1_bulk_tea.
MODIFY it_data FROM wa_data TRANSPORTING landx
bezei3
bezei4
ntgew_tot
kzwi1_tot.
* Summattion of grand totals
w_tot_ntgew_tea_bag = w_tot_ntgew_tea_bag + wa_data-ntgew_tea_bag.
w_tot_ntgew_pkt_tea = w_tot_ntgew_pkt_tea + wa_data-ntgew_pkt_tea.
w_tot_ntgew_bulk_tea = w_tot_ntgew_bulk_tea + wa_data-ntgew_bulk_tea.
w_tot_ntgew_tot = w_tot_ntgew_tot + wa_data-ntgew_tot.
w_tot_kzwi1_tea_bag = w_tot_kzwi1_tea_bag + wa_data-kzwi1_tea_bag.
w_tot_kzwi1_pkt_tea = w_tot_kzwi1_pkt_tea + wa_data-kzwi1_pkt_tea.
w_tot_kzwi1_bulk_tea = w_tot_kzwi1_bulk_tea + wa_data-kzwi1_bulk_tea.
w_tot_kzwi1_tot = w_tot_kzwi1_tot + wa_data-kzwi1_tot.
ENDLOOP.
* Append a grand Total row at the end
CLEAR wa_data.
wa_data-landx = 'Grand Total:'.
wa_data-ntgew_tea_bag = w_tot_ntgew_tea_bag.
wa_data-ntgew_pkt_tea = w_tot_ntgew_pkt_tea.
wa_data-ntgew_bulk_tea = w_tot_ntgew_bulk_tea.
wa_data-ntgew_tot = w_tot_ntgew_tot.
wa_data-kzwi1_tea_bag = w_tot_kzwi1_tea_bag.
wa_data-kzwi1_pkt_tea = w_tot_kzwi1_pkt_tea.
wa_data-kzwi1_bulk_tea = w_tot_kzwi1_bulk_tea.
wa_data-kzwi1_tot = w_tot_kzwi1_tot.
wa_data-line_color = 'C310'.
APPEND wa_data TO it_data.
ENDFORM. " populate_description
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* Initialise PF-STATUS and title
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'MAIN9000'.
SET TITLEBAR 'TITLE_9000'.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module initialize_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE initialize_9000 OUTPUT.
* Call the ALV grid to display data
PERFORM display_alv_grid.
ENDMODULE. " initialize_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* Module to handle User Command
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE okcode.
WHEN 'BACK'.
SET SCREEN 0.
CLEAR okcode.
LEAVE SCREEN.
WHEN 'CANCEL'.
SET SCREEN 0.
CLEAR okcode.
LEAVE SCREEN.
WHEN 'EXIT'.
CLEAR okcode.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Form display_alv_grid
*&---------------------------------------------------------------------*
* Display the data in ALV Grid
*----------------------------------------------------------------------*
FORM display_alv_grid .
IF w_alv_container IS INITIAL.
* Create the alv container object
CREATE OBJECT w_alv_container
EXPORTING
container_name = 'ALV_GRID'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE e999(zttl) WITH 'Problem in ALV display'(t04).
ENDIF.
* Create the ALV grid object. The parent is the ALV container
CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_alv_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE e999(zttl) WITH 'Problem in ALV display'(t04).
ENDIF.
* This subrotine creates the field catalog and
* store in internal table lt_fieldcat
PERFORM prepare_fieldcat CHANGING wt_fieldcat.
* Layout design
w_layo-no_toolbar = ''.
* Not to allow totaling feature
w_layo-no_totline = c_x.
* Report title
* w_layo-grid_title = text-004.
w_layo-grid_title = w_title.
w_layo-zebra = c_x. "Alternating line color (striped)
w_layo-cwidth_opt = c_x. "Optimize column width
w_layo-sel_mode = 'A'. "Selection Mode
* Name of the color field
w_layo-info_fname = 'LINE_COLOR'."For row color
* Call the method to display the data in ALV grid
CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = w_layo
CHANGING
it_outtab = it_data[]
it_fieldcatalog = wt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e999(zttl) WITH text-t04.
ENDIF.
ELSE.
* If the container & grid object is alreadt there reuse them
CALL METHOD w_alv_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e999(zttl) WITH text-t04.
ENDIF.
ENDIF.
IF okcode = 'CANCEL'.
EXIT.
ENDIF.
ENDFORM. " display_alv_grid
*&---------------------------------------------------------------------*
*& Form prepare_fieldcat
*&---------------------------------------------------------------------*
* Prepare the list of fields to be displayed *
*----------------------------------------------------------------------*
* <--P_WT_FIELDCAT text
*----------------------------------------------------------------------*
FORM prepare_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA : lx_fcat TYPE lvc_s_fcat.
REFRESH: pt_fieldcat.
**List of fields to be displayed should be added in pt_fieldcat
* Customer PO no
CLEAR lx_fcat.
lx_fcat-fieldname = 'LANDX'.
lx_fcat-ref_field = 'T005T'.
lx_fcat-ref_table = 'T005T'.
lx_fcat-coltext = 'Market Name'(c01).
lx_fcat-seltext = text-c01.
APPEND lx_fcat TO pt_fieldcat.
* Flavour type
CLEAR lx_fcat.
lx_fcat-fieldname = 'BEZEI3'.
lx_fcat-ref_field = 'BEZEI'.
lx_fcat-ref_table = 'TVM3'.
lx_fcat-coltext = 'Flavour Type'(c02).
lx_fcat-seltext = text-c02.
APPEND lx_fcat TO pt_fieldcat.
* Tea type
CLEAR lx_fcat.
lx_fcat-fieldname = 'BEZEI4'.
lx_fcat-ref_field = 'BEZEI4'.
lx_fcat-ref_table = 'TVM4'.
lx_fcat-coltext = 'Tea Type.'(c03).
lx_fcat-seltext = text-c03.
APPEND lx_fcat TO pt_fieldcat.
* Tea Bag Quantity in KG
CLEAR lx_fcat.
lx_fcat-fieldname = 'NTGEW_TEA_BAG'.
lx_fcat-ref_field = 'NTGEW'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Tea Bag(MT)'(c04).
lx_fcat-seltext = text-c04.
APPEND lx_fcat TO pt_fieldcat.
* PKT Tea Quantity in KG
CLEAR lx_fcat.
lx_fcat-fieldname = 'NTGEW_PKT_TEA'.
lx_fcat-ref_field = 'NTGEW'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'PKT Tea(MT)'(c05).
lx_fcat-seltext = text-c05.
APPEND lx_fcat TO pt_fieldcat.
* Bulk Tea Quantity in MT
CLEAR lx_fcat.
lx_fcat-fieldname = 'NTGEW_BULK_TEA'.
lx_fcat-ref_field = 'NTGEW'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Bulk Tea(MT)'(c06).
lx_fcat-seltext = text-c06.
APPEND lx_fcat TO pt_fieldcat.
* Total Quantity in MT
CLEAR lx_fcat.
lx_fcat-fieldname = 'NTGEW_TOT'.
lx_fcat-ref_field = 'NTGEW'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Total(MT)'(c07).
lx_fcat-seltext = text-c07.
APPEND lx_fcat TO pt_fieldcat.
* Tea Bag Quantity in KG
CLEAR lx_fcat.
lx_fcat-fieldname = 'KZWI1_TEA_BAG'.
lx_fcat-ref_field = 'KZWI1'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Tea Bag(FOB-Lacs)'(c08).
lx_fcat-seltext = text-c08.
APPEND lx_fcat TO pt_fieldcat.
* PKT Tea Price in Lakh
CLEAR lx_fcat.
lx_fcat-fieldname = 'KZWI1_PKT_TEA'.
lx_fcat-ref_field = 'KZWI1'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'PKT Tea(FOB-Lacs)'(c09).
lx_fcat-seltext = text-c09.
APPEND lx_fcat TO pt_fieldcat.
* PKT Tea Quantity in KG
CLEAR lx_fcat.
lx_fcat-fieldname = 'KZWI1_BULK_TEA'.
lx_fcat-ref_field = 'KZWI1'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Bulk Tea(FOB-Lacs)'(c10).
lx_fcat-seltext = text-c10.
APPEND lx_fcat TO pt_fieldcat.
* Total amount
CLEAR lx_fcat.
lx_fcat-fieldname = 'KZWI1_TOT'.
lx_fcat-ref_field = 'KZWI1'.
lx_fcat-ref_table = 'VBRP'.
lx_fcat-coltext = 'Total(FOB-Lacs)'(c11).
lx_fcat-seltext = text-c11.
APPEND lx_fcat TO pt_fieldcat.
ENDFORM. " prepare_fieldcat
*&---------------------------------------------------------------------*
*& Form form_title
*&---------------------------------------------------------------------*
* Form the ALV Title
*----------------------------------------------------------------------*
FORM form_title .
DATA: l_date(10) TYPE c.
CONCATENATE s_fkdat-low+6(2) s_fkdat-low+4(2) s_fkdat-low(4)
INTO l_date SEPARATED BY '/'.
CONCATENATE 'TTD - Statement of Export' '-From' l_date INTO
w_title SEPARATED BY space.
CLEAR l_date.
IF NOT s_fkdat-high IS INITIAL.
CONCATENATE s_fkdat-high+6(2) s_fkdat-high+4(2) s_fkdat-high(4)
INTO l_date SEPARATED BY '/'.
CONCATENATE w_title 'to' l_date INTO w_title SEPARATED BY space.
ENDIF.
ENDFORM. " form_title
selcuk
27 Nisan 2016 @ 15:08
PROGRAM zkmalvev.
* 1. SE38: create executable program (type 1), use PROGRAM
* instead of REPORT because it will have screen and modules
*
* 2. SE80: create screen 0100
*
* 3. Screen Painter: on the screen 0100 create ‘Custom control’
* CONT1_0100
*
* 4. SE80: for screen 0100 set the variable OK_CODE for the element OK
*
* 5. SE80: create calls to PBO and PAI in the flow logic of screen 0100:
*
* PROCESS BEFORE OUTPUT.
* MODULE pbo_0100.
* PROCESS AFTER INPUT.
* MODULE pai_0100.
*
* 6. SE80: create GUI Status STAT_0100, assign functions EXIT and SAVE
* to standard icons, eventually create your own toolbar button
TYPE-POOLS:
slis.
CLASS cl_event_receiver DEFINITION DEFERRED.
CLASS cl_base_event_receiver DEFINITION DEFERRED.
DATA:
gt_usr TYPE TABLE OF usr02,
gs_usr TYPE usr02.
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container,
go_event_receiver TYPE REF TO cl_event_receiver,
go_base_event_receiver TYPE REF TO cl_base_event_receiver,
ok_code TYPE sy-ucomm,
gt_fcat TYPE lvc_t_fcat.
*———————————————————————-*
* CLASS cl_event_receiver DEFINITION
*———————————————————————-*
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_right_click ” RIGHT_CLICK
FOR EVENT right_click OF cl_gui_alv_grid.
METHODS handle_left_click_design ” LEFT_CLICK_DESIGN
FOR EVENT left_click_design OF cl_gui_alv_grid.
METHODS handle_move_control ” MOVE_CONTROL
FOR EVENT move_control OF cl_gui_alv_grid.
METHODS handle_size_control ” SIZE_CONTROL
FOR EVENT size_control OF cl_gui_alv_grid.
METHODS handle_left_click_run ” LEFT_CLICK_RUN
FOR EVENT left_click_run OF cl_gui_alv_grid.
METHODS handle_onf1 ” ONF1
FOR EVENT onf1 OF cl_gui_alv_grid
IMPORTING
e_fieldname
es_row_no
er_event_data.
METHODS handle_onf4 ” ONF4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
METHODS handle_data_changed ” DATA_CHANGED
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm.
METHODS handle_ondropgetflavor ” ONDROPGETFLAVOR
FOR EVENT ondropgetflavor OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
e_dragdropobj
e_flavors.
METHODS handle_ondrag ” ONDRAG
FOR EVENT ondrag OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
e_dragdropobj.
METHODS handle_ondrop ” ONDROP
FOR EVENT ondrop OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
e_dragdropobj.
METHODS handle_ondropcomplete ” ONDROPCOMPLETE
FOR EVENT ondropcomplete OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
e_dragdropobj.
METHODS handle_subtotal_text ” SUBTOTAL_TEXT
FOR EVENT subtotal_text OF cl_gui_alv_grid
IMPORTING
es_subtottxt_info
ep_subtot_line
e_event_data.
METHODS handle_before_user_command ” BEFORE_USER_COMMAND
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm.
METHODS handle_user_command ” USER_COMMAND
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm.
METHODS handle_after_user_command ” AFTER_USER_COMMAND
FOR EVENT after_user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
e_not_processed.
METHODS handle_double_click ” DOUBLE_CLICK
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no.
METHODS handle_delayed_callback ” DELAYED_CALLBACK
FOR EVENT delayed_callback OF cl_gui_alv_grid.
METHODS handle_delayed_changed_sel_cal ” DELAYED_CHANGED_SEL_CALLBACK
FOR EVENT delayed_changed_sel_callback OF cl_gui_alv_grid.
METHODS handle_print_top_of_page ” PRINT_TOP_OF_PAGE
FOR EVENT print_top_of_page OF cl_gui_alv_grid
IMPORTING
table_index.
METHODS handle_print_top_of_list ” PRINT_TOP_OF_LIST
FOR EVENT print_top_of_list OF cl_gui_alv_grid.
METHODS handle_print_end_of_page ” PRINT_END_OF_PAGE
FOR EVENT print_end_of_page OF cl_gui_alv_grid.
METHODS handle_print_end_of_list ” PRINT_END_OF_LIST
FOR EVENT print_end_of_list OF cl_gui_alv_grid.
METHODS handle_top_of_page ” TOP_OF_PAGE
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING
e_dyndoc_id
table_index.
METHODS handle_context_menu_request ” CONTEXT_MENU_REQUEST
FOR EVENT context_menu_request OF cl_gui_alv_grid
IMPORTING
e_object.
METHODS handle_menu_button ” MENU_BUTTON
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING
e_object
e_ucomm.
METHODS handle_toolbar ” TOOLBAR
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive.
METHODS handle_hotspot_click ” HOTSPOT_CLICK
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id.
METHODS handle_end_of_list ” END_OF_LIST
FOR EVENT end_of_list OF cl_gui_alv_grid
IMPORTING
e_dyndoc_id.
METHODS handle_after_refresh ” AFTER_REFRESH
FOR EVENT after_refresh OF cl_gui_alv_grid.
METHODS handle_button_click ” BUTTON_CLICK
FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING
es_col_id
es_row_no.
METHODS handle_data_changed_finished ” DATA_CHANGED_FINISHED
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING
e_modified
et_good_cells.
ENDCLASS. “cl_event_receiver DEFINITION
*———————————————————————-*
* CLASS cl_event_receiver IMPLEMENTATION
*———————————————————————-*
CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_right_click.
BREAK-POINT.
ENDMETHOD. “handle_right_click
METHOD handle_left_click_design.
BREAK-POINT.
ENDMETHOD. “handle_left_click_design
METHOD handle_move_control.
BREAK-POINT.
ENDMETHOD. “handle_move_control
METHOD handle_size_control.
BREAK-POINT.
ENDMETHOD. “handle_size_control
METHOD handle_left_click_run.
BREAK-POINT.
ENDMETHOD. “handle_left_click_run
METHOD handle_onf1.
BREAK-POINT.
ENDMETHOD. “handle_onf1
METHOD handle_onf4.
BREAK-POINT.
ENDMETHOD. “handle_onf4
METHOD handle_data_changed.
BREAK-POINT.
ENDMETHOD. “handle_data_changed
METHOD handle_ondropgetflavor.
BREAK-POINT.
ENDMETHOD. “handle_ondropgetflavor
METHOD handle_ondrag.
BREAK-POINT.
ENDMETHOD. “handle_ondrag
METHOD handle_ondrop.
BREAK-POINT.
ENDMETHOD. “handle_ondrop
METHOD handle_ondropcomplete.
BREAK-POINT.
ENDMETHOD. “handle_ondropcomplete
METHOD handle_subtotal_text.
BREAK-POINT.
ENDMETHOD. “handle_subtotal_text
METHOD handle_before_user_command.
BREAK-POINT.
ENDMETHOD. “handle_before_user_command
METHOD handle_user_command.
BREAK-POINT.
ENDMETHOD. “handle_user_command
METHOD handle_after_user_command.
BREAK-POINT.
ENDMETHOD. “handle_after_user_command
METHOD handle_double_click.
BREAK-POINT.
ENDMETHOD. “handle_double_click
METHOD handle_delayed_callback.
BREAK-POINT.
ENDMETHOD. “handle_delayed_callback
METHOD handle_delayed_changed_sel_cal.
BREAK-POINT.
ENDMETHOD. “handle_delayed_changed_sel_cal
METHOD handle_print_top_of_page.
BREAK-POINT.
ENDMETHOD. “handle_print_top_of_page
METHOD handle_print_top_of_list.
BREAK-POINT.
ENDMETHOD. “handle_print_top_of_list
METHOD handle_print_end_of_page.
BREAK-POINT.
ENDMETHOD. “handle_print_end_of_page
METHOD handle_print_end_of_list.
BREAK-POINT.
ENDMETHOD. “handle_print_end_of_list
METHOD handle_top_of_page.
BREAK-POINT.
ENDMETHOD. “handle_top_of_page
METHOD handle_context_menu_request.
BREAK-POINT.
ENDMETHOD. “handle_context_menu_request
METHOD handle_menu_button.
BREAK-POINT.
ENDMETHOD. “handle_menu_button
METHOD handle_toolbar.
BREAK-POINT.
ENDMETHOD. “handle_toolbar
METHOD handle_hotspot_click.
BREAK-POINT.
ENDMETHOD. “handle_hotspot_click
METHOD handle_end_of_list.
BREAK-POINT.
ENDMETHOD. “handle_end_of_list
METHOD handle_after_refresh.
BREAK-POINT.
ENDMETHOD. “handle_after_refresh
METHOD handle_button_click.
BREAK-POINT.
ENDMETHOD. “handle_button_click
METHOD handle_data_changed_finished.
BREAK-POINT.
ENDMETHOD. “handle_data_changed_finished
ENDCLASS. “cl_event_receiver IMPLEMENTATION
*———————————————————————-*
* CLASS cl_base_event_receiver DEFINITION
*———————————————————————-*
CLASS cl_base_event_receiver DEFINITION INHERITING FROM cl_gui_alv_grid_base.
PUBLIC SECTION.
METHODS set_protected_handlers.
PROTECTED SECTION.
METHODS handle_toolbar_menubutton_clk ” TOOLBAR_MENUBUTTON_CLICK
FOR EVENT toolbar_menubutton_click OF cl_gui_alv_grid_base.
METHODS handle_click_col_header ” CLICK_COL_HEADER
FOR EVENT click_col_header OF cl_gui_alv_grid_base
IMPORTING
col_id.
METHODS handle_delayed_move_curr_cell ” DELAYED_MOVE_CURRENT_CELL
FOR EVENT delayed_move_current_cell OF cl_gui_alv_grid_base.
METHODS handle_f1 ” F1
FOR EVENT f1 OF cl_gui_alv_grid_base.
METHODS handle_dblclick_row_col ” DBLCLICK_ROW_COL
FOR EVENT dblclick_row_col OF cl_gui_alv_grid_base
IMPORTING
row_id
col_id.
METHODS handle_click_row_col ” CLICK_ROW_COL
FOR EVENT click_row_col OF cl_gui_alv_grid_base
IMPORTING
row_id
col_id.
METHODS handle_toolbar_button_click ” TOOLBAR_BUTTON_CLICK
FOR EVENT toolbar_button_click OF cl_gui_alv_grid_base.
METHODS handle_double_click_col_sep ” DOUBLE_CLICK_COL_SEPARATOR
FOR EVENT double_click_col_separator OF cl_gui_alv_grid_base
IMPORTING
col_id.
METHODS handle_delayed_change_select ” DELAYED_CHANGE_SELECTION
FOR EVENT delayed_change_selection OF cl_gui_alv_grid_base.
METHODS handle_context_menu ” CONTEXT_MENU
FOR EVENT context_menu OF cl_gui_alv_grid_base.
METHODS handle_total_click_row_col ” TOTAL_CLICK_ROW_COL
FOR EVENT total_click_row_col OF cl_gui_alv_grid_base
IMPORTING
row_id
col_id.
METHODS handle_context_menu_selected ” CONTEXT_MENU_SELECTED
FOR EVENT context_menu_selected OF cl_gui_alv_grid_base
IMPORTING
fcode.
METHODS handle_toolbar_menu_selected ” TOOLBAR_MENU_SELECTED
FOR EVENT toolbar_menu_selected OF cl_gui_alv_grid_base
IMPORTING
fcode.
ENDCLASS. “cl_base_event_receiver DEFINITION
*———————————————————————-*
* CLASS cl_base_event_receiver IMPLEMENTATION
*———————————————————————-*
CLASS cl_base_event_receiver IMPLEMENTATION.
METHOD set_protected_handlers.
SET HANDLER me->handle_toolbar_menubutton_clk FOR go_grid.
SET HANDLER me->handle_click_col_header FOR go_grid.
SET HANDLER me->handle_delayed_move_curr_cell FOR go_grid.
SET HANDLER me->handle_f1 FOR go_grid.
SET HANDLER me->handle_dblclick_row_col FOR go_grid.
SET HANDLER me->handle_click_row_col FOR go_grid.
SET HANDLER me->handle_toolbar_button_click FOR go_grid.
SET HANDLER me->handle_double_click_col_sep FOR go_grid.
SET HANDLER me->handle_delayed_change_select FOR go_grid.
SET HANDLER me->handle_context_menu FOR go_grid.
SET HANDLER me->handle_total_click_row_col FOR go_grid.
SET HANDLER me->handle_context_menu_selected FOR go_grid.
SET HANDLER me->handle_toolbar_menu_selected FOR go_grid.
ENDMETHOD. “set_protected_handlers
METHOD handle_toolbar_menubutton_clk.
BREAK-POINT.
ENDMETHOD. “handle_toolbar_menubutton_clk
METHOD handle_click_col_header.
BREAK-POINT.
ENDMETHOD. “handle_click_col_header
METHOD handle_delayed_move_curr_cell.
BREAK-POINT.
ENDMETHOD. “handle_delayed_move_curr_cell
METHOD handle_f1.
BREAK-POINT.
ENDMETHOD. “handle_f1
METHOD handle_dblclick_row_col.
BREAK-POINT.
ENDMETHOD. “handle_dblclick_row_col
METHOD handle_click_row_col.
BREAK-POINT.
ENDMETHOD. “handle_click_row_col
METHOD handle_toolbar_button_click.
BREAK-POINT.
ENDMETHOD. “handle_toolbar_button_click
METHOD handle_double_click_col_sep.
BREAK-POINT.
ENDMETHOD. “handle_double_click_col_sep
METHOD handle_delayed_change_select.
BREAK-POINT.
ENDMETHOD. “handle_delayed_change_select
METHOD handle_context_menu.
BREAK-POINT.
ENDMETHOD. “handle_context_menu
METHOD handle_total_click_row_col.
BREAK-POINT.
ENDMETHOD. “handle_total_click_row_col
METHOD handle_context_menu_selected.
BREAK-POINT.
ENDMETHOD. “handle_context_menu_selected
METHOD handle_toolbar_menu_selected.
BREAK-POINT.
ENDMETHOD. “handle_toolbar_menu_selected
ENDCLASS. “cl_base_event_receiver IMPLEMENTATION
*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.
* read sample data to internal table
SELECT * FROM usr02 UP TO 30 ROWS
APPENDING CORRESPONDING FIELDS OF TABLE gt_usr
ORDER BY bname.
* create field catalog
PERFORM create_fieldcat.
* display screen
CALL SCREEN 0100.
*&———————————————————————*
*& Form create_fieldcat
*&———————————————————————*
FORM create_fieldcat.
DATA:
ls_fcat TYPE lvc_s_fcat.
* create field catalog
CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’
EXPORTING
i_structure_name = ‘USR02’
CHANGING
ct_fieldcat = gt_fcat.
* hotspot fields
ls_fcat-hotspot = ‘X’.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING hotspot
WHERE fieldname = ‘BNAME’.
* editable column
ls_fcat-edit = ‘X’.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING edit
WHERE
fieldname = ‘GLTGV’.
* F4 list
ls_fcat-f4availabl = ‘X’.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING f4availabl
WHERE
fieldname = ‘UFLAG’
OR fieldname = ‘ANAME’.
* dropdown list
ls_fcat-drdn_hndl = ‘1’.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING drdn_hndl
WHERE
fieldname = ‘CLASS’
OR fieldname = ‘LOCNT’.
ENDFORM. “create_fieldcat
*&———————————————————————*
*& Form field_f4_register
*&———————————————————————*
FORM field_f4_register.
DATA:
lt_f4 TYPE lvc_t_f4,
ls_f4 TYPE lvc_s_f4.
ls_f4-fieldname = ‘UFLAG’.
ls_f4-register = ‘X’.
* ls_f4-getbefore = ‘X’.
* ls_f4-chngeafter = ‘X’.
INSERT ls_f4 INTO TABLE lt_f4.
ls_f4-fieldname = ‘ANAME’.
ls_f4-register = ‘X’.
* ls_f4-getbefore = ‘X’.
* ls_f4-chngeafter = ‘X’.
INSERT ls_f4 INTO TABLE lt_f4.
CALL METHOD go_grid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4.
ENDFORM. “field_f4_register
*———————————————————————-*
* MODULE pbo_0100 OUTPUT
*———————————————————————-*
MODULE pbo_0100 OUTPUT.
* set GUI status
SET PF-STATUS ‘STAT_0100’.
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING
container_name = ‘CONT1_0100’.
CREATE OBJECT go_grid
EXPORTING
i_appl_events = ‘X’
i_parent = go_custom_container.
* create handler
CREATE OBJECT go_event_receiver.
* register handler for events
SET HANDLER go_event_receiver->handle_right_click FOR go_grid.
SET HANDLER go_event_receiver->handle_left_click_design FOR go_grid.
SET HANDLER go_event_receiver->handle_move_control FOR go_grid.
SET HANDLER go_event_receiver->handle_size_control FOR go_grid.
SET HANDLER go_event_receiver->handle_left_click_run FOR go_grid.
SET HANDLER go_event_receiver->handle_onf1 FOR go_grid.
SET HANDLER go_event_receiver->handle_onf4 FOR go_grid.
SET HANDLER go_event_receiver->handle_data_changed FOR go_grid.
SET HANDLER go_event_receiver->handle_ondropgetflavor FOR go_grid.
SET HANDLER go_event_receiver->handle_ondrag FOR go_grid.
SET HANDLER go_event_receiver->handle_ondrop FOR go_grid.
SET HANDLER go_event_receiver->handle_ondropcomplete FOR go_grid.
SET HANDLER go_event_receiver->handle_subtotal_text FOR go_grid.
SET HANDLER go_event_receiver->handle_before_user_command FOR go_grid.
SET HANDLER go_event_receiver->handle_user_command FOR go_grid.
SET HANDLER go_event_receiver->handle_after_user_command FOR go_grid.
SET HANDLER go_event_receiver->handle_double_click FOR go_grid.
SET HANDLER go_event_receiver->handle_delayed_callback FOR go_grid.
SET HANDLER go_event_receiver->handle_delayed_changed_sel_cal FOR go_grid.
SET HANDLER go_event_receiver->handle_print_top_of_page FOR go_grid.
SET HANDLER go_event_receiver->handle_print_top_of_list FOR go_grid.
SET HANDLER go_event_receiver->handle_print_end_of_page FOR go_grid.
SET HANDLER go_event_receiver->handle_print_end_of_list FOR go_grid.
SET HANDLER go_event_receiver->handle_top_of_page FOR go_grid.
SET HANDLER go_event_receiver->handle_context_menu_request FOR go_grid.
SET HANDLER go_event_receiver->handle_menu_button FOR go_grid.
SET HANDLER go_event_receiver->handle_toolbar FOR go_grid.
SET HANDLER go_event_receiver->handle_hotspot_click FOR go_grid.
SET HANDLER go_event_receiver->handle_end_of_list FOR go_grid.
SET HANDLER go_event_receiver->handle_after_refresh FOR go_grid.
SET HANDLER go_event_receiver->handle_button_click FOR go_grid.
SET HANDLER go_event_receiver->handle_data_changed_finished FOR go_grid.
* create handler for protected events
CREATE OBJECT go_base_event_receiver.
* register handler for protected events
CALL METHOD go_base_event_receiver->set_protected_handlers.
* register F4 fields
PERFORM field_f4_register.
* register extra events for edit mode
* – events DATA_CHANGED and DATA_CHANGED_FINISHED are called, when:
* ENTER key is pressed or
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
* data is changed and cursor is moved from the cell
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
* display table
CALL METHOD go_grid->set_table_for_first_display
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_usr.
ENDIF.
ENDMODULE. “pbo_0100 OUTPUT
*———————————————————————-*
* MODULE pai_0100 INPUT
*———————————————————————-*
MODULE pai_0100 INPUT.
BREAK-POINT.
* to react on custom events:
CALL METHOD cl_gui_cfw=>dispatch.
BREAK-POINT.
CASE ok_code.
WHEN ‘EXIT’.
LEAVE PROGRAM.
WHEN ‘SAVE’.
* force ALV to copy the data from grid to the internal table
* (events DATA_CHANGED and DATA_CHANGED_FINISHED will be fired)
CALL METHOD go_grid->check_changed_data.
ENDCASE.
CLEAR ok_code.
ENDMODULE. “pai_0100 INPUT
Cemile
11 Haziran 2017 @ 04:50
Merhaba,
Blogunuzu çok begendim bilgilendirici olmuşsunuz, fakat site tasariminizda siyah zemine beyaz yazılar olduğu müddetçe okumanız çok zorlaşıyor. bilginize.
Burhan KARADERE
16 Haziran 2017 @ 15:24
Öneriniz için teşekkürler