2008 Feb 08 6:45 AM
plz gimme sample program forunderstanding structure of ALV PROGRAM using basic explanations
2008 Feb 08 6:49 AM
here is sample code
plz reward if helpful
REPORT YSUBALV.
--
TYPE-POOLS: SLIS.
To pass name of the report in function module for ALV
DATA: V_REPID LIKE SY-REPID .
To pass the overall structure of the ALV report
DATA: STRUCT_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: STRUCT_LAYOUT1 TYPE SLIS_LAYOUT_ALV.
Internal table to capture various events in ALV
DATA : I_EVENTS TYPE SLIS_T_EVENT.
Table for catalog of the fields to be displayed
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
data : x_fieldcat TYPE SLIS_FIELDCAT_ALV.
DATA: I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
data : x_fieldcat1 TYPE SLIS_FIELDCAT_ALV.
Internal table to mention the sort sequence
DATA : IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA : X_SORT TYPE SLIS_SORTINFO_ALV.
Internal table to display top of page
data : i_list_top_of_page type slis_t_listheader.
Structure to display variants
data : i_variant like disvariant,
i_variant1 like disvariant.
Internal table to pass data
DATA: BEGIN OF I_TAB OCCURS 0,
mblnr like mseg-mblnr ,
matnr like mseg-matnr,
maktg like makt-maktg ,
charg like mseg-charg ,
werks like mseg-werks,
lgort like mseg-lgort,
menge like mseg-menge ,
meins like mseg-meins ,
dmbtr like mseg-dmbtr,
ebeln like mseg-ebeln,
icn(4) type c ,
sym(4) type c ,
excpt(2) type c ,
box(1),
END OF I_TAB.
*EJECT
DATA : begin of i_doc occurs 0 .
INCLUDE STRUCTURE MSEG.
DATA : end of i_doc.
-------End of Data Declaration-------------*
PARAMETERS : P_VAR LIKE DISVARIANT-VARIANT.
initialization.
v_repid = sy-repid.
Display default variant
PERFORM SUB_VARIANT_INIT.
AT SELECTION-SCREEN ON P_VAR.
Once the user has entered variant, check about its existence
PERFORM SUB_CHECK_PVAR.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
Display a list of various variants of the report when the
user presses F4 key in the variant field
PERFORM SUB_VARIANT_F4.
START-OF-SELECTION.
Prepare field catalog for the main report. State the name of
the field , name of internal table , various formatting options etc
PERFORM SUB_PREPARE_FIELDCATALOG.
Fetches records from database into table i_tab to be passed as export
parameter t_outtab in function module : REUSE_ALV_GRID_DISPLAY
PERFORM SUB_SELECT_RECORD.
Populate stat and icon columns of internal table i_tab with specific
columns and symbols based on some logic for quantity and value fields.
PERFORM SUB_MODIFY_RECORDS.
Defines the overall layout of the report
PERFORM SUB_DETERMINE_ALV_LAYOUT.
Defines the sort sequence of the report
PERFORM SUB_DETERMINE_SORT_SEQUENCE.
Defines the event table
PERFORM SUB_EVENTTAB_BUILD USING I_EVENTS.
Things to be written at the top of the page
PERFORM SUB_COMMENT_BUILD USING i_list_top_of_page.
Display the ALV list
PERFORM SUB_SHOW_ALV_LIST.
struct_layout-hotspot_fieldname = 'X'.
AT LINE-SELECTION.
PERFORM SUB_HOTSPOT.
&----
*& Form SUB_VARIANT_INIT
&----
Display default variant
----
form SUB_VARIANT_INIT.
I_VARIANT1-REPORT = SY-REPID.
Search default variant for the report
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
If default variant is found , use it as default.
Else , use the variant LAYOUT1.
IF sy-subrc = 0.
p_var = i_variant1-variant.
ELSE.
p_var = 'LAYOUT1'.
ENDIF.
endform. " SUB_VARIANT_INIT
&----
*& Form SUB_CHECK_PVAR
&----
Once the user has entered variant, check about its existence
----
FORM SUB_CHECK_PVAR.
If the name of the variable is not blank, check about its existence
if not p_var is initial.
clear i_variant.
i_variant-report = sy-repid.
i_variant-variant = p_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
CS_VARIANT = I_VARIANT.
If no such variant found , flash error message
if sy-subrc ne 0 .
message e398(00) with 'No such variant exists'.
else.
If variant exists , use the variant name to populate structure
I_VARIANT1 which will be used for export parameter : IS_VARIANT
in the function module : REUSE_ALV_GRID_DISPLAY
clear i_variant1.
move p_var to i_variant1-variant.
move sy-repid to i_variant1-report.
endif.
else.
clear i_variant.
endif.
ENDFORM. " SUB_CHECK_PVAR
&----
*& Form SUB_PREPARE_FIELDCATALOG
&----
Prepare field catalog for the main report. State the name of
the field , name of internal table , various formatting options etc
----
form SUB_PREPARE_FIELDCATALOG.
First field to appear in ALV list
X_FIELDCAT-COL_POS = 1.
Name of the internal table field
X_FIELDCAT-FIELDNAME = 'SYM'.
Name of the internal table
X_FIELDCAT-TABNAME = 'I_TAB'.
Heading for the field
X_FIELDCAT-SELTEXT_M = 'Stat'.
The field is going to contain a symbol
x_fieldcat-symbol = 'X'.
Append the specifications to the internal table for field catalog.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
Second field to appear in ALV list
X_FIELDCAT-COL_POS = 2.
Name of the field in the internal table
X_FIELDCAT-FIELDNAME = 'MATNR'.
Name of the internal table
X_FIELDCAT-TABNAME = 'I_TAB'.
Heading for the column
X_FIELDCAT-SELTEXT_M = 'MatItem'.
It is going to be the key field.The color for this field is going to
be different
X_fieldcat-key = 'X'.
X_fieldcat-key_sel = 'X'.
Single click on the field will trigger double click event.Also, a hand
will appear when the cursor navigates to the field
X_fieldcat-hotspot = 'X'.
The column and those left to it will not scroll
X_fieldcat-fix_column = 'X'.
F1 help will come as it is referenced to DDIC table
x_fieldcat-ref_tabname = 'MSEG'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 3.
X_FIELDCAT-FIELDNAME = 'MAKTG'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Description'.
X_FIELDCAT-OUTPUTLEN = 50.
x_fieldcat-hotspot = space.
The field is centre(C for centre, R and L for left and
right) justified
x_fieldcat-just = 'C'.
x_fieldcat-key = 'X'.
x_fieldcat-fix_column = 'X'.
X_fieldcat-no_out = 'X'.
X_fieldcat-fix_column = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 4.
X_FIELDCAT-FIELDNAME = 'CHARG'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Batch'.
X_FIELDCAT-OUTPUTLEN = 10.
x_fieldcat-hotspot = space.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 5.
X_FIELDCAT-FIELDNAME = 'EBELN'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Purchase Order'.
X_FIELDCAT-OUTPUTLEN = 14.
The field will be colored differently(Cxyz)
x_fieldcat-emphasize = 'C511'.
Initially the field will be hidden
x_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 6.
X_FIELDCAT-FIELDNAME = 'MBLNR'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Document no'.
X_FIELDCAT-OUTPUTLEN = 14.
x_fieldcat-emphasize = 'C711'.
x_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 7.
X_FIELDCAT-FIELDNAME = 'WERKS'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Plant'.
X_FIELDCAT-OUTPUTLEN = 5.
x_fieldcat-emphasize = 'C310'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 8.
X_FIELDCAT-FIELDNAME = 'LGORT'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'St.Loc'.
X_FIELDCAT-OUTPUTLEN = 7.
X_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 9.
X_FIELDCAT-FIELDNAME = 'MENGE'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Quantity'.
X_FIELDCAT-OUTPUTLEN = 12.
Summation is allowed for this field
x_fieldcat-do_sum = 'X'.
X_FIELDCAT-ref_tabname = 'MSEG'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 10.
X_FIELDCAT-FIELDNAME = 'ICN'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = ''.
X_FIELDCAT-OUTPUTLEN = 2.
x_fieldcat-icon = 'X'.
X_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 11.
X_FIELDCAT-FIELDNAME = 'MEINS'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Unit'.
X_FIELDCAT-OUTPUTLEN = 5.
x_fieldcat-qfieldname = 'MEINS'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 12.
X_FIELDCAT-FIELDNAME = 'DMBTR'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Local curr'.
X_FIELDCAT-OUTPUTLEN = 12.
x_fieldcat-INTTYPE = 'P'.
x_fieldcat-just = 'R'.
x_fieldcat-do_sum = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 13.
X_FIELDCAT-FIELDNAME = 'EXCPT'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = ''.
X_FIELDCAT-OUTPUTLEN = 3.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
endform. " SUB_PREPARE_FIELDCATALOG
&----
*& Form SUB_SELECT_RECORD
&----
Fetches records from database into table i_tab to be passed as export
parameter t_outtab in function module : REUSE_ALV_GRID_DISPLAY
----
form SUB_SELECT_RECORD.
SELECT mblnr Amatnr Amaktg charg
werks lgort menge meins dmbtr ebeln
FROM makt as a join mseg as b
on ( amatnr = bmatnr )
INTO TABLE I_TAB
where b~bwart = '101' .
endform. " SUB_SELECT_RECORD
&----
*& Form SUB_MODIFY_RECORDS
&----
Populate stat and icon columns of internal table i_tab with specific
columns and symbols based on some logic for quantity and value fields.
----
form SUB_MODIFY_RECORDS.
loop at i_tab.
if i_tab-dmbtr gt 10000.
Field icn of internal table is going to contain icon . For this column
*icon_allowed is set in the field catalog table. For various icons,see
type pool <ICON>
i_tab-icn = '@1V@'.
modify i_tab transporting icn.
endif.
if i_tab-menge gt 50.
Field icn of internal table is going to contain symbol . For this
column symbol_allowed is set in the field catalog table. For various
icons,see type pool <SYMBOL>
i_tab-sym = 'N'.
modify i_tab transporting sym.
endif.
IF I_TAB-WERKS NE 'SDC1'.
This field will contain lights , traffic signals : red.yellow,green
That this field will be used as a light will be specified in the
column of structure STRUCT_LAYOUT.
I_TAB-EXCPT = '1'.
MODIFY I_TAB TRANSPORTING EXCPT.
endif.
endloop.
endform. " SUB_MODIFY_RECORDS
&----
*& Form SUB_DETERMINE_ALV_LAYOUT *
&----
*& Defines the overall structure of the report layout *
----
form SUB_DETERMINE_ALV_LAYOUT.
Field EXCPT will show the light signal
STRUCT_LAYOUT-LIGHTS_FIELDNAME = 'EXCPT'.
Field BOS of the internal table will act as pushbutton and will appear
at the left of the grid display. User will press that to select a
record
struct_layout-box_fieldname = 'BOX'.
STRUCT_layout-totals_text = 'Totqty '.
STRUCT_LAYOUT-ZEBRA = 'X'.
struct_layout-confirmation_prompt = 'X'.
struct_layout-detail_titlebar = 'Details of Storing'.
struct_layout-no_sumchoice = 'X'.
struct_layout-totals_only = 'X'.
endform. " SUB_DETERMINE_ALV_LAYOUT
&----
*& Form SUB_DETERMINE_SORT_SEQUENCE
&----
Defines the sort sequence of the report
----
form SUB_DETERMINE_SORT_SEQUENCE.
X_sort-spos = 1. " Sort order
X_sort-fieldname = 'MATNR'.
X_sort-tabname = 'I_TAB'.
X_sort-up = 'X'.
X_sort-subtot = 'X'. " Sub total allowed
append X_sort TO IT_SORT.
clear X_sort.
endform. " SUB_DETERMINE_SORT_SEQUENCE
&----
*& Form SUB_SHOW_ALV_LIST
&----
Shows ALV list in grid form
----
form SUB_SHOW_ALV_LIST.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
Name of the program
I_CALLBACK_PROGRAM = V_REPID
title
I_GRID_TITLE = 'Details of Storing'
calls subroutine : PF_STATUS_SET
i_callback_pf_status_set = 'PF_STATUS_SET'
Calls subroutine : user_command
i_callback_user_command = 'USER_COMMAND'
Overall structure of the report
IS_LAYOUT = STRUCT_LAYOUT
Passes the field catg internal table
IT_FIELDCAT = I_FIELDCAT
Passws the sort sequence internal table
IT_SORT = IT_SORT
I_DEFAULT = 'X'
I_SAVE = 'A'
Passes the internal table for variants
IS_VARIANT = i_variant1
fetches different events into internal table i_events
it_events = i_events[]
TABLES
Passes data table for ALV display
T_OUTTAB = I_TAB
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. " SUB_SHOW_ALV_LIST
&----
*& Form set_status
&----
Form used to set the Custom pf-status of the List Display
----
rt_extab :
----
FORM pf_status_set USING i_rt_extab TYPE slis_t_extab.
data : x_extab type slis_extab.
x_extab-fcode = '&LFO'.
append x_extab to i_rt_extab.
Pf-status STANDARD of program SAPLSALV is copied to ZSTANDARD of the
current program and the pushbutton for Information (okcode=&LFO) is
excluded
SET PF-STATUS 'ZSTANDARD' excluding i_rt_extab .
ENDFORM.
&----
*& Form user_command
&----
Form used to handle USER_COMMAND events
----
rf_ucomm: Function Code
rs : Internal Table containing the selection information.
----
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
data : v_mblnr like mseg-mblnr.
case rf_ucomm.
A custom pushbutton for record deletion is set in the GUI status.
When a record is selected , the field BOC for that record becomes 'X'.
The records are traced and deleted and the fields are refreshed( rs
of type slis_selfield is refreshed)
when '&DEL'. "Print button clicked.
delete i_tab where box = 'X'.
rs-refresh = 'X'.
When the user selects a row and presses the Select pushbutton ( user
defined ) from the application toolbar, the details of the document
will be shown in another ALV list
when '&SEL'.
PERFORM SUB_SELECT_DOCUMENT.
set parameter id 'MBN' field i_tab-mblnr.
call transaction 'MB03'.
Ok code for double click is &IC1 for ALV report
when '&IC1'.
perform sub_hotspot.
endcase.
ENDFORM.
&----
*& Form SUB_HOTSPOT
&----
text
----
--> p1 text
<-- p2 text
----
form SUB_HOTSPOT.
message i398(00) with 'Hello'.
endform. " SUB_HOTSPOT
&----
*& Form SUB_VARIANT_F4
&----
Display a list of various variants of the report when the
user presses F4 key in the variant field
----
form SUB_VARIANT_F4.
i_variant-report = sy-repid.
Utilising the name of the report , this function module will
search for a list of variants and will fetch the selected one into
the parameter field for variants
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = I_VARIANT
I_SAVE = 'A'
I_DISPLAY_VIA_GRID = 'X'
IMPORTING
ES_VARIANT = I_VARIANT1
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
P_VAR = I_VARIANT1-VARIANT.
ENDIF.
endform. " SUB_VARIANT_F4
&----
*& Form SUB_SELECT_DOCUMENT
&----
text
----
--> p1 text
<-- p2 text
----
form SUB_SELECT_DOCUMENT.
data : v_lines type i .
read table i_tab with key box = 'X'.
select *
from mseg INTO TABLE I_DOC
WHERE MBLNR = I_TAB-MBLNR.
IF SY-SUBRC EQ 0 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'I_DOC'
I_STRUCTURE_NAME = 'MSEG'
CHANGING
CT_FIELDCAT = I_FIELDCAT1
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear struct_layout1.
STRUCT_layout1-colwidth_optimize = 'X'.
refresh it_sort.
clear it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_GRID_TITLE = 'Details of Document'
IS_LAYOUT = STRUCT_LAYOUT1
IT_FIELDCAT = I_FIELDCAT1
i_structure_name = 'MSEG'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_DOC
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.
ENDIF.
endform. " SUB_SELECT_DOCUMENT
&----
*& Form SUB_COMMENT_BUILD
&----
text
----
-->P_I_LIST_TOP_OF_PAGE text
----
form SUB_COMMENT_BUILD using I_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
***Header
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: not used for this type
ls_line-info = 'Heading list'.
APPEND ls_line TO I_top_of_page.
***Selection
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Material '.
APPEND ls_line TO i_top_of_page.
ls_line-key = 'Key 2'.
ls_line-info = 'Document no'.
APPEND ls_line TO I_top_of_page.
***Action
CLEAR ls_line.
endform. " SUB_COMMENT_BUILD
&----
*& Form SUB_EVENTTAB_BUILD
&----
Defines the event table
----
FORM sub_eventtab_build USING l_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
Get the different events of the ALV
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = l_events.
Search the top of page events
READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO l_events.
ENDIF.
endform. " SUB_EVENTTAB_BUILD
----
FORM TOP_OF_PAGE *
----
When TOP-OF-PAGE will be fired , this event will be called and it
will use the contents of i_list_top_of_page for output in the header
----
FORM top_of_page.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_top_of_page.
ENDFORM.
plz gimme sample program forunderstanding structure of ALV PROGRAM using basic explanations
2008 Feb 08 6:48 AM
Hi,
Sample programs on ALV Grid
report zbnstest.
TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
INTERNAL TABLE DECLARATION.
INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
AND THE LAYOUT FOR THE ALV.
HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
THIS IS DONE TO MAKE THE CODE SIMPLER.
OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
PROGRAMS.
IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
MORE TABLES AND CREATE A STRUCTURE
IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
START-OF-SELECTION. *
start-of-selection.
SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
INTERNAL TABLE.
perform selectdata_and_sort.
SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
FORMS
IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
----
FORM FILL_FIELDS_OF_FIELDCATALOG *
----
........ *
----
--> FIELDCATALOG *
--> P_TABNAME *
--> P_FIELDNAME *
--> P_KEY *
--> P_KEY *
----
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
----
FORM POPULATE_LAYOUT *
----
........ *
----
--> FIELDLAYOUT *
----
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
----
FORM SELECTDATA_AND_SORT *
----
........ *
----
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
----
FORM MERGE_FIELDCATALOG *
----
........ *
----
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
i_structure_name = 'COLORSTRUCT'
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
FOLLOWS:-
i_callback_program --> CALLING PROGRAM NAME
i_structure_name --> STRUCTURE NAME.
is_layout --> LAYOUT NAME.
it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
TOOL BAR
i_save = 'A'
IS_VARIANT = ' '
it_events = eventstab[]
IT_EVENT_EXIT =
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
&----
*& Form POPULATE_ITAB1
&----
text
----
--> p1 text
<-- p2 text
----
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
&----
*& Form FILL_EVENTSTAB
&----
text
----
-->P_EVENTSTAB text *
----
form fill_eventstab tables p_eventstab structure eventstab.
WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
&----
*& Form FILL_HEADINGTABLE
&----
text
----
-->P_HEADING text *
----
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
WHEN 'HEADING5'.
P_HEADING-TYP = 'H'.
P_HEADING-INFO = 'LIST-MODIFY'.
APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
----
FORM TOP_OF_PAGE *
----
........ *
----
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
&----
*& Form FILL_COLORSTRUCT
&----
text
----
-->P_COLORSTRUCT text *
----
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
----
FORM TOP_OF_COVERPAGE *
----
........ *
----
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
----
FORM END_OF_COVERPAGE *
----
........ *
----
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
----
FORM FOREIGN_TOP_OF_PAGE *
----
........ *
----
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
----
FORM FOREIGN_END_OF_PAGE *
----
........ *
----
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
----
FORM LIST_MODIFY *
----
........ *
----
*FORM LIST_MODIFY.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING5[]
EXCEPTIONS
OTHERS = 1.
*ENDFORM.
----
FORM END_OF_PAGE *
----
........ *
----
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
----
FORM END_OF_LIST *
----
........ *
----
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
----
FORM TOP_OF_LIST *
----
........ *
----
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Don't forget to reward if useful...
2008 Feb 08 6:49 AM
hi,
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' .
To display ALV LISTS the function module used are :
REUSE_ALV_LIST_DISPLAY "For Normal LIST
REUSE_ALV_HIERARCHICAL_LIST_DISPLAY "For Hierarchical LIST
To display ALV GRID the function module used are :
REUSE_ALV_GRID_DISPLAY . "For GRID display
The most important component of the ALV is the FIELDCATALOG which is of
TYPE SLIS_T_FIEDLCAT_ALV
or of
TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV .
The line items of the field catalog are of
TYPE SLIS_FIELDCAT_ALV .
FIELDCATALOG
To prepare field catalog certain fields are essential .There are various other fields allowing for vaarious possibilities and display options.
TABNAME
FIELDNAME
REF_TABNAME
SELTECT_M
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Link containing all the important PDFS. ( There is a PDF for ALV Grid in this link)
http://www.easymarketplace.de/online-pdfs.php
Hope this is helpful, Do reward.
Edited by: Runal Singh on Feb 8, 2008 12:27 PM
2008 Feb 08 6:49 AM
here is sample code
plz reward if helpful
REPORT YSUBALV.
--
TYPE-POOLS: SLIS.
To pass name of the report in function module for ALV
DATA: V_REPID LIKE SY-REPID .
To pass the overall structure of the ALV report
DATA: STRUCT_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: STRUCT_LAYOUT1 TYPE SLIS_LAYOUT_ALV.
Internal table to capture various events in ALV
DATA : I_EVENTS TYPE SLIS_T_EVENT.
Table for catalog of the fields to be displayed
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
data : x_fieldcat TYPE SLIS_FIELDCAT_ALV.
DATA: I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
data : x_fieldcat1 TYPE SLIS_FIELDCAT_ALV.
Internal table to mention the sort sequence
DATA : IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA : X_SORT TYPE SLIS_SORTINFO_ALV.
Internal table to display top of page
data : i_list_top_of_page type slis_t_listheader.
Structure to display variants
data : i_variant like disvariant,
i_variant1 like disvariant.
Internal table to pass data
DATA: BEGIN OF I_TAB OCCURS 0,
mblnr like mseg-mblnr ,
matnr like mseg-matnr,
maktg like makt-maktg ,
charg like mseg-charg ,
werks like mseg-werks,
lgort like mseg-lgort,
menge like mseg-menge ,
meins like mseg-meins ,
dmbtr like mseg-dmbtr,
ebeln like mseg-ebeln,
icn(4) type c ,
sym(4) type c ,
excpt(2) type c ,
box(1),
END OF I_TAB.
*EJECT
DATA : begin of i_doc occurs 0 .
INCLUDE STRUCTURE MSEG.
DATA : end of i_doc.
-------End of Data Declaration-------------*
PARAMETERS : P_VAR LIKE DISVARIANT-VARIANT.
initialization.
v_repid = sy-repid.
Display default variant
PERFORM SUB_VARIANT_INIT.
AT SELECTION-SCREEN ON P_VAR.
Once the user has entered variant, check about its existence
PERFORM SUB_CHECK_PVAR.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
Display a list of various variants of the report when the
user presses F4 key in the variant field
PERFORM SUB_VARIANT_F4.
START-OF-SELECTION.
Prepare field catalog for the main report. State the name of
the field , name of internal table , various formatting options etc
PERFORM SUB_PREPARE_FIELDCATALOG.
Fetches records from database into table i_tab to be passed as export
parameter t_outtab in function module : REUSE_ALV_GRID_DISPLAY
PERFORM SUB_SELECT_RECORD.
Populate stat and icon columns of internal table i_tab with specific
columns and symbols based on some logic for quantity and value fields.
PERFORM SUB_MODIFY_RECORDS.
Defines the overall layout of the report
PERFORM SUB_DETERMINE_ALV_LAYOUT.
Defines the sort sequence of the report
PERFORM SUB_DETERMINE_SORT_SEQUENCE.
Defines the event table
PERFORM SUB_EVENTTAB_BUILD USING I_EVENTS.
Things to be written at the top of the page
PERFORM SUB_COMMENT_BUILD USING i_list_top_of_page.
Display the ALV list
PERFORM SUB_SHOW_ALV_LIST.
struct_layout-hotspot_fieldname = 'X'.
AT LINE-SELECTION.
PERFORM SUB_HOTSPOT.
&----
*& Form SUB_VARIANT_INIT
&----
Display default variant
----
form SUB_VARIANT_INIT.
I_VARIANT1-REPORT = SY-REPID.
Search default variant for the report
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
If default variant is found , use it as default.
Else , use the variant LAYOUT1.
IF sy-subrc = 0.
p_var = i_variant1-variant.
ELSE.
p_var = 'LAYOUT1'.
ENDIF.
endform. " SUB_VARIANT_INIT
&----
*& Form SUB_CHECK_PVAR
&----
Once the user has entered variant, check about its existence
----
FORM SUB_CHECK_PVAR.
If the name of the variable is not blank, check about its existence
if not p_var is initial.
clear i_variant.
i_variant-report = sy-repid.
i_variant-variant = p_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
CS_VARIANT = I_VARIANT.
If no such variant found , flash error message
if sy-subrc ne 0 .
message e398(00) with 'No such variant exists'.
else.
If variant exists , use the variant name to populate structure
I_VARIANT1 which will be used for export parameter : IS_VARIANT
in the function module : REUSE_ALV_GRID_DISPLAY
clear i_variant1.
move p_var to i_variant1-variant.
move sy-repid to i_variant1-report.
endif.
else.
clear i_variant.
endif.
ENDFORM. " SUB_CHECK_PVAR
&----
*& Form SUB_PREPARE_FIELDCATALOG
&----
Prepare field catalog for the main report. State the name of
the field , name of internal table , various formatting options etc
----
form SUB_PREPARE_FIELDCATALOG.
First field to appear in ALV list
X_FIELDCAT-COL_POS = 1.
Name of the internal table field
X_FIELDCAT-FIELDNAME = 'SYM'.
Name of the internal table
X_FIELDCAT-TABNAME = 'I_TAB'.
Heading for the field
X_FIELDCAT-SELTEXT_M = 'Stat'.
The field is going to contain a symbol
x_fieldcat-symbol = 'X'.
Append the specifications to the internal table for field catalog.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
Second field to appear in ALV list
X_FIELDCAT-COL_POS = 2.
Name of the field in the internal table
X_FIELDCAT-FIELDNAME = 'MATNR'.
Name of the internal table
X_FIELDCAT-TABNAME = 'I_TAB'.
Heading for the column
X_FIELDCAT-SELTEXT_M = 'MatItem'.
It is going to be the key field.The color for this field is going to
be different
X_fieldcat-key = 'X'.
X_fieldcat-key_sel = 'X'.
Single click on the field will trigger double click event.Also, a hand
will appear when the cursor navigates to the field
X_fieldcat-hotspot = 'X'.
The column and those left to it will not scroll
X_fieldcat-fix_column = 'X'.
F1 help will come as it is referenced to DDIC table
x_fieldcat-ref_tabname = 'MSEG'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 3.
X_FIELDCAT-FIELDNAME = 'MAKTG'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Description'.
X_FIELDCAT-OUTPUTLEN = 50.
x_fieldcat-hotspot = space.
The field is centre(C for centre, R and L for left and
right) justified
x_fieldcat-just = 'C'.
x_fieldcat-key = 'X'.
x_fieldcat-fix_column = 'X'.
X_fieldcat-no_out = 'X'.
X_fieldcat-fix_column = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 4.
X_FIELDCAT-FIELDNAME = 'CHARG'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Batch'.
X_FIELDCAT-OUTPUTLEN = 10.
x_fieldcat-hotspot = space.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 5.
X_FIELDCAT-FIELDNAME = 'EBELN'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Purchase Order'.
X_FIELDCAT-OUTPUTLEN = 14.
The field will be colored differently(Cxyz)
x_fieldcat-emphasize = 'C511'.
Initially the field will be hidden
x_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 6.
X_FIELDCAT-FIELDNAME = 'MBLNR'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Document no'.
X_FIELDCAT-OUTPUTLEN = 14.
x_fieldcat-emphasize = 'C711'.
x_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 7.
X_FIELDCAT-FIELDNAME = 'WERKS'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Plant'.
X_FIELDCAT-OUTPUTLEN = 5.
x_fieldcat-emphasize = 'C310'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 8.
X_FIELDCAT-FIELDNAME = 'LGORT'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'St.Loc'.
X_FIELDCAT-OUTPUTLEN = 7.
X_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 9.
X_FIELDCAT-FIELDNAME = 'MENGE'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Quantity'.
X_FIELDCAT-OUTPUTLEN = 12.
Summation is allowed for this field
x_fieldcat-do_sum = 'X'.
X_FIELDCAT-ref_tabname = 'MSEG'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 10.
X_FIELDCAT-FIELDNAME = 'ICN'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = ''.
X_FIELDCAT-OUTPUTLEN = 2.
x_fieldcat-icon = 'X'.
X_fieldcat-no_out = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 11.
X_FIELDCAT-FIELDNAME = 'MEINS'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Unit'.
X_FIELDCAT-OUTPUTLEN = 5.
x_fieldcat-qfieldname = 'MEINS'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 12.
X_FIELDCAT-FIELDNAME = 'DMBTR'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = 'Local curr'.
X_FIELDCAT-OUTPUTLEN = 12.
x_fieldcat-INTTYPE = 'P'.
x_fieldcat-just = 'R'.
x_fieldcat-do_sum = 'X'.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
X_FIELDCAT-COL_POS = 13.
X_FIELDCAT-FIELDNAME = 'EXCPT'.
X_FIELDCAT-TABNAME = 'I_TAB'.
X_FIELDCAT-SELTEXT_M = ''.
X_FIELDCAT-OUTPUTLEN = 3.
append X_fieldcat TO I_FIELDCAT.
clear x_fieldcat.
endform. " SUB_PREPARE_FIELDCATALOG
&----
*& Form SUB_SELECT_RECORD
&----
Fetches records from database into table i_tab to be passed as export
parameter t_outtab in function module : REUSE_ALV_GRID_DISPLAY
----
form SUB_SELECT_RECORD.
SELECT mblnr Amatnr Amaktg charg
werks lgort menge meins dmbtr ebeln
FROM makt as a join mseg as b
on ( amatnr = bmatnr )
INTO TABLE I_TAB
where b~bwart = '101' .
endform. " SUB_SELECT_RECORD
&----
*& Form SUB_MODIFY_RECORDS
&----
Populate stat and icon columns of internal table i_tab with specific
columns and symbols based on some logic for quantity and value fields.
----
form SUB_MODIFY_RECORDS.
loop at i_tab.
if i_tab-dmbtr gt 10000.
Field icn of internal table is going to contain icon . For this column
*icon_allowed is set in the field catalog table. For various icons,see
type pool <ICON>
i_tab-icn = '@1V@'.
modify i_tab transporting icn.
endif.
if i_tab-menge gt 50.
Field icn of internal table is going to contain symbol . For this
column symbol_allowed is set in the field catalog table. For various
icons,see type pool <SYMBOL>
i_tab-sym = 'N'.
modify i_tab transporting sym.
endif.
IF I_TAB-WERKS NE 'SDC1'.
This field will contain lights , traffic signals : red.yellow,green
That this field will be used as a light will be specified in the
column of structure STRUCT_LAYOUT.
I_TAB-EXCPT = '1'.
MODIFY I_TAB TRANSPORTING EXCPT.
endif.
endloop.
endform. " SUB_MODIFY_RECORDS
&----
*& Form SUB_DETERMINE_ALV_LAYOUT *
&----
*& Defines the overall structure of the report layout *
----
form SUB_DETERMINE_ALV_LAYOUT.
Field EXCPT will show the light signal
STRUCT_LAYOUT-LIGHTS_FIELDNAME = 'EXCPT'.
Field BOS of the internal table will act as pushbutton and will appear
at the left of the grid display. User will press that to select a
record
struct_layout-box_fieldname = 'BOX'.
STRUCT_layout-totals_text = 'Totqty '.
STRUCT_LAYOUT-ZEBRA = 'X'.
struct_layout-confirmation_prompt = 'X'.
struct_layout-detail_titlebar = 'Details of Storing'.
struct_layout-no_sumchoice = 'X'.
struct_layout-totals_only = 'X'.
endform. " SUB_DETERMINE_ALV_LAYOUT
&----
*& Form SUB_DETERMINE_SORT_SEQUENCE
&----
Defines the sort sequence of the report
----
form SUB_DETERMINE_SORT_SEQUENCE.
X_sort-spos = 1. " Sort order
X_sort-fieldname = 'MATNR'.
X_sort-tabname = 'I_TAB'.
X_sort-up = 'X'.
X_sort-subtot = 'X'. " Sub total allowed
append X_sort TO IT_SORT.
clear X_sort.
endform. " SUB_DETERMINE_SORT_SEQUENCE
&----
*& Form SUB_SHOW_ALV_LIST
&----
Shows ALV list in grid form
----
form SUB_SHOW_ALV_LIST.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
Name of the program
I_CALLBACK_PROGRAM = V_REPID
title
I_GRID_TITLE = 'Details of Storing'
calls subroutine : PF_STATUS_SET
i_callback_pf_status_set = 'PF_STATUS_SET'
Calls subroutine : user_command
i_callback_user_command = 'USER_COMMAND'
Overall structure of the report
IS_LAYOUT = STRUCT_LAYOUT
Passes the field catg internal table
IT_FIELDCAT = I_FIELDCAT
Passws the sort sequence internal table
IT_SORT = IT_SORT
I_DEFAULT = 'X'
I_SAVE = 'A'
Passes the internal table for variants
IS_VARIANT = i_variant1
fetches different events into internal table i_events
it_events = i_events[]
TABLES
Passes data table for ALV display
T_OUTTAB = I_TAB
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. " SUB_SHOW_ALV_LIST
&----
*& Form set_status
&----
Form used to set the Custom pf-status of the List Display
----
rt_extab :
----
FORM pf_status_set USING i_rt_extab TYPE slis_t_extab.
data : x_extab type slis_extab.
x_extab-fcode = '&LFO'.
append x_extab to i_rt_extab.
Pf-status STANDARD of program SAPLSALV is copied to ZSTANDARD of the
current program and the pushbutton for Information (okcode=&LFO) is
excluded
SET PF-STATUS 'ZSTANDARD' excluding i_rt_extab .
ENDFORM.
&----
*& Form user_command
&----
Form used to handle USER_COMMAND events
----
rf_ucomm: Function Code
rs : Internal Table containing the selection information.
----
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
data : v_mblnr like mseg-mblnr.
case rf_ucomm.
A custom pushbutton for record deletion is set in the GUI status.
When a record is selected , the field BOC for that record becomes 'X'.
The records are traced and deleted and the fields are refreshed( rs
of type slis_selfield is refreshed)
when '&DEL'. "Print button clicked.
delete i_tab where box = 'X'.
rs-refresh = 'X'.
When the user selects a row and presses the Select pushbutton ( user
defined ) from the application toolbar, the details of the document
will be shown in another ALV list
when '&SEL'.
PERFORM SUB_SELECT_DOCUMENT.
set parameter id 'MBN' field i_tab-mblnr.
call transaction 'MB03'.
Ok code for double click is &IC1 for ALV report
when '&IC1'.
perform sub_hotspot.
endcase.
ENDFORM.
&----
*& Form SUB_HOTSPOT
&----
text
----
--> p1 text
<-- p2 text
----
form SUB_HOTSPOT.
message i398(00) with 'Hello'.
endform. " SUB_HOTSPOT
&----
*& Form SUB_VARIANT_F4
&----
Display a list of various variants of the report when the
user presses F4 key in the variant field
----
form SUB_VARIANT_F4.
i_variant-report = sy-repid.
Utilising the name of the report , this function module will
search for a list of variants and will fetch the selected one into
the parameter field for variants
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = I_VARIANT
I_SAVE = 'A'
I_DISPLAY_VIA_GRID = 'X'
IMPORTING
ES_VARIANT = I_VARIANT1
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
P_VAR = I_VARIANT1-VARIANT.
ENDIF.
endform. " SUB_VARIANT_F4
&----
*& Form SUB_SELECT_DOCUMENT
&----
text
----
--> p1 text
<-- p2 text
----
form SUB_SELECT_DOCUMENT.
data : v_lines type i .
read table i_tab with key box = 'X'.
select *
from mseg INTO TABLE I_DOC
WHERE MBLNR = I_TAB-MBLNR.
IF SY-SUBRC EQ 0 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'I_DOC'
I_STRUCTURE_NAME = 'MSEG'
CHANGING
CT_FIELDCAT = I_FIELDCAT1
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear struct_layout1.
STRUCT_layout1-colwidth_optimize = 'X'.
refresh it_sort.
clear it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_GRID_TITLE = 'Details of Document'
IS_LAYOUT = STRUCT_LAYOUT1
IT_FIELDCAT = I_FIELDCAT1
i_structure_name = 'MSEG'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_DOC
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.
ENDIF.
endform. " SUB_SELECT_DOCUMENT
&----
*& Form SUB_COMMENT_BUILD
&----
text
----
-->P_I_LIST_TOP_OF_PAGE text
----
form SUB_COMMENT_BUILD using I_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
***Header
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: not used for this type
ls_line-info = 'Heading list'.
APPEND ls_line TO I_top_of_page.
***Selection
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Material '.
APPEND ls_line TO i_top_of_page.
ls_line-key = 'Key 2'.
ls_line-info = 'Document no'.
APPEND ls_line TO I_top_of_page.
***Action
CLEAR ls_line.
endform. " SUB_COMMENT_BUILD
&----
*& Form SUB_EVENTTAB_BUILD
&----
Defines the event table
----
FORM sub_eventtab_build USING l_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
Get the different events of the ALV
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = l_events.
Search the top of page events
READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO l_events.
ENDIF.
endform. " SUB_EVENTTAB_BUILD
----
FORM TOP_OF_PAGE *
----
When TOP-OF-PAGE will be fired , this event will be called and it
will use the contents of i_list_top_of_page for output in the header
----
FORM top_of_page.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_top_of_page.
ENDFORM.
2008 Feb 08 6:49 AM
Hi,
Check this simple program..
TABLES : MARA.
SELECT-OPTIONS:S_MATNR FOR MARA-MATNR DEFAULT '1' TO '1000'.
DATA ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM MARA INTO TABLE ITAB WHERE MATNR IN S_MATNR.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = 'MARA'
TABLES
T_OUTTAB = ITAB
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.Another Program...
TYPE-POOLS:SLIS.
TABLES:MARA.
DATA:IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:WA_FCAT TYPE SLIS_FIELDCAT_ALV.
*********************************************************************
* Selection Screen
*********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:S_MATNR FOR MARA-MATNR DEFAULT '000000000000000001'
TO'000000000000001000'.
SELECTION-SCREEN END OF BLOCK B1.
*********************************************************************
* Internal Table
********************************************************************
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
NTGEW LIKE MARA-NTGEW,
END OF ITAB.
**********************************************************************
* Start of Selection
**********************************************************************
START-OF-SELECTION.
SELECT MATNR
ERSDA
ERNAM
NTGEW FROM MARA INTO TABLE ITAB WHERE MATNR IN S_MATNR.
********************************************************************
* Field Cataloue Design
********************************************************************
WA_FCAT-COL_POS = '1'.
WA_FCAT-FIELDNAME = 'NTGEW'.
WA_FCAT-KEY = 'X'.
WA_FCAT-HOTSPOT = 'X'.
WA_FCAT-SELTEXT_M = 'Net Weight'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-KEY = ' '.
WA_FCAT-HOTSPOT = ''.
WA_FCAT-SELTEXT_M = 'Material Number'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-FIELDNAME = 'ERSDA'.
WA_FCAT-SELTEXT_M = 'Some thing'.
WA_FCAT-NO_OUT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-FIELDNAME = 'ERNAM'.
WA_FCAT-SELTEXT_M = 'Something 2t'.
WA_FCAT-NO_OUT = ' '.
APPEND WA_FCAT TO IT_FCAT.
************************************************************************
* Display Data
***********************************************************************
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'Material Details'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = ITAB
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.
2008 Feb 08 6:51 AM
hI,
There are 4 types of ALV's.
1. Basic ALV
2. Blocked ALV
3. Hierarchial ALV
4. Interactive ALV
Hi,
Refer this code
data : it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_fieldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_events TYPE slis_t_event,
it_event1 TYPE slis_t_event,
it_event2 TYPE slis_t_event,
it_header TYPE slis_t_listheader.
&----
*& Form sub_create_events *
&----
This form will display the ALV Events *
-
FORM sub_create_events .
*--Local Work Area
DATA: lwa_event TYPE slis_alv_event. "Work area for Events
*--Call Function to display the events for the ALV
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 1
IMPORTING
et_events = it_events.
*--Sort by Name
SORT it_events BY name.
*--Clear
CLEAR lwa_event.
READ TABLE it_events INTO lwa_event WITH KEY name =
slis_ev_top_of_page
BINARY SEARCH.
IF sy-subrc = 0.
MOVE c_top_of_page TO lwa_event-form.
MODIFY it_events FROM lwa_event TRANSPORTING form WHERE
name = slis_ev_top_of_page.
ENDIF.
*--Clear
CLEAR : lwa_event.
ENDFORM. "sub_create_events
&----
*& Form sub_top_of_page *
&----
This form is to build the Page Header *
-
FORM sub_top_of_page .
*--Local Variable
DATA : lv_title(120) TYPE c, " Title
lv_month(30) TYPE c,
lv_mont(30) TYPE c,
lv_bud(16) TYPE c.
*--Local Work Area
DATA : lwa_line TYPE slis_listheader. " Hold list header
CONCATENATE p_month 'to' s_hmonth INTO lv_month SEPARATED BY space.
IF NOT s_hmonth IS INITIAL.
lv_mont = lv_month.
ELSE.
lv_mont = p_month.
ENDIF.
*--Title Display
lwa_line-typ = 'H'. " header
lv_title = sy-title.
lwa_line-info = lv_title.
APPEND lwa_line TO it_header.
CLEAR lwa_line.
*--Month Display
lwa_line-typ = 'S'. " Item
WRITE: lv_mont TO lv_month.
lwa_line-key = text-024.
lwa_line-info = lv_month.
APPEND lwa_line TO it_header.
*--Budget Display
lwa_line-typ = 'S'. " Item
WRITE: p_bud TO lv_bud.
lwa_line-key = text-025.
lwa_line-info = lv_bud.
APPEND lwa_line TO it_header.
CLEAR: lwa_line,
lv_mont.
*--This funcation module will display the top of the page
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header.
*--Free
FREE : it_header.
ENDFORM. "sub_top_of_page
Check these links
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |