Sei sulla pagina 1di 54

DiIIerence between method overloading and method overriding

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)

Sample ALV Grid program using the function module


REUSE_ALV_GRID_DISPLAY
y Vikram Chellappa, Mouri Tech Solutions
&---------------------------------------------------------------------
& Report ZALV_REPJRT_SFLIGHT
&
&---------------------------------------------------------------------
Published at SAPTechnical.CJM
&---------------------------------------------------------------------
REPJRT ZALV_REPJRT_SFLIGHT.
TABLES : SFLIGHT.
TYPE-PJJLS : SLIS.
INTERNAL TABLE DECLARTIJN
DATA : WA_SFLIGHT TYPE SFLIGHT,
IT_SFLIGHT TYPE TABLE JF SFLIGHT.
DATA DECLARTIJN
DATA: FIELDCATALJG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYJUT TYPE SLIS_LAYJUT_ALV,
GD_REPID LIKE SY-REPID,
G_SAVE TYPE C VALUE 'X',
G_VARIANT TYPE DISVARIANT,
GX_VARIANT TYPE DISVARIANT,
G_EXIT TYPE C,
ISPFLI TYPE TABLE JF SPFLI.
To understand the importance of the following parameter, click here.
SELECTIJN SCREEN DETAILS
SELECTIJN-SCREEN BEGIN JF BLJCK B1 WITH FRAME TITLE TEXT-002 .
PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT.
SELECTIJN-SCREEN END JF BLJCK B1.
GETTING DEFAULT VARIANT
INITIALIZATIJN.
GX_VARIANT-REPJRT = SY-REPID.
CALL FUNCTIJN 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPJRTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIJNS
NJT_FJUND = 2.
IF SY-SUBRC = 0.
VARIANT = GX_VARIANT-VARIANT.
ENDIF.
PERFJRM DECLARATIJNS
START-JF-SELECTIJN.
PERFJRM DATA_RETRIVEL.
PERFJRM BUILD_FIELDCATALJG.
PERFJRM DISPLAY_ALV_REPJRT.
&---------------------------------------------------------------------
& Form BUILD_FIELDCATALJG
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM BUILD_FIELDCATALJG .
FIELDCATALJG-FIELDNAME = 'CARRID'.
FIELDCATALJG-SELTEXT_M = 'Airline Code'.
FIELDCATALJG-CJL_PJS = 0.
APPEND FIELDCATALJG TJ FIELDCATALJG.
CLEAR FIELDCATALJG.
FIELDCATALJG-FIELDNAME = 'CJNNID'.
FIELDCATALJG-SELTEXT_M = 'Flight Connection Number'.
FIELDCATALJG-CJL_PJS = 1.
APPEND FIELDCATALJG TJ FIELDCATALJG.
CLEAR FIELDCATALJG.
FIELDCATALJG-FIELDNAME = 'FLDATE'.
FIELDCATALJG-SELTEXT_M = 'Flight date'.
FIELDCATALJG-CJL_PJS = 2.
APPEND FIELDCATALJG TJ FIELDCATALJG.
CLEAR FIELDCATALJG.
FIELDCATALJG-FIELDNAME = 'PRICE'.
FIELDCATALJG-SELTEXT_M = 'Airfare'.
FIELDCATALJG-CJL_PJS = 3.
FIELDCATALJG-JUTPUTLEN = 20.
APPEND FIELDCATALJG TJ FIELDCATALJG.
CLEAR FIELDCATALJG.
ENDFJRM. " BUILD_FIELDCATALJG


&---------------------------------------------------------------------
& Form DISPLAY_ALV_REPJRT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM DISPLAY_ALV_REPJRT .
GD_REPID = SY-REPID.
CALL FUNCTIJN 'REUSE_ALV_GRID_DISPLAY'
EXPJRTING
I_CALLBACK_PRJGRAM = GD_REPID
I_CALLBACK_TJP_JF_PAGE = 'TJP-JF-PAGE' "see FJRM
I_CALLBACK_USER_CJMMAND = 'USER_CJMMAND'
IT_FIELDCAT = FIELDCATALJG,
I_SAVE = 'X'
IS_VARIANT = G_VARIANT
TABLES
T_JUTTAB = IT_SFLIGHT
EXCEPTIJNS
PRJGRAM_ERRJR = 1
JTHERS = 2.
IF SY-SUBRC < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFJRM. "DISPLAY_ALV_REPJRT
" DISPLAY_ALV_REPJRT
&---------------------------------------------------------------------
& Form DATA_RETRIVEL
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM DATA_RETRIVEL .
SELECT FRJM SFLIGHT INTJ TABLE IT_SFLIGHT.
ENDFJRM. " DATA_RETRIVEL
-------------------------------------------------------------------
Form TJP-JF-PAGE
-------------------------------------------------------------------
ALV Report Header
-------------------------------------------------------------------
FJRM TJP-JF-PAGE.
ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE WA_HEADER-INFJ,
LD_LINES TYPE I,
LD_LINESC(10) TYPE C.
Title
WA_HEADER-TYP = 'H'.
WA_HEADER-INFJ = 'SFLIGHT Table Report'.
APPEND WA_HEADER TJ T_HEADER.
CLEAR WA_HEADER.
Date
WA_HEADER-TYP = 'S'.
WA_HEADER-KEY = 'Date: '.
CJNCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM(4) INTJ WA_HEADER-INFJ. "todays date
APPEND WA_HEADER TJ T_HEADER.
CLEAR: WA_HEADER.
CALL FUNCTIJN 'REUSE_ALV_CJMMENTARY_WRITE'
EXPJRTING
IT_LIST_CJMMENTARY = T_HEADER.
ENDFJRM. "top-of-page

Displaying Lights (Red, Yellow and Green) using ALV


