Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

requrred screenshots for alvgrid display

hi,

i am the beginner to ABA/4,

i want to learn how to create alv reports .

can u people help me?

Former Member
Former Member replied

Hi Sravanthi,

if u want learn theory please go through this website,

http://abapprogramming.blogspot.com/search/label/ALE%20BASICS%20FAQ%27S

Ex:

TYPE-POOLS : SLIS.

TABLES : VBAK.

  • Internal Table for Sales Document Header Data.

DATA : BEGIN OF I_VBAK OCCURS 0,

VBELN LIKE VBAK-VBELN,

ERNAM LIKE VBAK-ERNAM,

AUDAT LIKE VBAK-AUDAT,

NETWR LIKE VBAK-NETWR,

VKORG LIKE VBAK-VKORG,

VTWEG LIKE VBAK-VTWEG,

SPART LIKE VBAK-SPART,

END OF I_VBAK.

  • Internal Table for Sales Document Item Data.

DATA : BEGIN OF I_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MANTR LIKE VBAP-MATNR,

NETWR LIKE VBAP-NETWR,

LGORT LIKE VBAP-LGORT,

END OF I_VBAP.

  • Work area and Body for Sales Document Header Data.

DATA : TY_VBAK TYPE ZSVBAK,

T_VBAK TYPE STANDARD TABLE OF ZSVBAK.

  • Object Reference for the ZCLASS_VBAK.

DATA : OBJ TYPE REF TO ZCLASS_VBAK.

  • For Fieldcatalog, Top of Page, and Layout.

DATA : FIELD TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

FIELD1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

TOP TYPE SLIS_T_LISTHEADER WITH HEADER LINE,

TOP1 TYPE SLIS_T_LISTHEADER WITH HEADER LINE,

LAYOUT TYPE SLIS_LAYOUT_ALV.

  • For get Select options lower and Higher Values.

DATA : L_VBELN TYPE VBELN_VA,

H_VBELN TYPE VBELN_VA.

  • Selection screen Declarations.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.

SELECTION-SCREEN END OF BLOCK B1.

  • values move to temp variable from select-options table fields.

L_VBELN = S_VBELN-LOW.

H_VBELN = S_VBELN-HIGH.

  • Initialization event

INITIALIZATION.

  • Assign Values to top page internal tables.

TOP-TYP = 'H'.

TOP-INFO = 'Sales Document Details'.

APPEND TOP.

CLEAR TOP.

TOP1-TYP = 'H'.

TOP1-INFO = 'Sales Document Item Details'.

APPEND TOP1.

CLEAR TOP1.

  • Start of selection Event.

START-OF-SELECTION.

  • Object creation for ZCLASS_VBAK.

CREATE OBJECT obj.

SELECT VBELN

ERNAM

AUDAT

NETWR

VKORG

VTWEG

SPART FROM VBAK INTO TABLE I_VBAK

WHERE VBELN BETWEEN L_VBELN AND H_VBELN.

  • Values moves to I_VBAK from T_VBAK.

MOVE T_VBAK[] TO I_VBAK[].

  • To call field, Layout, Display Subroutines.

PERFORM FIELD.

PERFORM LAYOUT.

PERFORM DISPLAY.

  • Definition for top subroutine.

FORM TOP.

  • To call REUSE_ALV_COMMENTARY_WITE function module,

  • and Pass the top internal table and logo name.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = TOP[]

I_LOGO = 'LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM.

&----


*& Form LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


  • Definition for Layout subroutines.

form LAYOUT .

  • Enable the Layout field Zebra.

LAYOUT-ZEBRA = 'X'.

endform. " LAYOUT

&----


*& Form FIELD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


  • Definition for Field Subroutine.

form FIELD .

  • To call a REUSE_ALV_FIELDCATALOG_MERGE function module, and Pass

  • Program name, Internal table name, and Include name, and get

  • fieldcatalog internal table.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'I_VBAK'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = FIELD[]

  • 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. " FIELD

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


  • Definition for Display subroutine.

form DISPLAY .

  • To call a REUSE_ALV_GRID_DISPLAY function module, Pass

  • callback_program, pf_status subroutine, user_command sobroutine, top-of-page subroutine,

  • layout, and Field catalog internal tables, and get

  • Sales document Header Data details.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'ZCLASS_VBAK01'

I_CALLBACK_PF_STATUS_SET = 'STATUS'

I_CALLBACK_USER_COMMAND = 'SECOND'

I_CALLBACK_TOP_OF_PAGE = 'TOP'

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

IT_FIELDCAT = FIELD[]

  • 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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = I_VBAK[]

  • 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. " DISPLAY

  • Definition for Status subroutine.

FORM STATUS USING EXTAB TYPE SLIS_T_EXTAB.

  • Set pf status value.

SET PF-STATUS 'SALES' EXCLUDING EXTAB.

ENDFORM.

  • Definition for secondary list subroutine.

FORM SECOND USING OK_CODE LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.

  • Check the function code using case statement.

CASE OK_CODE.

WHEN '&IC1'.

DATA : V_VBELN TYPE VBELN_VA.

  • Check the Clicked field name with VBELN and if its true then move value

  • to V_VBELN Variable.

IF SELFIELD-FIELDNAME = 'VBELN'.

V_VBELN = SELFIELD-VALUE.

DATA : V_VBELN(10) TYPE N.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = VBELN

IMPORTING

OUTPUT = V_VBELN

.

SELECT VBELN

POSNR

MATNR

NETWR FROM VBAP INTO CORRESPONDING FIELDS OF TABLE I_VBAP

WHERE VBELN = V_VBELN.

IF SY-SUBRC = 0.

  • To call REUSE_ALV_FIELDCATALOG_MERGE function module .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'I_VBAP'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = FIELD1[]

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

  • To call REUSE_ALV_GRID_DISPLAY function module, and pass

  • callback_program, pf_status, user_command, top-of-page,

  • layout, fieldcatalog internal tables and

  • get Sales Document Item Details.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'ZCLASS_VBAK01'

  • I_CALLBACK_PF_STATUS_SET = ''

  • I_CALLBACK_USER_COMMAND = ''

I_CALLBACK_TOP_OF_PAGE = 'TOP1'

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

IT_FIELDCAT = FIELD1[]

  • 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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = I_VBAP[]

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

ENDIF.

ENDCASE.

ENDFORM.

  • Definition for top subroutine .

FORM TOP1.

  • To call REUSE_ALV_COMMENTARY_WRITE function module, and pass

  • commentary, and logo values.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = TOP1[]

I_LOGO = 'LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM.

Regards,

Vijay

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question