Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV grid example

Former Member
0 Kudos
9,951

Can you give me an example/document on ALV grid ?

Thanks a lot.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
754

Hi,

in SE38, check for programs with name starting with BCALV*

Regards,

Vara

11 REPLIES 11

laxmanakumar_appana
Active Contributor
0 Kudos
754

Hi,

Check the programs with pattren BCALV in SE38 . there are many examples on ALV and also check the transaction DWDM.

check this link :

http://www.sapgenie.com/abap/controls/alvgrid.htm

Regards

Appana

Former Member
0 Kudos
755

Hi,

in SE38, check for programs with name starting with BCALV*

Regards,

Vara

Former Member
0 Kudos
754

Search in se38 for BALVGRID . This will list ALV GRID Sample programs by SAP.

Use BCALVGRID for Object oriented Grid samples.

Thanks

Sujamol

0 Kudos
754

Hi,

Please check the sample program for ALV

DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,

i_fieldcat TYPE lvc_t_fcat,

wa_layout TYPE lvc_s_layo,

o_container TYPE REF TO cl_gui_custom_container,

o_container_top TYPE REF TO cl_gui_container,

o_container_bot TYPE REF TO cl_gui_container,

o_split TYPE REF TO cl_gui_easy_splitter_container,

o_line_dockingcont TYPE REF TO cl_gui_docking_container,

o_event_receiver TYPE REF TO lcl_event_receiver.

DATA: i_final_log TYPE STANDARD TABLE OF zpesanlage.

SELECT-OPTIONS : s_anlage FOR eanl-anlage.

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

  • AT SELECTION SCREEN

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

AT SELECTION-SCREEN.

Select installation

SELECT * FROM zpesanlage INTO TABLE i_final_log

WHERE anlage IN s_anlage.

IF sy-subrc NE 0.

MESSAGE s001(zespur) WITH text-010.

EXIT.

ENDIF.

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

  • END OF SELECTION

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

END-OF-SELECTION.

IF NOT i_installation[] IS INITIAL.

CALL SCREEN 9000.

ELSE.

MESSAGE s001(zespur) WITH text-010.

LEAVE LIST-PROCESSING.

ENDIF.

&----


*& Module STATUS_9000 OUTPUT

&----


  • PBO

----


MODULE status_9000 OUTPUT.

SET PF-STATUS 'STATUS01'.

SET TITLEBAR 'TITLE01'.

IF o_alvgrid IS INITIAL.

*-- Create Instances

PERFORM create_object.

*-- Create Field catalog

PERFORM field_catalog TABLES i_fieldcat.

**-- Set ALV Layout

PERFORM create_layout.

**-- Sort i_final based on Installation No.

SORT i_final_log BY anlage ASCENDING.

**-- Generate ALV Grid

PERFORM display_list TABLES i_final_log

i_fieldcat

USING wa_layout.

ELSEIF NOT o_alvgrid IS INITIAL.

CALL METHOD o_alvgrid->refresh_table_display.

CLEAR wa_layout.

REFRESH: i_fieldcat.

ENDIF.

ENDMODULE. " STATUS_9000 OUTPUT

&----


*& Module USER_COMMAND_9000 INPUT

&----


  • PAI

----


MODULE user_command_9000 INPUT.

ok_code = sy-ucomm.

CASE ok_code.

WHEN 'EXIT' OR 'CANC'.

PERFORM free_objects USING o_alvgrid 'ALV' text-029.

PERFORM free_internal_tables.

LEAVE PROGRAM.

WHEN 'BACK'.

PERFORM free_objects USING o_alvgrid 'ALV' text-029.

PERFORM free_internal_tables.

SET SCREEN '0'.

LEAVE SCREEN.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

&----


*& Form create_object

&----


  • Create Object

----


FORM create_object .

IF sy-batch IS INITIAL.

IF o_alvgrid IS INITIAL.

CREATE OBJECT o_container

EXPORTING