y Tejaswini
Demo program Ior displaying lights (Red, Yellow and Green):
REPJRT ALV_LIGHTS.
Published at SAPTechnical.CJM
TYPES: BEGIN JF ty_alv,
lights(1) TYPE c, "Exception, Holding the value of the lights
text(20) TYPE c, "some text
END JF ty_alv.
DATA: gs_alv TYPE ty_alv,
gt_alv TYPE TABLE JF ty_alv,
gr_alv TYPE REF TJ cl_salv_table,
gr_columns TYPE REF TJ cl_salv_columns_table.
START-JF-SELECTIJN.
gs_alv-lights = '1'. "Color red
gs_alv-text = 'RED SIGNAL'.
APPEND gs_alv TJ gt_alv.
gs_alv-lights = '2'. "Color yellow
gs_alv-text = 'YELLJW SIGNAL'.
APPEND gs_alv TJ gt_alv.
gs_alv-lights = '3'. "Color green
gs_alv-text = 'GREEN SIGNAL'.
APPEND gs_alv TJ gt_alv.
CALL METHJD cl_salv_table=factory
IMPJRTING
r_salv_table = gr_alv
CHANGING
t_table = gt_alv.
gr_columns = gr_alv-get_columns( ).
gr_columns-set_exception_column( value = 'LIGHTS' ).
CALL METHJD gr_alv-display.

ALV Styles in Field catalogue using OOPS


y Swarna S, Tata Consultancy Services
&---------------------------------------------------------------------
& Report ZALV_STYLES
& Published at SAPTechnical.CJM
&---------------------------------------------------------------------
& AS : ALV Styles in a fieldcatalogue.
& The ALV is developed using JJPS and various styles are given for
& each column in the fieldcatalogue
&---------------------------------------------------------------------
REPJRT zalv_styles.
Include for ALV styles
INCLUDE <cl_alv_control.
Type ppols for alv
TYPE-PJJLS : slis.
structure for t582a tbale
TYPES : BEGIN JF ty_table,
infty TYPE infty,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
END JF ty_table.
Structure for infotype text
TYPES : BEGIN JF ty_itext,
infty TYPE infty,
itext TYPE intxt,
sprsl TYPE sprsl,
END JF ty_itext.
Structure for output display
TYPES : BEGIN JF ty_output,
infty TYPE infty,
itext TYPE intxt,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
text(6) TYPE c,
sradio(6) TYPE c,
scheck(6) TYPE c,
END JF ty_output.
internal table and work area declarations
DATA : it_table TYPE STANDARD TABLE JF ty_table INITIAL SIZE 0,
it_output TYPE STANDARD TABLE JF ty_output INITIAL SIZE 0,
it_ittext TYPE STANDARD TABLE JF ty_itext INITIAL SIZE 0,
wa_table TYPE ty_table,
wa_output TYPE ty_output,
wa_ittext TYPE ty_itext.
Data declarations for ALV
DATA: c_ccont TYPE REF TJ cl_gui_custom_container, "Custom container
c_alvgd TYPE REF TJ cl_gui_alv_grid, "ALV grid object
it_fcat TYPE lvc_t_fcat, "Field catalogue
it_layout TYPE lvc_s_layo. "Layout
Field symbols declarations for style
FIELD-SYMBJLS : <wa_fcat TYPE lvc_s_fcat.
initialization event
INITIALIZATIJN.
start of selection event
START-JF-SELECTIJN.
select the infotypes maintained
SELECT infty
pnnnn
zrmkz
zeitb
dname
edynr
ldynr
stypt
sytxt
davo
davoe
FRJM t582a UP TJ 25 RJWS
INTJ CJRRESPJNDING FIELDS JF TABLE it_table.
Select the infotype texts
IF it_table, IS NJT INITIAL.
SELECT itext
infty
sprsl
FRJM t582s
INTJ CJRRESPJNDING FIELDS JF TABLE it_ittext
FJR ALL ENTRIES IN it_table
WHERE infty = it_table-infty
AND sprsl = 'E'.
ENDIF.
Apppending the data to the internal table of ALV output
LJJP AT it_table INTJ wa_table.
wa_output-infty = wa_table-infty.
wa_output-pnnnn = wa_table-pnnnn.
wa_output-zrmkz = wa_table-zrmkz.
wa_output-zeitb = wa_table-zeitb.
wa_output-dname = wa_table-dname.
wa_output-edynr = wa_table-edynr.
wa_output-ldynr = wa_table-ldynr.
wa_output-stypt = wa_table-stypt.
wa_output-sytxt = wa_table-sytxt.
wa_output-davo = wa_table-davo.
wa_output-davoe = wa_table-davoe.
For texts
READ TABLE it_ittext INTJ wa_ittext WITH KEY infty = wa_table-infty.
wa_output-itext = wa_ittext-itext.
wa_output-text = wa_ittext-sprsl.
APPEND wa_output TJ it_output.
CLEAR wa_output.
ENDLJJP.
Calling the ALV screen with custom container
CALL SCREEN 0600.
Jn this statement double click it takes you to the screen painter SE51.
Enter the attributes
Create a Custom container and name it CC_CJNT 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
&---------------------------------------------------------------------
& Module STATUS_0600 JUTPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MJDULE status_0600 JUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
ENDMJDULE. " STATUS_0600 JUTPUT
calling the PBJ module ALV_GRID.
&---------------------------------------------------------------------
& Module ALV_GRID JUTPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MJDULE alv_grid JUTPUT.
CREATE JBJECT c_ccont
EXPJRTING
container_name = 'CC_CJNT'.
CREATE JBJECT c_alvgd
EXPJRTING
i_parent = c_ccont.
SET field for ALV
PERFJRM alv_build_fieldcat.
Setting the styles for the ALV grid control
using field-symbols
LJJP AT it_fcat ASSIGNING <wa_fcat.
For Each and every line of the fieldcat
CASE sy-tabix.
Color Styles
Background/Font/Group/positive/negative
WHEN '1'.
<wa_fcat-style = alv_style_color_inv_positive.
WHEN '2'.
<wa_fcat-style = alv_style_color_int_negative.
WHEN '3'.
<wa_fcat-style = alv_style_color_inv_negative.
WHEN '4'.
<wa_fcat-style = alv_style_color_int_positive.
WHEN '5'.
<wa_fcat-style = alv_style_color_background.
<wa_fcat-style = alv_style_color_inv_background.
WHEN '6'.
<wa_fcat-style = alv_style_color_group.
<wa_fcat-style = alv_style_color_int_background.
Style for F4
WHEN '7'.
<wa_fcat-style = alv_style_f4.
Style for Alignment(others are also possible)
WHEN '8'.
<wa_fcat-style = alv_style_align_left_bottom.
Style for Font Underlined/Bold and Italic are possible
WHEN '9'.
<wa_fcat-style = alv_style_font_underlined.
Style for button type
WHEN '10'.
<wa_fcat-style = alv_style_button.
Style for Font Symbol
WHEN '11'.
<wa_fcat-style = alv_style_font_symbol.
Style for Radiobutton
WHEN '12'.
<wa_fcat-style = alv_style_radio_checked.
Style for checkbox
WHEN '13'.
<wa_fcat-style = alv_style_checkbox_checked.
Style for column style characteristics(highlighting the col)
WHEN '14'.
<wa_fcat-style = alv_col_style_characteristic.
Styles for Enabling the column
WHEN '15'.
<wa_fcat-style = alv_style_enabled.
ENDCASE.
ENDLJJP.
Set ALV attributes FJR LAYJUT
PERFJRM alv_report_layout.
CHECK NJT c_alvgd IS INITIAL.
Call ALV GRID
CALL METHJD c_alvgd-set_table_for_first_display
EXPJRTING
is_layout = it_layout
CHANGING
it_outtab = it_output
it_fieldcatalog = it_fcat
EXCEPTIJNS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
JTHERS = 4.
IF sy-subrc < 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMJDULE. " ALV_GRID JUTPUT
&---------------------------------------------------------------------
& Form alv_build_fieldcat
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
<--P_IT_FCAT text
----------------------------------------------------------------------
subroutine to build fieldcat
FJRM alv_build_fieldcat.
DATA lv_fldcat TYPE lvc_s_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '1'.
lv_fldcat-fieldname = 'INFTY'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'Infotype'.
lv_fldcat-icon = 'X'.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '2'.
lv_fldcat-fieldname = 'PNNNN'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Structure'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '3'.
lv_fldcat-fieldname = 'ITEXT'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 60.
lv_fldcat-scrtext_m = 'Description'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '4'.
lv_fldcat-fieldname = 'TEXT'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'General'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.

lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '5'.
lv_fldcat-fieldname = 'ZRMKZ'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 1.
lv_fldcat-scrtext_m = 'PERIJD'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '6'.
lv_fldcat-fieldname = 'ZEITB'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 60.
lv_fldcat-scrtext_m = 'Time constraint'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '7'.
lv_fldcat-fieldname = 'DNAME'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Dialogmodule'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '8'.
lv_fldcat-fieldname = 'EDYNR'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Single screenno'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '9'.
lv_fldcat-fieldname = 'LDYNR'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'List screenno'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '10'.
lv_fldcat-fieldname = 'STYPT'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'SubtypeTable'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '11'.
lv_fldcat-fieldname = 'SYTXT'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Font Symbol'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '12'.
lv_fldcat-fieldname = 'SRADIJ'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'RADIJ'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '13'.
lv_fldcat-fieldname = 'SCHECK'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'CHECK'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '14'.
lv_fldcat-fieldname = 'DAVJ'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Start Date'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '15'.
lv_fldcat-fieldname = 'DAVJE'.
lv_fldcat-tabname = 'IT_JUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'End date'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TJ it_fcat.
CLEAR lv_fldcat.
ENDFJRM. " alv_build_fieldcat
&---------------------------------------------------------------------
& Form alv_report_layout
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
<--P_IT_LAYJUT text
----------------------------------------------------------------------
Subroutine for setting alv layout
FJRM alv_report_layout.
it_layout-cwidth_opt = 'X'.
it_layout-zebra = 'X'.
it_layout-col_opt = 'X'.
ENDFJRM. " alv_report_layout
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.
&---------------------------------------------------------------------
& Module USER_CJMMAND_0600 INPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
MJDULE user_command_0600 INPUT.
ENDMJDULE. " USER_CJMMAND_0600 INPUT
Output
!,7t 1

(Continued output)
!,7t 2

Displaying ALV on the Selection Screen


y Srinivas, Satyam Computers
REPJRT zalv_sel_screen .
TABLES: mara.
DATA: BEGIN JF i_alv JCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END JF i_alv.
DATA: alv_container TYPE REF TJ cl_gui_docking_container.
DATA: alv_grid TYPE REF TJ cl_gui_alv_grid.
DATA: layout TYPE lvc_s_layo.
DATA: fieldcat TYPE lvc_t_fcat.
PARAMETERS: p_check.
INITIALIZATIJN.
PERFJRM get_data.
AT SELECTIJN-SCREEN JUTPUT.
DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
layout-edit_mode = 'X'.
CHECK alv_container IS INITIAL.
CREATE JBJECT alv_container
EXPJRTING repid = repid
dynnr = sy-dynnr
side = alv_container-dock_at_left
extension = 1500.
CREATE JBJECT alv_grid
EXPJRTING
i_parent = alv_container.
ALV Specific. Data selection.
Populate Field Catalog
PERFJRM get_fieldcatalog.
CALL METHJD alv_grid-set_table_for_first_display
EXPJRTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv,
it_fieldcatalog = fieldcat,.
START-JF-SELECTIJN.

FJRM GET_DATA

FJRM get_data.
SELECT INTJ CJRRESPJNDING FIELDS JF TABLE i_alv
FRJM mara
INNER JJIN makt
JN mara~matnr = makt~matnr
UP TJ 100 RJWS
WHERE makt~spras = sy-langu.
SJRT i_alv ASCENDING BY matnr.
ENDFJRM. "get_data

Form Get_Fieldcatalog - Set Up Columns/Headers

FJRM get_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TJ fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TJ fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TJ fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GRJES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = '4'.
APPEND ls_fcat TJ fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = '5'.
APPEND ls_fcat TJ fieldcat.
ENDFJRM. "get_fieldcatalog







Output

Fields of the Field Catalog


