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: 

BLOCK LIST DISPLAY IN ALV

Former Member
0 Kudos

Moderator message: Please do not use ALL CAPITALS in your message subjects

I am facing a peculiar situation with respect to a report with 2 block lists.

STEP 1:

I first use REUSE_ALV_BLOCK_LIST_INIT with EXPORTING parameter as

i_callback_program = SY-REPID.

This works fine with return code of sy-subrc = 0.

STEP 2:

I build the field catalog and internal table - in debug I also check the sequence of fields of both the internal tables and field calatogs - perfect - no issues.

Then I call REUSE_ALV_BLOCK_LIST_APPEND with exporting parameters as layout, field catalog, table name & event and tables parameter as internal table and exception handling, I repeat this call for the two internal tables.

This works fine with return code of sy-subrc = 0

STEP 3:

I use REUSE_ALV_BLOCK_LIST_DISPLAY to display the two lists one after the other, and I have coded for error message if sy-subrc is non zero.

This works fine with return code of sy-subrc = 0

ISSUE :

Internal table 1 and internal table 2 both have say 4 records, then I see the two lists with heading(s) perfec and col width also optimized and zebra (alternate steipes also in place), and 4 rows for each internal table on output, however the rows are BLANK - NO DATA, whereas I have checked both internal tables before the call and they seem to have the data perfectly and in the same sequence as the field catalog - however the rows are BLANK.

I checked in debugging but was just not able to find out why if the internal tables and field catalog is perfect, no data is passed to output.

Please help !!

Edited by: M N on Nov 14, 2008 5:22 AM

Edited by: Matt on Nov 14, 2008 10:23 AM

5 REPLIES 5

Former Member
0 Kudos

Hi,

try like this..


*&---------------------------------------------------------------------*
*&      Form  SUB_DISPLAY_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sub_display_alv .

  CREATE DATA dref1 LIKE LINE OF tab_store.
  ASSIGN dref1->* TO <fs>.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-repid
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
            .

  LOOP AT <itab> INTO wa<itab>.
    temp = <itab>.
    MOVE-CORRESPONDING temp TO wa_<itab>2.
    APPEND wa_<itab>2 TO it_<itab>2.
    CLEAR:  wa_<itab>2,
            temp.
    <fs>-oa_no = wa_<itab>-oa_no.


    AT END OF oa_no.
      CREATE DATA dref TYPE STANDARD TABLE OF t_pend.
      ASSIGN dref->* TO <tab>.
      APPEND LINES OF it_<itab>2 TO <tab>.
      <fs>-tab = dref.
      <fs>-no = 1.
      APPEND <fs> TO tab_store.

      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = it_layout
          it_fieldcat                = it_fieldcat
          i_tabname                  = '<ITAB>2'
          it_events                  = it_evt_d
        TABLES
          t_outtab                   = <tab>
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
      IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

      REFRESH: it_<itab>2.
    ENDAT.
    CLEAR:wa_<itab>.
  ENDLOOP.


  IF tab_store[] IS INITIAL.
    MESSAGE i398(00) WITH'No Data Found With This Selection'.
    LEAVE LIST-PROCESSING.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
*   I_INTERFACE_CHECK             = ' '
*   IS_PRINT                      =
*   I_SCREEN_START_COLUMN         = 0
*   I_SCREEN_START_LINE           = 0
*   I_SCREEN_END_COLUMN           = 0
*   I_SCREEN_END_LINE             = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER       =
*   ES_EXIT_CAUSED_BY_USER        =
* EXCEPTIONS
*   PROGRAM_ERROR                 = 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.

ENDFORM.                    " SUB_DISPLAY_ALV

Arunima

p291102
Active Contributor
0 Kudos

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.

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,

Sankar M

Former Member
0 Kudos

Hi Mn,

Just check once again the itab's name and fieldcatalogs name.

You Did right coding.

Check with this example.

*Initialize Block

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = w_repid.

*Success List

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = wa_layout1

it_fieldcat = it_fldcat1

i_tabname = 'IT_SUCC'

it_events = it_events1[]

TABLES

t_outtab = it_succ

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*Failures List

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = wa_layout2

it_fieldcat = it_fldcat2

i_tabname = 'IT_FAIL'

it_events = it_events2[]

TABLES

t_outtab = it_fail

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

*Display Block

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

IF sy-subrc NE 0.

MESSAGE e906 WITH text-009.

ENDIF.

Thanks,

Krishna.

Former Member
0 Kudos

Hi,

If u r passing the same table in REUSE_ALV_BLOCK_LIST_APPEND then u shall get this type of error...

