‎2007 Dec 20 6:56 AM
hi friends below are sm questions which i faced in intervw.....plz answer it if u knw....
1)what is fieldcatloq in alv ?
2)what are the fields in the structure of fieldcatlog?
3)what is layout in alv? why do we use it?
4)what are the fields in the structure of layout in alv?
5)we declare the type-groups in alvs by using the statement TYPE-POOLS : SLIS
what does this type pools mean?
6)what is the use of REUSE_FLDCATLOG_MERGE function module?
7)Is it mandatory to pass the structure name in reuse_fldcatlog_merge function module. if we dnt gv want will happen.
8)what actually event does in alvs?
9)what are the ffiields of the structure SLIS_T_EVENT?
10)what is the header in alv program?
11)hw to set hotspot in alv report for a field?
12)in alvs hw to get the default values in the selection screen?
13)what is the difference between list,grid , block display?
14)what is bloc display? why is it differnt from other displays?
15)i have created one program in alvs, in that internal table contains 2fields.while in my structure contains 5 fields.
when output is displayed it showing all the fields of structure instead of internal table fields. hw to get only those two fields of intenal table?
‎2007 Dec 20 8:11 AM
*************************************************************
1
What is fieldcatalog in ALV?
Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE. You can see the sample in my post about Simple ALV Report.
In general case, we only use few field to describe output field.
To make it easier I use this form:
FORM f_alv_fieldcatg USING
fu_types "internal table name
fu_fname "Field name of internal table field
fu_reftb "reference table name
fu_refld "reference table field
fu_noout "X= No out
fu_outln "out
fu_fltxt "output length
fu_dosum "X=Do sum (total)
fu_hotsp "X=hotspot on
fu_just. "Justification:L,R,C
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_out = fu_noout.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-just = fu_just.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg
We can use it in two way:
1. refer to data dictionary:
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'EQUNR' 'EQUI' 'EQUNR' '' '' '' '' 'X' '',
'SPART' 'VBAK' 'SPART' '' '' '' '' '' ''.
2. or define yourself
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'FIELD1' '' '' '' '20' 'Text Field1' '' '' ''.
and for field with type number, I use this:
&----
*& Form f_alv_fieldcatg_number
&----
text
----
FORM f_alv_fieldcatg_number USING fu_types
fu_fname
fu_noout
fu_outln
fu_no_sign
fu_no_zero
fu_fltxt
fu_dosum
fu_exponent
fu_decimals_out.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_zero = fu_no_zero.
t_fieldcat-no_sign = fu_no_sign.
t_fieldcat-exponent = fu_exponent.
t_fieldcat-decimals_out = fu_decimals_out.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-datatype = 'FLTP'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg_number
For field currency, there are two options, fixed currency or variable currency.
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_cfield.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr_fixed USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_curr.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-datatype = 'CURR'.
t_fieldcat-currency = fu_curr.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
-
2.
Building a fieldcatalog based on a dictionary structure/table
This Method requires you to create a dictionary structure via
SE11 and pass that in the 'I_STRUCTURE_NAME' parameter.
The below example will be for all of EKKO but you could create a new
structure containing only the fields you require.
-
3
With the help of layout in ALV you can set the overall options for the ALV
Like:
ZEBRA - for zebra coloring
COLUMN_WIDTH_OPTIMAZTION - to optimize the columns
COLOR
BOX_FIELD - for checkbox
Layout controls the look Displaye parameters of your ALV..Check
FORM alv_layo.
g_r_layo-grid_title = text-019 . ( eg " Title of Grid )
g_r_layo-cwidth_opt = g_c_mark.
g_r_layo-zebra = g_c_mark.
g_r_layo-no_rowmark = space.
g_r_layo-sel_mode = g_c_selmode.
ENDFORM. " alv_layo
**************************************************************************
4
ZEBRA - for zebra coloring
COLUMN_WIDTH_OPTIMAZTION - to optimize the columns
COLOR
BOX_FIELD - for checkbox
*****************************************************************************
5.
Type pool is a collection of pre defined data types..
Frequently used data types in programming are clubbed into a type pool so that if u write in ur code:
TYPE-POOLS: slis.
the declarations in SLIS will apply to ur code also..
SLIS contains data definitions for ALV structures & internal tables. so that u dont need to declare alv data everytime in ur program..
check out type pools: ICON, etc.. In SE11, type groups..
We can use ABAP ALV LIST and GRID function modules to display Normal LIST and Hiearchical LISTS .
All the definitions TYPES and STRUCTURES and CONSTANTS are defined
in the TYPE-POOL 'SLIS' ,so it should be declared first.
TYPE-POOLS : 'SLIS' .
using type pools you can create global data declarations of an ABAP program.
TYPE Pools can be thought of as an include having TYPE declarations.
The use of this in your program gives your program access to these TYPE declarations which can then be used directly in your program when declaring new data declaration
*********************************************************************************
6.The function REUSE_ALV_FIELDCATALOG_MERGE is used for retrieve a catalog from a table defined in DDIC.
*********************************************************************************
7.
yes,
otherwise dump occurs..
******************************************************************************
8.
The main events in alv and their FM and why we use these:
1. SLIS_PRINT_ALV.
2. SLIS_T_LISTHEADER.
3. SLIS_T_EVENT.
4. SLIS_T_SORTINFO_ALV.
5. SLIS_T_LAYOUT_ALV.
6. SLIS_T_FIELDCAT_ALV.
For more information check the following link:
http://sap-img.com/abap/what-are-the-events-in-alv.htm
*************************************************************************
9.
SLIS_T_EVENT: Internal table for storing all the possible events of the ALV. This can be populated by the function module Reuse_alv_events_get
The columns are :
name : name of the event
form : name of the routine
*****************************************************************************
10.
we are having a FM to display header information....... on top of alv.
REUSE_ALV_COMMENTARY_WRITE is the FM used to display the header info for ALV.
List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.
This module outputs formatted simple header information at TOP-OF-PAGE.
Example
List <-- Type 'H'
Currency DEM Controlling area currency <-- Type 'S'
Material FGS_TEST Test material <-- Type 'S'
Action info <-- Type 'A'
-
Column headers
-
-
List
-
**************************************************************************
11
do this way
codefieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.[/code]
Check out this sample program
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
************************************************************************
12.
In INITIALIZATION event you can set like that.
INITIALIZATION.
s_date -low = sy-datum -1.
so that it will take that date always
**************************************************************
13.
For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
ALV LIST Can be coded using only FMs
ALV GRID Can be coded using FMs and object oriented concepts
ALV LIST Can be displayed hieraicharlly
ALV GRID cannot be displayed hierarichally
********************************************
14.
you need to call three FM's.
REUSE_ALV_BLOCK_LIST_INIT "initialization
REUSE_ALV_BLOCK_LIST_APPEND "append
REUSE_ALV_BLOCK_LIST_DISPLAY "display
1.
Blocked report means displaying multiple outputs one by one .
3 function module are used to display ALV blocked report.
REUSE_ALV_BLOCK_LIST_INIT.
REUSE_ALV_BLOCK_LIST_APPEND
pass the table which u want to display .
If u want to display another table call again .Like that u can call for more outputs on single list screen.
REUSE_ALV_BLOCK_LIST_DISPLAY
2.
Have a look at this sample program.
REPORT zvenkat_head1.
DATA: BEGIN OF i_mard OCCURS 0,
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 i_mard.
DATA: BEGIN OF i_makt OCCURS 0,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
maktg TYPE makt-maktg,
END OF i_makt.
&----
*& ALV Variables
&----
TYPE-POOLS :slis.
DATA :i_field TYPE slis_t_fieldcat_alv,
w_field LIKE LINE OF i_field,
w_layout TYPE slis_layout_alv,
i_events TYPE slis_t_event,
w_events LIKE LINE OF i_events.
DATA :i_field1 TYPE slis_t_fieldcat_alv,
w_field1 LIKE LINE OF i_field1,
w_layout1 TYPE slis_layout_alv,
i_events1 TYPE slis_t_event,
w_events1 LIKE LINE OF i_events1.
&----
*& START-OF-SELECTION
&----
START-OF-SELECTION.
PERFORM get_data_from_database .
&----
*& END-OF-SELECTION
&----
END-OF-SELECTION.
PERFORM build_fieldcatalog.
PERFORM build_events.
PERFORM display_data.
&----
*& Form build_fieldcatalog
&----
FORM build_fieldcatalog .
CLEAR :
w_field,
i_field[].
CLEAR :
w_field1,
i_field1[].
*----
Fieldcatalog 1
w_field-fieldname = 'WERKS' .
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Plant'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'LGORT' .
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'S.Location'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'MATNR'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Mat No'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'INSME' .
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'quality Stock'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'EINME'.
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Total Stock'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'SPEME'.
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Blocked stock'.
APPEND w_field TO i_field.
CLEAR w_field.
*----
Fieldcatalog 2
w_field1-fieldname = 'MATNR'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MATNR'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
w_field1-fieldname = 'MAKTX'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MAKTX'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
w_field1-fieldname = 'MAKTG'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MAKTG'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
ENDFORM. " build_fieldcatalog
&----
*& Form build_events
&----
FORM build_events .
CLEAR:
w_events,
i_events[],
w_events1,
i_events1[].
w_events-name = 'TOP_OF_PAGE' .
w_events-form = 'TOP_OF_PAGE' .
APPEND w_events TO i_events.
CLEAR w_events.
w_events1-name = 'TOP_OF_PAGE' .
w_events1-form = 'TOP_OF_PAGE' .
APPEND w_events1 TO i_events1.
CLEAR w_events1.
ENDFORM. " build_events
&----
*& Form display_data
&----
FORM display_data .
DATA :program LIKE sy-repid VALUE sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = program
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = w_layout
it_fieldcat = i_field
i_tabname = 'I_MARD'
it_events = i_events
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = i_mard
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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = w_layout
it_fieldcat = i_field1
i_tabname = 'I_MAKT'
it_events = i_events1
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = i_makt
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.
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_data
&----
*& Form get_data_from_database
&----
text
-
FORM get_data_from_database .
SELECT werks lgort matnr insme einme speme
FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard
UP TO 20 ROWS
WHERE werks = 'WF01'.
SELECT matnr
maktx
maktg
FROM makt
INTO TABLE i_makt
UP TO 20 ROWS.
ENDFORM. " get_data_from_database
&----
*& Form top_of_page
&----
text
-
FORM top_of_page.
DATA: inc_colnum TYPE i.
ULINE .
inc_colnum = sy-linsz - 60.
WRITE: / 'Report: ', sy-repid(18).
WRITE AT 30(inc_colnum) sy-title CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Page: ', (11) sy-pagno RIGHT-JUSTIFIED.
WRITE: / 'Client: ', sy-mandt.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Date: ', sy-datum.
WRITE: / 'User : ', sy-uname.
inc_colnum = sy-linsz - 60.
WRITE AT 30(inc_colnum) 'Blocked ALV' CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Time: ', (10) sy-uzeit RIGHT-JUSTIFIED.
ULINE .
ENDFORM. "top_of_page
*********************************************
15.
Define ur Fieldcatalog table like this .
DATA:
i_field TYPE lvc_t_fcat,
w_field TYPE lvc_s_fcat.
2.
Build like this
FORM build_fieldcatalog_tab .
DATA :pos TYPE i VALUE 1.
CLEAR: w_field,i_field[],pos.
w_field-col_pos = pos + 1.
w_field-fieldname = 'MATNR' .
w_field-tabname = 'I_MARC' .
w_field-scrtext_m = 'Material' .
APPEND w_field TO i_field.
CLEAR w_field.
w_field-col_pos = pos + 1.
w_field-fieldname = 'WERKS' .
w_field-tabname = 'I_MARC' .
w_field-scrtext_m = 'Plant' .
APPEND w_field TO i_field.
CLEAR w_field.
ENDFORM.
3.
Pass through this method
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
i_structure_name = 'MARA'
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = w_layout
IS_PRINT = w_print
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_field
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
4.
You should remove
i_structure_name = 'JOINTAB'
y should use this when u pass single table data display.
HOPE THIS HELPFUL TO YOU
*************************************************
THANX AND REGARDS......................
‎2007 Dec 20 7:10 AM
1)what is fieldcatloq in alv ?
field catalog is like a output layout... in which our data goes ans fits into it.
2)what are the fields in the structure of fieldcatlog?
there are many .. of which moslty we use field name_l /m /s
output length
field name
ref tabname
ref field name
key
sort etc...
3)what is layout in alv? why do we use it?
layout is the place when we can adjust the order of the fields... sort some fields etc... and we can save kind of our user settings for that report output...
4)what are the fields in the structure of layout in alv?
5)we declare the type-groups in alvs by using the statement TYPE-POOLS : SLIS
what does this type pools mean?
the alv field catalog is defined in types and there many of such soo type-pools of which we pick SLIS.. there are others aswell..
6)what is the use of REUSE_FLDCATLOG_MERGE function module?
we need not create field catalog for every field, think if its a standard structure with 100 field,, u cant create the for all the 100 fields,, in that scenario we use alv field catlog merge.. to autmatically create a field catalog for the std structure.
7)Is it mandatory to pass the structure name in reuse_fldcatlog_merge function module. if we dnt gv want will happen.
yes its mandt.. if we dont pass and nothing else... we dont get the field catalog..
8)what actually event does in alvs?
9)what are the ffiields of the structure SLIS_T_EVENT?
10)what is the header in alv program?
11)hw to set hotspot in alv report for a field?
in field catalog u have a field hot-spot u set it to X.
12)in alvs hw to get the default values in the selection screen?
in field catalog we can assign default..
13)what is the difference between list,grid , block display?
the output type .. like windoes XP , windows Vista..
14)what is bloc display? why is it differnt from other displays?
15)i have created one program in alvs, in that internal table contains 2fields.while in my structure contains 5 fields.
when output is displayed it showing all the fields of structure instead of internal table fields. hw to get only those two fields of intenal table?
play with field catalog.. some thing realted to field catalog stuff..
award points if useful....
‎2007 Dec 20 8:11 AM
*************************************************************
1
What is fieldcatalog in ALV?
Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE. You can see the sample in my post about Simple ALV Report.
In general case, we only use few field to describe output field.
To make it easier I use this form:
FORM f_alv_fieldcatg USING
fu_types "internal table name
fu_fname "Field name of internal table field
fu_reftb "reference table name
fu_refld "reference table field
fu_noout "X= No out
fu_outln "out
fu_fltxt "output length
fu_dosum "X=Do sum (total)
fu_hotsp "X=hotspot on
fu_just. "Justification:L,R,C
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_out = fu_noout.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-just = fu_just.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg
We can use it in two way:
1. refer to data dictionary:
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'EQUNR' 'EQUI' 'EQUNR' '' '' '' '' 'X' '',
'SPART' 'VBAK' 'SPART' '' '' '' '' '' ''.
2. or define yourself
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'FIELD1' '' '' '' '20' 'Text Field1' '' '' ''.
and for field with type number, I use this:
&----
*& Form f_alv_fieldcatg_number
&----
text
----
FORM f_alv_fieldcatg_number USING fu_types
fu_fname
fu_noout
fu_outln
fu_no_sign
fu_no_zero
fu_fltxt
fu_dosum
fu_exponent
fu_decimals_out.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_zero = fu_no_zero.
t_fieldcat-no_sign = fu_no_sign.
t_fieldcat-exponent = fu_exponent.
t_fieldcat-decimals_out = fu_decimals_out.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-datatype = 'FLTP'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg_number
For field currency, there are two options, fixed currency or variable currency.
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_cfield.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr_fixed USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_curr.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-datatype = 'CURR'.
t_fieldcat-currency = fu_curr.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
-
2.
Building a fieldcatalog based on a dictionary structure/table
This Method requires you to create a dictionary structure via
SE11 and pass that in the 'I_STRUCTURE_NAME' parameter.
The below example will be for all of EKKO but you could create a new
structure containing only the fields you require.
-
3
With the help of layout in ALV you can set the overall options for the ALV
Like:
ZEBRA - for zebra coloring
COLUMN_WIDTH_OPTIMAZTION - to optimize the columns
COLOR
BOX_FIELD - for checkbox
Layout controls the look Displaye parameters of your ALV..Check
FORM alv_layo.
g_r_layo-grid_title = text-019 . ( eg " Title of Grid )
g_r_layo-cwidth_opt = g_c_mark.
g_r_layo-zebra = g_c_mark.
g_r_layo-no_rowmark = space.
g_r_layo-sel_mode = g_c_selmode.
ENDFORM. " alv_layo
**************************************************************************
4
ZEBRA - for zebra coloring
COLUMN_WIDTH_OPTIMAZTION - to optimize the columns
COLOR
BOX_FIELD - for checkbox
*****************************************************************************
5.
Type pool is a collection of pre defined data types..
Frequently used data types in programming are clubbed into a type pool so that if u write in ur code:
TYPE-POOLS: slis.
the declarations in SLIS will apply to ur code also..
SLIS contains data definitions for ALV structures & internal tables. so that u dont need to declare alv data everytime in ur program..
check out type pools: ICON, etc.. In SE11, type groups..
We can use ABAP ALV LIST and GRID function modules to display Normal LIST and Hiearchical LISTS .
All the definitions TYPES and STRUCTURES and CONSTANTS are defined
in the TYPE-POOL 'SLIS' ,so it should be declared first.
TYPE-POOLS : 'SLIS' .
using type pools you can create global data declarations of an ABAP program.
TYPE Pools can be thought of as an include having TYPE declarations.
The use of this in your program gives your program access to these TYPE declarations which can then be used directly in your program when declaring new data declaration
*********************************************************************************
6.The function REUSE_ALV_FIELDCATALOG_MERGE is used for retrieve a catalog from a table defined in DDIC.
*********************************************************************************
7.
yes,
otherwise dump occurs..
******************************************************************************
8.
The main events in alv and their FM and why we use these:
1. SLIS_PRINT_ALV.
2. SLIS_T_LISTHEADER.
3. SLIS_T_EVENT.
4. SLIS_T_SORTINFO_ALV.
5. SLIS_T_LAYOUT_ALV.
6. SLIS_T_FIELDCAT_ALV.
For more information check the following link:
http://sap-img.com/abap/what-are-the-events-in-alv.htm
*************************************************************************
9.
SLIS_T_EVENT: Internal table for storing all the possible events of the ALV. This can be populated by the function module Reuse_alv_events_get
The columns are :
name : name of the event
form : name of the routine
*****************************************************************************
10.
we are having a FM to display header information....... on top of alv.
REUSE_ALV_COMMENTARY_WRITE is the FM used to display the header info for ALV.
List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.
This module outputs formatted simple header information at TOP-OF-PAGE.
Example
List <-- Type 'H'
Currency DEM Controlling area currency <-- Type 'S'
Material FGS_TEST Test material <-- Type 'S'
Action info <-- Type 'A'
-
Column headers
-
-
List
-
**************************************************************************
11
do this way
codefieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.[/code]
Check out this sample program
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
************************************************************************
12.
In INITIALIZATION event you can set like that.
INITIALIZATION.
s_date -low = sy-datum -1.
so that it will take that date always
**************************************************************
13.
For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
ALV LIST Can be coded using only FMs
ALV GRID Can be coded using FMs and object oriented concepts
ALV LIST Can be displayed hieraicharlly
ALV GRID cannot be displayed hierarichally
********************************************
14.
you need to call three FM's.
REUSE_ALV_BLOCK_LIST_INIT "initialization
REUSE_ALV_BLOCK_LIST_APPEND "append
REUSE_ALV_BLOCK_LIST_DISPLAY "display
1.
Blocked report means displaying multiple outputs one by one .
3 function module are used to display ALV blocked report.
REUSE_ALV_BLOCK_LIST_INIT.
REUSE_ALV_BLOCK_LIST_APPEND
pass the table which u want to display .
If u want to display another table call again .Like that u can call for more outputs on single list screen.
REUSE_ALV_BLOCK_LIST_DISPLAY
2.
Have a look at this sample program.
REPORT zvenkat_head1.
DATA: BEGIN OF i_mard OCCURS 0,
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 i_mard.
DATA: BEGIN OF i_makt OCCURS 0,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
maktg TYPE makt-maktg,
END OF i_makt.
&----
*& ALV Variables
&----
TYPE-POOLS :slis.
DATA :i_field TYPE slis_t_fieldcat_alv,
w_field LIKE LINE OF i_field,
w_layout TYPE slis_layout_alv,
i_events TYPE slis_t_event,
w_events LIKE LINE OF i_events.
DATA :i_field1 TYPE slis_t_fieldcat_alv,
w_field1 LIKE LINE OF i_field1,
w_layout1 TYPE slis_layout_alv,
i_events1 TYPE slis_t_event,
w_events1 LIKE LINE OF i_events1.
&----
*& START-OF-SELECTION
&----
START-OF-SELECTION.
PERFORM get_data_from_database .
&----
*& END-OF-SELECTION
&----
END-OF-SELECTION.
PERFORM build_fieldcatalog.
PERFORM build_events.
PERFORM display_data.
&----
*& Form build_fieldcatalog
&----
FORM build_fieldcatalog .
CLEAR :
w_field,
i_field[].
CLEAR :
w_field1,
i_field1[].
*----
Fieldcatalog 1
w_field-fieldname = 'WERKS' .
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Plant'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'LGORT' .
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'S.Location'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'MATNR'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Mat No'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'INSME' .
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'quality Stock'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'EINME'.
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Total Stock'.
APPEND w_field TO i_field.
CLEAR w_field.
w_field-fieldname = 'SPEME'.
w_field-do_sum = 'X'.
w_field-tabname = 'I_MARD'.
w_field-seltext_m = 'Blocked stock'.
APPEND w_field TO i_field.
CLEAR w_field.
*----
Fieldcatalog 2
w_field1-fieldname = 'MATNR'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MATNR'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
w_field1-fieldname = 'MAKTX'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MAKTX'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
w_field1-fieldname = 'MAKTG'.
w_field1-tabname = 'I_MAKT'.
w_field1-seltext_m = 'MAKTG'.
APPEND w_field1 TO i_field1.
CLEAR w_field1.
ENDFORM. " build_fieldcatalog
&----
*& Form build_events
&----
FORM build_events .
CLEAR:
w_events,
i_events[],
w_events1,
i_events1[].
w_events-name = 'TOP_OF_PAGE' .
w_events-form = 'TOP_OF_PAGE' .
APPEND w_events TO i_events.
CLEAR w_events.
w_events1-name = 'TOP_OF_PAGE' .
w_events1-form = 'TOP_OF_PAGE' .
APPEND w_events1 TO i_events1.
CLEAR w_events1.
ENDFORM. " build_events
&----
*& Form display_data
&----
FORM display_data .
DATA :program LIKE sy-repid VALUE sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = program
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = w_layout
it_fieldcat = i_field
i_tabname = 'I_MARD'
it_events = i_events
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = i_mard
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.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = w_layout
it_fieldcat = i_field1
i_tabname = 'I_MAKT'
it_events = i_events1
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = i_makt
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.
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_data
&----
*& Form get_data_from_database
&----
text
-
FORM get_data_from_database .
SELECT werks lgort matnr insme einme speme
FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard
UP TO 20 ROWS
WHERE werks = 'WF01'.
SELECT matnr
maktx
maktg
FROM makt
INTO TABLE i_makt
UP TO 20 ROWS.
ENDFORM. " get_data_from_database
&----
*& Form top_of_page
&----
text
-
FORM top_of_page.
DATA: inc_colnum TYPE i.
ULINE .
inc_colnum = sy-linsz - 60.
WRITE: / 'Report: ', sy-repid(18).
WRITE AT 30(inc_colnum) sy-title CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Page: ', (11) sy-pagno RIGHT-JUSTIFIED.
WRITE: / 'Client: ', sy-mandt.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Date: ', sy-datum.
WRITE: / 'User : ', sy-uname.
inc_colnum = sy-linsz - 60.
WRITE AT 30(inc_colnum) 'Blocked ALV' CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Time: ', (10) sy-uzeit RIGHT-JUSTIFIED.
ULINE .
ENDFORM. "top_of_page
*********************************************
15.
Define ur Fieldcatalog table like this .
DATA:
i_field TYPE lvc_t_fcat,
w_field TYPE lvc_s_fcat.
2.
Build like this
FORM build_fieldcatalog_tab .
DATA :pos TYPE i VALUE 1.
CLEAR: w_field,i_field[],pos.
w_field-col_pos = pos + 1.
w_field-fieldname = 'MATNR' .
w_field-tabname = 'I_MARC' .
w_field-scrtext_m = 'Material' .
APPEND w_field TO i_field.
CLEAR w_field.
w_field-col_pos = pos + 1.
w_field-fieldname = 'WERKS' .
w_field-tabname = 'I_MARC' .
w_field-scrtext_m = 'Plant' .
APPEND w_field TO i_field.
CLEAR w_field.
ENDFORM.
3.
Pass through this method
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
i_structure_name = 'MARA'
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = w_layout
IS_PRINT = w_print
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_field
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
4.
You should remove
i_structure_name = 'JOINTAB'
y should use this when u pass single table data display.
HOPE THIS HELPFUL TO YOU
*************************************************
THANX AND REGARDS......................