The Iollowing table assigns a purpose to each Iield. For inIormation on the minimum
selection oI required Iields in the Iield catalog, see Generating the Field Catalog Manually.
You use Iield FIELDNAME oI the Iield catalog to deIine a reIerence to a Iield in the output
table. All settings made through Iields in the same row oI the Iield catalog reIer to the output
column speciIied in FIELDNAME.
Internally, the ALV Grid Control uses the Iield COL_ID to identiIy columns at the Irontend.
Alphabetic index
Field name Short description Purpose
CFIELDNAME
Field name Ior currency unit
reIerenced
Value Display With
Currency/Quantity
Unit
CHECKBOX Output as checkbox Output Options oI
Columns
COL_ID Numerical column
identiIication (read-only)
ReIerence to the
Output Table
COL_POS Position oI output column Output Options oI
Columns
COLDDICTXT
DeIinition oI DDIC text
reIerence
Texts
COLTEXT
Column label Ior dialog
Iunctions
Texts
CURRENCY Currency unit Value Display With
Currency/Quantity
Unit
DD_OUTLEN
Output length in characters Parameters Ior
Fields Without
DDIC ReIerence
DECIMALS_O Number oI decimal places Ior
output
Formatting Column
Contents
DECMLFIELD Field name with DECIMALS
speciIication
Formatting Column
Contents
DO_SUM
Totals calculation Ior column
values
Output Options oI
Columns
DRAGDROPID
Drag & Drop handle Ior Drag
& Drop object
Other Fields
EDIT_MASK
EditMask Ior output Formatting Column
Contents
EMPHASIZE
Column color Output Options oI
Columns
EXPONENT
Exponent Ior Iloat
representation
Formatting Column
Contents
FIELDNAME
Field name oI internal table
Iield
ReIerence to the
Output Table
HOTSPOT
Single-click sensitive Output Options oI
Columns
HREF_HNDLE
Assign hyperlink Output Options oI
Columns
ICON Output as icon Formatting Column
Contents
INTLEN Internal length in Char Parameters Ior
Fields Without
DDIC ReIerence
INTTYPE
AAP data type (C,D,N,...) Parameters Ior
Fields Without
DDIC ReIerence
JUST JustiIication Formatting Column
Contents
KEY Key column Output Options oI
Columns
LOWERCASE
Lower case allowed/not
allowed
Output Options oI
Columns
LZERO
Display leading zeros Formatting Column
Contents
NO_MERGING
Do not merge cells Output Options oI
Columns
NO_OUT
Do not display columns Output Options oI
Columns
NO_SIGN
Supress sign in display Formatting Column
Contents
NO_SUM No totals calculation Ior
column values
Output Options oI
Columns
NO_ZERO Suppress zeros in display Formatting Column
Contents
OUTPUTLEN Column width in characters Output Options oI
Columns
QFIELDNAME
Field name Ior quantity unit
reIerenced
Value Display With
Currency/Quantity
Unit
QUANTITY
Quantity unit Value Display With
Currency/Quantity
Unit
REF_FIELD
ReIerence Iield name Ior
internal table Iield
ReIerence to the
Data Dictionary
REF_TABLE
ReIerence table name Ior
internal table Iield
ReIerence to the
Data Dictionary
REPREP
Property is selection criterion
Ior report/report interIace
Other Fields
REPTEXT
Header (DDIC text oI the
corresponding data element)
Texts
ROLLNAME
Data element Ior F1 help Parameters Ior
Fields Without
DDIC ReIerence
ROUND ROUND value Formatting Column
Contents
ROUNDFIELD
Field name with ROUND
speciIication
Formatting Column
Contents
SCRTEXT_L
Long Iield label (DDIC text
oI the corresponding data
element)
Texts
SCRTEXT_M
Medium Iield label (DDIC
text oI the corresponding data
element)
Texts
SCRTEXT_S
Short Iield label (DDIC text
oI the corresponding data
element)
Texts
SELDDICTXT DeIinition oI DDIC text
reIerence
Texts
SELTEXT Column label Ior dialog
Iunction
Texts
SP_GROUP Group key Other Fields
STYLE
Output as pushbutton Output Options oI
Columns
SYMBOL
Output as symbol Formatting Column
Contents
TECH Technical Iields Output Options oI
Columns
TIPDDICTXT
DeIinition oI DDIC text
reIerence
Texts
TOOLTIP Tool tip Ior column header Texts
TXT_FIELD
Field name oI internal table
Iield
Other Fields
WEB_FIELD
Field name oI internal table
Iield (Ior hyperlink)
Output Options oI
Columns

Demo program on interactive ALV using OOPS


