ALV report in OO concept
hi all
I am working on ALV report in OO concept. and facing in some difficulties in sorting, subtotal, coloring etc.. so it would be great help if there some sample program which can handle all this..
***Create new instance ALV table object
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = i_mara.
CATCH cx_salv_msg INTO lc_msg .
ENDTRY.
***.Enable Generic ALV functions
lo_functions = o_alv->get_functions( ).
lo_functions->set_all( ).
lo_functions->set_default( abap_true ).
***Sorting
lo_sorts = o_alv->get_sorts( ).
lo_sorts->add_sort( columnname = 'BRGEW' subtotal = abap_true ).
o_alv->display( ).
i tried this one but it is telling no column found and not doing subtotal..
pls giude
thanks
Edited by: JaiKarthik on Dec 7, 2009 4:17 AM
Hi You have to use ls_fieldcat-do_sum statement in your coding Check this sample report to display output in total & subtotal &---- *& Report ZALVTOTAL * *& * &---- *& * *& * &---- REPORT ZALVTOTAL . TYPES : BEGIN OF ty_vbak, vkorg TYPE vbak-vkorg, " Sales organization kunnr TYPE vbak-kunnr, " Sold-to party vbeln TYPE vbak-vbeln, " Sales document netwr TYPE vbak-netwr, " Net Value of the Sales Order waerk TYPE vbak-waerk, " Document currency END OF ty_vbak. DATA: vbak TYPE vbak, gt_vbak TYPE TABLE OF ty_vbak. SELECT-OPTIONS : s_vkorg FOR vbak-vkorg, " Sales organization s_kunnr FOR vbak-kunnr, " Sold-to party s_vbeln FOR vbak-vbeln. " Sales document SELECTION-SCREEN : SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY. SELECTION-SCREEN END OF LINE. ---- INITIALIZATION. v_1 = 'Maximum of records to read'. ---- START-OF-SELECTION. PERFORM f_read_data. PERFORM f_display_data. ---- * Form f_read_data ---- FORM f_read_data. SELECT vkorg kunnr vbeln netwr waerk UP TO p_max ROWS INTO TABLE gt_vbak FROM vbak WHERE kunnr IN s_kunnr AND vbeln IN s_vbeln AND vkorg IN s_vkorg. ENDFORM. " F_READ_DATA ---- * Form f_display_data ---- FORM f_display_data. TYPE-POOLS: slis. " ALV Global types DEFINE m_fieldcat. add 1 to ls_fieldcat-col_pos. ls_fieldcat-fieldname = &1. ls_fieldcat-ref_tabname = 'VBAK'. ls_fieldcat-do_sum = &2. ls_fieldcat-cfieldname = &3. append ls_fieldcat to lt_fieldcat. END-OF-DEFINITION. DEFINE m_sort. add 1 to ls_sort-spos. ls_sort-fieldname = &1. ls_sort-up = 'X'. ls_sort-subtot = &2. append ls_sort to lt_sort. END-OF-DEFINITION. DATA: ls_fieldcat TYPE slis_fieldcat_alv, lt_fieldcat TYPE slis_t_fieldcat_alv, lt_sort TYPE slis_t_sortinfo_alv, ls_sort TYPE slis_sortinfo_alv, ls_layout TYPE slis_layout_alv. m_fieldcat 'VKORG' '' ''. m_fieldcat 'KUNNR' '' ''. m_fieldcat 'VBELN' '' ''. m_fieldcat 'NETWR' 'X' 'WAERK'. m_fieldcat 'WAERK' '' ''. m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal m_sort 'VBELN' ''. " Sort by vbeln ls_layout-cell_merge = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = ls_layout it_fieldcat = lt_fieldcat it_sort = lt_sort TABLES t_outtab = gt_vbak. ENDFORM. " F_DISPLAY_DATA
Regards,
Arun.
Similar Messages
-
ALV report using OOPS concept.
Hi,
Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
Thanks in advance.Hi
Refer this code:
REPORT zcls_alv_oops MESSAGE-ID z1.
TABLES : mara.
Types Declaration..\
TYPES :
BEGIN OF t_mara,
matnr TYPE matnr,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_mara,
BEGIN OF t_marc,
matnr TYPE matnr,
werks TYPE werks_d,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_marc.
Internal Tables Declaration..\
DATA :
i_mara TYPE TABLE OF t_mara,
i_marc TYPE TABLE OF t_marc,
i_fcat1 TYPE lvc_t_fcat,
i_fcat2 TYPE lvc_t_fcat.
Constants Declaration..\
CONSTANTS :
c_cont1 TYPE scrfname VALUE 'CONT1',
c_cont2 TYPE scrfname VALUE 'CONT2'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS:
s_matnr FOR mara-matnr NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS :
p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
p_bttn RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
\* Class forward referncing.
CLASS lcl_rcvr_class DEFINITION DEFERRED.
\* Pointers Declaration..
DATA :
lp_rcvr TYPE REF TO lcl_rcvr_class,
lp_cont1 TYPE REF TO cl_gui_custom_container,
lp_cont2 TYPE REF TO cl_gui_custom_container,
lp_grid1 TYPE REF TO cl_gui_alv_grid,
lp_grid2 TYPE REF TO cl_gui_alv_grid.
\* Local Class Definiton.
CLASS lcl_rcvr_class DEFINITION.
PUBLIC SECTION.
METHODS :
hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
\* Local Class Implementation.
CLASS lcl_rcvr_class IMPLEMENTATION.
METHOD hotspot_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD handle_double_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
\* Start of Selection
START-OF-SELECTION.
\* Extract the Material Master data for the Input Material.
SELECT a~matnr
a~mtart
b~maktx
INTO TABLE i_mara
FROM mara AS a
INNER JOIN makt AS b
ON a~matnr EQ b~matnr
WHERE a~matnr IN s_matnr
AND b~spras EQ sy-langu.
END-OF-SELECTION.
IF NOT 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 OUTPUT
\* text
MODULE disp_grid OUTPUT.
\* Build the Field catelog for Material Master data.
PERFORM build_fcat.
\* Display the Material Master data using ALV.
PERFORM disp_alv.
ENDMODULE. " DISP_GRID OUTPUT
\*& Module USER_COMMAND_0100 INPUT
\* text
MODULE user_command_0100 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
\*& Form build_fcat
\* text
\* \--> p1 text
\* <-\- p2 text
FORM 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 TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ENDFORM. " build_fcat
\*& Form disp_alv
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv.
IF lp_cont1 IS INITIAL.
\* Create the Container Object of Material Master.
CREATE OBJECT lp_cont1
EXPORTING
container_name = c_cont1
EXCEPTIONS
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 Object for Grid of Material Master.
CREATE OBJECT lp_grid1
EXPORTING
i_parent = lp_cont1
EXCEPTIONS
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 METHOD lp_grid1->set_table_for_first_display
CHANGING
it_outtab = i_mara
it_fieldcatalog = i_fcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 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 OBJECT lp_rcvr.
IF p_hotspt EQ 'X'.
SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
ELSE.
SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " disp_alv
\*& Module STATUS_0100 OUTPUT
\* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STAT'.
SET TITLEBAR 'T_100'.
ENDMODULE. " STATUS_0100 OUTPUT
\*& Module STATUS_0200 OUTPUT
\* text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'PLANT_STAT'.
SET TITLEBAR 'T_200'.
ENDMODULE. " STATUS_0200 OUTPUT
\*& Module DISP_GRID_plant OUTPUT
\* text
MODULE disp_grid_plant OUTPUT.
\* Build the Field catelog for Material Plant data.
PERFORM build_fcat_plant.
\* Display the Material Master Plant data using ALV.
PERFORM disp_alv_plant.
ENDMODULE. " DISP_GRID_plant OUTPUT
\*& Module USER_COMMAND_0200 INPUT
\* text
MODULE user_command_0200 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
\*& Form build_fcat_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM 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 TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'WERKS'.
ws_fcat-scrtext_m = text-004.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ENDFORM. " build_fcat_plant
\*& Form disp_alv_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv_plant.
IF lp_cont2 IS INITIAL.
\* Create the Container Object of Material Plant data.
CREATE OBJECT lp_cont2
EXPORTING
container_name = c_cont2
EXCEPTIONS
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 Object for Grid of Material Plant data.
CREATE OBJECT lp_grid2
EXPORTING
i_parent = lp_cont2
EXCEPTIONS
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 METHOD lp_grid2->set_table_for_first_display
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_fcat2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 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 METHOD lp_grid2->refresh_table_display.
ENDIF.
ENDFORM. " disp_alv_plant
Thanks
Vasudha -
Creating ALV reports using OOP concept
After creating many reports i found out that 90% of the coding in a report is copy paste i.e. only 10% of coding effort is required which includes
creating the custom data types and internal table variables ...
populating the data
creating screen,GUI status and GUI title
Just copy paste the below code and do as stated :
*ALV TEMPLATE
*create screen no. 2000
*change flow logic in screen if necessary
*create GUI status and GUI title
*change selection texts and text symbols*
REPORT Y_TEMPLATE_ALV.
TABLES : ."use if range of values required on selection screen.
DATA: zcl_alvgrid TYPE REF TO cl_gui_alv_grid,
zcl_ccontainer TYPE REF TO cl_gui_docking_container,
wa_layout TYPE lvc_s_layo,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
wa_fieldcat TYPE lvc_s_fcat,
z_document TYPE REF TO cl_dd_document,
o_docking TYPE REF TO cl_gui_docking_container,"Docking Container
o_split TYPE REF TO cl_gui_easy_splitter_container, "Splitter
o_top_container TYPE REF TO cl_gui_container, "Top Container
o_bottom_container TYPE REF TO cl_gui_container."Bottom Container
TYPES : BEGIN OF TY_FINAL,
"All columns which are to be displayed in the report should be included here
END OF TY_FINAL.
*Add additional Internal Tables's if data is to be extracted from multiple tables
*Then loop at main table and Read the other tables
DATA :IT_DATA TYPE STANDARD TABLE OF , "data extracted from tables can be stored in this internal table variable ..
WA_DATA TYPE ,
iT_alv TYPE STANDARD TABLE OF TY_FINAL, " pass to the method SET_TABLE_FOR_FIRST_DISPLAY of class
ZCL_ALVGRID [Already done ; its just fyi]
WA_alv TYPE TY_FINAL.
DATA :V_CLN(255) TYPE C, " For no. of records
V_LINE TYPE I. " for conversion of integer to character
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
SELECT-OPTIONS: " PARAMETERS and Range on selection screen
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN OUTPUT.
* START OF SELECTION *
START-OF-SELECTION.
* SELECT * FROM INTO CORRESPONDING FIELDS OF TABLE IT_DATA WHERE ....in ....
IF SY-SUBRC = 0.
LOOP AT IT_DATA INTO WA_DATA.
MOVE-CORRESPONDING WA_DATA TO wa_alv. " if data is fetched from only one table
APPEND wa_alv TO it_alv.
CLEAR : wa_alv,WA_DATA.
ENDLOOP.
DESCRIBE TABLE it_alv LINES V_LINE.
V_CLN = V_LINE.
ENDIF.
END-OF-SELECTION.
PERFORM DISPLAY_ALV.
*& Module STATUS OUTPUT
* text
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STATUS'.
SET TITLEBAR 'ALV'.
* ** Creating Docking Container
CREATE OBJECT o_docking
EXPORTING
* side = cl_gui_docking_container=>dock_at_right
ratio = '95'.
IF sy-subrc EQ 0.
* Splitting the Docking container
CREATE OBJECT o_split
EXPORTING
parent = o_docking
sash_position = 05 "Position of Splitter Bar (in Percent)
with_border = 0. "With Border = 1 Without Border = 0
* Placing the containers in the splitter
o_top_container = o_split->top_left_container .
o_bottom_container = o_split->bottom_right_container .
* Creating the document
CREATE OBJECT z_document
EXPORTING
style = 'ALV_GRID'.
ENDIF.
* Calling the methods for dynamic text
CALL METHOD z_document->add_text
EXPORTING
TEXT = 'No. of Records:'
sap_emphasis = cl_dd_area=>strong. " For bold
* Adding GAP
CALL METHOD z_document->add_gap
EXPORTING
width = 10.
* Adding Text
CALL METHOD z_document->add_text
EXPORTING
TEXT = v_cln.
* Adding Line
CALL METHOD z_document->new_line.
* Display the data
CALL METHOD z_document->display_document
EXPORTING
parent = o_top_container.
IF zcl_alvgrid IS INITIAL .
*----Creating ALV Grid instance
CREATE OBJECT zcl_alvgrid
EXPORTING
i_parent = o_bottom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Calling the method of ALV to process top of page
CALL METHOD zcl_alvgrid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = z_document.
* Preparing field catalog.
PERFORM T_FIELDCAT USING:
'1' 'BRNCD' 'BRAND'.
* 'Column no' 'FIELDNAME' 'Column Heading'
WA_LAYOUT-CWIDTH_OPT = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-SEL_MODE = 'A'.
* Setting table for first display
CALL METHOD ZCL_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = it_alv
IT_FIELDCATALOG = IT_FIELDCAT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 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.
ELSE.
CALL METHOD ZCL_ALVGRID->REFRESH_TABLE_DISPLAY
EXCEPTIONS
FINISHED = 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.
ENDMODULE. " STATUS OUTPUT
MODULE USER_COMMAND_2000 INPUT.
DATA: V_OK_CODE TYPE SY-UCOMM,
V_SAVE_OK TYPE SY-UCOMM.
V_OK_CODE = SY-UCOMM.
V_SAVE_OK = V_OK_CODE.
CASE SY-UCOMM.
WHEN 'BACK'.
SET SCREEN 1000.
WHEN 'EXIT'.
LEAVE program.
WHEN OTHERS.
SET SCREEN 1000.
ENDCASE.
CLEAR V_SAVE_OK.
SET SCREEN 0.
LEAVE SCREEN.
ENDMODULE. " USER_COMMAND_2000 INPUT
*& Form T_FIELDCAT
* text
* -->x text
* -->y text
* -->z text
FORM T_FIELDCAT USING VALUE(X) TYPE ANY
VALUE(Y) TYPE ANY
VALUE(Z) TYPE ANY.
WA_FIELDCAT-COL_POS = X.
WA_FIELDCAT-FIELDNAME = Y.
WA_FIELDCAT-COLTEXT = Z.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " T_FIELDCAT
*& Form DISPLAY_ALV
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY_ALV .
IF NOT it_alv[] IS INITIAL.
CALL SCREEN 2000.
ELSE.
MESSAGE 'No data for Display' TYPE 'I'.
ENDIF.
ENDFORM. " DISPLAY_ALVHello Jay,
Calling methods, creating instances, casting etc are not OOP. When you say you've developed an OO-report you think OO, refer to this blog to see what i mean - Global Data in ABAP OO Programs
BR,
Suhas -
Icons in alv report....
Hi all,
I am creating an ALV report using oops concept all the things are working fine but i can not able to see all the icons enabled (icon for sum and and the next to that both are disabled) plz give the solution ASAP....
Thanks and Regards
AshuIn your fieldcatalog
for Summable fields(quantities, Currencies etc)
you provide inttype = 'P'.
fieldcatalog-inttype = 'P'.
and try... -
Hi Experts,
I am new to ALV Reports, can any one provide some inputs on how to create an Interactive ALV Reports using OOPS Concept.
I am getting the data from SFLIGHT on first ALV and i want that when i single click any cell or row or any check box associated with the row i should get the corresponding booking details from table SBOOK.
Thanks
RaviHi dude,
Go through this Link: [http://www.sap-img.com/abap/an-interactive-alv-report.htm]
for more information search in SDN only..
Re: Interactive ALV Report Using Function...? -
Hi Friends,
I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
The code written is as follows.
=====================================================
REPORT ZMMSTKH.
DATA: G_ALV_TREE TYPE REF TO CL_GUI_ALV_TREE,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GT_ZSD_BILLINFO TYPE ZSD_BILLINFO OCCURS 0, "Output-Table
OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM, "OK-Code
G_MAX TYPE I VALUE 255.
DATA CCONTAINER1.
DATA LS_FIELDCAT TYPE LVC_S_FCAT.
DATA GT_FIELDCAT_LVC TYPE LVC_S_FCAT OCCURS 0.
DATA IT_FIELDCATALOG TYPE LVC_S_FCAT OCCURS 0.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE PBO OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAINTITLE'.
IF G_ALV_TREE IS INITIAL.
PERFORM INIT_TREE.
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
IF SY-SUBRC NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Automation Queue failure'(801)
TXT1 = 'Internal error:'(802)
TXT2 = 'A method in the automation queue'(803)
TXT3 = 'caused a failure.'(804).
ENDIF.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE PAI INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM EXIT_PROGRAM.
WHEN OTHERS.
CALL METHOD CL_GUI_CFW=>DISPATCH.
ENDCASE.
CALL METHOD CL_GUI_CFW=>FLUSH.
ENDMODULE. " PAI INPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM INIT_TREE.
DATA: L_TREE_CONTAINER_NAME(30) TYPE C.
L_TREE_CONTAINER_NAME = 'CCONTAINER1'(001).
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = L_TREE_CONTAINER_NAME
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
IF SY-SUBRC <> 0.
MESSAGE X208(00) WITH 'ERROR'(100).
ENDIF.
CREATE OBJECT G_ALV_TREE
EXPORTING
PARENT = G_CUSTOM_CONTAINER
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = 'X'
NO_HTML_HEADER = 'X'
NO_TOOLBAR = ''
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
ILLEGAL_NODE_SELECTION_MODE = 5
FAILED = 6
ILLEGAL_COLUMN_NAME = 7.
IF SY-SUBRC <> 0.
MESSAGE X208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
DATA L_HIERARCHY_HEADER TYPE TREEV_HHDR.
PERFORM BUILD_HIERARCHY_HEADER CHANGING L_HIERARCHY_HEADER.
PERFORM ZF_CREATE_FIELDCAT.
CALL METHOD G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'zsd_billinfo'
IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
CHANGING
IT_OUTTAB = GT_ZSD_BILLINFO. "table must be empty !
IT_FIELDCATALOG = GT_FIELDCAT_LVC[].
PERFORM CREATE_HIERARCHY.
CALL METHOD G_ALV_TREE->FRONTEND_UPDATE.
ENDFORM. " init_tree
*& Form build_hierarchy_header
FORM BUILD_HIERARCHY_HEADER CHANGING
P_HIERARCHY_HEADER TYPE TREEV_HHDR.
P_HIERARCHY_HEADER-HEADING = 'Region / Material'(300).
p_hierarchy_header-tooltip = 'PO No'(400).
P_HIERARCHY_HEADER-WIDTH = 30.
P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM EXIT_PROGRAM.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM CREATE_HIERARCHY.
DATA: LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
LT_ZSD_BILLINFO TYPE ZSD_BILLINFO OCCURS 0,
l_bukrs like zsd_billinfo-bukrs,
l_vbeln like zsd_billinfo-vbeln,
l_fkdat like zsd_billinfo-fkdat,
l_fkart like zsd_billinfo-fkart,
l_vkorg like zsd_billinfo-vkorg,
l_spart like zsd_billinfo-spart,
L_BZIRK LIKE ZSD_BILLINFO-BZIRK,
L_BZIRK_LAST LIKE ZSD_BILLINFO-BZIRK,
l_vkbur like zsd_billinfo-vkbur,
L_WERKS LIKE ZSD_BILLINFO-WERKS,
L_WERKS_LAST LIKE ZSD_BILLINFO-WERKS,
L_MATNR LIKE ZSD_BILLINFO-MATNR,
L_MATNR_LAST LIKE ZSD_BILLINFO-MATNR,
L_FKIMG LIKE ZSD_BILLINFO-FKIMG,
L_NETWR LIKE ZSD_BILLINFO-NETWR.
DATA: L_BUKRS_KEY TYPE LVC_NKEY,
L_BZIRK_KEY TYPE LVC_NKEY,
L_WERKS_KEY TYPE LVC_NKEY,
L_MATNR_KEY TYPE LVC_NKEY,
l_vbeln_key type lvc_nkey,
L_LAST_KEY TYPE LVC_NKEY.
SELECT BUKRS BZIRK WERKS MATNR FKIMG FROM ZSD_BILLINFO
INTO CORRESPONDING FIELDS OF
TABLE LT_ZSD_BILLINFO
WHERE SPART = 'CT' AND
FKART = 'ZVAT'.
select * from zsd_billinfo into table lt_zsd_billinfo
where spart = 'CT' and
fkart = 'ZVAT'.
SORT LT_ZSD_BILLINFO BY BZIRK WERKS MATNR.
LOOP AT LT_ZSD_BILLINFO INTO LS_ZSD_BILLINFO.
L_BZIRK = LS_ZSD_BILLINFO-BZIRK.
L_WERKS = LS_ZSD_BILLINFO-WERKS.
L_MATNR = LS_ZSD_BILLINFO-MATNR.
IF L_BZIRK <> L_BZIRK_LAST.
L_BZIRK_LAST = L_BZIRK.
PERFORM ADD_BZIRK USING L_BZIRK
CHANGING L_BZIRK_KEY.
CLEAR L_WERKS_LAST.
ENDIF.
IF L_WERKS <> L_WERKS_LAST.
L_WERKS_LAST = L_WERKS.
PERFORM ADD_WERKS_LINE USING LS_ZSD_BILLINFO
L_WERKS_KEY
CHANGING L_WERKS_KEY.
IF L_MATNR <> L_MATNR_LAST.
L_MATNR_LAST = L_MATNR.
PERFORM ADD_MATNR_LINE USING LS_ZSD_BILLINFO
L_MATNR_KEY
CHANGING L_MATNR_KEY.
ENDIF.
PERFORM ADD_COMPLETE_LINE USING LS_ZSD_BILLINFO
L_MATNR_KEY
CHANGING L_LAST_KEY.
ENDIF.
*if l_matnr <> l_matnr_last.
l_matnr_last = l_matnr.
perform add_matnr_line using ls_zsd_billinfo
l_matnr_key
changing l_matnr_key.
endif.
perform add_complete_line using ls_zsd_billinfo
l_matnr_key
changing l_last_key.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_month
*& Form add_ebeln
FORM ADD_BZIRK USING P_BZIRK TYPE C
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
L_BZIRK(12) TYPE C. "output string for month
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_month
FORM ADD_WERKS_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
L_NODE_TEXT = PS_ZSD_BILLINFO-WERKS.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_carrid_line
FORM ADD_MATNR_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE,
LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
L_NODE_TEXT = PS_ZSD_BILLINFO-MATNR.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = LS_ZSD_BILLINFO
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_carrid_line
**& Form add_complete_line
FORM ADD_COMPLETE_LINE USING PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
P_RELAT_KEY TYPE LVC_NKEY
CHANGING P_NODE_KEY TYPE LVC_NKEY.
DATA: L_NODE_TEXT TYPE LVC_VALUE.
WRITE PS_ZSD_BILLINFO-BZIRK TO L_NODE_TEXT.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
IS_OUTTAB_LINE = PS_ZSD_BILLINFO
I_NODE_TEXT = L_NODE_TEXT
IMPORTING
E_NEW_NODE_KEY = P_NODE_KEY.
ENDFORM. " add_complete_line
*& Form zf_create_fieldcat
text
FORM ZF_CREATE_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'FKIMG'.
LS_FIELDCAT-REF_TABLE = 'zsd_billinfo'.
LS_FIELDCAT-NO_OUT = 'X'.
LS_FIELDCAT-KEY = ''.
APPEND LS_FIELDCAT TO GT_FIELDCAT_LVC.
ENDFORM. " ZF_CREATE_FIELDCAT
=================================================
Kindly look into the code and guide me the solution.
TIA.
Regards,
Mark Khi
good
i tried your ALV report but it is giving some error due to some ztable you have used in your progam,
you can go to se38 and give there BCALV* and press f4, you ll find lots of ALV example related to OOP concept, you can test them and use them as per your requirement.
thnaks
mrutyun^ -
ALV report Object Oriented way without containers?
Hi guru
I was hearing that alv report using OO concept can be created only using containers... if we use containers can we run the job in background as its gui interfacing... is there a way to create using oo and with out containers. Thanks.Hi Raj,
you can also use the new ALV object model class cl_salv_table for this. Refer to program SALV_DEMO_TABLE_REAL_SIMPLE to see how easy you can create a full screen ALV without container. Internally the class uses the FM REUSE_ALV_GRID_DISPLAY.
Regards Rudi -
ALV Report Development using OOPs concept
complete details of " ALV Report Development using OOPs concept".
Thanks in advance ...hi Sudharshan,
please use these sample codes to understand about OOALV
BC_ALV_GRID_CONTROL
BC_ALVHIERGRID1_D100
BC_ALVHIERGRID1_D210
BC_ALVHIERGRID1_HIER
BC_ALV_DEMO_HTML_D0100
BC_ALV_GRID_CONTROL
BC_ALVEXCEL
BC_ALVEXCEL_D100
BC_ALVEXCEL_D210
BC_ALVEXCEL_HIER
BC_ALVEXCEL_SAP_TEMPL
BC_ALVEXCEL_SAP_TEMPL_F01
BC_ALVEXCEL_SAP_TEMPL_TOP
BC_ALVEXCELTOP
BC_ALVHIERGRID1_D100
BC_ALVHIERGRID1_D210
BC_ALVHIERGRID1_HIER
BC_ALVHIERTOP
For learning OOPS-ALV in every SAP their is transaction named ZALV
or try the following links:
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
programs as detailed below:
BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.
BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
The report checks the input value(s) semantically and provides protocol messages in case of error
BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
implement the saving of the new data.
BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:
(1) how to define a column for editable checkboxes for an attribute of your list
(2) how to evaluate the checked checkboxes
(3) how to switch between editable and non-editable checkboxes
BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
Grid Control.
BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.
BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects
are dealt with:
(1) how to replace the standard f4 help
(2) how to pass the selected value to the ALV Grid Control
(3) how to build an f4 help, whose value range depend on a value of another cell. -
Context menu's in Alv Report (Grid)
hello,
what i have done- i have created a ALV report by using the function modlue REUSE_ALV_GRID_DISPLAY.
what i want- When user clicks with Right mouse button on some cell.
context menu should get displayed. a list of menu should appear then user can select one of these options and eventually i'll on user command.
however i know the concept of context menu's and i have created context menu on screen elements in module pool.
but i have no idea whether these menu's can be created on ALV Grid.(simple ALv Grid----not ABAP OOPS)check the program BCALV_GRID_06, it gives a demo of context menu functionalty,
but it uses cl_gui_alv_grid -
'Save layout' button missing in the ALV report layout screen
Hi Friends,
In one of our ALV report the 'save layout' button is missing in the report output screen.i have used the OO concept for creating the ALV output and not the function module.I have attached the code below used for creating the ALV grid.
CREATE OBJECT alv_grid
EXPORTING i_parent = g_container_2.
CALL METHOD alv_grid->set_table_for_first_display
exporting
i_structure_name = 'PA0002'
is_layout =
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = wa_fieldcat.
But i'm not able to trace why the 'save layout' button is missing in the output.Can anyone of you help me in sorting out this problem.
Thanks and Regards,
Vadivel.Pass <u><i><b>A to I_SAVE</b></i></u> parameter. That will give the options to the user to save the layout outs.
I_SAVE = SPACE
Layouts cannot be saved.
I_SAVE = 'U'
Only user-defined layouts can be saved.
I_SAVE = 'X'
Only global layouts can be saved.
I_SAVE = 'A'
Both user-defined and global layouts can be saved.
Regards,
Ravi
Note : Please mark all the helpful answers
Message was edited by: Ravikumar Allampallam -
Logic For Subtracting A Given Output In ALV Report
Hi,
I am working on a report in which i am using ALV Concept and there a problem arise i.e. in ALV Report output which always subtotals having values in addition only and i want to know is there any way through which subtraction can also be performed within the output of a ALV Report.
Please provide some guidelines for it.
Regards,
Rickky NVHi,
Thanks to both of you for your value able response. Actually, i am working on customer aging analysis report in which there are 2 columns i.e. debit and credit in which these both values are stored in 2 separate lines and i have to display the difference of them in the 3rd column and facing the problem.
Is it possible to display the required data of it in 3rd column of it?
Regards,
Ricky -
What is the difference between list display and grid display in alv report
Hai genious
i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me what is the main difference between list display and grid display in alv report
thanks®ards
chinnuHi ,
1. For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
I hope it helps.
Regards,
Mamta
Edited by: Mamta Verma on Nov 27, 2008 6:41 AM -
Can somebody give some real time questions for alv report
hi guru
can somebody give some real time questions for alv report.
answers also.
regards
subhasis.hi,
The ALV is a set of function modules and classes and their methods which are added to program code. Developers can use the functionality of the ALV in creating new reports, saving time which might otherwise have been spent on report enhancement
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. <b>To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).</b>
Using ALV, we can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
<b>Reward useful points</b>
Siva -
On ALV report in1 column I want to put Icon on every row of that column.
On ALV report there is 1 column I want to put Icon on every row of that column.That ALV program uses object oriented concept all class and methods.
I want to use that icon on that row. That icon name is ICON_OKAY
In my program when I assign values to internal table at that time I am assigning that ICON_OKAY value to that row as follow.
Itab-
Itab-icon = ICON_OKAY.
Append itab.please follow below procedure to display icon in ALV
1) In corresponding fieldcatelog entry do
fieldcatalog-icon = 'X'
2) While filling the internal table fill the corresponding key value of icon , for example ICON_OKAY value is '@0V@' so statement would be
Itab-icon = '@0V@'
to get list of corresponding key for icon open include <ICON> in se38 -
Create a Procedural ALV Report with editable fields and save the changes
Hi,
I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EDITABLE
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
But all these are using OO Concepts.
Please help.
Regards,
SmruthiTABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-edit = 'X'
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
LOOP AT it_ekko INTO wa_ekko.
ld_color = ld_color + 1.
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
FORM top-of-page *
FORM top-of-page.
WRITE:/ 'This is First Line of the Page'.
ENDFORM.
FORM status *
FORM status USING rt_extab TYPE slis_t_extab. .
SET PF-STATUS 'ALV'.
ENDFORM.
FORM USER_COMMAND *
--> RF_UCOMM *
--> RS *
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
CASE rf_ucomm.
when 'SAVE'.
get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
endcase.
endform.
ENDFORM.
here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
create a custom PF status and create push buttons and assign your ok codes in your PF status.
if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
Hope this will help you.
Regards,
phani.
Maybe you are looking for
-
Hi All, In my ALV GRID report I have a field which uses a domain. This domain has some fixed values like: 1 - Male, 2 - Female. In the output only 1 or 2 is appearing. Is there a way by which instead of the value, we can display the description of th
-
Installing Oracle 8i on Windows 98
Hi, I have Oracle 8i Enterprise edition for Windows NT/2000 CD with me. I have a machine with Windows 98. Can I install the same in Windows 98 platform ? Will there be any problem if I install 8i and Jdeveloper ( for Windows NT/2000) in Windows 98 ma
-
Change employee sub group code in configuration
Hello Fellows, I have requirement to change employee sub group code in configuration. For example there are existing code starting AA text1, AB text2 and so on. I want to change it with 10 text1, 11 text 2. System is allowing to change text only (i.
-
Failed to build mocha shape data
Hello, I come with error that adobe is sending me when im trying to paste my mocha shape data in AE. This is what is showing in message : "AEGP Plugin MochaShapeConverter : Failed to build correct mocha shape data. ( 5027 :: 12 )" I took some steps t
-
Missing details in hardware inventory
Hi, Hardware inventory details about Logical and Physical disks are not available for any of my managed workstations. ZLM7.2 HP3 server and agents. Is anyone experiencing the same problem? Thanks, Ovidiu