container_name = 'CONTAINER1'.

ENDIF.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_container.

ELSE.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_line_dockingcont

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE e001(zespur) WITH text-029.

LEAVE LIST-PROCESSING.

ENDIF.

ENDIF.

ENDFORM. " create_object

&----


*& Form field_catalog

&----


  • Field Catalog

----


FORM field_catalog TABLES p_fieldcat STRUCTURE lvc_s_fcat. "#EC *

DATA ls_fcat TYPE lvc_s_fcat.

REFRESH p_fieldcat.

CLEAR ls_fcat.

ls_fcat-col_pos = 1.

ls_fcat-fieldname = text-018.

ls_fcat-outputlen = 12.

ls_fcat-tabname = text-023.

ls_fcat-coltext = text-024.

ls_fcat-fix_column = c_x.

ls_fcat-just = c_x.

ls_fcat-no_zero = c_x.

APPEND ls_fcat TO p_fieldcat.

CLEAR ls_fcat.

ls_fcat-col_pos = 2.

ls_fcat-fieldname = text-019.

ls_fcat-outputlen = 15.

ls_fcat-tabname = text-023.

ls_fcat-coltext = text-025.

ls_fcat-fix_column = c_x.

ls_fcat-just = c_x.

APPEND ls_fcat TO p_fieldcat.

CLEAR ls_fcat.

ls_fcat-col_pos = 3.

ls_fcat-fieldname = text-020.

ls_fcat-tabname = text-023.

ls_fcat-coltext = text-026.

ls_fcat-just = c_x.

APPEND ls_fcat TO p_fieldcat.

CLEAR ls_fcat.

ls_fcat-col_pos = 4.

ls_fcat-fieldname = text-021.

ls_fcat-tabname = text-023.

ls_fcat-coltext = text-027.

ls_fcat-just = c_x.

APPEND ls_fcat TO p_fieldcat.

CLEAR ls_fcat.

ls_fcat-col_pos = 5.

ls_fcat-fieldname = text-022.

ls_fcat-tabname = text-023.

ls_fcat-coltext = text-028.

ls_fcat-just = c_x.

APPEND ls_fcat TO p_fieldcat.

ENDFORM. " field_catalog

&----


*& Form create_layout

&----


  • Layout

----


FORM create_layout.

wa_layout-zebra = c_x.

wa_layout-cwidth_opt = c_x.

ENDFORM. " create_layout

&----


*& Form display_list

&----


  • Dispalay List for grid

----


FORM display_list TABLES p_output

p_fieldcat "#EC *

USING value(p_layout).

*-- Display Report

CALL METHOD o_alvgrid->set_table_for_first_display

EXPORTING

i_save = c_a

is_layout = p_layout

it_toolbar_excluding = i_excl_func

CHANGING

it_outtab = p_output[]

it_fieldcatalog = p_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE i000(zo_spa) WITH text-039. " Error in Displaying

LEAVE LIST-PROCESSING.

ENDIF.

CREATE OBJECT o_event_receiver.

SET HANDLER o_event_receiver->handle_double_click FOR o_alvgrid.

CALL METHOD o_alvgrid->refresh_table_display.

ENDFORM. " display_list

&----


*& Form free_objects

&----


  • Free Objects

----


FORM free_objects USING pobject

value(ptype)

value(ptext) TYPE c.

DATA: lo_objectalv TYPE REF TO cl_gui_alv_grid.

CASE ptype.

WHEN 'ALV'.

lo_objectalv = pobject.

IF NOT ( lo_objectalv IS INITIAL ).

CALL METHOD lo_objectalv->free

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

CLEAR: pobject, lo_objectalv.

PERFORM error_handle USING ptext.

ENDIF.

WHEN OTHERS.

sy-subrc = 1.

PERFORM error_handle

USING text-029.

ENDCASE.

ENDFORM. " free_objects

&----


*& Form error_handle

&----


  • Error Handle

----