y Swarna S, Tata Consultancy Services
&---------------------------------------------------------------------
& Report ZALV_JJINTERACTIVE
& Author Swarna.S.
& Published at SAPTechnical.com
&---------------------------------------------------------------------
& AS : Simple Interactive ALV report developed using JJPS
&
&---------------------------------------------------------------------
REPJRT ZALV_JJINTERACTIVE.
Class definition for handling double click
CLASS event_class DEFINITIJN DEFERRED.
Internal table and work area declarations for dd02l and dd03l
DATA : it_dd02l TYPE TABLE JF dd02l,
wa_dd02l TYPE dd02l,
it_dd03l TYPE TABLE JF dd03l,
wa_dd03l TYPE dd03l.
data declarations for ALV Main list
DATA : ty_lay1 TYPE lvc_s_layo,
it_fieldcat TYPE lvc_t_fcat ,
ty_fieldcat TYPE lvc_s_fcat ,
c_alv1 TYPE REF TJ cl_gui_alv_grid,
c_cont1 TYPE REF TJ cl_gui_custom_container,
event_receiver TYPE REF TJ event_class.
data declarations for ALV Interactive list
DATA : ty_lay2 TYPE lvc_s_layo,
it_fcat TYPE lvc_t_fcat ,
ty_fcat TYPE lvc_s_fcat ,
c_alv2 TYPE REF TJ cl_gui_alv_grid,
c_cont2 TYPE REF TJ cl_gui_custom_container.
Select options for multiple values and NJT ranges
SELECT-JPTIJNS : s_table FJR wa_dd02l-tabname NJ INTERVALS.
Initialization event
INITIALIZATIJN.
Start of selection event
START-JF-SELECTIJN.
fetch data into table and field characteristics
PERFJRM fetch_data.
ALV display for output
PERFJRM alv_output.
&---------------------------------------------------------------------
& Form FETCH_DATA
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM fetch_data .
*Select the table details
SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE itdd02l
WHERE tabname IN stable
AND tabclass TRANSP.
ENDFJRM. " FETCH_DATA
----------------------------------------------------------------------
CLASS lcl_event_receiver DEFINITIJN
----------------------------------------------------------------------
CLASS event_class DEFINITIJN.
Handling double click
PUBLIC SECTIJN.
METHJDS:
handle_double_click
FJR EVENT double_click JF cl_gui_alv_grid IMPJRTING e_row .
ENDCLASS. "lcl_event_receiver DEFINITIJN
----------------------------------------------------------------------
CLASS lcl_event_receiver IMPLEMENTATIJN
----------------------------------------------------------------------
CLASS event_class IMPLEMENTATIJN.
METHJD handle_double_click.
DATA : ls_dd02l LIKE LINE JF it_dd02l.
Reading the selected data into a variable
READ TABLE it_dd02l INDEX e_row-index INTJ ls_dd02l.
Select the field details of the selected table
SELECT FRJM dd03l INTJ CJRRESPJNDING FIELDS JF TABLE it_dd03l
WHERE tabname EQ ls_dd02l-tabname.
calling the ALV containing the field values
CALL SCREEN 101.
ENDMETHJD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATIJN
&---------------------------------------------------------------------
& Module pbo_100 JUTPUT
&---------------------------------------------------------------------
MJDULE pbo_100 JUTPUT.
set pf-status 'XXX'.
set titlebar 'XXX'.
ENDMJDULE. " PBJ_100 JUTPUT
&---------------------------------------------------------------------
& Module alv_100 JUTPUT
&---------------------------------------------------------------------
MJDULE alv_100 JUTPUT.
Check if there is no custom container in screen 100
IF c_cont1 IS INITIAL.
Creating object of container
CREATE JBJECT c_cont1
EXPJRTING
container_name = 'CCJNT'.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Creating object of alv
CREATE JBJECT c_alv1
EXPJRTING
i_parent = c_cont1.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
alv layout
PERFJRM alv_100_layout.
alv field catalogue
PERFJRM alv_100_fieldcat.
Displaying the ALV grid
CALL METHJD c_alv1-set_table_for_first_display
EXPJRTING
is_layout = ty_lay1
CHANGING
it_outtab = it_dd02l,
it_fieldcatalog = it_fieldcat.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create object of the event class and setting handler for double click
CREATE JBJECT event_receiver.
SET HANDLER event_receiver-handle_double_click FJR c_alv1.
ENDIF.
ENDMJDULE. " ALV_100 JUTPUT
&---------------------------------------------------------------------
& Module pai_100 INPUT
&---------------------------------------------------------------------
MJDULE pai_100 INPUT.
ENDMJDULE. " pai_100 INPUT
----------------------------------------------------------------------
MJDULE PBJ_101 JUTPUT
----------------------------------------------------------------------
MJDULE pbo_101 JUTPUT.
SET PF-STATUS 'XXX'.
SET TITLEBAR 'XXX'.
ENDMJDULE. " PBJ_101 INPUT
----------------------------------------------------------------------
MJDULE ALV_101 JUTPUT
----------------------------------------------------------------------
MJDULE alv_101 JUTPUT.
Check if the Custom container exists.
IF c_cont2 IS INITIAL.
Creating container object
CREATE JBJECT c_cont2
EXPJRTING
container_name = 'CDCJNT'.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
creating ALV grid for interactive list
CREATE JBJECT c_alv2
EXPJRTING
i_parent = c_cont2.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ALV layout
PERFJRM alv_101_layout.
ALV fieldcatalogue
PERFJRM alv_101_fieldcat.
Sorting the output by field position
SJRT it_dd03l BY position.
ALV for display field details
CALL METHJD c_alv2-set_table_for_first_display
EXPJRTING
is_layout = ty_lay2
CHANGING
it_outtab = it_dd03l,
it_fieldcatalog = it_fcat.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMJDULE. " ALV_101 JUTPUT
&---------------------------------------------------------------------
& Module PAI_101 INPUT
&---------------------------------------------------------------------
MJDULE pai_101 INPUT.
ENDMJDULE. " PAI_101 INPUT
&---------------------------------------------------------------------
& Form ALV_JUTPUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM alv_output .
CALL SCREEN 100.
ENDFJRM. " ALV_JUTPUT
&---------------------------------------------------------------------
& Form ALV_100_LAYJUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM alv_100_layout .
ty_lay1-grid_title = 'TABLES'.
ty_lay1-zebra = 'X'.
ty_lay1-no_toolbar = 'X'.
ENDFJRM. " ALV_100_LAYJUT
&---------------------------------------------------------------------
& Form ALV_100_FIELDCAT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM alv_100_fieldcat .

CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 1.
ty_fieldcat-fieldname = 'TABNAME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TableName'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 2.
ty_fieldcat-fieldname = 'TABCLASS'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CATEGJRY'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 3.
ty_fieldcat-fieldname = 'AS4USER'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CREATED'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 4.
ty_fieldcat-fieldname = 'AS4DATE'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'DATE'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 5.
ty_fieldcat-fieldname = 'AS4TIME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TIME'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 6.
ty_fieldcat-fieldname = 'CJNTFLAG'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'Delivery Class'.
ty_fieldcat-outputlen = 15.
APPEND ty_fieldcat TJ it_fieldcat.
CLEAR ty_fieldcat.
ENDFJRM. " ALV_100_FIELDCAT
&---------------------------------------------------------------------
& Form ALV_101_LAYJUT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM alv_101_layout .
ty_lay2-grid_title = 'FIELDS'.
ty_lay2-zebra = 'X'.
ty_lay2-no_toolbar = 'X'.
ENDFJRM. " ALV_101_LAYJUT
&---------------------------------------------------------------------
& Form ALV_101_FIELDCAT
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-- p1 text
<-- p2 text
----------------------------------------------------------------------
FJRM alv_101_fieldcat .
REFRESH it_fieldcat.
REFRESH it_fcat.
CLEAR ty_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 1.
ty_fcat-fieldname = 'FIELDNAME'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Fieldname'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TJ it_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 2.
ty_fcat-fieldname = 'CHECKTABLE'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'CHECKTABLE'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TJ it_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 3.
ty_fcat-fieldname = 'KEYFLAG'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Key Flag'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TJ it_fcat.
ENDFJRM. " ALV_101_FIELDCAT
$election sc7een

i7st B,sic Output.

On double clicking the t,ble n,2e we get the fields in the t,ble ,s

REPJRT zcls_alv_oops MESSAGE-ID z1.



TABLES : mara.
,color:#0000ff,\----------------------------------------------------------
-----------\-,color,

,color:#0000ff,\ Types Declaration..,color,

,color:#0000ff,\----------------------------------------------------------
-----------\-,color,
TYPES :

BEGIN JF t_mara,

matnr TYPE matnr,

mtart TYPE mtart,

maktx TYPE maktx,

END JF t_mara,
,color:#0000ff,\,color,
BEGIN JF t_marc,

matnr TYPE matnr,

werks TYPE werks_d,

mtart TYPE mtart,

maktx TYPE maktx,

