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 Control problem

Former Member
0 Likes
1,512

Hi All,

I am trying to use alv controls.But i am getting the blank screen.

Here is my code.

TYPES: BEGIN OF t_mara,

matnr TYPE mara-matnr,

mbrsh TYPE mara-mbrsh,

meins TYPE mara-meins,

END OF t_mara.

DATA it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0.

DATA wa_mara TYPE t_mara.

SELECT matnr mbrsh meins FROM mara INTO TABLE it_mara.

IF g_alvgrid IS INITIAL.

CREATE OBJECT g_container

EXPORTING

  • PARENT =

container_name = g_cc_name

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT g_alvgrid

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = g_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

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.

CALL METHOD g_alvgrid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = g_layo

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

it_outtab = it_mara

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

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 g_alvgrid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

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.

ENDFORM.

Please help me in this.

Thanks,

Naveen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,489

Naveen,

You have not build the field catalog and you are not passing to set_table_for_first_display change parameters. That is the problem

Create field catalog as below

types: wa_fldcat type LVC_T_FCAT.
data: t_fldcat type wa_fldcat with header line.
t_fldcat-seltext = 'matnumber'.
t_fldcat-FIELDNAME = 'MATNR'.
t_fldcat-TABNAME = 'ITAB'.
t_fldcat-OUTPUTLEN = '18'.
append t_fldcat.

clear t_fldcat.
t_fldcat-seltext = 'matdecription'.
*wa_fieldcat-COL_POS
t_fldcat-FIELDNAME = 'MAKTX'.
t_fldcat-TABNAME = 'ITAB'.
t_fldcat-outputlen = '40'.
append t_fldcat.

Regards,

Satish

20 REPLIES 20
Read only

former_member191735
Active Contributor
0 Likes
1,489

If you use your own container, draw that on screen on which you want to display but i couldnt see any such thing in your code. Remove container.

use call screen 100. Draw the container and name it and assign to g_cc_name,

Get back to me if you need further clarification.

Read only

0 Likes
1,489

Thanks for reply buddy.

I used screen and given control name as CC_ALV and i am passing that screen container into alvgrid.You can see that in methods.

Thanks,

Naveen.

Read only

Former Member
0 Likes
1,489

Naveen,

How did you declared g_cc_name?

Regards,

Satish

Read only

0 Likes
1,489

Hi Satish,

These are the global declarations i did.

DATA: g_alvgrid TYPE REF TO cl_gui_alv_grid.

DATA: g_container TYPE REF TO cl_gui_custom_container.

DATA: g_cc_name TYPE scrfname VALUE 'CC_ALV'

CC_ALV is the container name which i have given in screen.

Thanks,

Naveen.

Read only

Former Member
0 Likes
1,489

Where is call screen 1000 ?

Please check the below simple example program ..

REPORT ZTEST_ALV no standard page heading.

tables : makt.

  • Variables

data : v_repid like sy-repid,

v_dynnr like sy-dynnr.

  • Internal table for MAKT

data i_makt like table of makt.

  • Object ALV Data Declaration

data : ok_code like sy-ucomm,

cl_gui_custom_container type ref to cl_gui_custom_container,

cl_gui_alv_grid type ref to cl_gui_alv_grid,

grid1 type scrfname.

  • Fill the default values

initialization.

v_repid = sy-repid.

v_dynnr = sy-dynnr.

start-of-selection.

  • Get the data from makt

perform get_data_makt.

  • Call Screen

perform call_screen.

&----


*& Form get_data_makt

&----


  • Get the data from MAKT

----


FORM get_data_makt.

select * from makt into table i_makt up to 100 rows.

ENDFORM. " get_data_makt

&----


*& Form call_screen

&----


  • Call Screen

----


FORM call_screen.

call screen 1000.

ENDFORM. " call_screen

&----


*& Module STATUS_1000 OUTPUT

&----


  • text

----


MODULE STATUS_1000 OUTPUT.

SET PF-STATUS '1000'.

CREATE OBJECT CL_GUI_CUSTOM_CONTAINER

EXPORTING

  • PARENT =

CONTAINER_NAME = 'GRID1'

  • STYLE =

  • LIFETIME = lifetime_default

REPID = v_repid

DYNNR = v_dynnr

  • NO_AUTODEF_PROGID_DYNNR =

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT CL_GUI_ALV_GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

I_PARENT = cl_gui_custom_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_USE_VARIANT_CLASS = SPACE

  • I_NAME =

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.

CALL METHOD cl_gui_alv_grid->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

I_STRUCTURE_NAME = 'MAKT'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = i_makt

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

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.

ENDMODULE. " STATUS_1000 OUTPUT

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


MODULE USER_COMMAND_1000 INPUT.

case ok_code.

when 'BACK'.

leave to screen 0.

when 'CANC'.

leave to screen 0.

when 'EXIT'.

leave to screen 0.

endcase.

ENDMODULE. " USER_COMMAND_1000 INPUT

Thanks

Seshu

Read only

0 Likes
1,489

Hi Sheshu,

Thanks for reply.

I am using alv control in dailog programming.

I written the code in PBO of my screen 100.

