Reagrding OO ALV
Hi All,
I have developed one editable ALV report using methods.
After editing the values when i press the save button iam getting the error
like ( itab-fieldname not in the ABAP dictionary ).
How to over come this problem.
Hi Mahesh
I think you are trying to pass the itab-field to some database table or using it in some reference ,
instead of using 'itab-field' try to use 'field'.
I hope i understood your problem correctly.
Check in this link for some useful info on editable fields.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
Regards
Neha
Edited by: Neha Shukla on Nov 26, 2008 8:41 AM
Similar Messages
-
Really urgent: reagrding alv format for like (internal tables)
Hi,
I making a report in which i am using the concept of 2 internal tables and i am usnig the concept of likes in a internal table .
for instance,
DATA : BEGIN OF ITAB OCCURS 0,
ITEMID LIKE CHVW-MATNR,
WERKS LIKE CHVW-WERKS,
CHARG LIKE CHVW-CHARG,
SHKZG LIKE CHVW-SHKZG,
MENGE LIKE CHVW-MENGE,
MEINS LIKE CHVW-MEINS,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
MATNR TYPE BSEG-MATNR,
LIFNR TYPE BSEG-LIFNR,
AUGDT TYPE BSEG-AUGDT,
WRBTR TYPE BSEG-WRBTR,
END OF IT_BSEG.
and i am able to create ALV for 1 itab only as i had declared all fields in a 1 itab ,but now i have to declare 1 more itab and i dont know how to perform ALV with 2 itabs..
Plzz help me out as it is really urgent to me.
Edited by: ric .s on Apr 22, 2008 11:45 AM
Edited by: ric .s on Apr 23, 2008 7:21 AM
Edited by: ric .s on Apr 23, 2008 7:55 AMHi Ric,
Yes, You can .
Check the sample ALV program which helps u in displaying output using ALV . Comments have been made everywhere .
report zvenkat_alv_2_grid_description.
types:
begin of t_mard,
werks type mard-werks,
lgort type mard-lgort,
matnr type mard-matnr,
insme type mard-insme,
einme type mard-einme,
speme type mard-speme,
end of t_mard.
data:
w_mard type t_mard.
data:
i_mard type standard table of t_mard.
" ALV Declarations
" ALV internal tables and Structures
" To refer ALV tables(slis tables) and structures.SLIS must be
" declared under TYPE-POOLS(see below).SLIS is a Type group which is
" defined in Dictionary.Internal tables and structures and constants
" are defined under type group.(Double click on SLIS).
* Types Pools
type-pools:
slis.
* Types
types:
t_fieldcat type slis_fieldcat_alv,
t_events type slis_alv_event,
t_layout type slis_layout_alv.
* Workareas
data:
w_fieldcat type t_fieldcat,
w_events type t_events,
w_layout type t_layout.
* Internal Tables
data:
i_fieldcat type standard table of t_fieldcat,
i_fieldcat1 type standard table of t_fieldcat,
i_events type standard table of t_events.
*& START-OF-SELECTION
start-of-selection.
perform get_data_from_database .
" END-OF-SELECTION
" Steps to create simple ALV program
" 1. Pass an internal table with the set of output information
" 2. Pass a field catalog as an internal table
" 3. Pass a structure with general list layout details
end-of-selection.
perform build_fieldcatalog.
perform build_events.
perform build_layout.
perform display_data.
" Form build_fieldcatalog
" Fieldcatalog Internal table
" 1. It contains descriptions of the list output fields
" (usually a subset of the internal output table fields).
" 2. A field catalog is required for every ALV list output.
form build_fieldcatalog .
clear :
w_fieldcat,
i_fieldcat[].
perform build_fcat using:
"Field Int.Table Column headings
'WERKS' 'I_MARD' 'WERKS',
'LGORT' 'I_MARD' 'LGORT',
'MATNR' 'I_MARD' 'MATNR',
'INSME' 'I_MARD' 'INSME',
'EINME' 'I_MARD' 'EINME',
'SPEME' 'I_MARD' 'SPEME'.
endform. " build_fieldcatalog
*& Form display_data
form display_data .
data :program like sy-repid value sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
tables
t_outtab = i_mard.
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 get_data_from_database
* text
form get_data_from_database .
clear :i_mard,
i_mard[].
select werks lgort matnr insme einme speme
from mard
into corresponding fields of table i_mard
up to 100 rows.
endform. " get_data_from_database
*& Form top_of_page
* text
form top_of_page.
data :
i_header type slis_t_listheader,
w_header like line of i_header.
data:l_date1 type datum,
l_date2 type datum.
w_header-typ = 'S'.
w_header-info = sy-title.
append w_header to i_header.
clear w_header.
w_header-typ = 'H'.
w_header-info = sy-repid.
append w_header to i_header.
clear w_header.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_header
i_logo = 'ENJOYSAP_LOGO'.
endform. "top_of_page
*& Form BUILD_FCAT
form build_fcat using l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
append w_fieldcat to i_fieldcat.
clear w_fieldcat.
endform. " BUILD_FCAT
" Form build_events
" Events
" 1. When we use ALV,certain events TOP-OF-PAGE ,END-OF-PAGE,
" AT LINE-SELECTION,AT USER-COMMANDs are not triggered.
" 2. To perform those Functions ,we have to build Events table and
" pass this table through REUSE_ALV_LIST_DISPALY Function.
form build_events .
clear :
w_events,i_events[].
w_events-name = 'TOP_OF_PAGE'.
w_events-form = 'TOP_OF_PAGE'.
append w_events to i_events.
clear w_events.
endform. " build_events
"& Form build_layout
" Layouts
" Use :We change the display of our list using layouts.
" ===
" Features
" ========
" The layouts that you can use vary according to the type of list:
" 1-->In all lists, you can do the following:
" (a).Choose one of the std layouts supplied with the std system.
" (b).Change the current layout of the list .
" 2-->In lists that use only the standard layouts in the std system
" you cannot save your changes to the current layout.When you
" choose the layouts, only the standard layouts will be proposed.
" 3-->In some lists, you can also save the layouts that you have
" defined as our own layouts.
" User-defined layouts are generally saved for all users. They can
" then be used by all users. All users will be able to choose from
" the user-defined layouts as well as the standard layouts.
" 4-->In some lists, you can also save user-specific layouts that you
" have defined . When you choose the current layout,only these
" layouts are available to you.
" 5-->You can delete or transport layouts, or define them as initial
" layouts
" 6-->STRUCTURE :SLIS_LAYOUT_ALV.
form build_layout .
clear:
w_layout.
w_layout-colwidth_optimize = 'X'.
endform. " build_layout
Regards,
Venkat.O -
Hello
I want sub-totals and totals for a feild depending on a particular area which is also a feild in ALV.
Points for SureHi,
Refer
http://help.sap.com/saphelp_erp2004/helpdata/en/ee/c8e056d52611d2b468006094192fe3/content.htm
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/doesnt-function-event-subtotal_text-in-alv-713787
Use the I_SORT internal table and pass it to fun module
see the sample code
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
Regards,
Padmam. -
Hi Gurus,
I have fileds like comapny code and other fields i am getting the output three records and i want to add a blank row at every new comapny code , can any one suggest or give me a clue.
I want at end of new company code i want adda blank row .
Regards
subbaraHi ,
Thanks for your suggestion.
Regards
subbara -
Problem in Expand when using Blocked ALV list
Hi All,
I am using the Blocked list ALV to display two lists in a program. One among them is a hierarchial ALV. When i click on the Expand button of this ALV it terminates with the runtime error "GETWA_NOT_ASSIGNED".
I was able to use this functionality using similar code in a stand alone hierarchial ALV list in another program without any problem.
I have assigned the Expand Field name as follows in both programs:
wa_layout-expand_fieldname = 'EXPAND'
Any suggestions or help in this would be highly appreciated.
Thanks & Reagrds,
PraveenHai Praveen
Check the following Code
*& Report ZALV_BLOCKLIST *
REPORT ZALV_BLOCKLIST NO STANDARD PAGE HEADING
LINE-SIZE 150
LINE-COUNT 60(4)
MESSAGE-ID Z00.
*..Type Definitions for ALV Report
TYPE-POOLS SLIS.
*..Includes
*for ICONs
*INCLUDE <ICON>.
Table/Structure declarations. *
TABLES: MARA,
MARC,
T134.
Internal Tables declaration *
*..To store Basic Report fields
DATA:BEGIN OF IT_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
MEINS LIKE MARA-MEINS,
NTGEW LIKE MARA-NTGEW,
END OF IT_MARA.
*DATA:BEGIN OF IT_MATKL OCCURS 0,
MATKL LIKE T023-MATKL,
WGBEZ LIKE T023-WGBEZ,
END OF IT_MATKL.
DATA:BEGIN OF IT_MARC OCCURS 0,
WERKS LIKE MARC-WERKS,
LADGR LIKE MARC-LADGR,
MTVFP LIKE MARC-MTVFP,
DISPR LIKE MARC-DISPR,
DISMM LIKE MARC-DISMM,
DISPO LIKE MARC-DISPO,
END OF IT_MARC.
ALV Type declaration *
DATA:V_NO_DATA TYPE C.
ALV Type declaration *
DATA:V_REPID TYPE SYREPID.
DATA: IT_FIELDCATALOG_MARA TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MARA TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCATALOG_MARC TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MARC TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCATALOG_MATKL TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MATKL TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT,
WA_KEYINFO TYPE SLIS_KEYINFO_ALV.
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR ,
S_MTART FOR MARA-MTART .
SELECTION-SCREEN END OF BLOCK B1.
Event:Initialization *
INITIALIZATION.
*Report Name
V_REPID = SY-REPID.
AT Selection Screen. *
AT SELECTION-SCREEN.
Event: Start-of-Selection *
START-OF-SELECTION.
PERFORM FETCH_DATA.
Event: End-of-Selection *
END-OF-SELECTION.
IF V_NO_DATA = ''.
MESSAGE I010 WITH 'NO DATA TO DISPLAY ! '.
EXIT.
ELSE.
PERFORM FILL_FIELDCAT_MARA.
PERFORM FILL_FIELDCAT_MAKT.
PERFORM FILL_FIELDCAT_MARC.
PERFORM FILL_LAYOUT.
PERFORM CALL_ALV_INIT.
PERFORM ADD_LISTS.
PERFORM DISPLAY_BLOCK_LIST.
ENDIF.
FORM DEFINITIONS *
*& Form FETCH_DATA
text
--> p1 text
<-- p2 text
FORM FETCH_DATA.
SELECT MATNR
MTART
MATKL
MEINS
NTGEW
INTO CORRESPONDING FIELDS OF TABLE IT_MARA
FROM MARA
WHERE MATNR IN S_MATNR
AND MTART IN S_MTART.
IF SY-SUBRC <> 0.
V_NO_DATA = ''.
ELSE.
V_NO_DATA = 'X'.
SELECT WERKS
LADGR
MTVFP
DISPR
DISMM
DISPO
INTO CORRESPONDING FIELDS OF TABLE IT_MARC
FROM MARC
WHERE MATNR IN S_MATNR.
ENDIF.
ENDFORM. " FETCH_DATA
*& Form FILL_FIELDCAT_MARA
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MARA.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'IT_MARA'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCATALOG_MARA
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.
LOOP AT IT_FIELDCATALOG_MARA INTO WA_FIELDCATALOG_MARA.
CASE WA_FIELDCATALOG_MARA-FIELDNAME.
WHEN 'MATNR'.
WA_FIELDCATALOG_MARA-COL_POS = '1'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Material NO'.
WHEN 'MTART'.
WA_FIELDCATALOG_MARA-COL_POS = '2'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Type'.
WHEN 'MATKL'.
WA_FIELDCATALOG_MARA-COL_POS = '3'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Group'.
WHEN 'MEINS'.
WA_FIELDCATALOG_MARA-COL_POS = '4'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Measure Unit'.
WHEN 'NTGEW'.
WA_FIELDCATALOG_MARA-COL_POS = '5'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Net Wt'.
WA_FIELDCATALOG_MARA-DO_SUM = 'X'.
ENDCASE.
MODIFY IT_FIELDCATALOG_MARA FROM WA_FIELDCATALOG_MARA INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_MARA
*& Form FILL_FIELDCAT_MARC
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MARC.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_MARC'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCATALOG_MARC
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.
LOOP AT IT_FIELDCATALOG_MARC INTO WA_FIELDCATALOG_MARC.
CASE WA_FIELDCATALOG_MARC-FIELDNAME.
WHEN 'WERKS'.
WA_FIELDCATALOG_MARC-COL_POS = '1'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'PLANT NAME'.
WHEN 'LADGR'.
WA_FIELDCATALOG_MARC-COL_POS = '2'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'Loading Group'.
WHEN 'MTVFP'.
WA_FIELDCATALOG_MARC-COL_POS = '3'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '20'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'Checking group'.
WHEN 'DISPR'.
WA_FIELDCATALOG_MARC-COL_POS = '4'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP PROFILE'.
WHEN 'DISMM'.
WA_FIELDCATALOG_MARC-COL_POS = '5'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP TYPE'.
WHEN 'DISPO'.
WA_FIELDCATALOG_MARC-COL_POS = '6'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP CONTROLLER'.
ENDCASE.
MODIFY IT_FIELDCATALOG_MARC FROM WA_FIELDCATALOG_MARC INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_MARC
*& Form FILL_FIELDCAT_MAKT
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MAKT.
ENDFORM. " FILL_FIELDCAT_MAKT
*& Form CALL_ALV_INIT
text
--> p1 text
<-- p2 text
FORM CALL_ALV_INIT.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
ENDFORM. " CALL_ALV_INIT
*& Form ADD_LISTS
text
--> p1 text
<-- p2 text
FORM ADD_LISTS.
*ADD IT_MARA TABLE TO THE OUTPUT
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCATALOG_MARA
I_TABNAME = 'IT_MARA'
IT_EVENTS = IT_EVENTS
IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_MARA
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
**ADD IT_MARC TABLE TO THE OUTPUT
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCATALOG_MARC
I_TABNAME = 'IT_MARC'
IT_EVENTS = IT_EVENTS
IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_MARC
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 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.
ENDFORM. " ADD_LISTS
*& Form FILL_LAYOUT
text
--> p1 text
<-- p2 text
FORM FILL_LAYOUT.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM. " FILL_LAYOUT
*& Form DISPLAY_BLOCK_LIST
text
--> p1 text
<-- p2 text
FORM DISPLAY_BLOCK_LIST.
WA_KEYINFO-HEADER01 = 'MATNR'.
WA_KEYINFO-ITEM01 = 'MATNR'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
IS_PRINT =
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 =
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_BLOCK_LIST .
Thanks & regards
Sreenivasulu P -
Alv grid mandatory field.
hi...
I have a ALV grid that is displayed ... i fill up the entries in this and then save them.
i need to declare some fields as mandatory
how shall i do it
thanksHi,
Check the fieldcatalog, if there is any option .. I don;t think we have option for it..
Other wise u have to take care in ur program by checking if there is any value entered in the field , if not throw error message , something like this..
This iam telling reagrding by using FM REUSE_ALV_GRID_DISPLAY..
Regards,
Nagaraj -
How to provide Hotspot in ALV tree????
Hi experts,
I have provided a double click event in ALV tree display. As of now I am able to open the transactions when I click on some the fields in output. But now I want to have a hotspot on those fields. See plz help me with this.
This is my catalog:
** get fieldcatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZPP_STR_BAR'
CHANGING
ct_fieldcat = t_fieldcat.
LOOP AT t_fieldcat INTO ls_fieldcat.
CASE ls_fieldcat-fieldname.
WHEN 'AUFNR'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-key = 'X'.
ls_fieldcat-scrtext_s = text-t21.
ls_fieldcat-tooltip = text-t01.
WHEN 'TXT'.
ls_fieldcat-outputlen = 40.
** ls_fieldcat-do_sum = 'X'.
ls_fieldcat-scrtext_s = text-t22.
ls_fieldcat-tooltip = text-t02.
WHEN 'CHARG'.
ls_fieldcat-outputlen = 16.
ENDCASE.
MODIFY t_fieldcat FROM ls_fieldcat.
ENDLOOP.
Is there any field in field catalog which i need to set?
or is there any event to provide hotspot?
<REMOVED BY MODERATOR>
Thanks in advance,
Sachin
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 2:31 PMhi,
You Can give hotspot using the Fieldcatalog.
hotspot_fieldname type slis_fieldname, " fieldname flag hotspot
key_hotspot(1) type c, " keys as hotspot " K_KEYHOT
Hope this helps u,
Reagrds,
Arunsri. -
Hi all,
Please let me know how to hanldle event handling , making a cell in editable mode ,double click and hotspot creation,colorign a single cell,calling a transatcion when clicked on hotspot in a alv grid display program (not using OO concepts).
Looikng forward for a positive response.
Reagrds,
Mohinder.Hi,
You can create your own custom status and asign it to your
ALV GRID. Here is a sample code to add custom status and handling events.
http://www.geocities.com/mpioud/Z_DEMO_ALV_REFRESH_BUTTON.html
Reward Points if found helpfull..
Cheers,
Chandra Sekhar. -
Hello!
This below listed code dumps all over the time.
I checked the whole code and its almost impossible to find
out the problem. Hopefully has somebody an idea.
Reagrds
Ilhan
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data tree1 type ref to cl_gui_alv_tree_simple.
INCLUDE /G2A/ZTREE_ICON.
INCLUDE /G2A/ZTREE_EVENT.
data: gt_sflight type sflight occurs 0, "Output-Table
gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
gt_sort type lvc_t_sort, "Sortiertabelle
ok_code like sy-ucomm. "OK-Code
data itab type ZQMCOMP occurs 0.
data wa type ZQMCOMP.
* Struktur Feldkatalog
data lw TYPE lvc_s_fcat.
* interne Tabelle Feldkatalog
data gt TYPE lvc_t_fcat.
* Layoutstruktur
data wa_layout TYPE lvc_s_layo.
start-of-selection.
end-of-selection.
call screen 100.
*& Form BUILD_FIELDCATALOG
* text
form build_fieldcatalog.
** get fieldcatalog
* call function 'LVC_FIELDCATALOG_MERGE'
* exporting
* i_structure_name = 'wa'
* changing
* ct_fieldcat = gt.
** change fieldcatalog
* data: ls_fieldcatalog type lvc_s_fcat.
* loop at gt_fieldcatalog into ls_fieldcatalog.
* case ls_fieldcatalog-fieldname.
* when 'CARRID' or 'CONNID' or 'FLDATE'.
* ls_fieldcatalog-no_out = 'X'.
* ls_fieldcatalog-key = ''.
* when 'PRICE' or 'SEATSOCC' or 'SEATSMAX' or 'PAYMENTSUM'.
* ls_fieldcatalog-do_sum = 'X'.
* endcase.
* modify gt_fieldcatalog from ls_fieldcatalog.
* endloop.
* ================================================
* FELDKATALOG
* ================================================
CLEAR: lw.
lw-fieldname = 'QMNUM'.
lw-tabname = 'wa'.
lw-col_pos = 1.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'QMART'.
lw-tabname = 'wa'.
lw-col_pos = 2.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'POSNR'.
lw-tabname = 'wa'.
lw-col_pos = 3 .
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'REFNR'.
lw-tabname = 'wa'.
lw-col_pos = 4.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'KUNDE'.
lw-tabname = 'wa'.
lw-col_pos = 5.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'DUNS'.
lw-tabname = 'wa'.
lw-col_pos = 6.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_OUTTAB
* text
* --> p1 text
* <-- p2 text
form build_outtab.
* select * from sflight into table gt_sflight.
select * from ZQMCOMP into table itab.
* up to 1 rows.
endform. " BUILD_OUTTAB
*& Form BUILD_SORT_TABLE
* text
* --> p1 text
* <-- p2 text
form build_sort_table.
data ls_sort_wa type lvc_s_sort.
* create sort-table
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'CARRID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 2.
ls_sort_wa-fieldname = 'CONNID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 3.
ls_sort_wa-fieldname = 'FLDATE'.
ls_sort_wa-up = 'X'.
append ls_sort_wa to gt_sort.
endform. " BUILD_SORT_TABLE
*& Module PBO OUTPUT
* text
module pbo output.
if tree1 is initial.
perform init_tree.
endif.
set pf-status 'MAIN100'.
endmodule. " PBO OUTPUT
*& Module PAI INPUT
* text
module pai input.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
perform exit_program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
clear ok_code.
endmodule. " PAI INPUT
*& Form exit_program
* free object and leave program
form exit_program.
call method tree1->free.
leave program.
endform. " exit_program
*& Form register_events
* text
* --> p1 text
* <-- p2 text
form register_events.
* define the events which will be passed to the backend
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event.
* define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
append l_event to lt_events.
call method tree1->set_registered_events
exporting
events = lt_events
exceptions
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
* set Handler
data: l_event_receiver type ref to lcl_tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->on_add_hierarchy_node
for tree1.
endform. " register_events
*& Form build_header
* build table for html_header
* --> p1 text
* <-- p2 text
form build_comment using
pt_list_commentary type slis_t_listheader
p_logo type sdydo_value.
data: ls_line type slis_listheader.
* LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = 'METZELER OEM-BEANSTANDUNGEN'.
append ls_line to pt_list_commentary.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Datum'.
ls_line-info = sy-datlo.
append ls_line to pt_list_commentary.
* ls_line-key = 'time'.
* ls_line-info = '00.00 pm'.
* append ls_line to pt_list_commentary.
** ACTION LINE: TYPE A
* clear ls_line.
* ls_line-typ = 'A'.
** LS_LINE-KEY: NOT USED FOR THIS TYPE
* ls_line-info = 'up-to-date data'.
* append ls_line to pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
endform.
*& Form init_tree
* text
* --> p1 text
* <-- p2 text
FORM init_tree.
perform build_fieldcatalog.
perform build_outtab.
* perform build_sort_table.
* create container for alv-tree
data: l_tree_container_name(30) type c,
l_custom_container type ref to cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
create object l_custom_container
exporting
container_name = l_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
* create tree control
create object tree1
exporting
i_parent = l_custom_container
i_node_selection_mode =
cl_gui_column_tree=>node_sel_mode_multiple
i_item_selection = 'X'
i_no_html_header = ''
i_no_toolbar = ''
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
* create info-table for html-header
data: lt_list_commentary type slis_t_listheader,
l_logo type sdydo_value.
perform build_comment using
lt_list_commentary
l_logo.
* repid for saving variants
data: ls_variant type disvariant.
ls_variant-report = sy-repid.
* register events
perform register_events.
* create hierarchy
call method tree1->set_table_for_first_display
exporting
it_list_commentary = lt_list_commentary
* i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
* it_sort = gt_sort
it_outtab = itab
* it_fieldcatalog = gt_fieldcatalog.
it_fieldcatalog = gt.
* expand first level
call method tree1->expand_Tree
exporting
i_level = 1.
* optimize column-width
call method tree1->column_optimize
exporting
i_start_column = tree1->c_hierarchy_column_name
i_end_column = tree1->c_hierarchy_column_name.
ENDFORM. " init_treesorry this the english version
ABAP runtime errors GETWA_NOT_ASSIGNED
Occurred on 09.03.2007 at 15:35:20
>> Short dump has not been completely stored. It is too big.
Field symbol has not yet been assigned.
What happened?
The current ABAP/4 program "CL_GUI_ALV_TREE_SIMPLE========CP " had to be
terminated because
one of the statements could not be executed.
This is probably due to an error in the ABAP/4 program.
What can you do?
Note the actions and input that caused the error.
Inform your SAP system administrator.
You can print out this message by choosing "Print". Transaction ST22
allows you to display and manage termination messages, including keeping
them beyond their normal deletion date.
Error analysis
You attempted to access an unassigned field symbol
(data segment 32771).
This error occurs:
- if you address a typed field symbol before it has been set with
ASSIGN or
- if you address a field symbol that has been reset with UNASSIGN
or pointed to a local field that no longer exists, or
- if you address a field symbol that pointed to a line of an internal
table that has now been deleted, or
- if you address a global function interface partameter, even
though the relevant function module is not active,
i.e. it is not in the list of active calls. You can get the list
of active calls from the this short dump.
How to correct the error
If the error occurred in a non-modified SAP program, you may be
able to find a solution in the SAP note system.
If you have access to the note system yourself, use the following
search criteria:
"GETWA_NOT_ASSIGNED"
"CL_GUI_ALV_TREE_SIMPLE========CP " or "CL_GUI_ALV_TREE_SIMPLE========CM00J "
"SET_NODES"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.
System environment
SAP Release.............. "46C"
Application server....... "s96as822"
Network address.......... "53.71.198.54"
Operating system......... "SunOS"
Release.................. "5.8"
Hardware type............ "sun4u"
Database server.......... "s96as822"
Database type............ "ORACLE"
Database name............ "G2E"
Database owner........... "SAPR3"
Character set............ "en_US"
SAP kernel............... "46D"
Created on............... "Nov 27 2005 20:48:26"
Created in............... "SunOS 5.7 Generic_106541-05 sun4u"
Database version......... "OCI_816_64__OCI_7_API "
Patch level.............. "2162"
Patch text............... " "
Supported environment....
Database................. "ORACLE 8.0.5.., ORACLE 8.0.6.., ORACLE
8.1.6.., ORACLE 8.1.7.., ORACLE 9.2.0.."
SAP database version..... "46D"
Operating system......... "SunOS 5.6, SunOS 5.7, SunOS 5.8, SunOS 5.9, SunOS
5.10, , System build information:, -
, LCHN
: 794995"
User, transaction...
Client.............. 112
User................ "ASIKOGLU"
Language key........ "E"
Transaction......... "SEU_INT "
Program............. "CL_GUI_ALV_TREE_SIMPLE========CP "
Screen.............. "/G2A/ZTREE 0100"
Screen line......... 2
Information on where termination occurred
The termination occurred in the ABAP/4 program
"CL_GUI_ALV_TREE_SIMPLE========CP " in
"SET_NODES".
The main program was "/G2A/ZTREE ".
The termination occurred in line 210
of the source code of program "CL_GUI_ALV_TREE_SIMPLE========CM00J " (when
calling the editor 2100).
Source code extract
001800 m_current_node_key = l_node_key.
001810 raise event ON_ADD_HIERARCHY_NODE
001820 exporting
001830 grouplevel = ls_sort_wa-fieldname
001840 index_outtab = l_index_outtab.
001850
001860 * stack last key
001870 insert l_node_key into lt_parent_stack index 1.
001880
001890 * set parameters for next loop.
001900 l_prev_level = <ls_grouplevels_wa>-level.
001910 l_index_from = <ls_grouplevels_wa>-index_from.
001920 l_index_to = <ls_grouplevels_wa>-index_to.
001930 endloop.
001940
001950 * complete last nodes from outtab
001960 loop at it_outtab assigning <wa> from l_index_from to l_index_to.
001970 l_index = sy-tabix.
001980 * get relation-key
001990 read table lt_parent_stack into l_relat_key index 1.
002000 l_relationship = cl_tree_control_base=>relat_last_child.
002010 assign component l_last_level of structure <wa> to <h_key>.
002020 * read and format output-data
002030 call method cl_gui_alv_grid=>CELL_Display
002040 exporting
002050 is_data = <wa>
002060 i_int_value = <h_key>
002070 importing
002080 e_ext_value = l_node_text
002090 changing
> cs_fieldcat = ls_fieldcatalog_wa.
002110 condense l_node_text.
002120
002130 * set layout
002140 clear ls_node_layout.
002150 clear lt_item_layout[].
002160 call method me->set_layout
002170 exporting
002180 i_grouplevel = l_last_level
002190 importing
002200 es_node_layout = ls_node_layout
002210 et_item_layout = lt_item_layout
002220 changing
002230 is_outtabline = <wa>.
002240
002250 call method me->add_model_node
002260 exporting
002270 i_relat_node_key = l_relat_key
002280 i_relationship = l_relationship
002290 i_node_text = l_node_text
Contents of system fields
SY field contents..................... SY field contents.....................
SY-SUBRC 4 SY-INDEX 0
SY-TABIX 1 SY-DBCNT 1
SY-FDPOS 1 SY-LSIND 0
SY-PAGNO 0 SY-LINNO 1
SY-COLNO 1 -
Give me some small program on hirerical alv
please give specification on simple alv and hirerical alv
Hi Rahul,
This is a simple ALV.
*& Report Z_ALV_DEMO_1 *
REPORT Z_ALV_DEMO_1 .
TYPE-POOLS: slis.
DB-Table
TABLES sflight.
Includes
INCLUDE <icon>.
INCLUDE <symbol>.
CONSTANTS:
c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
i_sp_group TYPE slis_t_sp_group_alv,
i_events TYPE slis_t_event,
i_print TYPE slis_print_alv,
i_sort TYPE slis_t_sortinfo_alv.
*internal table for data to be displayed
DATA: BEGIN OF i_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: box,
lights.
DATA: END OF i_sflight.
DATA: w_repid LIKE sy-repid.
DATA: i_list_top_of_page TYPE slis_t_listheader.
Report Selections
SELECT-OPTIONS s_carrid FOR sflight-carrid.
SELECT-OPTIONS s_connid FOR sflight-connid.
SELECT-OPTIONS s_fldate FOR sflight-fldate.
*SELECTION-SCREEN SKIP 1.
Parameters
PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection
SELECTION-SCREEN SKIP 1.
Variant for ALV display
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.
PARAMETERS: p_varnt LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK 0.
Layout of the report display
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern
p_nocolh AS CHECKBOX DEFAULT ' ', "No column heading
p_novlin AS CHECKBOX DEFAULT ' ', "No vertical lines
p_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wd
p_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hot
p_noinpt AS CHECKBOX DEFAULT ' '. "No field for input
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',
p_lightc AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',
p_totext(60),
p_sttext(60).
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.
PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',
p_detpop AS CHECKBOX DEFAULT 'X',
p_groupb AS CHECKBOX DEFAULT ' ',
p_groups AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK d.
SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.
PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',
p_nosinf AS CHECKBOX DEFAULT ' ',
p_nocove AS CHECKBOX DEFAULT ' ',
p_nonewp AS CHECKBOX DEFAULT ' ',
p_nolinf AS CHECKBOX DEFAULT ' ',
p_reserv TYPE i.
SELECTION-SCREEN END OF BLOCK e.
DATA: w_boxnam TYPE slis_fieldname VALUE 'BOX',
w_f2code LIKE sy-ucomm VALUE '&ETA',
w_lignam TYPE slis_fieldname VALUE 'LIGHTS',
w_save(1) TYPE c,
w_default(1) TYPE c,
w_exit(1) TYPE c,
i_variant LIKE disvariant,
i_variant1 LIKE disvariant.
INITIALIZATION.
w_repid = sy-repid.
PERFORM fieldcat_init USING i_fieldcat.
PERFORM eventtab_build USING i_events.
PERFORM comment_build USING i_list_top_of_page.
PERFORM sp_group_build USING i_sp_group.
PERFORM t_sort_build USING i_sort.
Set Options: save variant userspecific or general
'A or 'U' are for user-specific variants list
'X' or 'space' for general
w_save = 'A'.
PERFORM variant_init.
Get default variant
i_variant1 = i_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_varnt = i_variant1-variant.
ENDIF.
Process on value request (list of possible variants)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.
PERFORM f4_for_variant.
PAI
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
START-OF-SELECTION.
PERFORM selection.
END-OF-SELECTION.
PERFORM layout_build USING i_layout. "wg. Parameters
PERFORM print_build USING i_print. "wg. Parameters
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'I_SFLIGHT'
i_structure_name = 'SFLIGHT'
i_client_never_display = 'X'
i_inclname = w_repid
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Call ABAP/4 List Viewer
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_callback_program = w_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'SFLIGHT'
i_background_id = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_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 = i_sflight
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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_structure_name = 'SFLIGHT'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
i_default = W_DEFAULT
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_print
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 =
TABLES
t_outtab = i_sflight.
FORM FIELDCAT_INIT *
--> L_FIELDCAT *
FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSOCC'.
*The field is not displayed in the initial output, can be interactively
chosen for display
ls_fieldcat-no_out = 'X'.
*This field is assigned to a special group with tech. key 'A' and can be
*displayed using the special group buttons
ls_fieldcat-sp_group = 'A'.
*The field cannot be summed irrespective of its data type
ls_fieldcat-no_sum = 'X'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'A'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'B'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-outputlen = 7.
APPEND ls_fieldcat TO l_fieldcat.
ENDFORM.
FORM DATA_ADD *
--> L_SFLIGHT
FORM data_add TABLES l_sflight STRUCTURE i_sflight.
LOOP AT l_sflight.
IF sy-tabix > 10.
l_sflight-box = 'X'.
l_sflight-lights = '3'.
ELSE.
IF sy-tabix = 1.
l_sflight-lights = '2'.
ELSE.
l_sflight-lights = '1'.
ENDIF.
ENDIF.
MODIFY l_sflight.
ENDLOOP.
ENDFORM.
FORM EVENTTAB_BUILD *
--> l_EVENTS *
FORM eventtab_build USING l_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = l_events.
READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO ls_event-form.
APPEND ls_event TO l_events.
ENDIF.
ENDFORM.
FORM COMMENT_BUILD *
--> L_TOP_OF_PAGE *
FORM comment_build USING l_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
***Header
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: not used for this type
ls_line-info = 'Heading list'.
APPEND ls_line TO l_top_of_page.
***Selection
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Information'.
APPEND ls_line TO l_top_of_page.
ls_line-key = 'Key 2'.
APPEND ls_line TO l_top_of_page.
***Action
CLEAR ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: not used for this type
Ls_line-info = 'Status list'.
APPEND ls_line TO l_top_of_page.
ENDFORM.
FORM LAYOUT_BUILD *
<-> LS_LAYOUT *
FORM layout_build USING ls_layout TYPE slis_layout_alv.
ls_layout-f2code = w_f2code.
ls_layout-zebra = p_zebra.
ls_layout-colwidth_optimize = p_colopt.
IF p_chkbox = 'X'.
*Fieldname for check box on the report output
ls_layout-box_fieldname = w_boxnam.
ELSE.
ls_layout-box_fieldname = space.
ENDIF.
ls_layout-no_input = p_noinpt.
ls_layout-no_vline = p_novlin.
ls_layout-no_colhead = p_nocolh.
IF p_lights = 'X' OR p_lightc = 'X'.
**Fieldname for lights on the report output
ls_layout-lights_fieldname = w_lignam.
ELSE.
CLEAR ls_layout-lights_fieldname.
ENDIF.
ls_layout-lights_condense = p_lightc.
ls_layout-totals_text = p_totext.
ls_layout-subtotals_text = p_sttext.
ls_layout-totals_only = p_totonl.
ls_layout-key_hotspot = p_keyhot.
ls_layout-detail_popup = p_detpop.
ls_layout-group_change_edit = p_groups.
E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.
ls_layout-group_buttons = 'X'.
ENDFORM.
FORM SP_GROUP_BUILD *
--> L_SP_GROUP *
FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
*Fields are assigned to the special group
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = 'Reservation status'.
APPEND ls_sp_group TO l_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'B'.
ls_sp_group-text = 'Flight charges'.
APPEND ls_sp_group TO l_sp_group.
ENDFORM.
FORM SELECTION *
FORM selection.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight
UP TO p_maxrow ROWS WHERE carrid IN s_carrid
AND connid IN s_connid AND fldate IN s_fldate.
PERFORM data_add TABLES i_sflight.
ENDFORM.
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_top_of_page.
ENDFORM.
FORM F4_FOR_VARIANT *
FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = i_variant
i_save = w_save
it_default_fieldcat =
IMPORTING
e_exit = w_exit
es_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF w_exit = space.
p_varnt = i_variant1-variant.
ENDIF.
ENDIF.
ENDFORM.
*& Form PAI_OF_SELECTION_SCREEN
to check whether right variant is entered on the selection scr
FORM pai_of_selection_screen.
IF NOT p_varnt IS INITIAL.
MOVE i_variant TO i_variant1.
MOVE p_varnt TO i_variant1-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1.
i_variant = i_variant1.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form VARIANT_INIT
FORM variant_init.
CLEAR i_variant.
i_variant-report = w_repid.
ENDFORM. " VARIANT_INIT
FORM PRINT_BUILD *
FORM print_build USING l_print TYPE slis_print_alv.
l_print-print = p_print.
l_print-no_print_selinfos = p_nosinf.
l_print-no_coverpage = p_nocove.
l_print-no_new_page = p_nonewp.
l_print-no_print_listinfos = p_nolinf.
l_print-reserve_lines = p_reserv.
l_print-print = p_print.
ENDFORM.
FORM T_SORT_BUILD *
FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
ls_sort-fieldname = 'CARRID'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO l_sort.
ENDFORM.
-Hope it helps u.
Reagrds,
-Priyanka. -
Edit One Cell In Alvs Based On Some Condition
Hi Experts,
My Requirement Is :
Has To *Edit one cell using alv grid *, for ex: If Netpr > 100(value). that should be in editable mode,rest of the cells in non-editable mode. pls let me know how to do it,
best answer rewarded
Reagrds,
Fareedas.Hi Fareedas,
The follow program demonstrates how to make individual fields of an ALV grid editable (NetPR greater than 10). Changes required from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this field with style attribute and adding an entry to layout control table. Also from the previous examples used on this website you will also need to change the data type of the fieldcatalog, the layout and use a different function module for displaying the report
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM build_layout.
* Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
* call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
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 DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
* populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
* Populate style variable (FIELD_STYLE) with style properties
* The NETPR field/column has been set to editable in the fieldcatalog...
* The following code sets it to be disabled(display only) if 'NETPR'
* is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes
Check the above code.
For a sample code using ABAP OO check the program BCALV_EDIT_02.
Hope this helps.
Rwd points if helpful.
Thanks,
Balaji -
Dear SDN,
I found lots of posts with this title, however, after following all the instructions, my ALV does not show any page break.
Using input table IT_SORT of the ALV Function Module.
WA_SORT-FIELDNAME = 'PSPID'.
WA_SORT-SUBTOT = 'X'.
WA_SORT-GROUP = '* '.
APPEND WA_SORT TO IT_SORT.
What might be missing?
How should this page break come up?
Thank you.
Regards,
Fabiohi,
Check the below link
page break in ALV
Page break Ups in ALV reports
PS-> In ALV grid, we will not be able to see the page breaks on the screen. Once we convert the ALV grid to u201CList Outputu201D,we can see the page breaks or during print from the ALV grid.
Reagrds,
Nagaraj -
hi,
i need to right allign the cell contents of a column in alv.
can any1 suggest how to do dat?
points will b rewarded....HI,
In your fieldcat use this,
FORM Z_FIELDCAT USING P_I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: I_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*VBAK-VELN
I_FIELDCAT-COL_POS = '1'. " POSITION OF THE COLUMN.
I_FIELDCAT-FIELDNAME = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED.
I_FIELDCAT-TABNAME = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
I_FIELDCAT-KEY = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
<b> I_FIELDCAT-JUST = 'C'. " (R)ight (L)eft (C)ent.</b>
I_FIELDCAT-LZERO = 'X'. " OUTPUT WITH LEADING ZEROS.
I_FIELDCAT-SELTEXT_L = 'SALES ORDER'. " LONG TEXT FOR HEADER.
I_FIELDCAT-OUTPUTLEN = 15. " SET THE OUTPUT LENGTH.
I_FIELDCAT-REF_TABNAME = 'VBAK'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
APPEND I_FIELDCAT TO P_I_FIELDCAT.
Reagrds,
Pritha. -
Hi all,
i have to develop a ALV report.
In that report i have to put a open quantity column , so that the user can enter values in that, and that value should get updated in the database.
So please suggest me how to develop such report with open field.
Thanks in advance,
Regards,
PawanHi,
Try executing the below code
REPORT YMS_EDITBLOCKALV.
TABLES : rmmg1,MCHB, mkpf.
DATA: BEGIN OF t_mseg OCCURS 0,
zeile LIKE mseg-zeile,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
END OF t_mseg.
DATA:BEGIN OF t_mchb OCCURS 0.
INCLUDE STRUCTURE mchb.
data flag type c.
matnr LIKE mchb-matnr,
charg LIKE mchb-charg,
werks LIKE mchb-werks,
clabs LIKE mchb-clabs,
DATA END OF t_mchb.
TYPE-POOLS slis.
data: progname like sy-repid,
fieldcattab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
data tabindex type i.
data wa_matnr LIKE mchb-matnr.
progname = sy-repid.
SELECTION-SCREEN BEGIN OF BLOCK b_b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_docno FOR mkpf-mblnr. " OBLIGATORY.
PARAMETERS p_docyr LIKE mkpf-mjahr. " OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b_b1.
START-OF-SELECTION.
SELECT zeile
menge
meins
matnr
werks
charg
bwart
FROM mseg
INTO TABLE t_mseg
WHERE mblnr IN s_docno AND mjahr = p_docyr.
CLEAR fieldcattab.
fieldcattab-col_pos = 1.
fieldcattab-fieldname = 'ZEILE'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Item'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 2.
fieldcattab-fieldname = 'MENGE'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Quantity'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 3.
fieldcattab-fieldname = 'MEINS'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Unit'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 4.
fieldcattab-fieldname = 'MATNR'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Material'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 5.
fieldcattab-fieldname = 'WERKS'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Plant'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 6.
fieldcattab-fieldname = 'CHARG'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Batch No'.
APPEND fieldcattab.
CLEAR fieldcattab.
fieldcattab-col_pos = 7.
fieldcattab-fieldname = 'BWART'.
fieldcattab-tabname = 'T_MSEG'.
fieldcattab-seltext_l = 'Inventory'.
fieldcattab-hotspot = 'X'.
APPEND fieldcattab.
end-of-selection.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = PROGNAME
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND1'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = fieldcattab[]
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
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT = fieldcattab
IT_HYPERLINK =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_mseg
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 usercommand1 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
tabindex = rs_selfield-tabindex.
read table t_mseg INDEX tabindex.
select * from mchb into table t_mchb where matnr = t_mseg-matnr.
clear fieldcattab.
CLEAR fieldcattab[].
fieldcattab-col_pos = 1.
fieldcattab-fieldname = 'FLAG'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Check Box'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
fieldcattab-checkbox = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 2.
fieldcattab-fieldname = 'MATNR'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-fix_column = 'X'.
fieldcattab-seltext_l = 'Material'.
fieldcattab-emphasize = 'C1'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
fieldcattab-checkbox = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 3.
fieldcattab-fieldname = 'CHARG'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Batch No'.
fieldcattab-emphasize = 'C2'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 4.
fieldcattab-fieldname = 'WERKS'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Plant'.
fieldcattab-emphasize = 'C30'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
clear fieldcattab.
fieldcattab-col_pos = 5.
fieldcattab-fieldname = 'CLABS'.
fieldcattab-tabname = 'T_MCHB'.
fieldcattab-seltext_l = 'Stock'.
fieldcattab-emphasize = 'C601'.
fieldcattab-input = 'X'.
fieldcattab-edit = 'X'.
APPEND fieldcattab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = PROGNAME
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USERCOMMAND2'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = FIELDCATTAB[]
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
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_mchb
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.
endcase.
endform.
FORM usercommand2 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-sel_tab_field = 'T_MCHB-MATNR'.
CALL FUNCTION 'ZALV2'
EXPORTING
CTU = 'X'
MODE = 'E'
UPDATE = 'A'
GROUP =
USER =
KEEP =
HOLDDATE =
NODATA = '/'
MATNR_001 = '200-200'
KZSEL_01_002 = 'X'
IMPORTING
SUBRC =
TABLES
MESSTAB =
SET PARAMETER ID 'RID' FIELD RMMG1-MATNR.
CALL TRANSACTION 'MM03' and skip first screen.
ENDIF.
ENDCASE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = progname
i_callback_user_command = 'USERCOMMAND3'
it_fieldcat = fieldcattab[]
TABLES
t_outtab = t_mchb
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.
endcase.
ENDFORM.
Regards,
chandru -
Unable to capture data in an editable dynamic ALV.
Hi ,
I have created a dynamic editable ALV whose displayed structure can be changed at runtime based on the selection in a drop down list value selector.
Im trying to capture the values entered in the ALV into an internal table before the user changes the structure of the ALV to a different structure.
In the ON_SELECT event handler of the drop down list box , im rasing a data_check event to capture the ALV data.
The problem is that the control is not entering the event handler for the data_check event.
If i raise the data_check event in my save event handler or any other event handler , it works fine.
Can someone please suggest a solution.
Regards,
Newton.Hi ,
I have figured out that the problem is local to my machine , because the code works fine on other machines.
I guess my internet explorer has some bug.
Regards,
Newton.
Maybe you are looking for
-
How do I get a music track of an email to Ipad
How can I get a music track from an email on my IPad into my Music file on my ipad
-
Inactive External Procurement Relationship on a Trans Lane
Hello Experts, I have a situation were a PIR record in ECC has been flagged for deletion for a particular Material/Vendor/Plant/Purch Org. combination. The problem appears in APO. After the PIR changes are processed through the CIF, the External Proc
-
hi can anyone plz explain a small report based on oop in alv
-
How to send an individual video back to the cloud
How do I send a video (which is one of several in a season) back to the cloud so that I have room to download more from the cloud?
-
My iMac G5 without intel chips, Mac OS X 10.5.8. using Firefox 364 no problem at all. But unable to install Firefox 4 on it, prompt "You can't open the application because it is not supported on this architecture"