Application Development and Automation 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: 
Read only

ALV reports using OOPS

Former Member
0 Likes
493

Hi frnds,

I want to write an alv report program using oops concepts.CAn anybody send me a simple code to generate an alv reports?

Thanks a lot in advance.

4 REPLIES 4
Read only

Former Member
0 Likes
465

Hi

http://www.sapdev.co.uk/reporting/alv/alvobjgrid/alvobject_sort.htm

&----


*& Report ZLCL_ALV_INVOICE *

*& *

&----


*& *

*& *

&----


REPORT ZLCL_ALV_INVOICE .

TABLES: VBRK.

DATA: ITAB LIKE VBRP OCCURS 1 WITH HEADER LINE.

DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_GRID TYPE REF TO CL_GUI_ALV_GRID.

START-OF-SELECTION.

SET SCREEN 100.

&----


*& Form GET_DATA

&----


  • text

----


FORM GET_DATA .

SELECT *

FROM VBRP

INTO TABLE ITAB

WHERE VBELN = VBRK-VBELN.

ENDFORM. " GET_DATA

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MENU'.

IF O_CONT IS INITIAL.

CREATE OBJECT O_CONT

EXPORTING

CONTAINER_NAME = 'INV_CONT' "Screen custom control name

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6

.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in custom container'.

EXIT.

ENDIF.

CREATE OBJECT O_GRID

EXPORTING

I_PARENT = O_CONT "Custom container class object

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in alv grid linking'.

EXIT.

ENDIF.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module SHOW_ALV_GRID INPUT

&----


  • text

----


MODULE SHOW_ALV_GRID INPUT.

PERFORM GET_DATA.

CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'VBRP'

CHANGING

IT_OUTTAB = ITAB[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in showing alv grid'.

EXIT.

ENDIF.

ENDMODULE. " SHOW_ALV_GRID INPUT

you can understand very easily

Read only

Former Member
0 Likes
465

HI,

Please refer to the SAP standard demo program BCALV_GRID_DEMO.

And please refer to the link below :

http://www.saptechnical.com/Tutorials/OOPS/MainPage.htm

Thanks,

Sriram POnna.

Read only

Former Member
0 Likes
465

Hi,

Goto se80 and see in the package 'SLIS' all programs related ALV are given.

Programs starting with BCALV uses oops concepts.

PLzz reward if it helps.

Read only

Former Member
0 Likes
465

Hi Krishan,

Refer the below mentioned link for sample code for ALV with oops

[http://www.erpgenie.com/abap/controls/alvgrid.htm#Set%20the%20title%20of%20the%20grid|http://www.erpgenie.com/abap/controls/alvgrid.htm#Set%20the%20title%20of%20the%20grid]

Regards

Gaurav

*Reward points if useful