END JF t_marc.
,color:#0000ff,\----------------------------------------------------------
-----------\-,color,

,color:#0000ff,\ Internal Tables Declaration..,color,

,color:#0000ff,\----------------------------------------------------------
-----------\-,color,
DATA :

i_mara TYPE TABLE JF t_mara,

i_marc TYPE TABLE JF t_marc,

i_fcat1 TYPE lvc_t_fcat,

i_fcat2 TYPE lvc_t_fcat.
,color:#0000ff,\----------------------------------------------------------
-----------\-,color,

,color:#0000ff,\ Constants Declaration..,color,

,color:#0000ff,\----------------------------------------------------------
-----------\-,color,
CJNSTANTS :

c_cont1 TYPE scrfname VALUE 'CJNT1',

c_cont2 TYPE scrfname VALUE 'CJNT2'.

SELECTIJN-SCREEN BEGIN JF BLJCK b1 WITH FRAME.

SELECT-JPTIJNS:

s_matnr FJR mara-matnr NJ INTERVALS.

SELECTIJN-SCREEN SKIP 1.

PARAMETERS :

p_hotspt RADIJBUTTJN GRJUP r1 DEFAULT 'X',

p_bttn RADIJBUTTJN GRJUP r1.

SELECTIJN-SCREEN END JF BLJCK b1.

\

\ Class forward referncing.

CLASS lcl_rcvr_class DEFINITIJN DEFERRED.

\---------------------------------------------------------------------\-

\ Pointers Declaration..

\---------------------------------------------------------------------\-

DATA :

lp_rcvr TYPE REF TJ lcl_rcvr_class,

lp_cont1 TYPE REF TJ cl_gui_custom_container,

lp_cont2 TYPE REF TJ cl_gui_custom_container,

lp_grid1 TYPE REF TJ cl_gui_alv_grid,

lp_grid2 TYPE REF TJ cl_gui_alv_grid.

\---------------------------------------------------------------------\-

\ Local Class Definiton.

\---------------------------------------------------------------------\-

CLASS lcl_rcvr_class DEFINITIJN.

PUBLIC SECTIJN.

METHJDS :

hotspot_click FJR EVENT hotspot_click JF cl_gui_alv_grid

IMPJRTING e_row_id e_column_id es_row_no,

\

handle_double_click FJR EVENT double_click JF cl_gui_alv_grid

IMPJRTING e_row e_column.

ENDCLASS.

\---------------------------------------------------------------------\-

\ Local Class Implementation.

\---------------------------------------------------------------------\-

CLASS lcl_rcvr_class IMPLEMENTATIJN.

METHJD hotspot_click.

DATA :

wa_mara TYPE t_mara,

wa_marc TYPE t_marc.

\

DATA :

l_index TYPE sy-tabix.

\

READ TABLE i_mara INTJ wa_mara INDEX e_row_id-index.

IF sy-subrc EQ 0.

REFRESH i_marc.

SELECT matnr

werks

INTJ TABLE i_marc

FRJM marc

WHERE matnr EQ wa_mara-matnr.

\

IF sy-subrc EQ 0.

LJJP AT i_marc INTJ wa_marc.

l_index = sy-tabix.

wa_marc-mtart = wa_mara-mtart.

wa_marc-maktx = wa_mara-maktx.

MJDIFY i_marc FRJM wa_marc INDEX l_index

TRANSPJRTING mtart maktx.

ENDLJJP.

CALL SCREEN 200.

ELSE.

MESSAGE e121 WITH text-005 wa_mara-matnr.

ENDIF.

ENDIF.

\

ENDMETHJD.

\

METHJD handle_double_click.

DATA :

wa_mara TYPE t_mara,

wa_marc TYPE t_marc.

\

DATA :

l_index TYPE sy-tabix.

\

READ TABLE i_mara INTJ wa_mara INDEX e_row-index.

IF sy-subrc EQ 0.

REFRESH i_marc.

SELECT matnr

werks

INTJ TABLE i_marc

FRJM marc

WHERE matnr EQ wa_mara-matnr.

\

IF sy-subrc EQ 0.

LJJP AT i_marc INTJ wa_marc.

l_index = sy-tabix.

wa_marc-mtart = wa_mara-mtart.

wa_marc-maktx = wa_mara-maktx.

MJDIFY i_marc FRJM wa_marc INDEX l_index

TRANSPJRTING mtart maktx.

ENDLJJP.

CALL SCREEN 200.

ELSE.

MESSAGE e121 WITH text-005 wa_mara-matnr.

ENDIF.

ENDIF.

\

ENDMETHJD.

ENDCLASS.

\---------------------------------------------------------------------\-

\ Start of Selection

\---------------------------------------------------------------------\-

START-JF-SELECTIJN.

\ Extract the Material Master data for the Input Material.

SELECT a~matnr

a~mtart

b~maktx

INTJ TABLE i_mara

FRJM mara AS a

INNER JJIN makt AS b

JN a~matnr EQ b~matnr

WHERE a~matnr IN s_matnr

AND b~spras EQ sy-langu.

\

END-JF-SELECTIJN.

IF NJT i_mara\\, IS INITIAL.

\ Call Screen to display the Material Master data.

CALL SCREEN 100.

ELSE.

MESSAGE s121 WITH text-006.

ENDIF.

\&---------------------------------------------------------------------\

\& Module DISP_GRID JUTPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE disp_grid JUTPUT.

\ Build the Field catelog for Material Master data.

PERFJRM build_fcat.

\ Display the Material Master data using ALV.

PERFJRM disp_alv.

\

ENDMJDULE. " DISP_GRID JUTPUT

\&---------------------------------------------------------------------\

\& Module USER_CJMMAND_0100 INPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE user_command_0100 INPUT.

\

\when exit or cancel is clicked program has to come out

CASE sy-ucomm.

WHEN 'EXIT' JR 'CANC'.

LEAVE PRJGRAM.

WHEN 'BACK'.

LEAVE TJ SCREEN 0.

ENDCASE.

\

ENDMJDULE. " USER_CJMMAND_0100 INPUT

\&---------------------------------------------------------------------\

\& Form build_fcat

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

\ \-- p1 text

\ <-\- p2 text

\----------------------------------------------------------------------\

FJRM build_fcat.

\

DATA : ws_fcat TYPE lvc_s_fcat.

\

ws_fcat-fieldname = 'MATNR'.

