Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
a) In overloading, there is a relationship between methods available in the same class whereas
in overriding, there is relationship between a super class method and subclass method.
b) Overloading does not block inheritance Irom the super class whereas overriding blocks
inheritance Irom the super class.
c) In overloading, separate methods share the same name whereas in overriding, subclass
method replaces the super class.
d) Overloading must have diIIerent method signatures whereas overriding must have same
signature.
whut's un ALV Iield cutulog
In order to display some tabular data in an ALV,the ALV needs some inIormation about the
columns/ Iields which will be displayed in the ALV. Field catalog is basically the internal
table which carries inIormation about each oI the columns/ Iields with which ALV has to deal
with. It need not necessarily contain inIormation about each oI the columns/ Iields in the data
table used as data source oI ALV. Only the Iields which are important Ior display or oI some
technical use Ior ALV need to be inIormed to ALV through Iield catalog.
Field catalog containing descriptions oI the list output Iields. You can use Iields oI
the catalog to determine the number Iormat and column properties oI the list to be displayed.
The Iield catalog contains more than 60 Iields, some oI which are only used internally. The
Iield catalog is deIined in the Data Dictionary through table type LVCTFCAT.
We can get Iield description by calling Iunction module
REUSEALVFIELDCATALOGMERGE.
In general case, we only use Iew Iield to describe output Iield.
Demo program to color particular row or column or cell
of an ALV list using 'REUSE_ALV_LIST_DISPLAY'
y Haritha
REPORT ZALVLIST1.
TALES:
SPFLI.
TYPE-POOLS:
SLIS.
PARAMETERS:
PCOL TYPE I ,
PROW TYPE I,
PCOLOR(4) TYPE C .
DATA:
TFIELDCAT TYPE SLISTFIELDCATALV,
FSFIELDCAT LIKE LINE OF TFIELDCAT,
FSLAYOUT TYPE SLISLAYOUTALV ,
WCOLOR(4) ,
WROW TYPE I,
WFIELDNAME(20),
WPROG TYPE SY-REPID.
DATA:
EGIN OF TSPFLI OCCURS 0,
COLOR(4),
CHECKOX ,
CELL TYPE SLISTSPECIALCOLALV,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
CITYFROM TYPE SPFLI-CITYFROM,
CITYTO TYPE SPFLI-CITYTO,
DISTANCE TYPE SPFLI-DISTANCE,
END OF TSPFLI.
DATA:
FSCELL LIKE LINE OF TSPFLI-CELL.
SELECT *
FROM SPFLI
INTO CORRESPONDING FIELDS OF TALE TSPFLI.
WCOLOR PCOLOR.
TSPFLI-COLOR PCOLOR.
IF PCOL IS INITIAL AND PROW GT 0.
MODIFY TSPFLI INDEX PROW TRANSPORTING COLOR.
ENDIF.
FSFIELDCAT-FIELDNAME 'CARRID'.
FSFIELDCAT-REFTANAME 'SPFLI'.
FSFIELDCAT-COLPOS 1.
FSFIELDCAT-KEY 'X'.
FSFIELDCAT-HOTSPOT 'X'.
APPEND FSFIELDCAT TO TFIELDCAT.
CLEAR FSFIELDCAT .
FSFIELDCAT-FIELDNAME 'CONNID'.
FSFIELDCAT-REFTANAME 'SPFLI'.
FSFIELDCAT-COLPOS 2.
FSFIELDCAT-KEY 'X'.
FSFIELDCAT-HOTSPOT 'X'.
APPEND FSFIELDCAT TO TFIELDCAT.
CLEAR FSFIELDCAT .
FSFIELDCAT-FIELDNAME 'DISTANCE'.
FSFIELDCAT-REFTANAME 'SPFLI'.
FSFIELDCAT-COLPOS 3.
FSFIELDCAT-KEY ' '.
FSFIELDCAT-EDIT 'X'.
APPEND FSFIELDCAT TO TFIELDCAT.
CLEAR FSFIELDCAT.
FSFIELDCAT-FIELDNAME 'CITYFROM'.
FSFIELDCAT-REFTANAME 'SPFLI'.
FSFIELDCAT-COLPOS 4.
FSFIELDCAT-KEY ' '.
APPEND FSFIELDCAT TO TFIELDCAT.
LOOP AT TFIELDCAT INTO FSFIELDCAT.
IF FSFIELDCAT-COLPOS EQ PCOL.
FSFIELDCAT-EMPHASIZE PCOLOR.
WFIELDNAME FSFIELDCAT-FIELDNAME.
IF PROW IS INITIAL AND PCOL GT 0.
MODIFY TFIELDCAT FROM FSFIELDCAT TRANSPORTING EMPHASIZE.
ENDIF.
ENDIF.
ENDLOOP.
FSCELL-FIELDNAME WFIELDNAME .
FSCELL-COLOR-COL 6.
FSCELL-NOKEYCOL 'X'.
APPEND FSCELL TO TSPFLI-CELL.
IF PROW IS NOT INITIAL AND PCOL IS NOT INITIAL.
MODIFY TSPFLI INDEX PROW TRANSPORTING CELL.
ENDIF.
FSLAYOUT-INFOFIELDNAME 'COLOR'.
FSLAYOUT-OXFIELDNAME 'CHECKOX'.
FSLAYOUT-COLTAFIELDNAME 'CELL'.
FSLAYOUT-F2CODE '&ETA'.
WPROG SY-REPID.
CALL FUNCTION 'REUSEALVLISTDISPLAY'
EXPORTING
ICALLACKPROGRAM WPROG
ISLAYOUT FSLAYOUT
ITFIELDCAT TFIELDCAT
TALES
TOUTTA TSPFLI
EXCEPTIONS
PROGRAMERROR 1
OTHERS 2
.
IF SY-SURC ~ 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE
Column and Row are colored with a coded color Cxyz`.
Where C: Color (coding must begin with C)
X: Color Number
Y: old
Z: Inverse.
The Selection Screen will be as Iollows.
In the Selection screen iI we enter only the Column Number and color the whole column will
be colored as Iollows.
In the Selection screen iI we enter only the row Number and color, the whole column will be
colored as Iollows.
In the Selection screen iI we enter both the Row number and the Column Number then that
particular cell will be colored as Iollows (this color is not picked Irom selection screen, it is
already written in the program itselI)
Simple code for creating dropdown lists for columns in ALV grid output
Author : Swarna.S.
Published at SAPTechnical.CJM
REPJRT zalv_dropdowns.
Type pools declarations for ALV
TYPE-PJJLS : slis.
data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TJ cl_gui_alv_grid,
g_custom_container TYPE REF TJ cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
INTERNAL TABLE AND WA DECLARATIJNS FJR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE JF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
initialisation event
INITIALIZATIJN.
Start of selection event
START-JF-SELECTIJN.
Call to ALV
CALL SCREEN 600.
Jn this statement double click it takes you to the screen painter SE51.
Create a Custom container and name it CCJNT and JK code as JK_CJDE.
Save check and Activate the screen painter.
Now a normal screen with number 600 is created which holds the ALV grid.
PBJ of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
---------------------------------------------------------------------
MJDULE PBJ JUTPUT
---------------------------------------------------------------------
MJDULE pbo JUTPUT.
set pf-status 'xxx'.
set titlebar 'MAIN100'.
Subroutine to display the output in alv
PERFJRM alv_output.
ENDMJDULE. "pbo JUTPUT
PAI module of the screen created. In case we use an interactive ALV or
for additional functionalities we can create JK codes and
based on the user command we can do the coding.
---------------------------------------------------------------------
MJDULE PAI INPUT
---------------------------------------------------------------------
MJDULE pai INPUT.
ENDMJDULE. "pai INPUT
&---------------------------------------------------------------------
& Form BUILD_FIELDCAT
&---------------------------------------------------------------------
FJRM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
Build the field catalogue
CALL FUNCTIJN 'LVC_FIELDCATALJG_MERGE'
EXPJRTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LJJP AT gt_fieldcat INTJ ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
drdn-hndl = '1' is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MJDIFY gt_fieldcat FRJM ls_fcat.
drdn-hndl = '2' is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MJDIFY gt_fieldcat FRJM ls_fcat.
ENDCASE.
ENDLJJP.
ENDFJRM. "build_fieldcat
&---------------------------------------------------------------------
& Form ALV_JUTPUT
&---------------------------------------------------------------------
FJRM alv_output .
Create object for container
CREATE JBJECT g_custom_container
EXPJRTING container_name = 'CCJNT'.
create object for grid
CREATE JBJECT g_grid
EXPJRTING i_parent = g_custom_container.
Build fieldcat and set column
Assign a handle for the dropdown listbox.
PERFJRM build_fieldcat.
Build layout
PERFJRM build_layout.
Define a drop down table.
PERFJRM dropdown_table.
fetch values from the T517A table
SELECT FRJM t517a INTJ TABLE gt_outtab.
Display ALV output
CALL METHJD g_grid-set_table_for_first_display
EXPJRTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
ENDFJRM. "ALV_JUTPUT
&---------------------------------------------------------------------
& Form dropdown_table
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM dropdown_table.
Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Jther Establishment'.
APPEND ls_dropdown TJ lt_dropdown.
Second ABART listbox (handle '2').
ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TJ lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TJ lt_dropdown.
method to display the dropdown in ALV
CALL METHJD g_grid-set_drop_down_table
EXPJRTING
it_drop_down = lt_dropdown.
ENDFJRM. " dropdown_table
&---------------------------------------------------------------------
& Form build_layout
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
layout for ALV output
FJRM build_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DRJPDJWN LISTS'.
gs_layout-no_toolbar = 'X'.
ENDFJRM. " build_layout
' D7opdown lists output
D7op down ist 1 fo7 field $#% (educ,tion,l est,blish2ent)
D7op down ist 2 fo7 field B#%(ce7tific,te)