FORM error_handle USING value(ptext) TYPE c.

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = text-030

txt2 = sy-subrc

txt1 = ptext.

ENDIF.

ENDFORM. " error_handle

&----


*& Form free_internal_tables

&----


  • Free Internal tables

----


FORM free_internal_tables .

clear: i_installation.

ENDFORM. " free_internal_tables

Regards,

Prakash.

Former Member
0 Kudos
754

hi nuren,

check the demo programs by typing Balv in se38

check these..

http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm

http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm

http://help.sap.com/saphelp_sm32/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/content.htm

REPORT ZTEST_ALV NO STANDARD PAGE HEADING LINE-COUNT 5.

TABLES: LFA1,LFB1,LFM1.

TYPE-POOLS: SLIS.

TYPE-POOLS: ICON.

***DATA DECLN.

DATA: V_LIFNR LIKE LFA1-LIFNR,

V_BUKRS LIKE LFB1-BUKRS,

V_EKORG LIKE LFM1-EKORG,

V_KTOKK LIKE LFA1-KTOKK.

***FIELD CATALOG.

*CHANGES BY LAXMI

DATA: ITAB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

*END CHANGES

***SORTING

DATA: GS_SORT TYPE SLIS_SORTINFO_ALV,

GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.

    • FOR LAYOUT

DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : V_REPID TYPE SY-REPID.

*INTERNAL TABLE DECLN

DATA: BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

BUKRS LIKE LFB1-BUKRS,

EKORG LIKE LFM1-EKORG,

KTOKK LIKE LFA1-KTOKK,

NAME1 LIKE LFA1-NAME1,

STRAS LIKE LFA1-STRAS,

ORT01 LIKE LFA1-ORT01,

REGIO LIKE LFA1-REGIO,

PFORT LIKE LFA1-PFORT,

PSTLZ LIKE LFA1-PSTLZ,

PSTL2 LIKE LFA1-PSTL2,

TELF1 LIKE LFA1-TELF1,

COLOR(3) TYPE C,

*CELLCOLOR TYPE LVC_T_SCOL,

END OF ITAB.

*SELECTION-SCREEN.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.

SELECT-OPTIONS: S_LIFNR FOR LFA1-LIFNR.

SELECT-OPTIONS: S_BUKRS FOR LFB1-BUKRS.

SELECT-OPTIONS: S_EKORG FOR LFM1-EKORG.

SELECT-OPTIONS: S_KTOKK FOR LFA1-KTOKK.

SELECTION-SCREEN: END OF BLOCK B1.

PARAMETERS: R_LIST RADIOBUTTON GROUP G1,

R_GRID RADIOBUTTON GROUP G1.

**AT SELECTION-SCREEN.

AT SELECTION-SCREEN.

IF NOT S_LIFNR IS INITIAL.

SELECT SINGLE LIFNR

INTO V_LIFNR

FROM LFA1

WHERE LIFNR IN S_LIFNR.

IF SY-SUBRC <> 0.

MESSAGE E001(ZZ1).

ENDIF.

ELSE.

MESSAGE E005(ZZ1).

ENDIF.

IF NOT S_BUKRS IS INITIAL.

SELECT SINGLE BUKRS

FROM T001

INTO V_BUKRS

WHERE BUKRS IN S_BUKRS.

IF SY-SUBRC <> 0.

MESSAGE E002(ZZ1).

ENDIF.

ELSE.

MESSAGE E006(ZZ1).

ENDIF.

IF NOT S_EKORG IS INITIAL.

SELECT SINGLE EKORG

FROM T024E

INTO V_EKORG

WHERE EKORG IN S_EKORG.

IF SY-SUBRC <> 0.

MESSAGE E003(ZZ1).

ENDIF.

ELSE.

MESSAGE E007(ZZ1).

ENDIF.

IF NOT S_KTOKK IS INITIAL.

SELECT SINGLE KTOKK

FROM T077K

INTO V_KTOKK

