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: 

ALV Block list Display

Former Member
0 Kudos

Hello,

I have a problem in display of a report.

The data in the internal table stored according to the material num. The requirement is such that the material numbers have to be the column heading and the second heading should be new/old. And the list should contain the count of old and new qty of the material.

For eg -

123.123.123

new/old

10 / 20

I have to use block list as there are many lists to be displayed in the same format according to the users' choice. How will i achive it ?

Thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi usha,

1. This simple program will give u an idea

of block alv.

2. It will print two alv

a) itab = table from t001

b) ptab = table from t000

3. Just copy paste in new program.

REPORT zam_temp54 .

type-pools : slis.

data : alvfc type slis_t_fieldcat_alv.

data : alvly type slis_layout_alv.

data : alvev type slis_t_event .

*----


DATA : BEGIN OF itab OCCURS 0.

include structure t001.

DATA: END OF itab.

DATA : BEGIN OF ptab OCCURS 0.

INCLUDE STRUCTURE t000.

DATA: END OF ptab..

*----


PARAMETERS : a TYPE c.

*----


start-of-selection.

*----


SELECT DATA

SELECT * FROM t001 into table itab.

select * from t000 into table ptab.

*----


INIT BLOCK ALV

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = sy-repid.

*----


ADD INTERNAL TABLE ITAB

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

I_INCLNAME = SY-REPID

CHANGING

CT_FIELDCAT = ALVFC.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = alvly

it_fieldcat = alvfc

i_tabname = 'ITAB'

it_events = alvev

TABLES

t_outtab = ITAB

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*----


ADD INTERNAL TABLE PTAB

REFRESH ALVFC[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'PTAB'

I_INCLNAME = SY-REPID

CHANGING

CT_FIELDCAT = ALVFC.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = alvly

it_fieldcat = alvfc

i_tabname = 'PTAB'

it_events = alvev

TABLES

t_outtab = PTAB

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*----


DISPLAY

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

program_error = 1

OTHERS = 2.

regards,

amit m.

9 REPLIES 9

Former Member
0 Kudos

Hi usha,

1. This simple program will give u an idea

of block alv.

2. It will print two alv

a) itab = table from t001

b) ptab = table from t000

3. Just copy paste in new program.

REPORT zam_temp54 .

type-pools : slis.

data : alvfc type slis_t_fieldcat_alv.

data : alvly type slis_layout_alv.

data : alvev type slis_t_event .

*----


DATA : BEGIN OF itab OCCURS 0.

include structure t001.

DATA: END OF itab.

DATA : BEGIN OF ptab OCCURS 0.

INCLUDE STRUCTURE t000.

DATA: END OF ptab..

*----


PARAMETERS : a TYPE c.

*----


start-of-selection.

*----


SELECT DATA

SELECT * FROM t001 into table itab.

select * from t000 into table ptab.

*----


INIT BLOCK ALV

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = sy-repid.

*----


ADD INTERNAL TABLE ITAB

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

I_INCLNAME = SY-REPID

CHANGING

CT_FIELDCAT = ALVFC.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = alvly

it_fieldcat = alvfc

i_tabname = 'ITAB'

it_events = alvev

TABLES

t_outtab = ITAB

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*----


ADD INTERNAL TABLE PTAB

REFRESH ALVFC[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'PTAB'

I_INCLNAME = SY-REPID

CHANGING

CT_FIELDCAT = ALVFC.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = alvly

it_fieldcat = alvfc

i_tabname = 'PTAB'

it_events = alvev

TABLES

t_outtab = PTAB

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*----


DISPLAY

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

program_error = 1

OTHERS = 2.

regards,

amit m.

0 Kudos

Thanks Amit. But my issue is not with block display. I have to display the records in the internal table in the format as shown. i.e the material number will be the column heading and the other records of the material has to be displayed below the material number. I hope I am clear.

Please let me know if you have any idea about it.

0 Kudos

Usha,

Do you know how many materials you are going to have? If yes, you can create a structure with so many fields and specify the heading of the column in the field catalog. This heading with come from the internal table and at the same you can also count.

If you don't know the number of materials then its a little tricky. Assume you have materials in ITAB. Now you will have to build the catalog using that.

LOOP AT ITAB.

FIELDCAT-FIELDNAME = ITAB-MATNR.

FIELDCAT-SELTEXT = ITAB-MATNR.

...

ENDLOOP.

Now create a dynamic internal table using this field catalog.

CL_ALV_TABLE_CREATE->CREATE_DYNAMIC_TABLE

Now populate this table with whatever data you want to display.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

Hi Usha,

This is related to Hierarchical Display means header record and Corresponding Item records .

<b>1</b>. Here u have to create 2 tables one for Header

records and another for Item records with

common keys.

<b>2</b>. Function module used here is

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

i_callback_program = program

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

is_layout = w_layout3

it_fieldcat = i_field3

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = i_sort3

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

i_save = 'A'

is_variant = variant3

it_events = i_events3

  • IT_EVENT_EXIT =

<b> i_tabname_header = 'H_MARD'

i_tabname_item = 'I_MARD'</b>

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

<b> is_keyinfo = w_keyinfo3</b>

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

<b> t_outtab_header = h_mard

t_outtab_item = i_mard</b> EXCEPTIONS

program_error = 1

OTHERS = 2

<b>3</b>.Key information between those two tables should

be passed throw <b>w_keyinfo3</b>.I mentioned in the above FM.

Please let me know if u need more information or example program reg this .

I think it helps u.

<b>Thanks,

Venkat.O</b>

0 Kudos

Hi,

You need to Go for Hierarchial list Not Blocklist.

Check the Sample Demo Program on Hierarchial list <b>BALVHD01</b>

Material No..

under the material display material related stuff.

in the above case only possible solution is Hierarchial list.

Regards

vijay

0 Kudos

Hello Ravi,

Thank you. This might help me. I would like to know how to populate the dynamicaly generated internal table.

Also, I cannot use the fieldcatlog in the FM REUSE_ALV_BLOCK_LIST_APPEND as they will be of different types.

Thank you,

Usha

0 Kudos

Usha,

Populating the data will be the tricky part as you don't the field names. See these blogs, it might help you

/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

You will have to use the ASSIGN COMPONENT statement to update each column of the work area and then finally append the row to the table.

You can use a different field catalog each time you call the BLOCK_LIST_APPEND function. That is the whold purpose, to show data of different structures.

Regards,

Ravi

0 Kudos

Thank you Ravi. The blogs were helpful too. My problem is solved.

Cheers

Usha

aris_hidalgo
Contributor
0 Kudos

Hi!

As per my understanding, What you could do is to concatenate the new and old into one field so it can be displayed as 10/20. And if you want to multiple windows to be displayed in your report you could use ALV block list. Here is an example:

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = g_repid

i_callback_user_command = 'USER_COMMAND'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

it_fieldcat = gt_fieldcat[]

is_layout = gs_layout

i_tabname = 'IT_DELIVERY'

it_events = gt_events[]

i_text = '1ST'

TABLES

t_outtab = it_delivery.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

it_fieldcat = gt_fieldsum[]

is_layout = gs_layout

i_tabname = 'IT_SUM'

it_events = gt_events_sum[]

it_sort = gt_sort

i_text = '2ND'

TABLES

t_outtab = it_sum.

gt_print-reserve_lines = 2.

gt_print-no_coverpage = 'X'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXPORTING

is_print = gt_print.