ws_fcat-scrtext_m = text-001.

ws_fcat-tabname = 'I_MARA'.

IF p_hotspt EQ 'X'.

ws_fcat-hotspot = 'X'.

ENDIF.

APPEND ws_fcat TJ i_fcat1.

CLEAR ws_fcat.

\

ws_fcat-fieldname = 'MTART'.

ws_fcat-scrtext_m = text-002.

ws_fcat-tabname = 'I_MARA'.

APPEND ws_fcat TJ i_fcat1.

CLEAR ws_fcat.

\

ws_fcat-fieldname = 'MAKTX'.

ws_fcat-scrtext_m = text-003.

ws_fcat-tabname = 'I_MARA'.

APPEND ws_fcat TJ i_fcat1.

CLEAR ws_fcat.

\

ENDFJRM. " build_fcat

\&---------------------------------------------------------------------\

\& Form disp_alv

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

\ \-- p1 text

\ <-\- p2 text

\----------------------------------------------------------------------\

FJRM disp_alv.

\

IF lp_cont1 IS INITIAL.

\ Create the Container Jbject of Material Master.

CREATE JBJECT lp_cont1

EXPJRTING

container_name = c_cont1

EXCEPTIJNS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6 .

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

\ Create the Jbject for Grid of Material Master.

CREATE JBJECT lp_grid1

EXPJRTING

i_parent = lp_cont1

EXCEPTIJNS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

\ Dipslay Material Master data by calling method.

CALL METHJD lp_grid1-set_table_for_first_display

CHANGING

it_outtab = i_mara

it_fieldcatalog = i_fcat1

EXCEPTIJNS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

JTHERS = 4.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

\ Set Handler for the Hot Spot Event.

CREATE JBJECT lp_rcvr.

IF p_hotspt EQ 'X'.

SET HANDLER lp_rcvr-hotspot_click FJR lp_grid1.

ELSE.

SET HANDLER lp_rcvr-handle_double_click FJR lp_grid1.

ENDIF.

ENDIF.

\

ENDIF.

\

ENDIF.

\

ENDIF.

\

ENDFJRM. " disp_alv

\&---------------------------------------------------------------------\

\& Module STATUS_0100 JUTPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE status_0100 JUTPUT.

SET PF-STATUS 'MAIN_STAT'.

SET TITLEBAR 'T_100'.

ENDMJDULE. " STATUS_0100 JUTPUT

\&---------------------------------------------------------------------\

\& Module STATUS_0200 JUTPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE status_0200 JUTPUT.

SET PF-STATUS 'PLANT_STAT'.

SET TITLEBAR 'T_200'.

ENDMJDULE. " STATUS_0200 JUTPUT

\&---------------------------------------------------------------------\

\& Module DISP_GRID_plant JUTPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE disp_grid_plant JUTPUT.

\ Build the Field catelog for Material Plant data.

PERFJRM build_fcat_plant.

\ Display the Material Master Plant data using ALV.

PERFJRM disp_alv_plant.

ENDMJDULE. " DISP_GRID_plant JUTPUT

\&---------------------------------------------------------------------\

\& Module USER_CJMMAND_0200 INPUT

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

MJDULE user_command_0200 INPUT.

\

\when exit or cancel is clicked program has to come out

CASE sy-ucomm.

WHEN 'EXIT' JR 'CANC'.

LEAVE PRJGRAM.

WHEN 'BACK'.

LEAVE TJ SCREEN 0.

ENDCASE.

\

ENDMJDULE. " USER_CJMMAND_0200 INPUT

\&---------------------------------------------------------------------\

\& Form build_fcat_plant

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

\ \-- p1 text

\ <-\- p2 text

\----------------------------------------------------------------------\

FJRM build_fcat_plant.

DATA : ws_fcat TYPE lvc_s_fcat.

\

ws_fcat-fieldname = 'MATNR'.

ws_fcat-scrtext_m = text-001.

ws_fcat-tabname = 'I_MARC'.

APPEND ws_fcat TJ i_fcat2.

CLEAR ws_fcat.

\

ws_fcat-fieldname = 'WERKS'.

ws_fcat-scrtext_m = text-004.

ws_fcat-tabname = 'I_MARC'.

APPEND ws_fcat TJ i_fcat2.

CLEAR ws_fcat.

\

ws_fcat-fieldname = 'MTART'.

ws_fcat-scrtext_m = text-002.

ws_fcat-tabname = 'I_MARC'.

APPEND ws_fcat TJ i_fcat2.

CLEAR ws_fcat.

\

ws_fcat-fieldname = 'MAKTX'.

ws_fcat-scrtext_m = text-003.

ws_fcat-tabname = 'I_MARC'.

APPEND ws_fcat TJ i_fcat2.

CLEAR ws_fcat.

\

ENDFJRM. " build_fcat_plant

\&---------------------------------------------------------------------\

\& Form disp_alv_plant

\&---------------------------------------------------------------------\

\ text

\----------------------------------------------------------------------\

\ \-- p1 text

\ <-\- p2 text

\----------------------------------------------------------------------\

FJRM disp_alv_plant.

IF lp_cont2 IS INITIAL.

\ Create the Container Jbject of Material Plant data.

CREATE JBJECT lp_cont2

EXPJRTING

container_name = c_cont2

EXCEPTIJNS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

\ Create the Jbject for Grid of Material Plant data.

CREATE JBJECT lp_grid2

EXPJRTING

i_parent = lp_cont2

EXCEPTIJNS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

\ Dipslay Material Plant data by calling method.

CALL METHJD lp_grid2-set_table_for_first_display

CHANGING

it_outtab = i_marc

it_fieldcatalog = i_fcat2

EXCEPTIJNS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

JTHERS = 4.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

\

ENDIF.

\

ENDIF.

\

ELSE.

\ Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.

CALL METHJD lp_grid2-refresh_table_display.

ENDIF.

\

ENDFJRM. " disp_alv_plant

Dropdown list in ALV


y Swarna S, Tata Consultancy Services


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)

Displaying Logo in ALV Grid


y Madhavi
Logo should be uploaded into application server using transaction 'OAER'.
1. Go to Transaction OAER,
2. Give Class Name as PICTURES
3. Class type as OT
4. Object Key as the name oI the Object u want to speciIy
5. Upon execution you would be prompted to give the Iile path details. Just upload
which ever logo u want to display
6. Now you can use the same name in your ALV FM
In your ALV program, you need to have event Ior TOPOFPAGE, and also this works only
in case oI Grid not in ALV LIST.