WHERE KTOKK IN S_KTOKK.

IF SY-SUBRC <> 0.

MESSAGE E008(ZZ1).

ENDIF.

ELSE.

MESSAGE E008(ZZ1).

ENDIF.

***start of selection.

START-OF-SELECTION.

V_REPID = SY-REPID.

PERFORM GET_DATA.

****END OF SELECTION.

END-OF-SELECTION.

PERFORM GET_FIELD_CATALOG.

*PERFORM BUILD_FIELDCAT.

IF R_LIST = 'X'.

PERFORM LIST_DISPLAY.

ELSE.

PERFORM GRID_DISPLAY.

ENDIF.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

SELECT LFA1~LIFNR

LFB1~BUKRS

LFM1~EKORG

LFA1~KTOKK

LFA1~NAME1

LFA1~STRAS

LFA1~ORT01

LFA1~REGIO

LFA1~PFORT

LFA1~PSTLZ

LFA1~PSTL2

LFA1~TELF1

FROM LFA1 INNER JOIN LFB1 ON LFA1LIFNR = LFB1LIFNR

INNER JOIN LFM1 ON LFA1LIFNR = LFM1LIFNR

INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE LFA1~LIFNR IN S_LIFNR.

ENDFORM. " GET_DATA

&----


*& Form GET_FIELD_CATALOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_FIELD_CATALOG .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = V_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = ITAB_FIELDCAT[]

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.

ENDFORM. " GET_FIELD_CATALOG

&----


*& Form LIST_DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM LIST_DISPLAY .

WA_LAYOUT-INFO_FIELDNAME = 'COLOR'.

WA_LAYOUT-ZEBRA = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = ITAB_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • 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 = 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.

ENDFORM. " LIST_DISPLAY

&----


*& Form BUILD_FIELDCAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELDCAT .

ITAB_FIELDCAT-COL_POS = 0.

ITAB_FIELDCAT-FIELDNAME = 'LIFNR'.

ITAB_FIELDCAT-KEY = 'X'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-OUTPUTLEN = '10'.

ITAB_FIELDCAT-SELTEXT_L = 'VENDOR'(009).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 1.

ITAB_FIELDCAT-FIELDNAME = 'BUKRS'.

ITAB_FIELDCAT-KEY = 'X'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-OUTPUTLEN = '4'.

ITAB_FIELDCAT-SELTEXT_L = 'COMPANY CODE'(010).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 2.

ITAB_FIELDCAT-FIELDNAME = 'EKORG'.

ITAB_FIELDCAT-KEY = 'X'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-OUTPUTLEN = '4'.

ITAB_FIELDCAT-SELTEXT_L = 'PURCHASING ORG'(011).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 3.

ITAB_FIELDCAT-FIELDNAME = 'KTOKK'.

ITAB_FIELDCAT-OUTPUTLEN = '4'.

ITAB_FIELDCAT-SELTEXT_L = 'ACCOUNT GRP'(012).

ITAB_FIELDCAT-EMPHASIZE = 'X'.

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 4.

ITAB_FIELDCAT-FIELDNAME = 'NAME1'.

ITAB_FIELDCAT-OUTPUTLEN = '12'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-SELTEXT_L = 'VENDOR NAME'(013).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 5.

ITAB_FIELDCAT-FIELDNAME = 'STRAS'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-OUTPUTLEN = '12'.

ITAB_FIELDCAT-SELTEXT_L = 'STREET'(014).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 6.

ITAB_FIELDCAT-FIELDNAME = 'ORT01'.

ITAB_FIELDCAT-OUTPUTLEN = '12'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-SELTEXT_L = 'CITY'(015).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 7.

ITAB_FIELDCAT-FIELDNAME = 'REGIO'.

ITAB_FIELDCAT-OUTPUTLEN = '2'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-SELTEXT_L = 'REGION'(016).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 8.

ITAB_FIELDCAT-FIELDNAME = 'PFORT'.

