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

Former Member
0 Likes
1,567

REPORT zthiyaga4 .

TYPES : BEGIN OF ig_ekt1,

c1 TYPE zinfo6-zcol1,

c2 TYPE zinfo6-zcol2,

END OF ig_ekt1.

data ig_ek type ig_ekt1 occurs 0 with header line.

DATA alv_list1 TYPE REF TO cl_gui_alv_grid.

SELECT zcol1 zcol2 FROM zinfo6 INTO TABLE ig_ek.

CREATE OBJECT alv_list1

EXPORTING i_parent = cl_gui_container=>screen0.

CALL METHOD alv_list1->set_table_for_first_display

EXPORTING

i_structure_name = 'zinfo9'

CHANGING

it_outtab = ig_ek[].

CALL SCREEN 221.

The above report executes good.But there is no values in the SAP ALV .The outcome ALV just displays an empty column.

Can anyone please help me out in this regarding?

Thanks

Bala

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,535

hi,

if u want to display the entire table you have to pass the structure as i said in the previous post.

<b>CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

CHANGING

IT_OUTTAB = ITAB

.</b>

in your case as i said you to populate fieldcatalog of the 2 fields which you are selecting and pass the <b>fieldacatalog</b> instead of <b>structure</b>.

*do award points for all helpful answers.

regards

Message was edited by:

sowjanya s

12 REPLIES 12
Read only

Former Member
0 Likes
1,535

Welcome to SDN!!!

CALL METHOD alv_list1->set_table_for_first_display
EXPORTING
i_structure_name =

<b>'ZINFO9'</b>

CHANGING
it_outtab = ig_ek[].

Structure name in CAPS.

Also if u r not referring to the ZINFO9 then use the

ig_ekt1 in the structure name in CAPS.

If u r using all fields for display use ZINFO9.

Also have u built the fieldcatalog?

reward points if this helps.

Read only

Former Member
0 Likes
1,535

Hello,

Place break point on the internal table and check if it has any data.

Also if the ALV is in screen 221,then call screen 221 should be before the ALV display method.The set_table_for_first_dispaly method should be in the PBO of the screen.

Regards,

Beejal

**reward if this helps

Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
1,535

Hi BALA,

Please make the following changes and let me know whether it works or not ,

CALL METHOD alv_list1->set_table_for_first_display

EXPORTING

i_structure_name = <b>'ZINFO9'</b>

CHANGING

it_outtab = ig_ek[].

The STRUCTURE NAME sent to the METHOD is case sensitive.

Thanks and regards,

Ravi :).

NOTE: Points keep me alive on SDN .

Read only

raviprakash
Product and Topic Expert
Product and Topic Expert
0 Likes
1,535

Hi Bala,

Also tell me whether the structure of ZINFO9 is same as IG_EKT1. If its the same structure then declare IG_EK as:-

DATA ig_ek type table of ZINFO9.

But if the structure is different, then you need to create a FIELD CATALOGUE with same fields as your TYPE IG_EKT1. And pass this FIELD CATALOGUE to the Method to create ALV.

Thanks and regards,

Ravi .

Read only

Former Member
0 Likes
1,535

hi,

go thru the below prog,it's very simple,

i am displaying only 3 fields from SFLIGHT table

if u are selecting * (all the fields) from the dbtable you have to pass the structure name as the DBTABLE name

else if you are fetching only some fields,you have to specify fieldactalog and pass that instead of structure.

I hope you got it.

REPORT ZSOW_OBJECT4

NO STANDARD PAGE HEADING

LINE-SIZE 80

LINE-COUNT 100.

DATA:G_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

G_GRID TYPE REF TO CL_GUI_ALV_GRID,

G_LAYOUT TYPE LVC_S_LAYO,

G_FCAT TYPE LVC_T_FCAT,

W_FCAT TYPE LVC_S_FCAT,

G_SEL_ROWS TYPE LVC_T_ROID,

