F4 help on ALV with FM REUSE_ALV_GRID_DISPLAY
Hi all;
A little question, I am implementing a editable ALV grid in R/3, for some fields the is an F4 input help available, for others not. (In the data dictionary is an F4 input help available for all fields from the Z-table). What can be wrong, or how do I attach the F4 input help in the coding of the ALV. The fields REF_TABLE and REF_FIELD from the fieldcatalog don't work.
Thanks in advance
<b>If you have F4 help at the Dictionary level, then those should definitely reflect in the ALV Grid.</b>
Check the dictionary table first.
Here is an example of F4 help.
Use Function Module F4IF_INT_TABLE_VALUE_REQUEST.
This Function Module returns the values selected in an internal table. Very
handy when programming your very own F4 help for a field.
Example:
data:
begin of t_values occurs 2,
value like kna1-begru,
end of t_values,
t_return like ddshretval occurs 0 with header line.
t_values = 'PAR*'.
append t_values.
t_values = 'UGG'.
append t_values.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'BEGRU'
value_org = 'S'
tables
value_tab = t_values
return_tab = t_return
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc = 0.
read table t_return index 1.
endif.
If you are using REUSE_ALV_GRID_DISPLAY..... make sure of these
In the filedcatalog have you mentioned the reference table and field
wa_fcat-ref_table = 'ZTABLE'.
wa_fcat-ref_field = 'FIELD'.
Regards,
Pavan
Similar Messages
-
Select single line in ALV with FM REUSE_ALV_GRID_DISPLAY
Hi!
How can i set for select just a single line in ALV? I´m using FM REUSE_ALV_GRID_DISPLAY and in layout structure doesn´t has field SEL_MODE for set.
In my ALV, in left site of colum names has a buttom for select all lines. I would like to hide this buttom. I removed this buttom from toolbar but it appear in left side of colum names yet.
Anybody can help me?I do that but buttom just disappear from toolbar. It still appear in left side of colum name.
My code:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'ALV_USER_COMMAND'
i_callback_pf_status_set = 'F_SET_PF_STATUS'
is_layout = gs_layout
it_fieldcat = gw_fieldcat
TABLES
t_outtab = gw_relat
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM f_set_pf_status USING t_kkblo_t_extab.
DATA: lw_fcode TYPE TABLE OF sy-ucomm.
APPEND '&ALL' TO lw_fcode.
APPEND '&SAL' TO lw_fcode.
SET PF-STATUS 'ALV_STATUS_GUI' EXCLUDING lw_fcode.
ENDFORM. "F_SET_PF_STATUS -
Help on ALV with multiple header/item output
Dear all:
Below is the actual working code on a multiple header/item display. The alv is supposed to output the details differently in each list. But somehow it only display the last i_tab I gave in all the list(they all look the same). Please help me out here how I can change my code to work properly. Thanks...
*& Report ZTEST2
REPORT ZTEST2.
type-pools: slis.
data : NUM1 type I,
NUM type I,
begin of str,
client like mara-mandt,
mat like mara-matnr,
end of str,
tab like standard table of str.
data :wa2 type slis_alv_event ,
tab2 like standard table of wa2,
wa1 type slis_layout_alv,
wa type line of slis_t_fieldcat_alv,
tab1 like standard table of wa.
wa-reptext_ddic = 'Client Num'.
wa-fieldname = 'CLIENT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MANDT'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'CLIENT'.
append wa to tab1.
wa-reptext_ddic = 'Mat Number'.
wa-fieldname = 'MAT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MATNR'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'MATERIAL'.
append wa to tab1.
wa1-no_colhead = 'X'.
wa2-NAME = SLIS_EV_TOP_OF_PAGE.
wa2-FORM = 'WRITE_TOP_PAGE'.
APPEND wa2 TO tab2.
NUM = 0.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog.
do 2 times.
NUM1 = NUM1 + 10.
refresh: tab.
select mandt matnr up to NUM1 rows from mara into table tab.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = wa1
IT_FIELDCAT = tab1
I_TABNAME = 'TAB'
IT_EVENTS = tab2
TABLES
T_OUTTAB = tab.
enddo.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
FORM WRITE_TOP_PAGE.
NUM = NUM + 1.
WRITE: / ,
/ 'TABLE NUMBER :', NUM.
ENDFORM.Hi Jim,
yes for some reason ALV expects you to be using different tables. It seems that it does not save the contents of the tables at each call of 'append' rather it waits until 'display' to deal with the table contents at that time, which in your case is the 20 items.
What you can do is use dynamic tables. check this out:
REPORT ZNRW_ALV_BLOCK .
type-pools: slis.
data : NUM1 type I,
NUM type I.
types:
begin of str,
client like mara-mandt,
mat like mara-matnr,
end of str.
data
tab type standard table of str.
data :wa2 type slis_alv_event ,
tab2 like standard table of wa2,
wa1 type slis_layout_alv,
wa type line of slis_t_fieldcat_alv,
tab1 like standard table of wa.
wa-reptext_ddic = 'Client Num'.
wa-fieldname = 'CLIENT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MANDT'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'CLIENT'.
append wa to tab1.
wa-reptext_ddic = 'Mat Number'.
wa-fieldname = 'MAT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MATNR'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'MATERIAL'.
append wa to tab1.
wa1-no_colhead = 'X'.
wa2-NAME = SLIS_EV_TOP_OF_PAGE.
wa2-FORM = 'WRITE_TOP_PAGE'.
APPEND wa2 TO tab2.
NUM = 0.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog.
DATA tabDREF TYPE REF TO DATA.
FIELD-SYMBOLS <tab> TYPE table.
do 2 times.
CREATE DATA tabdref TYPE table of str.
ASSIGN tabDREF->* TO <tab>.
NUM1 = NUM1 + 10.
refresh: tab.
select mandt matnr up to NUM1 rows from mara into table <tab>.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = wa1
IT_FIELDCAT = tab1
I_TABNAME = 'TAB'
IT_EVENTS = tab2
TABLES
T_OUTTAB = <tab>.
enddo.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
FORM WRITE_TOP_PAGE.
NUM = NUM + 1.
WRITE: / ,
/ 'TABLE NUMBER :', NUM.
ENDFORM. -
Output lenght in ALV with FM REUSE_ALV_GRID_DISPLAY
Hi people! I need some help!
I trying to set output lenght of a field to better view. I used in fieldcatalog OUTPUTLEN and set it to 50, but doesn't work...
Anyone can give me a tip?
Thanks!
i = i + 5.
CLEAR ltype_fieldcat.
ltype_fieldcat-col_pos = i.
ltype_fieldcat-fieldname = 'SOMA_6190'.
ltype_fieldcat-tabname = 'T_FINAL'.
ltype_fieldcat-ref_fieldname = 'DMBTR'.
ltype_fieldcat-ref_tabname = 'BSAD'.
ltype_fieldcat-seltext_s = 'Value Total Cod 6190'(025).
ltype_fieldcat-seltext_m = 'Value Total Cod 6190'(025).
ltype_fieldcat-seltext_l = 'Value Total Cod 6190'(025).
ltype_fieldcat-reptext_ddic = 'Value Total Cod 6190'(025).
ltype_fieldcat-outputlen = 50.
APPEND ltype_fieldcat TO t_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_pf_status_set = 'STATUS_GUI'
i_grid_title = 'Relatório de retenções de órgãos públicos'(021)
is_layout = l_layout
it_fieldcat = t_fieldcat[]
i_default = 'X'
i_save = 'X'
is_variant = l_variante
is_print = l_print
TABLES
t_outtab = t_final
EXCEPTIONS
program_error = 1
OTHERS = 2.also supply the intlen ,and ddic_outputlen.
ltype_fieldcat-reptext_ddic = 'Value Total Cod 6190'(025).
ltype_fieldcat-outputlen = 50.
ltype_fieldcat-intlen = 50.
ltype_fieldcat-DDIC_OUTPUTLEN = 50.
APPEND ltype_fieldcat TO t_fieldcat. -
F4 help in ALV report output (FM REUSE_ALV_GRID_DISPLAY)
Hello,
I have developed ALV report using the FM REUSE_ALV_GRID_DISPLAY.
My requirement is to have a customized search help on the output of ALV on one field.
I tried to find it on SDN but all the methods are using OO ALV.
How we can attaché customized search help in ALV developed using the FM REUSE_ALV_GRID_DISPLAY.
Kindly Help
Regards
SachinHii..
If you use OO then it is very easy to create a F4 help on the ALV..
try this sample code
<removed by moderator>
Hope this will help u..
Regards,
Jhings
Moderator message: please post only relevant code parts, your post must be less than 5000 characters to preserve formatting.
Edited by: Thomas Zloch on Mar 28, 2011 12:51 PM -
Editable field with F4 help in alv tree output using cl_gui_alv_tree
HI
i need Editable field with F4 help in alv tree output using cl_gui_alv_tree
Regards
NareshHi Naresh,
Pass the field catalog with the additional parameter (ls_fcat-edit = 'X'.).
for F4 help if the data element have the search help it automatically will come. other wise include the additional parameter in the field catalog (ls_fcat-F4AVAILABL = 'X')
Reward if found helpful.
Regards,
Boobalan Suburaj -
A ALV with some editable fields which have dictionary search help
Hi all:
There is a requirement to implement an ALV with some editable fields which have dictionary search help, do you have any idea?
thank you very muchHi - yes it can be done.
1st in your object select the component SALV_WD_TABLE (ALV component) * do all the bindings of your component to your VIEW, Component usage interface, etc.
When you are declaring your context node attributes if you add a TYPE Data element that has a search help bind to the data element it will be accessible in your ALV or in the Attribute there's a INPUT HELP that option that you can add the search help there but you need to have your ALV input enable
for example:
data: lr_input_field Type Ref To cl_salv_wd_uie_input_field,
lt_column Type salv_wd_t_column_ref,
ls_colum Type salv_wd_s_column_ref,
lv_value Type Ref To cl_salv_wd_config_table,
l_col_name type string,
lr_cmp_usage Type Ref To if_wd_component_usage,
lo_interfacecontroller Type Ref To iwci_salv_wd_table.
lr_cmp_usage = wd_this->wd_cpuse_alv( ). *ALV is the name you enter for your component usage when declaring component SALV_WD_TABLE at the beginning.
if lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
endif.
lo_interfacecontroller = wd_this->wd_cpifc_alv( ). *once again your ALV name
lv_value = lo_interfacecontroller->get_model( ).
lt_columns = lv_value->if_salv_wd_column_settings~get_columns( ).
Loop at lt_columns into ls_column.
l_col_name = ls_column-r_column->get_id( ).
create object lr_input_field
exporting
value_fieldname = l_col_name.
ls_column-r_column->set_cell_editor( value = lr_input_field ). *this will made all your columns input fields
endloop.
hope this help!
Jason PV -
Is there any help for ALV report development with funcation modules?
Hi,
please tell me any help or example to understand the ALV function module.Hi neha,
1. very simple alv
(with minimum code)
2. just copy paste
3.
report abc.
TYPE-POOLS : slis.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvfcwa TYPE slis_fieldcat_alv.
data : begin of itab occurs 0.
include structure usr02.
data : end of itab.
START-OF-SELECTION.
select * from usr02
into table itab.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
regards,
amit m. -
Explicit Search Helps Short-Dump in Editable ALV with included structure
I have an editable ALV grid defined as follows:
TYPES: BEGIN OF gs_outtab200.
TYPES: row_indx(4) TYPE n.
TYPES: multipurp TYPE c.
INCLUDE structure zxrfwc_test.
TYPES: end of gs_outtab200.
DATA:
gt_outtab200 TYPE TABLE OF gs_outtab200,
wa_outtab200 TYPE gs_outtab200.
The included structure zxrfwc_test has a component (field) which is defined with a data element that has an explicit search helps associated with it.
I know that this search help is working properly because it works fine in the program's selection screen.
But when I invoke the search help from within a column of the ALV itself, I get a short dump with a "GETWA_NOT_ASSIGNED" error.
I have done plenty of editable ALVs with search helps defined on the data elements and never encountered this problem.
Am I hitting this problem because the zxrfwc_test structure is defined within the
gs_outtab200 structure ??
If not, what is causing this problem. (Please note that I have set ls_fcat-F4AVAILABL = 'X' in the fieldcat routine - this doesn't seem to help at all.)
Please advise!!!!
I'm really stuck on this one because it's always worked before when I'm not dealing with a dictionary structure that's included within a larger ALV structure.
Thanks.Hi,
How you are creating your field catalog?
Try to create a field catalog in the following way giving reference to your structure. is it possible for you create a DDIC structure as same as
TYPES: BEGIN OF gs_outtab200.
TYPES: row_indx(4) TYPE n.
TYPES: multipurp TYPE c.
INCLUDE structure zxrfwc_test.
TYPES: end of gs_outtab200.
* Form f_generate_fieldcatalog *
* Form generate the field catalog table *
form f_generate_fieldcatalog.
* Private variable
data : v_structure like dd02l-tabname. " Table Name
v_structure = c_yatt_alv. " Structure Name
* Build the fieldcat according to DDIC structure YATT_ALV:
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = v_structure
i_client_never_display = c_x
changing
ct_fieldcat = i_fieldcat[].
endform. " F_generate_fieldcatalog
a® -
Hi Gurus,
I have created an editable ALV with F4 help, but the value doesnt reflect in the F4 help.
Regards,
ChinmayaHi Chinmaya,
Include the field F4AVAILABL in your field catalog internal table.
itab_fieldcatalog-F4AVAILABL = X
if you are not using the data element for the field 'F4' help won't come. in this situation, use the ONF4 event to build the F4 Help.
Reward if found helpful.
Regards,
Boobalan Suburaj -
HOW TO USE OOBJECT ORIENTD ALV INSTED OF REUSE_ALV_GRID_DISPLAY
Pls help me to implement the object oriented ALV Insted of REUSE_ALV_GRID_DISPLAY.
Pls find the report below its working fine but we want the OBJECT ORIENTD ALV.
THNAKS
TYPE-POOLS: slis. " ALV Global types
tables:pa0001,
pa0315,
pa0007,
disvariant.
Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_pernr FOR pa0001-pernr OBLIGATORY
. " Personnel No
SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh . " Organization unit
SELECT-OPTIONS: s_werks FOR pa0001-werks. " Personnel Area
SELECT-OPTIONS: s_plans FOR pa0001-plans. " Position
SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln. " Purchase order
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
*SELECT-OPTIONS: s_var FOR disvariant-variant.
PARAMETERS: p_disva1 LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b2k2.
Type Definition *
TYPES :
BEGIN OF ty_pa0001_pa0002,
pernr TYPE pa0001-pernr , " Personnel no.
endda TYPE pa0001-endda , " end date
begda TYPE pa0001-begda , " start date
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
plans TYPE pa0001-plans , " Position
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
END OF ty_pa0001_pa0002 ,
BEGIN OF ty_pa0315,
pernr TYPE pa0315-pernr , " Personnel no.
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
END OF ty_pa0315,
BEGIN OF ty_pa0007,
pernr TYPE pa0007-pernr,
schkz TYPE pa0007-schkz,
END OF ty_pa0007,
BEGIN OF ty_t527x,
orgeh TYPE t527x-orgeh,
orgtx TYPE t527x-orgtx,
END OF ty_t527x,
BEGIN OF ty_t528t,
plans TYPE t528t-plans,
plstx TYPE t528t-plstx,
END OF ty_t528t,
BEGIN OF ty_final,
pernr TYPE pa0001-pernr , " Personnel no.
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
orgtx TYPE t527x-orgtx , " Organizational text
plans TYPE pa0001-plans , " Position
plstx TYPE t528t-plstx , " Position text
schkz TYPE pa0007-schkz , " Work schedule rule
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks_p TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
begda TYPE pa0001-begda , " start date
endda TYPE pa0001-endda , " end date
END OF ty_final.
Data Declaration *
DATA :
t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
w_pa0315 TYPE ty_pa0315 ,
t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
w_pa0007 TYPE ty_pa0007 ,
t_t527x TYPE STANDARD TABLE OF ty_t527x ,
w_t527x TYPE ty_t527x ,
t_t528t TYPE STANDARD TABLE OF ty_t528t ,
w_t528t TYPE ty_t528t ,
t_final TYPE STANDARD TABLE OF ty_final ,
w_final TYPE ty_final .
START-OF-SELECTION .
SELECT a~pernr
a~endda
a~begda
a~bukrs
a~werks
a~persg
a~persk
a~btrtl
a~abkrs
a~kostl
a~orgeh
a~plans
b~nachn
b~vorna
b~midnm
INTO TABLE t_pa0001_pa0002
FROM pa0001 AS a INNER JOIN pa0002 AS b
ON apernr = bpernr
WHERE a~pernr IN s_pernr
AND a~werks IN s_werks
AND a~orgeh IN s_orgeh
AND a~plans IN s_plans.
SORT t_pa0001_pa0002 BY pernr .
IF NOT t_pa0001_pa0002[] IS INITIAL .
SELECT pernr
kostl
lstar
werks
lifnr
ebeln
ebelp
lstnr
FROM pa0315
INTO TABLE t_pa0315
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr
AND kostl = t_pa0001_pa0002-kostl
AND ebeln IN s_ebeln.
SELECT pernr
schkz
FROM pa0007
INTO TABLE t_pa0007
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr.
SELECT orgeh
orgtx
FROM t527x
INTO TABLE t_t527x
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE orgeh = t_pa0001_pa0002-orgeh.
SELECT plans
plstx
FROM t528t
INTO TABLE t_t528t
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE plans = t_pa0001_pa0002-plans.
ENDIF.
Merging data of t_pa0001_pa0002,t_pa0315 & t_pa0007 into t_final.
LOOP AT t_pa0001_pa0002 INTO w_pa0001_pa0002 .
MOVE-CORRESPONDING w_pa0001_pa0002 TO w_final.
READ TABLE t_pa0315 INTO w_pa0315 WITH KEY pernr =
w_pa0001_pa0002-pernr
kostl = w_pa0001_pa0002-kostl.
IF sy-subrc = 0.
w_final-kostl = w_pa0315-kostl.
w_final-lstar = w_pa0315-lstar.
w_final-werks_p = w_pa0315-werks.
w_final-lifnr = w_pa0315-lifnr.
w_final-ebeln = w_pa0315-ebeln.
w_final-ebelp = w_pa0315-ebelp.
w_final-lstnr = w_pa0315-lstnr.
ENDIF.
READ TABLE t_pa0007 INTO w_pa0007 WITH KEY pernr =
w_pa0001_pa0002-pernr.
IF sy-subrc = 0.
w_final-schkz = w_pa0007-schkz.
ENDIF.
READ TABLE t_t527x INTO w_t527x WITH KEY orgeh = w_pa0001_pa0002-orgeh
IF sy-subrc = 0.
w_final-orgtx = w_t527x-orgtx.
ENDIF.
READ TABLE t_t528t INTO w_t528t WITH KEY plans =
w_pa0001_pa0002-plans.
IF sy-subrc = 0.
w_final-plstx = w_t528t-plstx.
ENDIF.
APPEND w_final to t_final.
ENDLOOP.
PERFORM f_display_data.
FORM f_display_data.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'PERNR' 'PA0001'.
m_fieldcat 'NACHN' 'PA0002'.
m_fieldcat 'VORNA' 'PA0002'.
m_fieldcat 'MIDNM' 'PA0002'.
m_fieldcat 'BUKRS' 'PA0001'.
m_fieldcat 'WERKS' 'PA0001'.
m_fieldcat 'PERSG' 'PA0001'.
m_fieldcat 'PERSK' 'PA0001'.
m_fieldcat 'BTRTL' 'PA0001'.
m_fieldcat 'ABKRS' 'PA0001'.
m_fieldcat 'ORGEH' 'PA0001'.
m_fieldcat 'ORGTX' 'T527X'.
m_fieldcat 'PLANS' 'PA0001'.
m_fieldcat 'PLSTX' 'T528T'.
m_fieldcat 'SCHKZ' 'PA0007'.
m_fieldcat 'KOSTL' 'PA0315'.
m_fieldcat 'LSTAR' 'PA0315'.
m_fieldcat 'WERKS' 'PA0315'.
m_fieldcat 'LIFNR' 'PA0315'.
m_fieldcat 'EBELN' 'PA0315'.
m_fieldcat 'EBELP' 'PA0315'.
m_fieldcat 'LSTNR' 'PA0315'.
m_fieldcat 'BEGDA' 'PA0001'.
m_fieldcat 'ENDDA' 'PA0001'.
ls_fieldcat-col_pos = '1'.
ls_fieldcat-fieldname = 'PERNR'.
ls_fieldcat-tabname = 't_FINAL'.
*ls_fieldcat-rollname = 'PERNR'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '2'.
ls_fieldcat-fieldname = 'NACHN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '3'.
ls_fieldcat-fieldname = 'VORNA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '4'.
ls_fieldcat-fieldname = 'MIDNM'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0002'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '5'.
ls_fieldcat-fieldname = 'BUKRS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '6'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '7'.
ls_fieldcat-fieldname = 'PERSG'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '8'.
ls_fieldcat-fieldname = 'PERSK'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-fieldname = 'BTRTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '10'.
ls_fieldcat-fieldname = 'ABKRS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '11'.
ls_fieldcat-fieldname = 'ORGEH'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '12'.
ls_fieldcat-fieldname = 'ORGTX'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'T527X'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '13'.
ls_fieldcat-fieldname = 'PLANS'.
ls_fieldcat-tabname = 'T_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '14'.
ls_fieldcat-fieldname = 'PLSTX'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'T528T'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '15'.
ls_fieldcat-fieldname = 'SCHKZ'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0007'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '16'.
ls_fieldcat-fieldname = 'KOSTL'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '17'.
ls_fieldcat-fieldname = 'LSTAR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '18'.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '19'.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '20'.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '21'.
ls_fieldcat-fieldname = 'EBELP'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '22'.
ls_fieldcat-fieldname = 'LSTNR'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0315'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '23'.
ls_fieldcat-fieldname = 'BEGDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-col_pos = '24'.
ls_fieldcat-fieldname = 'ENDDA'.
ls_fieldcat-tabname = 't_FINAL'.
ls_fieldcat-ref_tabname = 'PA0001'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR: ls_fieldcat.
*DATA: v_repid TYPE sy-repid.
v_repid = sy-repid.
*Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = t_final.
ENDFORM. " F_DISPLAY_DATAHi,
<b>Sample programs on ALV Grid</b>
report zbnstest.
* TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
* GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
* INTERNAL TABLE DECLARATION.
* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
* INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
* INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
* INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
* THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
* AND THE LAYOUT FOR THE ALV.
* HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
* WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
* OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
* THIS IS DONE TO MAKE THE CODE SIMPLER.
* OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
* PROGRAMS.
* IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
* MORE TABLES AND CREATE A STRUCTURE
* IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
* LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
* DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
* TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
* DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
* STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
* INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
* START-OF-SELECTION. *
start-of-selection.
* SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
* SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
* INTERNAL TABLE.
perform selectdata_and_sort.
* SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
* SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
* SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
* SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
* SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
* FORMS
* IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
* OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
* COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
* FORM FILL_FIELDS_OF_FIELDCATALOG *
* --> FIELDCATALOG *
* --> P_TABNAME *
* --> P_FIELDNAME *
* --> P_KEY *
* --> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
* p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
* FORM POPULATE_LAYOUT *
* --> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
* FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
* This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
* fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
* FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
* FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
* i_structure_name = 'COLORSTRUCT'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
* IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
* FOLLOWS:-
* i_callback_program --> CALLING PROGRAM NAME
* i_structure_name --> STRUCTURE NAME.
* is_layout --> LAYOUT NAME.
* it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
* TOOL BAR
i_save = 'A'
* IS_VARIANT = ' '
it_events = eventstab[]
* IT_EVENT_EXIT =
* 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 =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
* text
* --> p1 text
* <-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
* text
* -->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
* WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
* INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
* AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
* EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
* BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
* THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
* WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
* FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
* IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
* text
* -->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
* WHEN 'HEADING5'.
* P_HEADING-TYP = 'H'.
* P_HEADING-INFO = 'LIST-MODIFY'.
* APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
* text
* -->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
* FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
* FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
* FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
* FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
* FORM LIST_MODIFY *
*FORM LIST_MODIFY.
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* IT_LIST_COMMENTARY = HEADING5[]
* EXCEPTIONS
* OTHERS = 1.
*ENDFORM.
* FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
* FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
* FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Regards
Sudheer -
Can I get a sample program of ALV (oops) with check boxes in it. thank you.
Types: begin of lt_io.
include structure mara. " Your Structure
Types: style_table type lvc_t_style.
Types: end of lt_io.
data: lt_io type table of lt_io,
ls_layout type lvc_s_layo,
lt_fcat type lvc_t_fcat,
lo_grid type ref to cl_gui_alv_grid.
field-symbols: <io> type lt_io,
<fcat> type lvc_s_fcat.
... fill your output table ....
ls_layout-stylefname = 'STYLE_TABLE'.
loop at lt_io assigning <io>.
PERFORM set_style USING 'CHECKBOX' "Your Filename
CHANGING <io>.
endloop.
... Fill Your Field Catalog lt_fcat
read table lt_fcat assigning <fcat>
where fieldname = 'CHECKBOX'.
<fcat>-checkbox = 'X'.
create grid control lo_grid.
CALL METHOD lo_grid->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_fieldcatalog = lt_fcat
it_outtab = lt_io[].
FORM set_button_to_line
USING iv_fieldname TYPE lvc_fname
CHANGING cs_io TYPE io.
DATA: ls_style TYPE lvc_s_styl,
lt_style TYPE lvc_t_styl.
ls_style-fieldname = iv_fieldname.
if cs_io-checkbox = ' '.
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
else.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
endif.
ls_style-maxlen = 2.
INSERT ls_style INTO TABLE io-style_table.
ENDFORM. "set_icon_to_status_line
[/code].
A classical report is a program that generates a single list, which must contain all of the required detail information.
1) This procedure may result in extensive lists from which the user has to pick the relevant data.
2) For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program.
3) The desired selections must be made beforehand and the list must provide detailed information.
4) For dialog sessions, there are no such restrictions.
5) The user is present during the execution of the program and can control and manipulate the program flow directly.
6) To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.
ALV is Application List viewer. 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.
Advantages.
Collapse multiple reports into one, drastically cutting down your report development time
Save many hours using built-in ALV sorting, subtotaling and filtering capabilities
Add conditional structures into your ALV report: No programming required!
Combine ALV with display variants to meet a wide range of reporting requirements more easily
Dynamically reorder column layouts and add/subtract fields
Enable users and analysts to save their own personalized variants
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
declarations for spl.group.
GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV
GT_SORT TYPE SLIS_T_SORTINFO_ALV, "for sort
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR LS_SORT.
LS_SORT-FIELDNAME = 'FIELD1'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
ls_sort-subtot = 'X'. "subtotal
APPEND LS_SORT TO E06_LT_SORT.
APPEND LS_SORT TO E06_LT_SORT.
LS_SORT-FIELDNAME = 'FIELD2'.
LS_SORT-SPOS = 2.
LS_SORT-UP = 'X'.
ls_sort-subtot = 'X'. "subtotal
APPEND LS_SORT TO E06_LT_SORT.
for creating the group..
DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.
CLEAR LS_SP_GROUP.
LS_SP_GROUP-SP_GROUP = 'A'.
LS_SP_GROUP-TEXT = TEXT-005.
APPEND LS_SP_GROUP TO E07_LT_SP_GROUP.
and pass this info to FM...
layout-sUBTOTALS_TEXT = 'SUbt...'
and pass spl group info to fieldcatalog also...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
IT_SPECIAL_GROUPS = GT_SP_GROUP[]
IT_SORT = GT_SORT[]
TYPES :
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
waerk TYPE vbak-waerk, " Document currency
END OF ty_vbak.
DATA:
vbak TYPE vbak,
gt_vbak TYPE TABLE OF ty_vbak.
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
Form f_read_data
FORM f_read_data.
SELECT vkorg kunnr vbeln netwr waerk
UP TO p_max ROWS
INTO TABLE gt_vbak
FROM vbak
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
Form f_display_data
FORM f_display_data.
TYPE-POOLS: slis. " ALV Global types
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM.
Check out these sample programs
BCALV_GRID_01
This program illustrates how the events for print processing PRINT_TOP_OF_PAGE,
PRINT_END_OF_PAGE, PRINT_TOP_OF_LIST,PRINT_END_OF_LIST are handled. The
corresponding handler methods control the appearance of the list printed.
BCALV_GRID_02
Show a detail list in an amodal window. There is no second dynro needed in contrast to
BCALV_GRID_03.
BCALV_GRID_03
This program implements a function on event DOUBLE_CLICK. According to the selected line data
from table SBOOK is selected and displayed by a second ALV Control in a dialog dynpro.
BCALV_GRID_04
Illustrates the use of exceptions (lights or leds). According to the values of SFLIGHT-SEATSOCC, the
lights are set to 1 (red), 2 (yellow) or 3 (green).
BCALV_GRID_05
Demonstrate the creation of an own toolbar button.
BCALV_GRID_06
Demonstrate the creation of an own context menu.
BCALV_GRID_07
Append a menu button to the standard toolbar.
BCALV_GRID_08
Append a menu with default button to the standard toolbar. It is exactly the same as
BCALVC_TB_WITH_MENU except for methods HANDLE_MENU_BUTTON and HANDLE_TOOLBAR.
Editable ALV grids
BCALV_EDIT_01
This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
BCALV_EDIT_02
This report illustrates how to set chosen cells of an ALV Grid Control editable.
BCALV_EDIT_03
In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
The report checks the input value(s) semantically and provides protocol messages in case of error
BCALV_EDIT_04
This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
implement the saving of the new data.
BCALV_EDIT_05
This example shows how to use checkboxes within an ALV Grid Control. You learn:
(1) how to define a column for editable checkboxes for an attribute of your list
(2) how to evaluate the checked checkboxes
(3) how to switch between editable and non-editable checkboxes
BCALV_EDIT_06
This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
Grid Control.
BCALV_EDIT_07
This example shows how to define dropdown listboxes for particular cells of your output table.
BCALV_EDIT_08
This report implements an ALV Grid Control with an application specific F4 help. The following aspects
are dealt with:
(1) how to replace the standard f4 help
(2) how to pass the selected value to the ALV Grid Control
(3) how to build an f4 help, whose value range depend on a value of another cell.
Check this link tooo
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/07/23/oopsALVin+ABAP&showComments=true
The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
standardized format. The list data is displayed as a table on the screen.
The ALV Grid Control offers a range of interactive standard list functions that users need
frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
export list (in different formats), and so on. These functions are implemented in the
proxy object class. You as the programmer have the possibility to turn off functions not
needed. In most cases the implementations of the standard functions provided by the
control are sufficient. However, if required, you can adjust these implementations to
meet application-specific needs.
You can add self-defined functions to the toolbar, if necessary.
The ALV Grid Control allows users to adjust the layout of lists to meet their individual
requirements (for example, they can swap columns, hide columns, set filters for the
data to be displayed, calculate totals, and so on). The settings (list customizing) made
by a specific user are called a display variant. Display variants can be saved on a userspecific
or on a global basis. If such display variants exist for a list, they can be offered
to the user for selection. If a display variant is set as the default variant, the associated
list is always displayed based on the settings of this variant.
2. REUSE_ALV_LIST_DISPLAY
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_COMMENTARY_WRITE
3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
7.fieldcat-fieldname
fieldcat-ref_fieldname
fieldcat-tabname
fieldcat-seltext_m
5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
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;
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
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
The object F_IT_ALV has a field, the activity ACTVT, which can
contain four permitted values: 01, 02, 03 and 70. Each of the
activities 01, 02 and 70 controls the availability of particular
functions (in the menu and the toolbar) of the ALV line item list:
a) 01: "Settings -> Display variant -> Save..."
b) 02: "Settings -> Display variant -> Current..." and
"Settings -> Display variant -> Current header rows "
c) 70: "Settings -> Display variant -> Administration..."
Activity 03 corresponds to the minimum authorization, which is the
most restricted one: The user can only select layouts which have
been configured already. In particular, all of the other functions
named above are inactive with activity 03.
Now if you want to permit a user to change the column selection and
the headers as well as to save the layout thus created, for example,
but if you do not want to permit the user to administrate the
layouts, you grant him or her the authorization for activities 01
and 02.
Check this link it will be mosty usefull for u
http://www.sap-img.com/fu017.htm
check this link
http://abapprogramming.blogspot.com/
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
Changing width of a custom container dynamically
Display Page numbers in ALV
Insert picture in selection screen.
Logo in OO ALV Grid
check these links
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
Try these links
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
For More alv report examples check these Tcodes LIBS, BIBS Here u can find more number of examples on alv reports of different kinds
check this sample code for intercative alv report
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 -
Where can i find the theory for alv with function modules
hi
where can i find the theory for alv with function modulesHi,
Please check this link
http://sap.niraj.tripod.com/id66.html
ALV function module
http://wiki.ittoolbox.com/index.php/How_do_I_insert_a_logo_in_ALV_using_Function_Modules%3F
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/using-function-module-fm-reuse_alv_grid_display-to-display-a-report-in-alv-1472543
reward if helpful
raam -
ALV with dropdown in column and other questions
hi,
I created an editable alv with configuration model via external context mapping.
now I have a column which contains strings and my aim is to show this whole column as a dropdownlist. the possible values of this dropdown are fetched in a database table at runtime and each cell in this column got its own selected value in this dropdownlist.
changes of the selected values should be written in the database table in a later step.
1. what changes do I have to do?
should I remove my external mapping concerning the alv and use the setData method? or what is the easiest way to get my dropdownlist in this column instead of normal text (string) ?
2. should I choose dropdownbykey or by index?
I suppose I have to change the context when changing the selected value in the dropdownlist and the read out the changed context element and update my database table?
3. how could I access rows (= tuples) in an alv?
4. how can I avoid that a row could be deleted, inserted or added with the normal functions of the alv?Hi Thorsten,
If the possible list of values in the dropdown is different for each row, you need a drop down by index. Else this can be done using a dropdown by key itself.
The only change that you need to do is create a cell editor of type dropdown for that particular column and configure your ALV model.
The sample code for changing the cell editor would be:
l_alv_model = l_ref_interfacecontroller->get_model( ).
DATA:
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column type ref to CL_SALV_WD_COLUMN.
lr_dropdown TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
lr_column_settings ?= l_alv_model.
lr_column = lr_column_settings->get_column( <column name> ).
CREATE OBJECT lr_dropdown EXPORTING
SELECTED_KEY_FIELDNAME= '<fieldname>'
lr_column->set_cell_editor( lr_dropdown ).
Here, you can substitute the field name with your field name that has to be displayed as a dropdown.
The dropdown list can be populated in the wddoinit method by attaching a value set to the attribute in the context node info. Everything else will be like you do in a normal table. You can so a get_static_attributes of your elements and persist in tables. Whenever you change the selected value, the context will be updated immediately. You can have a user defined function like 'Save' or something where you can just read the context and process the data.
If you do not want to display any of the normal functions, you can do the following:
data: lt_functions type SALV_WD_T_FUNCTION_STD_REF,
ls_function type SALV_WD_s_FUNCTION_STD_REF.
lt_functions = l_alv_model->if_salv_wd_function_settings~get_functions_std( ).
loop at lt_functions into ls_function.
ls_function-r_function->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ).
endloop.
The above code will hide all the standard functions. If you want to hide specific ones, do a get_function(id) and set_visible.
Hope this helps.
Regards
Nithya -
Hi all,
How to use ABAP objects. I have created a program in se38 and how to call this function. ehat is the function call name. What are the uses.Hi
Please check the standard SAP Programs
Goto SE38 and give BCALV and press F4 you will get standard SAP programs for most requirements.
They use ABAP OO to develop the ALV.
Also please check these links
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
http://www.geocities.com/mpioud/Abap_programs.html
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIDOCK/BCCIDOCK.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIGOF/BCCIGOF.pdf
http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm
http://esnips.com/doc/b708766f-a934-42a1-8064-c4de75b48fc4/Sample-Program-of-alv-using-oops.ppt
http://esnips.com/doc/a2e42503-cf0f-4418-94ee-580f5900a81f/alv-with-oop.doc
http://esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf
Hope this helps
Maybe you are looking for
-
So my husband peeled off the part where you are supposed to scratch and took off a good portion of the code on the back of 2 25 dollar itunes gift cards. I do not have the recipet and do not know what to do. Is there anyway I can still redeem then?
-
Problem using window.showModalDialog in Internet Explorer7
hi, can any one tell me the issues related with <b>window.showModalDialog</b> and Internet Explore 7 as i am getting error when i am trying to log out a page where i am using ShowModalDialog Thanks
-
Can be open a pdf without abrir it?
HELLO!! My consultation is the following one: I have passed a Smartforms to pdf and no problemu2026 The question is the siguente abrir the pdf I have to keep it in a directoryu2026 The pdf without keeping it in a directory can be open. Program: O
-
How to map the form fields with zoho crm module?
I am integrating a web app with Zoho CRM,I created a form in .aspx and put some fields on it like first name,last name,email etc.Now i want to map these fields with the zoho crm contacts module,so that when i submit this form it will save the data th
-
Is there a good file encryption app for iPad2?
I am looking for an app to encrypt text notes of private information on the iPad2. Does anyone know of such an app? Thanks, APS Csontos