1. u must be passing the same table....

2. u must be refreshing this table after call of REUSE_ALV_BLOCK_LIST_APPEND

3. the again inserting data in that table.....

If that is the case then i have the solution....

regards

Sukriti....

Former Member
0 Kudos

&----


*& Report Y_ALV_BLOCKLIST_

*&

&----


*&

*&

&----


REPORT Y_ALV_BLOCKLIST_16131.

TYPE-POOLS : SLIS.

DATA: X_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • Events

DATA: GT_XEVENTS TYPE SLIS_T_EVENT.

DATA: GT_YEVENTS TYPE SLIS_T_EVENT.

data : XS_EVENT TYPE SLIS_ALV_EVENT.

DATA: XFIELD TYPE SLIS_T_FIELDCAT_ALV.

DATA: YFIELD TYPE SLIS_T_FIELDCAT_ALV.

DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.

DATA: GT_PRINT TYPE SLIS_PRINT_ALV.

*----


TYPES : BEGIN OF TY_MARA ,

MATNR TYPE MATNR,

MTART TYPE MTART,

END OF TY_MARA.

TYPES: BEGIN OF TY_MAKT ,

MATNR TYPE MATNR,

MAKTX TYPE MAKTX,

END OF TY_MAKT.

*----


DATA : ITAB TYPE TABLE OF TY_MARA,

PTAB TYPE TABLE OF TY_MAKT.

*----


START-OF-SELECTION.

*----


SELECT DATA

SELECT MATNR MAKTX FROM MAKT INTO TABLE PTAB UP TO 10 ROWS.

SELECT MATNR MTART FROM MARA INTO TABLE ITAB UP TO 10 ROWS.

*eVENT FOR Heading

PERFORM F_EVENTS.

  • FIELD CATALOG

PERFORM F_FIELDCAT.

*----


INIT BLOCK ALV

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID.

*----


ADD INTERNAL TABLE ITAB

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = X_LAYOUT

IT_FIELDCAT = XFIELD "ALVFC

I_TABNAME = 'ITAB'

IT_EVENTS = GT_XEVENTS

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_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = X_LAYOUT

IT_FIELDCAT = YFIELD "ALVFC

I_TABNAME = 'PTAB'

IT_EVENTS = GT_YEVENTS

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.

*GT_PRINT-RESERVE_LINES = 2.

  • CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • IS_PRINT = GT_PRINT.

&----


*& Form F_FIELDCAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_FIELDCAT .

DATA: L_COUNT TYPE I.

*

CLEAR AFIELD.

L_COUNT = L_COUNT + 1.

AFIELD-COL_POS = L_COUNT.

AFIELD-FIELDNAME = 'MATNR'.

AFIELD-REF_TABNAME = 'MARA'.

AFIELD-KEY = 'X'. "define field as key

  • AFIELD-DO_SUM = 'X'.

APPEND AFIELD TO XFIELD.

CLEAR AFIELD.

L_COUNT = L_COUNT + 1.

AFIELD-COL_POS = L_COUNT.

AFIELD-FIELDNAME = 'MTART'.

AFIELD-REF_TABNAME = 'MARA'.

AFIELD-KEY = 'X'. "define field as key

APPEND AFIELD TO XFIELD.

L_COUNT = 0.

CLEAR AFIELD.

L_COUNT = L_COUNT + 1.

AFIELD-COL_POS = L_COUNT.

AFIELD-FIELDNAME = 'MATNR'.

AFIELD-REF_TABNAME = 'MAKT'.

AFIELD-KEY = 'X'. "define field as key

APPEND AFIELD TO YFIELD.

CLEAR AFIELD.

L_COUNT = L_COUNT + 1.

AFIELD-COL_POS = L_COUNT.

AFIELD-FIELDNAME = 'MAKTX'.

AFIELD-REF_TABNAME = 'MAKT'.

AFIELD-KEY = 'X'. "define field as key

APPEND AFIELD TO YFIELD.

ENDFORM. " F_FIELDCAT

&----


*& Form F_EVENTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_EVENTS .

CLEAR XS_EVENT.

XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

XS_EVENT-FORM = 'TOP1'.

APPEND XS_EVENT TO GT_XEVENTS.

CLEAR XS_EVENT.

XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

XS_EVENT-FORM = 'TOP2'.

APPEND XS_EVENT TO GT_YEVENTS.

ENDFORM. " F_EVENTS

FORM TOP1.

WRITE : 'MARA TABLE'.

ENDFORM.

FORM TOP2.

WRITE : 'MAKT TABLE'.

ENDFORM.