ITAB_FIELDCAT-OUTPUTLEN = '10'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-SELTEXT_L = 'PO BOX'(017).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 9.

ITAB_FIELDCAT-FIELDNAME = 'PFTLZ'.

ITAB_FIELDCAT-EMPHASIZE = 'X'.

ITAB_FIELDCAT-OUTPUTLEN = '10'.

ITAB_FIELDCAT-SELTEXT_L = 'POST CODE'(018).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 10.

ITAB_FIELDCAT-FIELDNAME = 'PSTL2'.

ITAB_FIELDCAT-OUTPUTLEN = '10'.

ITAB_FIELDCAT-SELTEXT_L = 'PO ZIP'(019).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

ITAB_FIELDCAT-COL_POS = 11.

ITAB_FIELDCAT-FIELDNAME = 'TELF1'.

ITAB_FIELDCAT-OUTPUTLEN = '16'.

ITAB_FIELDCAT-SELTEXT_L = 'TELEPHONE'(020).

APPEND ITAB_FIELDCAT.

CLEAR ITAB_FIELDCAT.

CLEAR GS_SORT.

GS_SORT-FIELDNAME = 'LIFNR'.

GS_SORT-SPOS = 1.

GS_SORT-UP = 'X'.

GS_SORT-SUBTOT = 'X'.

APPEND GS_SORT TO GT_SORT.

*L_POS = L_POS + 1.

*DATA: LS_CELLCOLOR TYPE LVC_S_SCOL.

*DATA: L_INDEX TYPE SY-TABIX.

*

*LOOP AT ITAB.

  • L_INDEX = SY-TABIX.

  • if l_index = 1 or l_index = 10.

  • LS_CELLCOLOR-FNAME = 'VBELN'.

  • LS_CELLCOLOR-COLOR-COL = '6'.

  • LS_CELLCOLOR-COLOR-INT = '1'.

  • APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

  • MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

  • endif.

  • if l_index = 5 or l_index = 20.

  • LS_CELLCOLOR-FNAME = 'VBELN'.

  • LS_CELLCOLOR-COLOR-COL = '4'.

  • LS_CELLCOLOR-COLOR-INT = '1'.

  • APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.

  • MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.

  • endif.

*ENDLOOP.

ENDFORM. " BUILD_FIELDCAT

&----


*& Form GRID_DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GRID_DISPLAY .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = ITAB_FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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.

ENDFORM. " GRID_DISPLAY

hope this helps,

do reward if it helps,

priya.

abdul_hakim
Active Contributor
0 Kudos
754

Hi,

Have a look at the below demo programs.

<b>BCALV_GRID_01

BCALV_GRID_02

BCALV_GRID_03

BCALV_GRID_04

BCALV_GRID_05

BCALV_GRID_06

BCALV_GRID_07

BCALV_GRID_08

BCALV_GRID_09

BCALV_GRID_10

BCALV_GRID_11</b>

Complete ALV Programming Guide can be viewed from http://help.sap.com

Cheers,

Abdul Hakim

Former Member
0 Kudos
754

Hi Nuren

Refer to the following links.

http://www.esnips.com/web/ALVDocs

http://www.esnips.com/web/ALV

http://www.sapfans.com/forums/viewtopic.php?t=58286

Award points if found useful.

Regards

Inder

Former Member
0 Kudos
754

hi nuren,

check the below good example for alv grid

ALV Grid

I assume the documentation was showing examples of entire table structure being output in ALV. The following is a basic example of displaying an internal table in. I hope this helps in some way.

-


&----


*& Report Z_TEST_ALV_EX1 *

*& *

&----


*& *

*& *

&----


report z_test_alv_ex1.

*& Types

types: begin of type_1,

pernr like pa0001-pernr,

begda like pa0001-begda,

endda like pa0001-endda,

orgeh like pa0001-orgeh,

plans like pa0001-plans,

count type i,