W_SELROWS TYPE LVC_S_ROID,

G_ROW TYPE I,

G_VALUE(20) TYPE C,

G_ROW_ID TYPE LVC_S_ROW,

G_ROW_NO TYPE LVC_S_ROID.

DATA:ITAB TYPE STANDARD TABLE OF SFLIGHT.

START-OF-SELECTION.

SET SCREEN 100.

SELECT CARRID CONNID PRICE FROM SFLIGHT

INTO CORRESPONDING FIELDS OF TABLE ITAB.

  • G_LAYOUT-SEL_MODE = 'A'.

W_FCAT-FIELDNAME = 'CARRID'.

W_FCAT-TABNAME = 'SFLIGHT'.

W_FCAT-COLTEXT = 'Airline Code'.

W_FCAT-OUTPUTLEN = '20'.

APPEND W_FCAT TO G_FCAT.

W_FCAT-FIELDNAME = 'CONNID'.

W_FCAT-TABNAME = 'SFLIGHT'.

W_FCAT-COLTEXT = 'Flight No.'.

W_FCAT-OUTPUTLEN = '20'.

APPEND W_FCAT TO G_FCAT.

W_FCAT-FIELDNAME = 'PRICE'.

W_FCAT-TABNAME = 'SFLIGHT'.

W_FCAT-COLTEXT = 'Airfare'.

W_FCAT-OUTPUTLEN = '20'.

APPEND W_FCAT TO G_FCAT.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'PF1'.

  • SET TITLEBAR 'xxx'.

CREATE OBJECT G_CONT

EXPORTING

CONTAINER_NAME = 'CONT1'.

CREATE OBJECT G_GRID

EXPORTING

I_PARENT = G_CONT

.

<b>CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

CHANGING

IT_OUTTAB = ITAB

IT_FIELDCATALOG = G_FCAT

.</b>

ENDMODULE. " STATUS_0100 OUTPUT

Regards

Read only

0 Likes
1,535

HI Sowjanya,

Thanks for ur reply.

My requirement is to get particular fields form more than 4 tables(eina,eine,konp,a017)

At this we have to create structure and then internal table i think.

But u mentioned internal table of type sflight.

DATA:ITAB TYPE STANDARD TABLE OF SFLIGHT.

I'm getting error while creating internal table.

This is how I'm doing,

TYPES : BEGIN OF ig_ekt1,

infnr LIKE eina-infnr,

peinh LIKE eine-peinh,

knumh LIKE konp-knumh,

END OF ig_ekt1.

data ig_ek type ig_ekt1 OCCURS 0.

Please clarify reg this.

Thanks,

Raj Bala

Read only

0 Likes
1,535

Hi,

Below is the modified program as u said.

REPORT ZREPORT .

DATA: G_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

alv_list1 TYPE REF TO cl_gui_alv_grid,

G_FCAT TYPE LVC_T_FCAT,

W_FCAT TYPE LVC_S_FCAT.

TYPES : BEGIN OF ig_ekt1,

c1 TYPE zinfo6-zcol1,

c2 TYPE zinfo9-zcol2,

END OF ig_ekt1.

data ig_ek type ig_ekt1 occurs 0.

start-of-selection.

SELECT zcol1 zcol2 FROM zinfo6 INTO TABLE ig_ek.

W_FCAT-FIELDNAME = 'zcol1'.

W_FCAT-TABNAME = 'zinfo6'.

W_FCAT-COLTEXT = 'COLUMN1'.

W_FCAT-OUTPUTLEN = '20'.

APPEND W_FCAT TO G_FCAT.

W_FCAT-FIELDNAME = 'zcol2'.

W_FCAT-TABNAME = 'zinfo6'.

W_FCAT-COLTEXT = 'COLUMN2'.

W_FCAT-OUTPUTLEN = '20'.

APPEND W_FCAT TO G_FCAT.

CREATE OBJECT alv_list1

