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: 

How to assign alv grid to custom control in a screen?

Former Member
0 Kudos

Hi,

I have created a custom control in a screen. Now i want to assign my alv grid to that custom control which i have named 'ALV_GRID1'.

I am currently using FM REUSE_ALV_GRID_DISPLAY to display ALV. Maybe i need to OO way to display ALV?

Reason for using a custom control is to restrict the ALV grid window because i am planning on having some other parameters in the same screen as alv.

Some sample code or reference to SAP standard where they are implementing this logic would be great.

Thanks

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos

Hi,

If you are making use of a screen with custom control on which you have to display the ALV GRID then do not use the FM REUSE_ALV_GRID_DISPLAY .

You will have to make use of the object(class) CL_GUI_ALV_GRID.

Inorder to use it please follow the following steps:-

1. Create a container on your screen using custom controls.

2. Give some name to this container. for eg. CC_CONTAINER.

3. Declare 2 data types as follows:-

a. data: GV_GRID_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER.

b. data: GV_GRID type ref to CL_GUI_ALV_GRID.

4. In your program call your specific screen. CALL SCREEN xxxx.

5. In the PBO of the screen; set the PF-STATUS as required.

6. Create the instance of the container object

Create object GV_GRID_CONTAINER
              exporting
               CONTAINER_NAME = 'CC_CONTAINER'.  "NAME OF THE CONTAINER
    

7. Create the grid object.

if  gv_grid is initial.
          Create object gv_grid
              exporting
               I_PARENT = GV_GRID_CONTAINER
         endif.

Now you alv grid object is created and is attached to the custom control.

Now display the data using the method SET_TABLE_FOR_FIRST_DISPLAY.

Here IT_OUTTAB is your internal table and IT_FIELDCATALOG is your fieldcatalog table.

Refer to the following programs for more details.

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

I hope this is useful for you.

Regars,

Ankur Parab

Edited by: Ankur Parab on Jun 8, 2009 6:43 PM

Edited by: Ankur Parab on Jun 8, 2009 6:44 PM

4 REPLIES 4

Former Member
0 Kudos

Hi

See program demo BCALV_GRID_DEMO

Max

Former Member
0 Kudos

You can check out the programs BCALV* or BALV*

former_member555112
Active Contributor
0 Kudos

Hi,

If you are making use of a screen with custom control on which you have to display the ALV GRID then do not use the FM REUSE_ALV_GRID_DISPLAY .

You will have to make use of the object(class) CL_GUI_ALV_GRID.

Inorder to use it please follow the following steps:-

1. Create a container on your screen using custom controls.

2. Give some name to this container. for eg. CC_CONTAINER.

3. Declare 2 data types as follows:-

a. data: GV_GRID_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER.

b. data: GV_GRID type ref to CL_GUI_ALV_GRID.

4. In your program call your specific screen. CALL SCREEN xxxx.

5. In the PBO of the screen; set the PF-STATUS as required.

6. Create the instance of the container object

Create object GV_GRID_CONTAINER
              exporting
               CONTAINER_NAME = 'CC_CONTAINER'.  "NAME OF THE CONTAINER
    

7. Create the grid object.

if  gv_grid is initial.
          Create object gv_grid
              exporting
               I_PARENT = GV_GRID_CONTAINER
         endif.

Now you alv grid object is created and is attached to the custom control.

Now display the data using the method SET_TABLE_FOR_FIRST_DISPLAY.

Here IT_OUTTAB is your internal table and IT_FIELDCATALOG is your fieldcatalog table.

Refer to the following programs for more details.

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

I hope this is useful for you.

Regars,

Ankur Parab

Edited by: Ankur Parab on Jun 8, 2009 6:43 PM

Edited by: Ankur Parab on Jun 8, 2009 6:44 PM

Former Member
0 Kudos

hi

Please check it ...

and goto se38 BCALV* lof ot demp reports available

Declaration:

DATA : MY_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

GRID TYPE REF TO CL_GUI_ALV_GRID,

GT_FCAT TYPE TABLE OF LVC_S_FCAT WITH HEADER LINE.

DATA : BEGIN OF GT_VBAK OCCURS 0,

VBELN TYPE VBAK-VBELN,

ERNAM TYPE VBAK-ERNAM,

AUDAT TYPE VBAK-AUDAT,

END OF GT_VBAK.

data:ok_code TYPE sy-ucomm.

START-OF-SELECTION.

CALL SCREEN 200.

-


BPO

-


ET PF-STATUS 'ZMMK_OOPS1'.

if MY_CONTAINER is initial.

SELECT VBELN ERNAM AUDAT

FROM VBAK INTO TABLE GT_VBAK

UP TO 10 ROWS.

CREATE OBJECT MY_CONTAINER

EXPORTING

CONTAINER_NAME = 'ZCON'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6.

CREATE OBJECT GRID

EXPORTING

I_PARENT = MY_CONTAINER

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

OTHERS = 5.

GT_FCAT-FIELDNAME = 'VBELN'.

GT_FCAT-TABNAME = 'GT_VBAK'.

GT_FCAT-REPTEXT = 'SO'.

APPEND GT_FCAT.

GT_FCAT-FIELDNAME = 'ERNAM'.

GT_FCAT-TABNAME = 'GT_VBAK'.

GT_FCAT-REPTEXT = 'NAME'.

APPEND GT_FCAT.

GT_FCAT-FIELDNAME = 'AUDAT'.

GT_FCAT-TABNAME = 'GT_VBAK'.

GT_FCAT-REPTEXT = 'DATE'.

APPEND GT_FCAT.

CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY

CHANGING

IT_OUTTAB = GT_VBAK[]

IT_FIELDCATALOG = GT_FCAT[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

  • SET TITLEBAR 'xxx'.

endif.

Thanks

Dharma