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: 

Error: Displaying 3 ALV blocks for 1 itab but with diff. values

aris_hidalgo
Contributor
0 Kudos

Lets say I have 1 internal table named GT_COMPANY that I need to display 3 times but for every ALV block

it shows different values. For example, the 1st ALV block shows data under company code 1000,

the 2nd shows data under company code 2000 and so on...

I tried this using by using the FMs REUSE_ALV_BLOCK_LIST_INIT, REUSE_ALV_BLOCK_LIST_APPEND and

REUSE_ALV_BLOCK_LIST_DISPLAY. But the problem is, instead of displaying 3 ALV blocks displaying

the diffrent company codes, it only showed the last company code. It seems that it overwrites the

previous data.

So what I did was to call the FM REUSE_ALV_BLOCK_LIST_APPEND 3 times but I filtered the data first so

it will show values under a specific criteria(company code).

Hope you can help me guys. Thank you and take care!

1 ACCEPTED SOLUTION

former_member387317
Active Contributor
0 Kudos

Hi Viraylab,

it might be because u r using same internal table..

Try to declare three internal tables and populate it...

itab1[] = itab[].
itab2[] = itab[].
itab3[] = itab[].

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

7 REPLIES 7

Former Member
0 Kudos

Hi,

just have a look at this code...

tables: vbrk.

data: begin of it_vbrk1 occurs 0,

vbeln like vbrk-vbeln,

end of it_vbrk1.

data: begin of it_vbrk2 occurs 0,

vbeln like vbrk-vbeln,

vtweg like vbrk-vtweg,

end of it_vbrk2.

select-options : doc for vbrk-vbeln.

type-pools: slis.

data: fc type slis_t_fieldcat_alv.

data: fc1 type slis_t_fieldcat_alv.

data: wa1 like line of fc.

data: wa2 like line of fc1.

data: it_layout type slis_layout_alv.

data: it_event type slis_t_event.

data: wa_event type slis_alv_event.

select * up to 19 rows from vbrk

into corresponding fields of table it_vbrk1

where vbeln in doc.

select * up to 19 rows from vbrk

into corresponding fields of table it_vbrk2

where vbeln in doc.

wa1-fieldname = 'VBELN'.

wa1-seltext_l = 'DOCUMENT NUMBER'.

append wa1 to fc.

wa_event-name = 'TOP_OF_PAGE'.

wa_event-form = 'TOP_OF_PAGE1'.

append wa_event to it_event.

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = sy-repid.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = it_layout

it_fieldcat = fc

i_tabname = 'IT_VBRK1'

it_events = it_event

tables

t_outtab = it_vbrk1.

refresh it_event.

wa2-fieldname = 'VBELN'.

wa2-seltext_l = 'DOCUMENT NUMBER'.

append wa1 to fc1.

wa2-fieldname = 'VTWEG'.

wa2-seltext_l = 'NET WEIGHT'.

append wa2 to fc1.

wa_event-name = 'TOP_OF_PAGE'.

wa_event-form = 'TOP_OF_PAGE2'.

append wa_event to it_event.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = it_layout

it_fieldcat = fc1

i_tabname = 'IT_VBRK2'

it_events = it_event

tables

t_outtab = it_vbrk2.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

form top_of_page1.

format color col_positive.

write: / 'FIRST BLOCK'.

endform.

form top_of_page2.

format color col_total.

write: / 'SECOND BLOCK'.

endform.

Regards,

Sathish Reddy.

0 Kudos

Hi,

You are using 2 different internal tables and not 1. In my question I only have 1 internal table.

former_member387317
Active Contributor
0 Kudos

Hi Viraylab,

it might be because u r using same internal table..

Try to declare three internal tables and populate it...

itab1[] = itab[].
itab2[] = itab[].
itab3[] = itab[].

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

0 Kudos

That is exactly my dillema. I only have 1 internal table that needs to show different values so that is why I am using ALV block to seperate the displays.

For example, in my itab named GT_COMPANY, I have 3 company codes and its corresponding data.So I need to display now 3 ALV blocks showing the 3 different company code per block. So 1 company code, 1 ALV block.

0 Kudos

>

> That is exactly my dillema. I only have 1 internal table that needs to show different values so that is why I am using ALV block to seperate the displays.

>

> For example, in my itab named GT_COMPANY, I have 3 company codes and its corresponding data.So I need to display now 3 ALV blocks showing the 3 different company code per block. So 1 company code, 1 ALV block.

For this ...

U must declare three different Internal tables and populate it based on Company Code let's say 1001 1002 1003...

Either u can write three different Select Queries with where conditon like

eg.

BUKRS = 1001 for itab1

BUKRS = 1002 for itab2

BUKRS = 1003 for itab3

Use LOOP... ENDLOOP and populate it by using append and where condition with LOOP or IF conditon inside loop..

then use

FMs

REUSE_ALV_BLOCK_LIST_INIT,

REUSE_ALV_BLOCK_LIST_APPEND for itab1

REUSE_ALV_BLOCK_LIST_APPEND for itab2

REUSE_ALV_BLOCK_LIST_APPEND for itab3

REUSE_ALV_BLOCK_LIST_DISPLAY

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

0 Kudos

You Really need to Debug the Transaction code

FBL5N

For your Requirement.

Former Member
0 Kudos

Better use alv with OOP concept

that will solve you problem