EXPORTING i_parent = cl_gui_container=>screen0.

CALL METHOD alv_list1->set_table_for_first_display

CHANGING

it_outtab = ig_ek[]

IT_FIELDCATALOG = G_FCAT.

CALL SCREEN 221.

Still the final ALV shows empty fields.

Can u pls check it out?

I would be much happy if get reply from u soon.

Thanks,

Raj bala

Read only

0 Likes
1,535

Specify the fiedlname adn column name in<b> CAPS</b>

<b>W_FCAT-FIELDNAME = 'ZCOL1'.

W_FCAT-TABNAME = 'ZINFO6'.</b>

W_FCAT-COLTEXT = 'COLUMN1'.
W_FCAT-OUTPUTLEN = '20'.
APPEND W_FCAT TO G_FCAT.

<b>W_FCAT-FIELDNAME = 'ZCOL2'.

W_FCAT-TABNAME = 'ZINFO6'.</b>

W_FCAT-COLTEXT = 'COLUMN2'.
W_FCAT-OUTPUTLEN = '20'.
APPEND W_FCAT TO G_FCAT.

Hope this helps.

Read only

Former Member
0 Likes
1,536

hi,

if u want to display the entire table you have to pass the structure as i said in the previous post.

<b>CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

CHANGING

IT_OUTTAB = ITAB

.</b>

in your case as i said you to populate fieldcatalog of the 2 fields which you are selecting and pass the <b>fieldacatalog</b> instead of <b>structure</b>.

*do award points for all helpful answers.

regards

Message was edited by:

sowjanya s

Read only

Former Member
0 Likes
1,535

hi,

i have taken MARA and MARD tables and displaying some fields from these 2 diff tables.

check below code

type-pools:slis.

DATA:BEGIN OF ITAB1 OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

END OF ITAB1.

DATA:BEGIN OF ITAB2 OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARD-WERKS,

END OF ITAB2.

TYPES:BEGIN OF TY_IT_FINAL,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

WERKS LIKE MARD-WERKS,

END OF TY_IT_FINAL.

DATA:IT_FINAL TYPE TABLE OF TY_IT_FINAL WITH HEADER LINE.

data:x_fcat type SLIS_FIELDCAT_ALV,

t_fcat type SLIS_T_FIELDCAT_ALV.

define build_fieldcat.

clear x_fcat.

x_fcat-fieldname = &1.

x_fcat-seltext_l = &2.

x_fcat-col_pos = &3.

x_fcat-outputlen = &4.

append x_fcat to t_fcat.

end-of-definition.

START-OF-SELECTION.

SELECT MATNR MTART FROM MARA

INTO TABLE ITAB1.

SELECT MATNR WERKS FROM MARD

INTO TABLE ITAB2

FOR ALL ENTRIES IN ITAB1

WHERE MATNR = ITAB1-MATNR.

LOOP AT ITAB1.

IT_FINAL-MATNR = ITAB1-MATNR.

IT_FINAL-MTART = ITAB1-MTART.

READ TABLE ITAB2 WITH KEY MATNR = ITAB1-MATNR.

IT_FINAL-WERKS = ITAB2-WERKS.

APPEND IT_FINAL.

ENDLOOP.

build_fieldcat:

'MATNR' 'Material No.' '1' '20',

'MTART' 'Material type' '2' '20',

'WERKS' 'Plant' '3' '10'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = t_fcat

TABLES

T_OUTTAB = it_final.

i have done it using ALV concept not oops concept.

Regards

Read only

Former Member
0 Likes
1,535

hi raj,

i have done the program using reuse_alv_grid_display (simple ALV concept) not using class cl_gui_alv_grid methods,

can't you do it in that way, is it mandatory to go for classes.

Regards

Read only

Former Member
0 Likes
1,535

hi,

u must also give Container i.e.. custom control area name declared in screen..

g_countainer = ' ' . '' container name

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER.

add this to u code.

regards,

Naresh.