Thanks,

Naveen.

Read only

0 Likes
1,489

Hello Navee,

Try to pass Report id ,DYNNR.

CREATE OBJECT g_container

EXPORTING

  • PARENT =

container_name = g_cc_name

  • STYLE =

  • LIFETIME = lifetime_default

<b>* REPID =

  • DYNNR =</b>* NO_AUTODEF_PROGID_DYNNR =

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6

Thanks

Seshu

Read only

0 Likes
1,489

Naveen,

I think you are doing everything fine. Any how check this blog for ALV's in OOPS

/people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid

Regards,

Satish

Read only

0 Likes
1,489

Hi Sheshu,

Now I tested as u mentioned.I passed repid and dynnr.

Still it is not working.

Thanks,

Naveen.

Read only

0 Likes
1,489

Naveen,

Small change in your program and see the results.

1. * Fill the default values

initialization.

v_repid = sy-repid. " Use this one in g_container

v_dynnr = sy-dynnr. " Use this one in g_container

2. Build internal table as like below

DATA it_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0.

DATA wa_mara TYPE mara.

3. write the query like

SELECT * from mara INTO TABLE it_mara up to 100 rows..

4.

CALL METHOD cl_gui_alv_grid->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

<b>I_STRUCTURE_NAME = 'MARA'</b>

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

IT_OUTTAB = it_mara

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

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.

Thanks

Seshu

Read only

0 Likes
1,489

Hi Sheshu,

Sorry for late reply.It is working fine with your code.

But u r taking whole mara structure.It is wasting of memory.if I want to use specific fields ur code doesn't work.If i have 2 to fetch data from 2 tables also, ur code doesn't work.Any way thanks for giving reply and if u get any other logic for specific fields please inform me.

Thanks,

Naveen.

Read only

0 Likes
1,489

Naveen,

As i told you, if you consider standard table you need not build the field catalog otherwise you have to build the field catalog and need to pass to the method set_table_for_first_display.

Regards,

Satish

Read only

0 Likes
1,489

You are right satish.Thanks for the suggestion.

where can i find the fieldcat fields??

I mean in normal ALV we can find in SLIS pool.

for this lvc_t_fcat where can i find??

Naveen.

Read only

0 Likes
1,489

Thanks satish.I got it.

Naveen.

Read only

former_member191735
Active Contributor
0 Likes
1,489

Check this out.

Write in PBO of screen 100 or whatever you defined to create container.

data: gc_custom_container TYPE REF TO cl_gui_custom_container, "screen container,

gc_container TYPE scrfname VALUE 'CONTAINER', "grid name

gc_grid TYPE REF TO cl_gui_alv_grid,

IF gc_custom_container IS INITIAL.

CREATE OBJECT gc_custom_container

EXPORTING container_name = gc_container.

ENDIF.

CREATE OBJECT gc_grid

EXPORTING i_parent = gc_custom_container.

CALL METHOD gc_grid->set_table_for_first_display

EXPORTING

GC

Read only

0 Likes
1,489

Hi abap technical,

There is no difference between ur code and my code.I am doing exactly as u did.

Thanks,

Naveen.

Read only

Former Member
0 Likes
1,489

Naveen,

First of all are you getting any data in it_mara. check in debugging.

Also try by removing INITIAL SIZE 0.

Regards,

Satish

Read only

0 Likes
1,489

Hi Satish,

I checked in the debugging.I am getting data in my internal table i.e. it_mara.

can you please tell me what happens if i put initial size 0.Coz i have seen that decaration in many programs.Thats why i am using that.

Thanks,

Naveen.

Read only

Former Member
0 Likes
1,490

Naveen,

You have not build the field catalog and you are not passing to set_table_for_first_display change parameters. That is the problem

Create field catalog as below

types: wa_fldcat type LVC_T_FCAT.
data: t_fldcat type wa_fldcat with header line.
t_fldcat-seltext = 'matnumber'.
t_fldcat-FIELDNAME = 'MATNR'.
t_fldcat-TABNAME = 'ITAB'.
t_fldcat-OUTPUTLEN = '18'.
append t_fldcat.

clear t_fldcat.
t_fldcat-seltext = 'matdecription'.
*wa_fieldcat-COL_POS
t_fldcat-FIELDNAME = 'MAKTX'.
t_fldcat-TABNAME = 'ITAB'.
t_fldcat-outputlen = '40'.
append t_fldcat.

Regards,

Satish

Read only

former_member191735
Active Contributor
0 Likes
1,489

I remember i had the same problem when i first wrote the code but it was due to the container. i didnt draw the container. well, check out your fieldcatalog. Pass the field catalog and check your internal table for data.

One more thing is You need to check if gc_custom_container is initial. if it is initial please use refresh method to refresh the container.

after all here is the display code.

CALL METHOD gc_grid->set_table_for_first_display

EXPORTING

i_save = 'U'

CHANGING

it_outtab = it_final

it_fieldcatalog = it_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

If you cannot solve the problem please reply back with your full code.

Or you can use SALV which is pretty simple and there is a demo ... search for SALV* or email me at abap2001@gmail.com