ALV Report Event
Hi All
Can you please tell me 'under which event do we write fieldcatalog ' in ALV Report.
Thanks in Advance!
Kiran
Hi
We fetch the data in start-of-selection and write the ALV related data in end of selection
See the sample report
report ZRGRIRNA no standard page heading
line-count 65
line-size 255
message-id mm.
GR IR Detail Report *
Description : The output has to be displayed
in the ALV Grid format with the Selection *
screen appearing on the output. In The Output *
Subtotals for Vendor, Plant, Period, Material,*
Valuation Class, Purchase Order,Cost Center, *
Cost Element and Receipt Date are displayed *
after sorting the data by same fields. *
Declaration for Tables
tables: t001, " Company Codes
t001w, " Plants/Branches
lfa1, " Vendor Master
ska1, " GL Account Master
mara, " Material Master
mbew, " Material Valuation
ekko, " PO Header Data
cska, " Cost Elements
csks, " Cost Centers
bsis, " GL Accounts: Open Items Data
bkpf. " Accounting Doc: Header Data
Type-pools
Type pools for ALV display
type-pools : slis.
Global variables
data: g_repid like sy-repid,
g_exit type c,
g_events type slis_t_event,
g_list_top_of_page type slis_t_listheader,
g_exit_caused_by_caller,
g_exit_caused_by_user type slis_exit_by_user,
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_variant like disvariant,
g_save.
Declaration for Constants
constants : c_x type c value 'X', " Flag
c_c type c value 'C', " Flag
c_l type c value 'L', " Flag
c_a type c value 'A', " Line Type
c_h type c value 'H', " Dr/Cr
c_s type c value 'S', " Line Type
c_mkpf(4) type c value 'MKPF'. " Table
Declaration of Internal Tables
Internal Table for BSIS Table data
data: begin of i_bsis occurs 0,
bukrs like bsis-bukrs, " Company Code
hkont like bsis-hkont, " GR IR Account
gjahr like bsis-gjahr, " Fiscal Year
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
budat like bsis-budat, " Receipt Date(Posting)
monat like bsis-monat, " Period
end of i_bsis.
Internal Table for BSEG Table data
data: begin of i_bseg occurs 0,
bukrs like bsis-bukrs, " Company Code
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
gjahr like bsis-gjahr, " Fiscal Year
shkzg like bseg-shkzg, " Dr/Cr Indicator
lifnr like bseg-lifnr, " Vendor Code
matnr like bseg-matnr, " Material No
ebeln like bseg-ebeln, " Purchase Order
ebelp like bseg-ebelp, " PO Item
werks like bseg-werks, " Plant
menge like bseg-menge, " PO Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Amount in Local Currency
wrbtr like bseg-wrbtr, " Amount in Trans.Currency
end of i_bseg.
Internal Table for BKPF Table data
data: begin of i_bkpf occurs 0,
bukrs like bkpf-bukrs, " Company Code
belnr like bkpf-belnr, " Acc Document
gjahr like bkpf-gjahr, " Fiscal Year
waers like bkpf-waers, " Trans. Currency
awkey like bkpf-awkey, " Object Key
awtyp like bkpf-awtyp, " Reference Procedure
end of i_bkpf.
Internal Table for MSEG Table data
data: begin of i_mseg occurs 0,
mblnr like mseg-mblnr, " Material Document
mjahr like mseg-mjahr, " Fiscal Year
bwart like mseg-bwart, " Movement Type
matnr like mseg-matnr, " Material No
menge like mseg-menge, " PO Quantity
meins like mseg-meins, " UOM
end of i_mseg.
Internal Table for MBEW Table data
data: begin of i_mbew occurs 0,
matnr like mbew-matnr, " Material No
werks like mbew-bwkey, " Plant
bklas like mbew-bklas, " Valuation Class
end of i_mbew.
Internal Table for EKPO Table data
data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln, " Purchase Order
ebelp like ekpo-ebelp, " PO Item
matnr like ekpo-matnr, " Material No
txz01 like ekpo-txz01, " Material Text
end of i_ekpo.
Internal Table for EKKN Table data
data: begin of i_ekkn occurs 0,
ebeln like ekkn-ebeln, " Purchase Order
ebelp like ekkn-ebelp, " PO Item
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
end of i_ekkn.
Internal Table for LFA1 Table data
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, " Vendor
name1 like lfa1-name1, " Name
end of i_lfa1.
Declaration of Output Internal Table
data: begin of i_final occurs 0,
lifnr like lfa1-lifnr, " Vendor
werks like bseg-werks, " Plant
monat like bsis-monat, " Period
matnr like mara-matnr, " Material Number
bklas like mbew-bklas, " Val Class
ebeln like bseg-ebeln, " PO
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
budat like bsis-budat, " Rec. Date
name1 like lfa1-name1, " Vendor Name
belnr like bsis-belnr, " FI Document
bwart like mseg-bwart, " Movement Type
txz01 like ekpo-txz01, " Material Text
menge like bseg-menge, " Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Local Amount
wrbtr like bseg-wrbtr, " Tran.Amount
waers like bkpf-waers, " Tran.Currency
status type c, " Material Status
end of i_final.
Internal table to hold field catgory data
data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
Structure
data: x_layout type slis_layout_alv, " Structure-layout
x_fldcat like line of i_fldcat, " Structure-field catagory
x_sort like line of i_sort. " Structure-Sort/Subtotals
Selection screen
selection-screen : begin of block b1 with frame title text-000.
parameters:
p_bukrs like t001-bukrs obligatory, " Company Code
p_grira like ska1-saknr default '0241101000' obligatory. " Account
select-options:
s_budat for bkpf-budat, " Posting Date
s_werks for t001w-werks, " Plant
s_lifnr for lfa1-lifnr, " Vendor
s_matnr for mara-matnr, " Material Number
s_kostl for csks-kostl, " Cost Center
s_kstar for cska-kstar, " Cost Element
s_ebeln for ekko-ebeln, " Purchase Order
s_monat for bsis-monat. " Period
selection-screen skip.
parameters:
p_incmt as checkbox default 'X',
p_incnm as checkbox default 'X'.
selection-screen end of block b1.
Initialization
initialization.
g_repid = sy-repid.
perform layout_init using x_layout.
perform eventtab_build using g_events[].
g_variant-report = g_repid.
g_save = 'A'.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
perform validate_screen.
Start of selection
start-of-selection.
Read Data from Database Tables
perform read_data.
End of selection
end-of-selection.
Build layout report layout.
perform populate_layout_stucture.
Perform build_field_catalog and Sort Table
perform build_field_catalog.
perform build_sort_totals.
List Header for Top-Of-Page
perform comment_build using g_list_top_of_page[].
Call list viewer function module
perform call_list_viewer .
****************Form - Routines**************************************
Form : layout_init
Description : Form to Build layout for list display
form layout_init using rs_layout type slis_layout_alv.
rs_layout-detail_popup = c_x.
endform.
Form : Eventtab_build
Description : Registration of events to happen during list display
form eventtab_build using rt_events type slis_t_event.
Registration of events to happen during list display
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = rt_events.
read table rt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move g_top_of_page to ls_event-form.
append ls_event to rt_events.
endif.
endform. "eventtab_build
Form : top_of_page
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
I_LOGO = 'ENJOYSAP_LOGO'
it_list_commentary = g_list_top_of_page.
endform.
Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Company Code
clear t001.
if not p_bukrs is initial.
select single bukrs
into t001-bukrs
from t001
where bukrs eq p_bukrs.
if sy-subrc <> 0.
message e899 with 'Enter Valid Company Code'(012).
endif.
endif.
Validation of GL Account (GR/IR)
clear ska1.
if not p_grira is initial.
select saknr
into ska1-saknr
from ska1
up to 1 rows
where saknr eq p_grira.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid GR/IR Account'(013).
endif.
endif.
Validation of Vendor Code
clear lfa1.
if not s_lifnr[] is initial.
select single lifnr
into lfa1-lifnr
from lfa1
where lifnr in s_lifnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Vendor'(001).
endif.
endif.
Validation of Plant Code
clear t001w.
if not s_werks[] is initial.
select single werks
into t001w-werks
from t001w
where werks in s_werks.
if sy-subrc <> 0.
message e899 with 'Enter Valid Plant'(014).
endif.
endif.
Validation of Material Code
clear mara.
if not s_matnr[] is initial.
select single matnr
into mara-matnr
from mara
where matnr in s_matnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Material'(015).
endif.
endif.
Validation of Purchase Order
clear ekko.
if not s_ebeln[] is initial.
select single ebeln
into ekko-ebeln
from ekko
where ebeln in s_ebeln.
if sy-subrc <> 0.
message e899 with 'Enter Valid Purchase Order'(016).
endif.
endif.
Validation of Cost Center
clear csks.
if not s_kostl[] is initial.
select kostl
into csks-kostl
from csks
up to 1 rows
where kostl in s_kostl.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Center'(017).
endif.
endif.
Validation of Cost Element
clear cska.
if not s_kstar[] is initial.
select kstar
into cska-kstar
from cska
up to 1 rows
where kstar in s_kstar.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Element'(018).
endif.
endif.
endform. "validate_screen
*& Form read_data
Read the Data from the database Tables
form read_data.
Get the Accounting Documents for the GR/IR Account Entered on
Selection Screen
clear i_bsis.
refresh i_bsis.
select bukrs " Company Code
hkont " GR IR Account
gjahr " Fiscal Year
belnr " Acc Document
buzei " Item No
budat " Receipt Date(Posting)
monat " Period
into table i_bsis
from bsis
where bukrs = p_bukrs
and hkont = p_grira
and budat in s_budat
and monat in s_monat .
if sy-subrc <> 0.
message i899 with 'No data found'(043).
g_exit = c_x.
stop.
endif.
sort i_bsis by bukrs hkont gjahr belnr buzei.
Get the Vendor,PO,Material,Qty details from BSEG Table
if not i_bsis[] is initial.
clear i_bseg.
refresh i_bseg.
select bukrs " Company Code
belnr " Acc Document
buzei " Item No
gjahr " Fiscal Year
shkzg " Dr/Cr Indicator
lifnr " Vendor Code
matnr " Material No
ebeln " Purchase Order
ebelp " PO Item
werks " Plant
menge " PO Quantity
meins " UOM
dmbtr " Amount in Local Currency
wrbtr " Amount in Trans.Currency
into table i_bseg
from bseg
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr
and buzei = i_bsis-buzei
and lifnr in s_lifnr
and werks in s_werks
and matnr in s_matnr
and ebeln in s_ebeln.
sort i_bseg by bukrs belnr buzei gjahr.
Select the Trans.Currency from BKPF Table
clear i_bkpf.
refresh i_bkpf.
select bukrs " Company Code
belnr " Acc Document
gjahr " Fiscal Year
waers " Trans. Currency
awkey " Object Key
awtyp " Reference Procedure
into table i_bkpf
from bkpf
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr.
endif.
sort i_bkpf by bukrs belnr gjahr.
Get the Quantity and UOM of Material from MSEG Table
if not i_bkpf[] is initial.
clear i_mseg.
refresh i_mseg.
select mblnr " Material Document
mjahr " Fiscal Year
bwart " Movement Type
matnr " Material No
menge " PO Quantity
meins " UOM
into table i_mseg
from mseg
for all entries in i_bkpf
where mblnr = i_bkpf-awkey(10).
endif.
sort i_mseg by mblnr mjahr.
Get the Material And Description from EKPO Table
if not i_bseg[] is initial.
clear i_ekpo.
refresh i_ekpo.
select ebeln " Purchase Order
ebelp " PO Item
matnr " Material No
txz01 " Material Text
into table i_ekpo
from ekpo
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp.
sort i_ekpo by ebeln ebelp.
Get the Valuation Class from MBEW Table
clear i_mbew.
refresh i_mbew.
select matnr " Material No
bwkey " Plant
bklas " Valuation Class
into table i_mbew
from mbew
for all entries in i_bseg
where matnr = i_bseg-matnr
and bwkey = i_bseg-werks.
sort i_mbew by matnr werks.
Get the Cost Center and Cost Element of the PO from EKKN Table
clear i_ekkn.
refresh i_ekkn.
select ebeln " Purchase Order
ebelp " PO Item
kostl " Cost Center
sakto " Cost Element
into table i_ekkn
from ekkn
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp
and kostl in s_kostl
and sakto in s_kstar.
sort i_ekkn by ebeln ebelp.
Get the Vendor Name
clear i_lfa1.
refresh i_lfa1.
select lifnr " Vendor
name1 " Name
into table i_lfa1
from lfa1
for all entries in i_bseg
where lifnr = i_bseg-lifnr.
endif.
sort i_lfa1 by lifnr.
Move the data to Final Output Internal Table
loop at i_bsis.
i_final-belnr = i_bsis-belnr. " FI Document
i_final-monat = i_bsis-monat. " Period
i_final-budat = i_bsis-budat. " Rec. Date
Read the Transaction Currency from BKPF Internal Table
read table i_bkpf with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
binary search.
if sy-subrc = 0.
i_final-waers = i_bkpf-waers. " Tran.Currency
Read the Movement Type for all Material Related
Documents from MSEG Internal Table
if i_bkpf-awtyp = c_mkpf.
read table i_mseg with key mblnr = i_bkpf-awkey(10)
mjahr = i_bkpf-awkey+10(4).
if sy-subrc = 0.
i_final-bwart = i_mseg-bwart. " Movement Type
endif.
endif.
endif.
Read Vendor, Plant, PO Document, Local And Trans.Amounts
from BSEG Internal Table
read table i_bseg with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
buzei = i_bsis-buzei
binary search.
if sy-subrc = 0.
i_final-lifnr = i_bseg-lifnr. " Vendor
i_final-werks = i_bseg-werks. " Plant
i_final-ebeln = i_bseg-ebeln. " PO
i_final-dmbtr = i_bseg-dmbtr. " Local Amount
i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount
i_final-menge = i_bseg-menge. " Quantity
i_final-meins = i_bseg-meins. " UOM
For Credit Indicator(SHKZG = H) amounts should be (-)ve
if i_bseg-shkzg = c_h.
i_final-dmbtr = i_final-dmbtr * -1.
i_final-wrbtr = i_final-wrbtr * -1.
i_final-menge = i_final-menge * -1.
endif.
Read the Material and its Description from EKPO Internal Table
read table i_ekpo with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
matnr = i_bseg-matnr
binary search.
if sy-subrc = 0.
i_final-matnr = i_ekpo-matnr. " Material Number
i_final-txz01 = i_ekpo-txz01. " Material Text
Populate the Material Status depending on the Input Checkbox
On Selection Screen
if not i_ekpo-matnr is initial.
i_final-status = c_x.
endif.
endif.
Read the PO related Cost Element and Cost Centers
from EKKN Internal Table
read table i_ekkn with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
binary search.
if sy-subrc = 0.
i_final-kostl = i_ekkn-kostl. " Cost Center
i_final-sakto = i_ekkn-sakto. " Cost Element
endif.
Read the Valuation Class from MBEW Internal Table
read table i_mbew with key matnr = i_bseg-matnr
werks = i_bseg-werks
binary search.
if sy-subrc = 0.
i_final-bklas = i_mbew-bklas. " Val Class
endif.
Read the Vendor Name from LFA1 Internal Table
read table i_lfa1 with key lifnr = i_bseg-lifnr
binary search.
if sy-subrc = 0.
i_final-name1 = i_lfa1-name1. " Vendor Name
endif.
endif.
append i_final.
clear i_final.
endloop.
sort i_final by lifnr werks monat matnr.
Depending on the check Box Selected display the data
if p_incmt = c_x and p_incnm ne c_x.
delete i_final where matnr eq space.
elseif p_incnm = c_x and p_incmt ne c_x.
delete i_final where matnr ne space.
endif.
endform. "Read Data
Form : populate_layout_stucture
Description : Populating the layout structure
form populate_layout_stucture.
clear x_layout .
Layout properties
x_layout-zebra = c_x.
x_layout-detail_popup = c_x.
x_layout-detail_initial_lines = c_x.
x_layout-colwidth_optimize = c_x.
endform. " populate_layout_stucture
Form : build_field_catalog
Description : Building the field catalog data
form build_field_catalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = g_repid
i_internal_tabname = 'I_FINAL'
i_inclname = g_repid
changing
ct_fieldcat = i_fldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Getting the Header text for the coloums
loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
fieldname = 'NAME1' or
fieldname = 'WERKS' or
fieldname = 'MONAT' or
fieldname = 'MATNR' or
fieldname = 'BKLAS' or
fieldname = 'EBELN' or
fieldname = 'KOSTL' or
fieldname = 'SAKTO' or
fieldname = 'BUDAT' or
fieldname = 'BELNR' or
fieldname = 'BWART' or
fieldname = 'TXZ01' or
fieldname = 'MENGE' or
fieldname = 'MEINS' or
fieldname = 'DMBTR' or
fieldname = 'WRBTR' or
fieldname = 'WAERS' or
fieldname = 'STATUS'.
if x_fldcat-fieldname = 'LIFNR'.
x_fldcat-seltext_l = 'Vendor'(003).
x_fldcat-seltext_m = 'Vendor'(003).
x_fldcat-seltext_s = 'Vendor'(003).
x_fldcat-reptext_ddic = 'Vendor'(003).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'NAME1'.
x_fldcat-seltext_l = 'Vendor Name'(002).
x_fldcat-seltext_m = 'Vendor Name'(002).
x_fldcat-seltext_s = 'Vendor Name'(002).
x_fldcat-reptext_ddic = 'Vendor Name'(002).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'WERKS'.
x_fldcat-seltext_l = 'Plant'(010).
x_fldcat-seltext_m = 'Plant'(010).
x_fldcat-seltext_s = 'Plant'(010).
x_fldcat-reptext_ddic = 'Plant'(010).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MONAT'.
x_fldcat-seltext_l = 'Period'(011).
x_fldcat-seltext_m = 'Period'(011).
x_fldcat-seltext_s = 'Period'(011).
x_fldcat-reptext_ddic = 'Period'(011).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MATNR'.
x_fldcat-seltext_l = 'Material'(004).
x_fldcat-seltext_m = 'Material'(004).
x_fldcat-seltext_s = 'Material'(004).
x_fldcat-reptext_ddic = 'Material'(004).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BKLAS'.
x_fldcat-seltext_l = 'Valuation Class'(009).
x_fldcat-seltext_m = 'Valuation Class'(009).
x_fldcat-seltext_s = 'Valuation Class'(009).
x_fldcat-reptext_ddic = 'Valuation Class'(009).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'EBELN'.
x_fldcat-seltext_l = 'Purchase Order'(005).
x_fldcat-seltext_m = 'Purchase Order'(005).
x_fldcat-seltext_s = 'Purchase Order'(005).
x_fldcat-reptext_ddic = 'Purchase Order'(005).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'KOSTL'.
x_fldcat-seltext_l = 'Cost Center'(006).
x_fldcat-seltext_m = 'Cost Center'(006).
x_fldcat-seltext_s = 'Cost Center'(006).
x_fldcat-reptext_ddic = 'Cost Center'(006).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'SAKTO'.
x_fldcat-seltext_l = 'Cost Element'(007).
x_fldcat-seltext_m = 'Cost Element'(007).
x_fldcat-seltext_s = 'Cost Element'(007).
x_fldcat-reptext_ddic = 'Cost Element'(007).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BUDAT'.
x_fldcat-seltext_l = 'Receipt Date'(008).
x_fldcat-seltext_m = 'Receipt Date'(008).
x_fldcat-seltext_s = 'Receipt Date'(008).
x_fldcat-reptext_ddic = 'Receipt Date'(008).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BELNR'.
x_fldcat-seltext_l = 'Acc.Document'(100).
x_fldcat-seltext_m = 'Acc.Document'(100).
x_fldcat-seltext_s = 'Acc.Document'(100).
x_fldcat-reptext_ddic = 'Acc.Document'(100).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BWART'.
x_fldcat-seltext_l = 'Movement Type'(101).
x_fldcat-seltext_m = 'Movement Type'(101).
x_fldcat-seltext_s = 'Movement Type'(101).
x_fldcat-reptext_ddic = 'Movement Type'(101).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'TXZ01'.
x_fldcat-seltext_l = 'Material Text'(102).
x_fldcat-seltext_m = 'Material Text'(102).
x_fldcat-seltext_s = 'Material Text'(102).
x_fldcat-reptext_ddic = 'Material Text'(102).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE'.
x_fldcat-seltext_l = 'Quantity'(103).
x_fldcat-seltext_m = 'Quantity'(103).
x_fldcat-seltext_s = 'Quantity'(103).
x_fldcat-reptext_ddic = 'Quantity'(103).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'(104).
x_fldcat-seltext_m = 'UOM'(104).
x_fldcat-seltext_s = 'UOM'(104).
x_fldcat-reptext_ddic = 'UOM'(104).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'DMBTR'.
x_fldcat-seltext_l = 'Amount in Local Curr'(105).
x_fldcat-seltext_m = 'Amount in Local Curr'(105).
x_fldcat-seltext_s = 'Amount in Local Curr'(105).
x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WRBTR'.
x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).
x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WAERS'.
x_fldcat-seltext_l = 'Trans.Currency'(107).
x_fldcat-seltext_m = 'Trans.Currency'(107).
x_fldcat-seltext_s = 'Trans.Currency'(107).
x_fldcat-reptext_ddic = 'Trans.Currency'(107).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'STATUS'.
x_fldcat-seltext_l = 'Material Status'(019).
x_fldcat-seltext_m = 'Material Status'(019).
x_fldcat-seltext_s = 'Material Status'(019).
x_fldcat-reptext_ddic = 'Material Status'(019).
x_fldcat-ddictxt = c_l.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
endloop.
endform. " build_field_catalog
Form : build_sort_totals
Description : Building the Criteria for Sort/Subtotals
form build_sort_totals.
x_sort-fieldname = 'LIFNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WERKS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 3.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MATNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 4.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BKLAS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 5.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'EBELN'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 6.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'KOSTL'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 7.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'SAKTO'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 8.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BUDAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 9.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
endform. " build_sort_totals
Form : comment_build
Description : This form is used to display the Report Header(ALV)
form comment_build using lt_top_of_page type
slis_t_listheader.
data: l_line type slis_listheader,
l_heading1 like rs38m-repti,
l_date(10), l_time(8).
clear l_line.
l_heading1 = 'GR/IR DETAIL REPORT'(021).
g_repid = sy-repid.
write sy-uzeit to l_time.
write sy-datum to l_date.
l_line-typ = c_h.
move l_heading1 to l_line-info.
append l_line to lt_top_of_page.
clear l_line.
l_line-typ = c_s.
concatenate 'System:'(023) sy-sysid
'Date:'(024) l_date
' Time:'(025)
l_time into l_line-info.
append l_line to lt_top_of_page.
concatenate 'Report:'(026) g_repid
' User:'(027) sy-uname into
l_line-info.
append l_line to lt_top_of_page.
l_line-typ = c_a.
move 'SELECTION CRITERIA:'(028) to l_line-info.
append l_line to lt_top_of_page.
concatenate ' Company Code : '(029)
p_bukrs into l_line-info.
append l_line to lt_top_of_page.
concatenate ' GR/IR Account: '(030)
p_grira into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Posting Date : '(032) s_budat-low
' To: '(031) s_budat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Plant : '(033) s_werks-low
' To: '(031) s_werks-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Vendor: '(034) s_lifnr-low
' To: '(031) s_lifnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Material: '(035) s_matnr-low
' To: '(031) s_matnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Center : '(036) s_kostl-low
' To: '(031) s_kostl-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Element: '(037) s_kstar-low
' To: '(031) s_kstar-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Purchase Order: '(038) s_ebeln-low
' To: '(031) s_ebeln-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Period : '(039) s_monat-low
' To: '(031) s_monat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Material Items: '(040)
p_incmt into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Non-Material Items: '(041)
p_incnm into l_line-info.
append l_line to lt_top_of_page.
endform.
Form : call_list_viewer
Description : This form is used to display the grid through ALV
form call_list_viewer.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = x_layout
it_fieldcat = i_fldcat[]
i_default = c_x
it_sort = i_sort[]
i_save = g_save
is_variant = g_variant
it_events = g_events[]
importing
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = g_exit_caused_by_user
tables
t_outtab = i_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
write: / 'Problem in calling the ALV report'(042).
endif.
endform. " call_list_viewer
<b>Reward points for useful Answers</b>
Regards
Anji
Similar Messages
-
In alv report can i use control break events? if no .whay?
Hi all,
in alv report can i use control break events? if no .whay?hi,
you can use control break statements in ALV report.
for example: if one PO is having more than one line item, that time you need to display PO only once. -
End of Page event not triggering in ALV report
Hello,
I am developing an ALV report using REUSE_ALV_LIST_DISPLAY. Whatever I write in top_of_page, it will be displayed in the header portion of the output.
But I want to display some footer text at the end of the page. The problem I am facing is, the WRITE statements within end_of_page are not displayed when the report is run.
I have populated the i_events as follows :
FORM f_events CHANGING p_i_events TYPE slis_t_event.
CONSTANTS : l_c_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
l_c_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
DATA : l_wa_event TYPE slis_alv_event.
Returns table of possible events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_i_events.
To append internal table holding event names with event 'TOP OF PAGE'
READ TABLE p_i_events INTO l_wa_event
WITH KEY name = slis_ev_top_of_page.
IF sy-subrc = 0.
MOVE l_c_top_of_page TO l_wa_event-form.
APPEND l_wa_event TO p_i_events.
ENDIF.
To append internal table holding event names with event 'END OF PAGE'
READ TABLE p_i_events INTO l_wa_event
WITH KEY name = slis_ev_end_of_page.
IF sy-subrc = 0.
MOVE l_c_end_of_page TO l_wa_event-form.
APPEND l_wa_event TO p_i_events.
ENDIF.
ENDFORM. "f_events
Regds
RajeshHi have a look at the following code, and change ur code for end of page accordingly. this will resolve ur problem.
This is a basic ALV with the followings:-
- Page Heading
- Page No
- Sub-Total
- Grand Total
REPORT ZALV.
TYPE-POOLS: SLIS.
DATA: G_REPID LIKE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
COL_POS TYPE I.
DATA: BEGIN OF ITAB,
FIELD1(5) TYPE C,
FIELD2(5) TYPE C,
FIELD3(5) TYPE P DECIMALS 2,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB1.
DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB_FIELDCAT.
Print Parameters
PARAMETERS:
P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
P_RESERV TYPE I. "NO OF FOOTER LINE
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS
START-OF-SELECTION.
TEST DATA
MOVE 'TEST1' TO ITAB1-FIELD1.
MOVE 'TEST1' TO ITAB1-FIELD2.
MOVE '10.00' TO ITAB1-FIELD3.
APPEND ITAB1.
MOVE 'TEST2' TO ITAB1-FIELD1.
MOVE 'TEST2' TO ITAB1-FIELD2.
MOVE '20.00' TO ITAB1-FIELD3.
APPEND ITAB1.
DO 50 TIMES.
APPEND ITAB1.
ENDDO.
END-OF-SELECTION.
PERFORM BUILD.
PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.
PERFORM CALL_ALV.
FORM BUILD.
DATA FIELD CATALOG
Explain Field Description to ALV
DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD1'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
*FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD2'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-NO_OUT = 'X'.
FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD3'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
FIELDCAT_LN-REF_TABNAME = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-DO_SUM = 'X'. "SUM UPON DISPLAY
APPEND FIELDCAT_LN TO GT_FIELDCAT.
DATA SORTING AND SUBTOTAL
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
ENDFORM.
FORM CALL_ALV.
ABAP List Viewer
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'ITAB1'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = GT_SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
IT_EVENT_EXIT =
IS_PRINT = GS_PRINT
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
HEADER FORM
FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
define END_OF_PAGE event
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
ENDFORM.
FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GS_LINE TYPE SLIS_LISTHEADER.
CLEAR GS_LINE.
GS_LINE-TYP = 'H'.
GS_LINE-INFO = 'HEADER 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'S'.
GS_LINE-KEY = 'STATUS 1'.
GS_LINE-INFO = 'INFO 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
GS_LINE-KEY = 'STATUS 2'.
GS_LINE-INFO = 'INFO 2'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'A'.
GS_LINE-INFO = 'ACTION'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
ENDFORM.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
ENDFORM.
FORM END_OF_PAGE.
WRITE at (sy-linsz) sy-pagno CENTERED.
ENDFORM.
PRINT SETTINGS
FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE
LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO
LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE
LS_PRINT-NO_NEW_PAGE = P_NONEWP.
LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
LS_PRINT-RESERVE_LINES = P_RESERV.
ENDFORM.
*END OF ZALV PROGRAM
Satish -
End-of-page event in alv report
Hi all,
I want to create end-of-page in alv report i have used event also
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' * "
EXPORTING *
i_callback_program = sy-repid * "
i_callback_user_command = 'USER_COMMAND' * "
i_callback_top_of_page = 'TOP_OF_PAGE' * "
I_STRUCTURE_NAME = * "
it_fieldcat = fcat[] * "
it_events = it_event[] * "
TABLES
t_outtab = gtbl_pohead * "
EXCEPTIONS
program_error = 1 * "
OTHERS = 2 "
FORM end_of_page. *
DATA: listwidth TYPE i, *
ld_pagepos(10) TYPE c, *
ld_page(10) TYPE c. *
WRITE: sy-uline(50). "
SKIP 3.
WRITE:/40 'Page No',sy-pagno. "
ENDFORM. "END_OF_PAGE "hi
Search in SDN.You can find the solution for this.Before posting please search in SDN.
You have to use this FM 'REUSE_ALV_EVENTS_GET'
[End-Of-Page|http://www.sapdev.co.uk/reporting/alv/alvgrid_events.htm]
[Endo Of Page|http://www.sdn.sap.com/irj/scn/advancedsearch?query=alvend-of-pageevent+] -
Hi ,
have been working on a ALV report using the class SALV cl_salv_hierseq_table
I am facing few issues pertaining to two things:
1. Displaying some subtotal text along with the subtotals.
Example refer the standard demo example: SALV_DEMO_HIERSEQ_FORM_EVENTS
Now instead of A 17 and A26 I would like to show text like Subtotal for the Carrid.for subtotals and grand totals
Like Subtotal for A 17 is : XXXXXXX
GrandTotal is : YYYYYY
2. We have a page break and a new page for every purchasing group as in the standard example SALV_DEMO_HIERSEQ_FORM_EVENTS for CARRID.
I need to display some variable values as number of documents ,total number of records etc at the end of each CARRID group before a new page starts for the next CARRID.Please note i do not want it on every page.it should only be diaplyed at the end of page whose next page would be for next CARRID.[basically at end of every carrid]Example:after displaying all details for AA need to display the number of records for that carrid at the end of the page[as page break is based on CARRID]/
Thanks
Jyotsnaat end of page event, for CL_SALV_EVENTS_HIERSEQ, has some useful parameters allowing to know where you are at the time of event
parameter VALUE is of type CL_SALV_FORM which contains public attribute IF_SALV_FORM~ACCDESCRIPTION; you can slo get contents of it
about text of total/subtotal, this is normally set in the layout -
How to Display Page Numbers in ALV Report HTML End of page Event
hai Gurus
Greetings
Please tell me how to get current page noumber and total number of pages in ALV Report (in HTML End of Page Event)
i tried with sy-pagno system field but it is not working
so please guide me
Thanks
Rameshcheck below code....
*Work area for Layout
gf_layout type slis_layout_alv,
*Work area for HEADER FOOTER
gf_header type slis_listheader,
*Work area for Field catalogue
gf_fieldcat type slis_fieldcat_alv.
it_top_page type slis_t_listheader,
*Internal table for Field catalogue
it_fcat type slis_t_fieldcat_alv.
perform:fill_layout,
prepare_header,
field_catlog,
display_report.
Form fill_layout
form fill_layout .
gf_layout-colwidth_optimize = 'X'.
endform. " fill_layout
Form field_catlog
form field_catlog .
data : lf_fcat type line of slis_t_fieldcat_alv,
l_cnt type i.
clear : lf_fcat, l_cnt.
Employee Number
add 1 to l_cnt.
lf_fcat-fieldname = 'EMPLID'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 8.
lf_fcat-seltext_l = text-003.
append lf_fcat to it_fcat.
clear lf_fcat.
*Last Name
add 1 to l_cnt.
lf_fcat-fieldname = 'USERNAME'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 20.
lf_fcat-seltext_l = text-004.
append lf_fcat to it_fcat.
*First Name
add 1 to l_cnt.
lf_fcat-fieldname = 'EMPMAIL'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 40.
lf_fcat-seltext_l = text-005.
append lf_fcat to it_fcat.
*Known As
clear lf_fcat.
add 1 to l_cnt.
lf_fcat-fieldname = 'EMPSTATUS'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 10.
lf_fcat-seltext_l = text-006.
append lf_fcat to it_fcat.
clear lf_fcat.
*System UserID
add 1 to l_cnt.
lf_fcat-fieldname = 'COSTCENTER'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 10.
lf_fcat-seltext_l = text-007.
append lf_fcat to it_fcat.
clear lf_fcat.
*EMail ID
add 1 to l_cnt.
lf_fcat-fieldname = 'DEPTDESC'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 8.
lf_fcat-seltext_l = text-008.
append lf_fcat to it_fcat.
clear lf_fcat.
*Employment Status
add 1 to l_cnt.
lf_fcat-fieldname = 'LOC'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 20.
lf_fcat-seltext_l = text-009.
append lf_fcat to it_fcat.
clear lf_fcat.
*Personnel Area
add 1 to l_cnt.
lf_fcat-fieldname = 'TITLE'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 40.
lf_fcat-seltext_l = text-010.
append lf_fcat to it_fcat.
clear lf_fcat.
*Personnel Area Text
clear lf_fcat.
add 1 to l_cnt.
lf_fcat-fieldname = 'HDATE'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 10.
lf_fcat-seltext_l = text-011.
append lf_fcat to it_fcat.
clear lf_fcat.
*Country Grouping text
add 1 to l_cnt.
lf_fcat-fieldname = 'MGRID'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 10.
lf_fcat-seltext_l = text-012.
append lf_fcat to it_fcat.
clear lf_fcat.
*Cost Center
add 1 to l_cnt.
lf_fcat-fieldname = 'MGRNAME'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 20.
lf_fcat-seltext_l = text-013.
append lf_fcat to it_fcat.
clear lf_fcat.
*Employee Group
add 1 to l_cnt.
lf_fcat-fieldname = 'MGMAIL'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 40.
lf_fcat-seltext_l = text-014.
append lf_fcat to it_fcat.
clear lf_fcat.
*Organizational Unit
add 1 to l_cnt.
lf_fcat-fieldname = 'DIV'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 25.
lf_fcat-seltext_l = text-015.
append lf_fcat to it_fcat.
clear lf_fcat.
*Supervisor
add 1 to l_cnt.
lf_fcat-fieldname = 'BUSUNIT'.
lf_fcat-tabname = 'IT_EMPLOYEE'.
lf_fcat-col_pos = l_cnt.
lf_fcat-emphasize = 'X'.
lf_fcat-outputlen = 25.
lf_fcat-seltext_l = text-016.
append lf_fcat to it_fcat.
clear lf_fcat.
endform. " field_catlog
Form display_report
form display_report .
data : l_repid type sy-repid.
clear l_repid.
l_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = l_repid
is_layout = gf_layout
it_fieldcat = it_fcat
i_callback_top_of_page = 'TOP-OF-PAGE'
tables
t_outtab = it_employee
exceptions
program_error = 1
others = 2.
endform. " display_report
Form PREPARE_HEADER
form prepare_header.
data:l_header1(20),
l_header2(60).
data:l_header3(20),
l_header4(60).
l_header1 = 'Met Life Census Data'.
l_header2+40(8) = 'Run Date'.
write sy-datum to l_header2+50(10).
header
gf_header-typ = 'S'.
gf_header-key = l_header1.
gf_header-info = l_header2.
append gf_header to it_top_page.
clear gf_header.
endform. " PREPARE_HEADER
form top-of-page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_top_page.
endform. "TOP-OF-PAGE
*& Form end_of_list_html
output at the end of the list - not in printed output *
FORM END_OF_LIST_HTML USING END TYPE REF TO CL_DD_DOCUMENT.
DATA: LS_TEXT TYPE SDYDO_TEXT_ELEMENT,
L_GRID TYPE REF TO CL_GUI_ALV_GRID,
F(14) TYPE C VALUE 'SET_ROW_HEIGHT'.
LS_TEXT+0(20) = 'Total Employees'.
LS_TEXT+40(10) = g_count.
CALL METHOD END->ADD_TEXT
EXPORTING
TEXT = LS_TEXT
SAP_EMPHASIS = 'STRONG'.
*adds new line (start new line)
CALL METHOD END->NEW_LINE.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 10.
ENDFORM. -
Hi experts,
Can anyone brief me about events which appears in an ALV report.
I want the events only for Alv report not for any report program.
Thanks
Sanket sethi.Hi Sanket,
<b>ALV is Application List viewer.</b>
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
<b>1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT</b>
Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
But either no.7 or No.8 is there in the Program.
How you call this function in your report?
After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
Then use follwing function module.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Prog.name'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA
Sample ALV1:
REPORT Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB .
*Simple example to use ALV and to define the ALV data in an internal
*table
Martin Schlegel, BearingPoint, December 2004
Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing
and feedback
*For a very long time, people gave me the feeling that ALV is a
*complicated tool that is difficult to understand and to use.
*Lately I had to use it and I discovered that ALV is easy to use and
*saves a lot of work:
*ALV will generate the column headings on its own, so one does not need
*to work on headlines and transalation.
*ALV allows the user to select the columns he wants to see, so the user
*does not need to contact a developer for every change he likes to have.
*ALV allows the user to create his own sums, so
*ALV has a simple way to work with internal tables.
*If you really want to save time, use ALV instead of write!
*Please take 30 minutes to explore the following example and see how
*easy it is to use ALV!
*data definition
tables:
marav. "Table MARA and table MAKT
Data to be displayed in ALV
Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.
Other data needed
field to store report name
data i_repid like sy-repid.
field to check table length
data i_lines like sy-tabix.
Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
select-options:
s_matnr for marav-matnr matchcode object MAT1.
start-of-selection.
read data into table imat
select * from marav
into corresponding fields of table imat
where
matnr in s_matnr.
Check if material was found
clear i_lines.
describe table imat lines i_lines.
if i_lines lt 1.
Using hardcoded write here for easy upload
write: /
'No materials found.'.
exit.
endif.
end-of-selection.
Now, we start with ALV
To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
report source, including this report.
The only problem one might have is that the report and table names
need to be in capital letters. (I had it )
Store report name
i_repid = sy-repid.
Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
*explanations:
I_PROGRAM_NAME is the program which calls this function
I_INTERNAL_TABNAME is the name of the internal table which you want
to display in ALV
I_INCLNAME is the ABAP-source where the internal table is defined
(DATA....)
CT_FIELDCAT contains the Fieldcatalouge that we need later for
ALV display
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
*This was the fieldcatlogue
And now, we are ready to display our list
Call for ALV list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
I_CALLBACK_PROGRAM = i_repid
IT_FIELDCAT = int_fcat
I_SAVE = 'A'
TABLES
T_OUTTAB = imat
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*explanations:
I_CALLBACK_PROGRAM is the program which calls this function
IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
now the data definition needed for display
I_SAVE allows the user to save his own layouts
T_OUTTAB contains the data to be displayed in ALV
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.
Samle ALV2:
*& Report ZZ_22038_22098_002 *
*& This is an Interactive ALV report, where on line slection we can see
*& the secondry list
REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
MESSAGE-ID ZZ_9838 .
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*& Form BUILD_FIELDCATLOG
Fieldcatalog has all the field details from ekko
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*& Form EVENT_CALL
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "EVENT_CALL
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form data_retrieval
retreiving values from the database table ekko
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*& Form bUild_listheader
text
-->I_LISTHEADEtext
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*& Form display_alv_report
text
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
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. "display_alv_report
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*& Form BUILD_FIELDCATLOG_EKPO
text
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*& Form event_call_ekpo
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_ekpo
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form TOP_OF_PAGE
text
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = '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_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
<b>Reward Points if Useful</b>
Regards
Gokul -
About double click event in ALV report
Hi all,
I want to program a double-click event in ALV reprot.
I am not suppose to use module pool approach for the same.
If a user double clicks on the any of the row of ALV report, the transaction should get called.
Again, I am using function 'REUSE_ALV_GRID_DISPLAY' for displaying ALV.
Can you please help me to solve this?
Thanks,
-SiddhiHi Sidhi,
You can do it easily by using Reuse_ALV_GRID_DISPALY.
The User Command subroutine which you pass to this function module in that you can check which field is selected and what is the value of that and also you can get the table index.
I am giving you a code example where interactivity of ALV report is done .
*& Report ZRAIL_LOT_REPORT
REPORT zrail_lot_report.
TABLES :qals,aufk.
TYPE-POOLS:slis.
TYPES:BEGIN OF x_lot,
sel(1) TYPE c, "SELECTION
prueflos TYPE qals-prueflos, "INSPECTION LOT NUMBER
werk TYPE qals-werk, "PLANT
losmenge TYPE qals-losmenge, "LOT QUANTITY
mengeneinh TYPE qals-mengeneinh, "BASE UNIT OF MEASURE FOR THE INSPECTION LOT QUANTITY
matnr TYPE qals-matnr, " MATERIAL NO. ATTACHED TO ORDER
zzequnr TYPE qals-zzequnr, "EQUIPMENT NO.
zzassembly TYPE qals-zzassembly, "ASSEMBLY
herkunft TYPE qals-herkunft, "INSPECTION LOT ORIGIN
aufnr TYPE qals-aufnr, "ORDER NO.
sttxt TYPE qals_d02-sttxt, "LOT STATUS
objnr TYPE qals-objnr, "OBJECT NUMBER
enstehdat TYPE qals-enstehdat, "lot creation date
pruefer TYPE qamr-pruefer, "Name of the Inspector
END OF x_lot.
TYPES:BEGIN OF x_ordmat,
aufnr TYPE aufk-aufnr, "Order No.
equnr TYPE afih-equnr, "Equipment No. attached to Order
zmatnr TYPE aufk-zmatnr, "Material No. attached to Order
bautl TYPE afih-bautl, "Assembly attached to Order
END OF x_ordmat.
TYPES:BEGIN OF x_status,
objnr TYPE jest-objnr,
stat TYPE jest-stat,
txt04 TYPE tj02t-txt04,
END OF x_status.
DATA:it_qals TYPE STANDARD TABLE OF x_lot,
wa_qals TYPE x_lot.
DATA:it_ordmat TYPE TABLE OF x_ordmat,
wa_ordmat TYPE x_ordmat.
DATA:it_status TYPE STANDARD TABLE OF x_status,
wa_status TYPE x_status.
DATA:mytabix TYPE sy-tabix.
DATA: wa_layout TYPE slis_layout_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE TABLE OF slis_fieldcat_alv,
it_fcat TYPE TABLE OF slis_fieldcat_alv.
DATA:mytabix1 TYPE sy-tabix.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_werks FOR qals-werk,
s_zmatnr FOR aufk-zmatnr,
s_assbly FOR qals-zzassembly,
s_equnr FOR qals-zzequnr,
s_lotor FOR qals-herkunft,
s_lotdat FOR qals-enstehdat.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
s_lotdat-low = sy-datum - 7.
s_lotdat-high = sy-datum.
APPEND s_lotdat.
START-OF-SELECTION.
PERFORM get_data_qals.
PERFORM build_fieldcat.
PERFORM display_data.
EXIT.
END-OF-SELECTION.
*& Form get_data_qals
text
--> p1 text
<-- p2 text
FORM get_data_qals .
IF it_qals[] IS INITIAL.
SELECT a~prueflos
a~werk
a~losmenge
a~mengeneinh
a~zzequnr
a~zzassembly
a~herkunft
a~aufnr
a~objnr
a~matnr
a~enstehdat
b~pruefer
FROM qals AS a INNER JOIN qamr AS b
ON aprueflos = bprueflos
INTO CORRESPONDING FIELDS OF TABLE it_qals
WHERE werk IN s_werks
AND zzassembly IN s_assbly
AND zzequnr IN s_equnr
AND herkunft IN s_lotor
AND enstehdat IN s_lotdat.
ENDIF.
IF it_ordmat[] IS INITIAL.
SELECT a~aufnr
a~zmatnr
b~bautl
b~equnr
FROM aufk AS a INNER JOIN afih AS b
ON aaufnr = baufnr
INTO CORRESPONDING FIELDS OF TABLE it_ordmat FOR ALL ENTRIES IN it_qals
WHERE a~aufnr = it_qals-aufnr
AND zmatnr IN s_zmatnr.
ENDIF.
IF it_status[] IS INITIAL.
SELECT a~objnr
a~stat
b~txt04
FROM tj02t AS b
INNER JOIN jest AS a ON bistat = astat
INTO CORRESPONDING FIELDS OF TABLE it_status FOR ALL ENTRIES IN it_qals
WHERE a~objnr = it_qals-objnr
AND b~spras = sy-langu
AND a~inact = space.
ENDIF.
LOOP AT it_qals INTO wa_qals.
mytabix = sy-tabix.
READ TABLE it_ordmat INTO wa_ordmat WITH KEY aufnr = wa_qals-aufnr.
IF sy-subrc = 0.
IF wa_qals-herkunft = '14'.
wa_qals-matnr = wa_ordmat-zmatnr.
wa_qals-zzequnr = wa_ordmat-equnr.
wa_qals-zzassembly = wa_ordmat-bautl.
MODIFY it_qals FROM wa_qals INDEX mytabix TRANSPORTING matnr zzassembly zzequnr.
ENDIF.
ENDIF.
LOOP AT it_status INTO wa_status WHERE objnr = wa_qals-objnr.
CONCATENATE wa_qals-sttxt wa_status-txt04 INTO wa_qals-sttxt SEPARATED BY space.
CLEAR :wa_status.
ENDLOOP.
MODIFY it_qals FROM wa_qals INDEX mytabix TRANSPORTING sttxt.
CLEAR :wa_qals,wa_ordmat,mytabix.
ENDLOOP.
IF s_zmatnr[] IS NOT INITIAL.
DELETE it_qals WHERE matnr IS INITIAL.
ENDIF.
ENDFORM. " get_data_qals
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM build_fieldcat .
wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-box_fieldname = 'SEL'.
wa_layout-box_tabname = 'IT_QALS'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME =
i_internal_tabname = 'IT_QALS'
i_structure_name = 'QALS_D02'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = it_fieldcat
IF sy-subrc = 0.
LOOP AT it_fieldcat INTO wa_fieldcat.
CASE wa_fieldcat-fieldname .
WHEN 'PRUEFLOS'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO it_fcat.
WHEN 'WERK'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fcat.
WHEN 'LOSMENGE'.
wa_fieldcat-col_pos = 4.
wa_fieldcat-no_out = ''.
APPEND wa_fieldcat TO it_fcat.
WHEN 'MENGENEINH'.
wa_fieldcat-col_pos = 5.
wa_fieldcat-no_out = ''.
APPEND wa_fieldcat TO it_fcat.
WHEN 'ZZEQUNR'.
wa_fieldcat-col_pos = 6.
wa_fieldcat-no_out = ''.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO it_fcat.
WHEN 'ZZASSEMBLY'.
wa_fieldcat-col_pos = 7.
wa_fieldcat-no_out = ''.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO it_fcat.
WHEN 'HERKUNFT'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fcat.
WHEN 'AUFNR'.
wa_fieldcat-col_pos = 9.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO it_fcat.
WHEN 'ENSTEHDAT'."enstehdat
wa_fieldcat-col_pos = 10.
APPEND wa_fieldcat TO it_fcat.
WHEN 'STTXT'.
wa_fieldcat-col_pos = 12.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat TO it_fcat.
WHEN OTHERS.
ENDCASE.
CLEAR wa_fieldcat.
ENDLOOP.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_QALS'.
wa_fieldcat-col_pos = 2.
wa_fieldcat-ref_tabname = 'AUFK'.
wa_fieldcat-hotspot = 'X'.
wa_fieldcat-seltext_l = 'Material No.'.
APPEND wa_fieldcat TO it_fcat.
wa_fieldcat-fieldname = 'PRUEFER'.
wa_fieldcat-tabname = 'IT_QALS'.
wa_fieldcat-col_pos = 11.
wa_fieldcat-ref_tabname = 'QAMR'.
wa_fieldcat-seltext_l = 'Name of the Inspector'.
APPEND wa_fieldcat TO it_fcat.
ENDIF.
ENDFORM. " build_fieldcat
*& Form display_data
text
--> p1 text
<-- p2 text
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZRAIL_LOT_REPORT'
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
is_layout = wa_layout
it_fieldcat = it_fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
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 =
TABLES
t_outtab = it_qals
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. " display_data
*& Form USER_COMMAND
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM user_command USING r_ucomm TYPE sy-ucomm rs_selfield TYPE slis_selfield.
CASE rs_selfield-fieldname .
WHEN 'PRUEFLOS'.
SET PARAMETER ID 'QLS' FIELD rs_selfield-value.
CALL TRANSACTION 'QA03' AND SKIP FIRST SCREEN.
WHEN 'ZZEQUNR'.
SET PARAMETER ID 'EQN' FIELD rs_selfield-value.
CALL TRANSACTION 'IE03' AND SKIP FIRST SCREEN.
WHEN 'ZMATNR'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'ZZASSEMBLY'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'AUFNR'.
SET PARAMETER ID 'ANR' FIELD rs_selfield-value.
CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN.
WHEN 'STTXT'.
MOVE rs_selfield-tabindex TO mytabix1.
PERFORM show_status.
ENDCASE.
ENDFORM. "USER_COMMAND
*& Form show_status
text
--> p1 text
<-- p2 text
FORM show_status .
DATA:it_systat TYPE TABLE OF bapi2045ss,
wa_sysstat TYPE bapi2045ss,
it_bapi2045us TYPE TABLE OF bapi2045us.
DATA:it_fsys TYPE TABLE OF slis_fieldcat_alv.
DATA:insplot TYPE bapi2045d_il0-insplot.
DATA:language TYPE bapi2045la.
CLEAR wa_qals.
READ TABLE it_qals INTO wa_qals INDEX mytabix1.
insplot = wa_qals-prueflos.
language-langu = sy-langu.
CALL FUNCTION 'BAPI_INSPLOT_GETSTATUS'
EXPORTING
number = insplot
language = language
TABLES
system_status = it_systat
user_status = it_bapi2045us.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'ZRAIL_LOT_REPORT'
i_internal_tabname = 'IT_SYSTAT'
i_structure_name = 'BAPI2045SS'
CHANGING
ct_fieldcat = it_fsys.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZRAIL_LOT_REPORT'
it_fieldcat = it_fsys
TABLES
t_outtab = it_systat.
ENDFORM. " show_status
IIn the subrouitne the User command the Parameter rs_selfield will give you the selected or clicked field and its value its record no .
I hope this will help you. -
Mouse over events on alv report?
Hello,
i want to make mouse over event for rows of a alv report.When mouse is on a row there will be shown explanations.
how can i do this?
thanks inn advance.Cem ,
Please follow the code mentioned in the links below :
Hotspot in ALV grid
http://wiki.scn.sap.com/wiki/display/Snippets/Interactive?original_fqdn=wiki.sdn.sap.com
Thanks
Ankit -
In ALV reports how double click event works?
in ALV reports how double click event works? Explain in detail.....
hi,
last lines is used for clicking
*& Report Z_SWAS_FUNCTIONAL
report z_swas_functional.
tables: qmel,viqmel,iloa,afko.
-- global data declerations--
data: ok_code like sy-ucomm,
gt_itab type table of zfunctional,
t_output type table of zfunctional,
g_container type scrfname value 'CUSTOM_CONTROL',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container,
e_row type lvc_s_row,
e_column type lvc_s_col,
es_row_no type lvc_s_roid.
*CLASS DECLARATION
class z_functional definition.
public section.
class-methods : handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
endclass.
*CLASS IMPLEMENTATION
class z_functional implementation.
method handle_double_click.
perform handle_double_click using e_row e_column es_row_no.
endmethod.
endclass.
*CODE FOR SELECTION SCREEN
selection-screen begin of block 84433 with frame title text-t01.
parameters : n_number like viqmel-qmnum,
n_type like qmel-qmart,
f_loca like iloa-tplnr,
name like qmel-qmnam.
selection-screen end of block 84433.
screen validation event *
at selection-screen on n_number.
select single *
from viqmel
where qmnum eq n_number.
if sy-subrc ne 0.
MESSAGE 'NOTIFICATION NUMBER DOESNOT EXIST' TYPE 'E'.
endif.
select qmart from qmel into qmel where qmart eq N_TYPE.
endselect.
if sy-subrc ne 0.
MESSAGE 'NOTIFICATION TYPE DOES NOT EXIST' TYPE 'E'.
endif.
*START OF SELECTION EVENT
start-of-selection.
perform fetchdata.
end-of-selection.
*Call screen event
call screen 100.
*PERFORM DISPLAY.
*& Form FETCHDATA
text
--> p1 text
<-- p2 text
form fetchdata .
*SELECT VIQMEL~QMNUM VIQMEL~QMTXT VIQMEL~QMDAT VIQMEL~LTRMN VIQMEL~PRIOK
VIQMELBEZDT VIQMELAUFNR VIQMELTPLNR AFKOGLTRP into corresponding fields of table GT_ITAB
FROM VIQMEL INNER JOIN AFKO ON VIQMELAUFNR = AFKOAUFNR
WHERE VIQMELQMNUM IN N_NUMBER and VIQMELQMART IN N_TYPE AND VIQMEL~QMNAM IN NAME.
call function 'ZSWAS_TEST'
exporting
qmnum = n_number
qmart = n_type
tplnr = f_loca
qmnam = name
tables
output = gt_itab
if sy-subrc ne 0.
message e000(z84433_msg_class).
endif.
endform. " FETCHDATA
*& Module STATUS_0100 OUTPUT
text
module status_0100 output.
set pf-status 'MAIN'.
SET TITLEBAR 'xxx'.
*creating custom container and grid instance
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object grid1
exporting i_parent = g_custom_container.
call method grid1->set_table_for_first_display
exporting
i_structure_name = 'ZFUNCTIONAL'
changing
it_outtab = gt_itab.
*set handler events
set handler z_functional=>handle_double_click for grid1.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module user_command_0100 input.
case ok_code.
when 'EXIT'.
perform exit_program.
endcase.
clear ok_code.
endmodule. " USER_COMMAND_0100 INPUT
*& Form EXIT_PROGRAM
text
--> p1 text
<-- p2 text
form exit_program .
leave program.
endform. " EXIT_PROGRAM
*& Form handle_double_click
text
-->P_E_ROW text
-->P_E_COLUMN text
-->P_ES_ROW_NO text
form handle_double_click using e_row type lvc_s_row
e_column type lvc_s_col
es_row_no type lvc_s_roid.
data: t_output type zfunctional.
read table gt_itab into t_output index e_row-index .
if sy-subrc = 0 and e_column-fieldname eq 'QMNUM'.
set parameter id 'K01' field t_output-qmnum.
call transaction 'ZSMART' and skip first screen .
endif.
endform. " handle_double_click
regards,
swaroop. -
What are main events in that are used in ALV reports
hi gurus
what are main events in that are used in ALV reports....
regards
baskarhi
i think this will help u.
Events in alv and their FM The main events in alv and their FM and why we use these:
1. SLIS_PRINT_ALV.
2. SLIS_T_LISTHEADER.
3. SLIS_T_EVENT.
4. SLIS_T_SORTINFO_ALV.
5. SLIS_T_LAYOUT_ALV.
6. SLIS_T_FIELDCAT_ALV.
and in classic reports what is the sequence of events: === Events are
At selection-screen output.
Initialization.
At selection-screen on field
At selection-screen on end of field
At selection-screen on Radiobutton Group R1. (If you have any radio buttons)
At selection-screen on block b1. (If you have any blocks)
Start-of-selection.
Get node. (if the data is retreived from a logical database)
Get node late. (if the data is retreived from a logical database)
Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)
end-of-selection.
and fuction modules are
LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information. EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation. These events are captured by this FM. LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style. FIELDCAT - These are used to populate the List header. We can change them according to our req.
User-defined Text Output Event
Application
print_end_of_list
Define output text to be printed at the end of the entire list
print_top_of_list
Define output text to be printed at the beginning of the entire list
print_end_of_page
Define output text to be printed at the end of each page
print_top_of_page
Define output text to be printed at the beginning of each page
subtotal_text
Define self-defined subtotals texts
Mouse-controlled Actions in the Grid Control Event
Application
button_click
Query a click on a pushbutton in the ALV Grid Control
double_click
Query a double-click on a cell of the ALV Grid control
hotspot_click
Query a hotspot click on columns defined for this purpose in advance
onDrag
Collect information when elements of the ALV Grid Control are dragged
onDrop
Process information when elements of the ALV Grid Control are dropped
onDropComplete
Perform final actions after successful Drag&Drop
onDropGetFlavor
Distinguish between options for Drag&Drop behavior
Processing of Self-defined and Standard Functions Event
Application
before_user_command
Query self-defined and standard function codes
user_command
Query self-defined function codes
after_user_command
Query self-defined and standard function codes
Definition of Self-defined Functions Event
Application
toolbar
Change, delete or add GUI elements in the toolbar
menu_button
Define menus for menu buttons in the toolbar
context_menu_request
Change context menu
onf1
Define self-defined F1 help
All of these can be found under type group SLIS.
Events
SLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',
SLIS_EV_REPREP_SEL_MODIFY TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',
SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
SLIS_EV_DATA_CHANGED TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',
SLIS_EV_TOP_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',
SLIS_EV_END_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',
SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME
VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME
VALUE 'FOREIGN_END_OF_PAGE',
SLIS_EV_PF_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
SLIS_EV_LIST_MODIFY TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',
SLIS_EV_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
SLIS_EV_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',
SLIS_EV_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
SLIS_EV_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',
SLIS_EV_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.
with regards
sravani
award points if found useful. -
Regarding events in alv reports
Dear Friends,
Sorry for this post, Events not triggering in alv reports. There is no errors and no warnings.I am using interactive reports. Please tell me where could be i went wrong. It is displaying basic list information but with out events triggering.Hi,
go through the following piece of code..........
*& Form EVENT_CALL
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "EVENT_CALL
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
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. "display_alv_report
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*& Form event_call_ekpo
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_ekpo
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form TOP_OF_PAGE
text
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
Thanks
Ashu -
Reg. Events in ALV Reports
Hi all,
Can anybody send me the sample program, related to Events on ALV Reports.
Use ful answers rewards more.Hi Raj,
Here I'm sending 2 programs with user command on grid and list.
along with interaction and commentory boxes and all.
separate box ****************
TABLES: KNA1,VBAK,VBAP.
TYPE-POOLS: SLIS.
SELECT-OPTIONS: CUST FOR KNA1-KUNNR.
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME LIKE KNA1-NAME1,
LAND1 LIKE KNA1-LAND1,
END OF ITAB.
DATA: BEGIN OF JTAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
NETWR LIKE VBAK-NETWR,
END OF JTAB.
DATA: BEGIN OF KTAB OCCURS 0,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
END OF KTAB.
DATA: REPID LIKE SY-REPID,
*INTERNAL TABLE AND STRUCTURE.
*SLIS_T_FIELDCAT_ALV IS AN INTERNAL TABLE.
*SLIS_FIELDCAT_ALV IS AN STRUCTURE.
F_KNA11 TYPE SLIS_T_FIELDCAT_ALV,
F_KNA1 TYPE SLIS_FIELDCAT_ALV,
F_VBAK1 TYPE SLIS_T_FIELDCAT_ALV,
F_VBAK TYPE SLIS_FIELDCAT_ALV,
F_VBAP1 TYPE SLIS_T_FIELDCAT_ALV,
F_VBAP TYPE SLIS_FIELDCAT_ALV,
I_EVENTS TYPE SLIS_T_EVENT,
S_EVENTS TYPE SLIS_ALV_EVENT.
PERFORM GET-VAL.
REPID = SY-REPID.
SELECT KUNNR NAME1 LAND1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR IN
CUST
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = F_KNA11
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = ITAB.
GET VAL
FORM GET-VAL.
F_KNA1-FIELDNAME = 'KUNNR'.
F_KNA1-REF_TABNAME = 'KNA1'.
F_KNA1-REF_FIELDNAME = 'KUNNR'.
APPEND F_KNA1 TO F_KNA11.
F_KNA1-FIELDNAME = 'NAME'.
F_KNA1-REF_TABNAME = 'KNA1'.
F_KNA1-REF_FIELDNAME = 'NAME1'.
APPEND F_KNA1 TO F_KNA11.
F_KNA1-FIELDNAME = 'LAND1'.
F_KNA1-REF_TABNAME = 'KNA1'.
F_KNA1-REF_FIELDNAME = 'LAND1'.
APPEND F_KNA1 TO F_KNA11.
F_VBAK-FIELDNAME = 'VBELN'.
F_VBAK-REF_TABNAME = 'VBAK'.
F_VBAK-REF_FIELDNAME = 'VBELN'.
APPEND F_VBAK TO F_VBAK1.
F_VBAK-FIELDNAME = 'NETWR'.
F_VBAK-REF_TABNAME = 'VBAK'.
F_VBAK-REF_FIELDNAME = 'NETWR'.
F_VBAK-DO_SUM = 'X'.
APPEND F_VBAK TO F_VBAK1.
F_VBAP-FIELDNAME = 'POSNR'.
F_VBAP-REF_TABNAME = 'VBAP'.
F_VBAP-REF_FIELDNAME = 'POSNR'.
APPEND F_VBAP TO F_VBAP1.
F_VBAP-FIELDNAME = 'MATNR'.
F_VBAP-REF_TABNAME = 'VBAP'.
F_VBAP-REF_FIELDNAME = 'MATNR'.
APPEND F_VBAP TO F_VBAP1.
S_EVENTS-NAME = 'USER_COMMAND'.
S_EVENTS-FORM = 'VAL'.
APPEND S_EVENTS TO I_EVENTS.
ENDFORM.
FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
DATA: CUS(10) TYPE N,
SALNO(10) TYPE N,
MAT(10) TYPE C.
display lists
IF SEL-FIELDNAME = 'KUNNR'.
CUS = SEL-VALUE.
SELECT VBELN NETWR FROM VBAK INTO TABLE JTAB WHERE KUNNR = CUS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = F_VBAK1
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = JTAB.
ENDIF.
IF SEL-FIELDNAME = 'VBELN'.
SALNO = SEL-VALUE.
SELECT POSNR MATNR FROM VBAP INTO TABLE KTAB WHERE VBELN = SALNO.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = ' ITEM DETAILS'
I_TABNAME = VBAP
IT_FIELDCAT = F_VBAP1
I_CALLBACK_PROGRAM = REPID
IMPORTING
ES_SELFIELD = SEL
TABLES
T_OUTTAB = KTAB.
ENDIF.
IF SEL-FIELDNAME = 'MATNR'.
MAT = SEL-VALUE.
SET PARAMETER ID 'MAT' FIELD MAT.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM.
Grid Display ***************
TYPE-POOLS: SLIS.
TABLES: KNA1.
*DATA: ITAB TYPE STANDARD TABLE OF ZJKNA1 WITH HEADER LINE.
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR TYPE KUNNR,
NAME1 TYPE KNA1-NAME1,
END OF ITAB.
DATA: JTAB LIKE ITAB OCCURS 0 WITH HEADER LINE.
DATA: IT_TOP TYPE SLIS_T_LISTHEADER.
DATA: W_TOP TYPE SLIS_LISTHEADER.
DATA: IT_EVENT TYPE SLIS_T_EVENT.
DATA: W_EVENT TYPE SLIS_ALV_EVENT.
W_EVENT-NAME = 'TOP_OF_PAGE'.
W_EVENT-FORM = 'TOPS'.
APPEND W_EVENT TO IT_EVENT.
W_EVENT-NAME = 'USER_COMMAND'.
W_EVENT-FORM = 'UCOM'.
APPEND W_EVENT TO IT_EVENT.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV.
*S_LAYOUT-NO_VLINE = 'X'.
S_LAYOUT-ZEBRA = 'X'.
S_LAYOUT-NO_COLHEAD = ''.
S_LAYOUT-TOTALS_ONLY = 'TL'.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: W_LISTHEADER TYPE SLIS_LISTHEADER.
W_LISTHEADER-TYP = 'H'.
W_LISTHEADER-KEY = 'THIS IS LIST'.
APPEND W_LISTHEADER TO IT_LISTHEADER.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-FIELDNAME = 'KUNNR'.
W_FIELDCAT-TABNAME = 'ITAB'.
W_FIELDCAT-SELTEXT_M = 'CUST. NO'.
W_FIELDCAT-HOTSPOT = 'X'.
APPEND W_FIELDCAT TO IT_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 2.
W_FIELDCAT-FIELDNAME = 'NAME1'.
W_FIELDCAT-TABNAME = 'ITAB'.
W_FIELDCAT-SELTEXT_M = 'CUST. NAME'.
W_FIELDCAT-OUTPUTLEN = 30.
APPEND W_FIELDCAT TO IT_FIELDCAT.
CLEAR W_FIELDCAT.
SELECT KUNNR NAME1 FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE ITAB
UP TO 50 ROWS.
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 = W_LISTHEADER
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ENJOY.BMP'
I_GRID_TITLE = 'THIS IS MY FIRST ALV REPORT'
I_GRID_SETTINGS = W_LISTHEADER
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = IT_EVENT
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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
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.
**& Form TOPS
text
--> p1 text
<-- p2 text
FORM TOPS .
REFRESH IT_TOP.
W_TOP-TYP = 'H'.
*W_TOP-KEY = 'JAGAN'.
W_TOP-INFO = 'THIS IS SAMPLE HEADER'.
APPEND W_TOP TO IT_TOP.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_TOP
I_LOGO = 'IDLOGO1'
I_END_OF_LIST_GRID =
ENDFORM. " TOPS
*& Form UCOM
text
--> p1 text
<-- p2 text
FORM UCOM USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
DATA: CUS(10) TYPE N VALUE '0000000000'.
CUS = SEL-VALUE.
REFRESH ITAB.
SELECT KUNNR NAME1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR = CUS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = ITAB.
ENDFORM. " UCOM -
WHAT ARE EVENTS IN AN ALV REPORT ?
WHAT ARE EVENTS IN AN ALV REPORT ? PLEASE EXPLAIN HOW TO MAKE AN ALV REPORT AND WHAT THE EVENTS DO ?
BEST REGARDS,
RYANEvents are driven by user interaction...Like...
DATA_CHANGED
DOUBLE_CLICK
ONF4
Here's a sample code of OO ALV using events...
*& Report ZDUMMY_ATG_2
REPORT zdummy_atg_2.
TYPES: BEGIN OF ty_scarr,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
currcode TYPE scarr-currcode,
END OF ty_scarr.
DATA: t_spfli TYPE STANDARD TABLE OF spfli,
w_spfli LIKE LINE OF t_spfli,
lt_f4 TYPE lvc_t_f4 WITH HEADER LINE,
return_tab TYPE STANDARD TABLE OF ddshretval WITH HEADER LINE,
t_custom_scarr TYPE STANDARD TABLE OF ty_scarr WITH HEADER LINE,
t_stable TYPE STANDARD TABLE OF lvc_s_stbl WITH HEADER LINE.
FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,
<fs_scarr> LIKE LINE OF t_custom_scarr.
CLASS cl_gui_object DEFINITION LOAD.
CLASS lcl_event_receiver DEFINITION DEFERRED.
INCLUDE <cl_alv_control>.
DATA: ok_code LIKE sy-ucomm,
gt_fieldcat TYPE lvc_t_fcat,
gt_sort TYPE lvc_t_sort,
event_receiver TYPE REF TO lcl_event_receiver,
gs_layout TYPE lvc_s_layo,
mycontainer TYPE scrfname VALUE 'CUSTOM_ALV',
custom_container TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
gs_variant TYPE disvariant,
x_save,
w_error TYPE c,
l_valid(1) TYPE c.
* CLASS LCL_EVENT_RECEIVER DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_f4_help
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname es_row_no er_event_data.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM data_changed USING er_data_changed.
ENDMETHOD. "HANDLE_DATA_CHANGED
METHOD handle_f4_help.
PERFORM handle_onf4 USING e_fieldname es_row_no.
er_event_data->m_event_handled = 'X'.
ENDMETHOD. "HANDLE_F4_HELP
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
*& START-OF-SELECTION *
START-OF-SELECTION.
PERFORM cargar_customs.
PERFORM cargar_datos.
PERFORM fill_layout.
PERFORM fill_catalog.
PERFORM llamar_alv.
CALL SCREEN 0100.
*& Form CARGAR_DATOS *
FORM cargar_datos.
SELECT mandt carrid connid countryfr cityfrom
airpfrom countryto cityto airpto
fltime deptime arrtime distance
distid fltype period
INTO TABLE t_spfli
FROM spfli.
ENDFORM. " CARGAR_DATOS
*& Form CARGAR_CUSTOMS *
FORM cargar_customs.
SELECT carrid carrname currcode
INTO TABLE t_custom_scarr
FROM scarr.
ENDFORM. " CARGAR_DATOS
*& Form FILL_LAYOUT *
FORM fill_layout.
gs_layout-sel_mode = 'A'.
ENDFORM. " FILL_LAYOUT
*& Form FILL_CATALOG *
FORM fill_catalog.
DATA: gs_fieldcat TYPE lvc_s_fcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 1.
gs_fieldcat-fieldname = 'CARRID'.
gs_fieldcat-reptext = 'Compañia'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-f4availabl = 'X'.
gs_fieldcat-outputlen = '8'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 2.
gs_fieldcat-fieldname = 'CONNID'.
gs_fieldcat-reptext = 'Conexión'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '8'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 3.
gs_fieldcat-fieldname = 'COUNTRYFR'.
gs_fieldcat-reptext = 'País'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '4'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 4.
gs_fieldcat-fieldname = 'CITYFROM'.
gs_fieldcat-reptext = 'Ciudad Salida'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = space.
gs_fieldcat-outputlen = '20'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 5.
gs_fieldcat-fieldname = 'AIRPFROM'.
gs_fieldcat-reptext = 'Arp. Salida'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '10'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 6.
gs_fieldcat-fieldname = 'COUNTRYTO'.
gs_fieldcat-reptext = 'País'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = 'X'.
gs_fieldcat-outputlen = '4'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-col_pos = 7.
gs_fieldcat-fieldname = 'CITYTO'.
gs_fieldcat-reptext = 'Ciudad Llegada'.
gs_fieldcat-tabname = 'T_SPFLI'.
gs_fieldcat-edit = space.
gs_fieldcat-outputlen = '20'.
APPEND gs_fieldcat TO gt_fieldcat.
ENDFORM. " FILL_CATALOG
*& Form LLAMAR_ALV *
FORM llamar_alv.
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = mycontainer
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = custom_container.
CREATE OBJECT event_receiver.
lt_f4-fieldname = 'CARRID'.
lt_f4-register = 'X' .
lt_f4-getbefore = 'X' .
lt_f4-chngeafter = 'X' .
APPEND lt_f4.
SET HANDLER event_receiver->handle_data_changed FOR grid1.
SET HANDLER event_receiver->handle_f4_help FOR grid1.
CALL METHOD grid1->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[].
IF sy-batch IS INITIAL.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDIF.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = x_save
i_default = 'X'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort[]
it_outtab = t_spfli[].
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. " LLAMAR_ALV
*& Form HANDLE_ONF4 *
FORM handle_onf4 USING p_e_fieldname
p_es_row_no STRUCTURE lvc_s_roid.
CASE p_e_fieldname.
WHEN 'CARRID'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID'
value_org = 'S'
TABLES
value_tab = t_custom_scarr
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF NOT return_tab[] IS INITIAL.
READ TABLE return_tab INDEX 1.
READ TABLE t_spfli INDEX p_es_row_no-row_id
ASSIGNING <fs_spfli>.
<fs_spfli>-carrid = return_tab-fieldval.
CALL METHOD grid1->refresh_table_display
EXPORTING
is_stable = t_stable.
ENDIF.
ENDCASE.
ENDFORM. " HANDLE_ONF4
*& Module STATUS_0100 OUTPUT *
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STATUS'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT *
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK' OR 'STOP' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'SAVE'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid EQ 'X'.
PERFORM grabar_datos.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form DATA_CHANGED *
FORM data_changed USING rr_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA: w_new,
ls_mod_cells TYPE lvc_s_modi,
ls_cells TYPE lvc_s_modi.
DATA: l_carrid TYPE spfli-carrid.
CLEAR l_carrid.
LOOP AT rr_data_changed->mt_good_cells INTO ls_mod_cells.
CASE ls_mod_cells-fieldname.
WHEN 'CARRID'.
CALL METHOD rr_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
IMPORTING
e_value = l_carrid.
IF l_carrid IS INITIAL.
CALL METHOD rr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = 'Seleccione algún código'
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
w_error = 'X'.
ELSE.
READ TABLE t_custom_scarr WITH KEY carrid = l_carrid
ASSIGNING <fs_scarr>.
IF sy-subrc NE 0.
CALL METHOD rr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = 'Código ingresado no existe'
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
w_error = 'X'.
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
ENDFORM. " DATA_CHANGED
*& Form GRABAR_DATOS *
FORM grabar_datos.
LOOP AT t_spfli ASSIGNING <fs_spfli>.
w_spfli = <fs_spfli>.
MODIFY spfli FROM w_spfli.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDLOOP.
ENDFORM. " GRABAR_DATOS
Greetings,
Blag. -
What are events in ALV report and explain how sorting is done alv report
events in alv report and sorting in alv report
Moderator Message: Search before posting.
Edited by: kishan P on Dec 21, 2011 11:13 AMHi Raja,
<<content and links removed by moderator>>
PavanKumar.G
Edited by: kishan P on Dec 21, 2011 11:12 AM
Maybe you are looking for
-
AP Trial Balance Query.
I'm trying to re-create the AP Trial Balance report so I can add additional info for the Accountants allowing them to analyze the data better. we are in R12.1.3 Can any anyone provide query that gives the same data as 'Accounts Payable Trial Balance'
-
IMac DV SE 400 chimes, gives flashing question mark. Hard drive bad?
My G3 iMac DV SE 400 will not start up. This is what happens: 1. Startup chime 2. Hard drive starts to spin 3. Hard drive "clicks" once 4. Flashing question mark on screen I tried resetting the PRAM and disconnecting everything like it says in the ma
-
Would anybody know if a PDF file can be imported into an excel spreadsheet? if so HOW?
-
Hey guys, I have a MacBook and im just not sure if I should sell it and buy a MBP. The reason is because I am planning to start video editing with FCE 4 also buying a video camera?I just think my MB could not handle the editing? Thanks, Josh
-
All, We have set the following parameters in our SAP system but still get an error when sending an email to the SAP system. The parameters are: icm/server_port_1 = PROT=SMTP,PORT=8025 is/SMTP/virt_host_0 = *:8025; In SICF we have the SMTP node active