Look at the sample code to display LOGO.

**********************

call Iunction 'REUSEALVGRIDDISPLAY'
exporting
icallbackprogram irepid
itIieldcat header
islayout gtlayout
icallbacktopoIpage 'TOP-OF-PAGE1'
igridtitle xyz
itsort gtsort||
ideIault 'X'
isave 'U'
isvariant gtvariant
itevents gtevents
tables
touttab toutput.

*****************

*-------------------------------------------------------------------*

* Form TOP-OF-PAGE1

*-------------------------------------------------------------------*

Iorm top-oI-page1.

data: header type slistlistheader,
wa type slislistheader.

* TITLE AREA

wa-typ 'S'.
wa-inIo text-h04.
append wa to header.

wa-typ 'S'.
write sy-datum to wa-inIo mm/dd/yyyy.

concatenate text-h03 wa-inIo into wa-inIo separated by space.
append wa to header.

wa-typ 'S'.
concatenate text-h02 sy-uname into wa-inIo separated by space.
append wa to header.

wa-typ 'S'.
concatenate text-h01 sy-repid into wa-inIo separated by space.
append wa to header.

********" LOGO

call Iunction 'REUSEALVCOMMENTARYWRITE'

exporting

itlistcommentary header

ilogo 'ENJOYSAPLOGO'.

*********" LOGO

endIorm.

Here in TOP-OF-PAGE Iorm it will show you the Prog name,Date, User Name.
" cl_gui_custom_container container for hosting splitter
DATA cl_gui_custom_container_obj TYPE REF TJ cl_gui_custom_container.
" cl_gui_splitter_container splitter container
DATA cl_gui_splitter_container_obj TYPE REF TJ cl_gui_splitter_container.
" cl_gui_container objects for splitter
DATA cl_gui_container_1 TYPE REF TJ cl_gui_container.
DATA cl_gui_container_2 TYPE REF TJ cl_gui_container.
DATA cl_gui_container_3 TYPE REF TJ cl_gui_container.
" cl_gui_picture objects
DATA cl_gui_picture_1 TYPE REF TJ cl_gui_picture.
DATA cl_gui_picture_2 TYPE REF TJ cl_gui_picture.
DATA cl_gui_picture_3 TYPE REF TJ cl_gui_picture.

START-JF-SELECTIJN.
CALL SCREEN 100.
END-JF-SELECTIJN.

MJDULE STATUS_0100 JUTPUT.

SET TITLEBAR 'TITLE'.
SET PF-STATUS 'STATUS'.

IF init IS INITIAL.

CREATE JBJECT cl_gui_custom_container_obj EXPJRTING container_name =
'CUSTJM'.

" Create SPLITTER and SPLITTER panes
CREATE JBJECT cl_gui_splitter_container_obj
EXPJRTING parent = cl_gui_custom_container_obj
rows = 1
columns = 3.

CALL METHJD cl_gui_splitter_container_obj-get_container
EXPJRTING
row = 1
column = 1
RECEIVING
container = cl_gui_container_1.

CALL METHJD cl_gui_splitter_container_obj-get_container
EXPJRTING
row = 1
column = 2
RECEIVING
container = cl_gui_container_2.

CALL METHJD cl_gui_splitter_container_obj-get_container
EXPJRTING
row = 1
column = 3
RECEIVING
container = cl_gui_container_3.

DATA repid TYPE sy-repid.
DATA dynnr TYPE sy-dynnr.
repid = sy-repid.
dynnr = sy-dynnr.

CREATE JBJECT cl_gui_picture_1 EXPJRTING parent = cl_gui_container_1.
CREATE JBJECT cl_gui_picture_2 EXPJRTING parent = cl_gui_container_2.
CREATE JBJECT cl_gui_picture_3 EXPJRTING parent = cl_gui_container_3.

" Request an URL from the data provider by exporting the pic_data.
CLEAR url.
PERFJRM load_pic_from_db CHANGING url.

" load picture
CALL METHJD cl_gui_picture_1-load_picture_from_url
EXPJRTING
url = url.

CLEAR url.
url = 'file://C:\sap-logo.gif'.
CALL METHJD cl_gui_picture_2-load_picture_from_url
EXPJRTING
url = url.

CLEAR url.
url = 'http://www.sap-press.com/images/logo_books_online_162_50.gif'.
CALL METHJD cl_gui_picture_3-load_picture_from_url
EXPJRTING
url = url.

init = 'X'.

CALL METHJD cl_gui_cfw=flush
EXCEPTIJNS
cntl_system_error = 1
cntl_error = 2.

ENDIF.

ENDMJDULE. " STATUS_0100 JUTPUT
FJRM load_pic_from_db CHANGING url.

DATA query_table LIKE w3query JCCURS 1 WITH HEADER LINE.
DATA html_table LIKE w3html JCCURS 1.
DATA return_code LIKE w3param-ret_code.
DATA content_type LIKE w3param-cont_type.
DATA content_length LIKE w3param-cont_len.
DATA pic_data LIKE w3mime JCCURS 0.
DATA pic_size TYPE i.

REFRESH query_table.
query_table-name = '_JBJECT_ID'.
query_table-value = 'ENJJYSAP_LJGJ'.
APPEND query_table.

CALL FUNCTIJN 'WWW_GET_MIME_JBJECT'
TABLES
query_string = query_table
html = html_table
mime = pic_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIJNS
JBJECT_NJT_FJUND = 1
parameter_not_found = 2
JTHERS = 3.
IF sy-subrc = 0.
pic_size = content_length.
ENDIF.

CALL FUNCTIJN 'DP_CREATE_URL'
EXPJRTING
type = 'image'
subtype = cndp_sap_tab_unknown
size = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data = pic_data
CHANGING
url = url
EXCEPTIJNS
JTHERS = 1.

ENDFJRM. " load_pic_from_db
MJDULE USER_CJMMAND_0100 INPUT.

SAVE_JK = JK_CJDE.
CLEAR JK_CJDE.

CASE SAVE_JK.
WHEN 'EXIT' JR 'CNCL' JR 'BACK'.
LEAVE PRJGRAM.
WHEN JTHERS.
ENDCASE.

ENDMJDULE. " USER_CJMMAND_0100 INPUT