end of type_1.

*&

data: it_1 type table of type_1,

wa_1 type type_1.

*& Declare Layout Of The Output

data: g_layout type lvc_s_layo,

gs_variant type disvariant. "finally chosen layout

*& Layouts should always be based on the type LVC_S_LAYO. This layout

*& determine overall settings for the output

*& Declare the Field Catalog

data: g_fieldcat type lvc_t_fcat with header line.

*& The Field catalog should always be based on the type lvc_t_fcat

data: ok_code like sy-ucomm.

data: g_container type scrfname value 'BCALV_GRID1',

grid1 type ref to cl_gui_alv_grid,

g_custom_container type ref to cl_gui_custom_container.

*&-Start-Of-Selection

start-of-selection.

select * from pa0001 into corresponding fields of table it_1

where endda = '99991231'.

loop at it_1 into wa_1.

wa_1-count = wa_1-count + 1.

modify it_1 from wa_1.

endloop.

call screen 0100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

set pf-status 'MAIN100'.

*Set Container

if g_custom_container is initial.

create object g_custom_container exporting container_name = g_container.

create object grid1 exporting i_parent = g_custom_container.

*& Fill Field catalog

perform field_catalogue.

*Display Data Using the Method

gs_variant = sy-repid.

call method grid1->set_table_for_first_display

exporting is_layout = g_layout

is_variant = gs_variant

changing it_outtab = it_1

it_fieldcatalog = g_fieldcat[].

endif.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

  • to react on custom events:

call method cl_gui_cfw=>dispatch.

case ok_code.

when 'EXIT'.

leave program.

when others.

endcase.

clear ok_code.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form field_catalogue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form field_catalogue.

clear g_fieldcat.

g_fieldcat-fieldname = 'PERNR'.

g_fieldcat-dd_outlen = '8'.

g_fieldcat-inttype = 'N'.

g_fieldcat-coltext = 'Personnel Id'.

append g_fieldcat.

clear g_fieldcat.

g_fieldcat-fieldname = 'BEGDA'.

g_fieldcat-dd_outlen = '8'.

g_fieldcat-inttype = 'D'.

g_fieldcat-coltext = 'Start Date'.

append g_fieldcat.

clear g_fieldcat.

g_fieldcat-fieldname = 'ENDDA'.

g_fieldcat-dd_outlen = '8'.

g_fieldcat-inttype = 'D'.

g_fieldcat-coltext = 'End Date'.

append g_fieldcat.

clear g_fieldcat.

g_fieldcat-fieldname = 'ORGEH'.

g_fieldcat-dd_outlen = '8'.

g_fieldcat-inttype = 'N'.

g_fieldcat-coltext = 'Org Unit'.

append g_fieldcat.

clear g_fieldcat.

g_fieldcat-fieldname = 'PLANS'.

g_fieldcat-dd_outlen = '8'.

g_fieldcat-inttype = 'N'.

g_fieldcat-coltext = 'Position'.

append g_fieldcat.

clear g_fieldcat.

g_fieldcat-fieldname = 'COUNT'.

g_fieldcat-do_sum = 'X'.

g_fieldcat-coltext = 'Count'.

append g_fieldcat.

endform. " field_catalogue

if u need further info on alv-grid shoot me a test mail to callnaveen@gmail.com

if u find it useful mark the points

Regards,

Naveen

Manohar2u
Active Contributor
0 Kudos
754

Check all the example programs in SLIS development class / package.

Regds

Manohar

Former Member
0 Kudos
754

Hi Nuren,

There are two methods of creating ALV grid.

1) Using the Function Modules

2) Using Object Oriented Methodology.

If you want to work on ALV using Object Oriented Methodology, you can go through this document for a beginning...

http://esnips.com/doc/b708766f-a934-42a1-8064-c4de75b48fc4/Sample-Program-of-alv-using-oops.ppt

You can explore ALV using this document.

http://esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf

Regards,

Amit.