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 reports

Former Member
0 Kudos

hi,

how can print 4 block of output in single screen , if its possable please send the code.....

8 REPLIES 8

Former Member
0 Kudos

Hi

try this code and modify according to your requirment.

This will display a screen with 3 grids on it.You can add one more to it if you want.

REPORT  ZALV.

TABLES : scarr .
DATA : it_scarr TYPE TABLE OF scarr .

DATA : ob_custom TYPE REF TO cl_gui_custom_container ,
       ob_split1 TYPE REF TO cl_gui_easy_splitter_container ,
       ob_split2 TYPE REF TO cl_gui_easy_splitter_container ,
       ob_grid1  TYPE REF TO cl_gui_alv_grid ,
       ob_grid2  TYPE REF TO cl_gui_alv_grid ,
       ob_grid3  TYPE REF TO cl_gui_alv_grid .

SELECT-OPTIONS : s_carrid FOR scarr-carrid .

START-OF-SELECTION .

  SELECT *
    INTO TABLE it_scarr
    FROM scarr
   WHERE carrid IN s_carrid .

  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'ZTEST'.
  SET TITLEBAR 'ZTITLE01'.
* This will create a container
  CREATE OBJECT ob_custom
    EXPORTING
      container_name = 'CONTAINER'.

* This spit the container OB_CUSTOM into two
  CREATE OBJECT ob_split1
    EXPORTING
      parent      = ob_custom
      orientation = cl_gui_easy_splitter_container=>orientation_vertical.

  CREATE OBJECT ob_split2
    EXPORTING
      parent      = ob_split1->bottom_right_container
      orientation = cl_gui_easy_splitter_container=>orientation_horizontal.

  CREATE OBJECT ob_grid1
    EXPORTING
      i_parent = ob_split1->top_left_container.

  CREATE OBJECT ob_grid2
    EXPORTING
      i_parent = ob_split2->top_left_container.

  CREATE OBJECT ob_grid3
    EXPORTING
      i_parent = ob_split2->bottom_right_container.

  CALL METHOD ob_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SCARR'
    CHANGING
      it_outtab        = it_scarr.

  CALL METHOD ob_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SCARR'
    CHANGING
      it_outtab        = it_scarr.

  CALL METHOD ob_grid3->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SCARR'
    CHANGING
      it_outtab        = it_scarr.
ENDMODULE.                             " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  IF sy-ucomm = 'BACK' OR sy-ucomm = 'EXIT' .
    FREE : ob_grid1 ,
           ob_grid2 ,
           ob_grid3 ,
           ob_split1 ,
           ob_split2 ,
           ob_custom .
    LEAVE TO SCREEN 0 .
  ENDIF.

ENDMODULE.                             " USER_COMMAND_0100  INPUT

Hope this has helped you.

Regards

Hareesh Menon

0 Kudos

alv normal reports.........

0 Kudos

Hi Santhosh

alv normal reports.........?could you be pls more elaborate...

0 Kudos

HI,

See the BALVBT01 report.

HERE IT will use CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' .

which helps in getting the list one by one........ in the alv reports.

Regards,

Venkatesh

Former Member
0 Kudos

Hi Santosh,

here is a program to display 6 tables using blocks..

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/blockedalvwith6tables

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abap-ProgramforALVBlocklist


DATA : fcat TYPE slis_t_fieldcat_alv,          "FIELDCATALOG
DATA : layout1 TYPE slis_layout_alv,         "LAYOUT 1
layout2 TYPE slis_layout_alv,                     "LAYOUT 2
gt_event1 TYPE slis_t_event.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = SY-REPID.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT1
I_TABNAME = 'FS_TAB1'  " structure of itab1
IT_EVENTS = GT_EVENT1

TABLES
T_OUTTAB = itab1.
* call for all the no.of tables u want to display..
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT2
IT_FIELDCAT = FCAT2
I_TABNAME = 'FS_TAB2'  " structure of itab2
IT_EVENTS = GT_EVENT1

TABLES
T_OUTTAB = itab2.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.


Hope it helps..

Regards,

Mdi.Deeba

Former Member
0 Kudos

go through this program.

type-pools : slis.

&----


*& structure declaration

&----


types : begin of st_ekko,

ebeln type ekko-ebeln, "Purchasing Document Number

bstyp type ekko-bstyp, "Purchasing Document Category

bsart type ekko-bsart, "Purchasing Document Type

aedat type ekko-aedat, "record created on

ernam type ekko-ernam, "Person who Created the Object

end of st_ekko.

types : begin of st_ekpo,

ebeln type ekko-ebeln,

ebelp type ekpo-ebelp, "Item Number of Purchasing Document

ematn type ekpo-ematn, "Material number

matkl type ekpo-matkl, "Material group

netpr type ekpo-netpr, "Net price in purchasing document

end of st_ekpo.

&----


*& internal table and work area declaration

&----


data : it_ekpo type standard table of st_ekpo,

it_ekko type standard table of st_ekko,

it_fieldcat1 type slis_t_fieldcat_alv,

wa_fieldcat1 type slis_fieldcat_alv,

it_fieldcat2 type slis_t_fieldcat_alv,

wa_fieldcat2 type slis_fieldcat_alv,

it_events type slis_t_event,

wa_layout type slis_layout_alv.

&----


*& data declaration

&----


data : v_ebeln type ekko-ebeln.

&----


*& selection-screen

&----


selection-screen begin of block a with frame title text-000.

select-options : so_ebeln for v_ebeln.

selection-screen end of block a.

&----


*& At-selection-screen

&----


at selection-screen on so_ebeln.

perform validate_ebeln.

&----


*& start-of-selection

&----


start-of-selection.

perform data_retrieval.

&----


*& end-of-selection

&----


end-of-selection.

perform initialize_alv_block.

perform build_fieldcatalog1.

perform build_fieldcatalog2.

perform build_layout.

perform get_events .

perform append_ekkodata_to_alv_block.

perform append_ekpodata_to_alv_block.

perform display_blocked_alv.

&----


*& FORM initialize_alv_block

&----


form initialize_alv_block.

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = sy-repid.

endform.

&----


*& FORM validate_ebeln

&----


form validate_ebeln.

select ebeln

from ekko

into table it_ekko

where ebeln in so_ebeln.

if sy-subrc ne 0.

message text-003 type 'W'.

endif.

endform.

&----


*& FORM data_retrieval

&----


form data_retrieval.

select ebeln bstyp bsart aedat ernam

from ekko

into table it_ekko

where ebeln in so_ebeln.

if sy-subrc ne 0.

message text-001 type 'I'.

endif.

select ebeln ebelp ematn matkl netpr

from ekpo

into table it_ekpo

where ebeln in so_ebeln.

if sy-subrc ne 0.

message text-002 type 'I'.

endif.

endform.

&----


*& Form build_fieldcatalog1

&----


form build_fieldcatalog1.

wa_fieldcat1-fieldname = 'EBELN'.

wa_fieldcat1-seltext_l = 'PURCHASE ORDER'.

wa_fieldcat1-col_pos = 0.

wa_fieldcat1-do_sum = 'X'.

append wa_fieldcat1 to it_fieldcat1.

wa_fieldcat1-fieldname = 'BSTYP'.

wa_fieldcat1-seltext_l = 'DOCUMENT CATEGORY'.

wa_fieldcat1-col_pos = 1.

append wa_fieldcat1 to it_fieldcat1.

wa_fieldcat1-fieldname = 'BSART'.

wa_fieldcat1-seltext_l = 'DOCUMENT TYPE'.

wa_fieldcat1-col_pos = 2.

append wa_fieldcat1 to it_fieldcat1.

wa_fieldcat1-fieldname = 'AEDAT'.

wa_fieldcat1-seltext_l = 'DATE'.

wa_fieldcat1-col_pos = 3.

append wa_fieldcat1 to it_fieldcat1.

wa_fieldcat1-fieldname = 'ERNAM'.

wa_fieldcat1-seltext_l = 'NAME'.

wa_fieldcat1-col_pos = 4.

append wa_fieldcat1 to it_fieldcat1.

endform. "build_fieldcatalog

&----


*& Form build_fieldcatalog2

&----


form build_fieldcatalog2.

wa_fieldcat2-fieldname = 'EBELN'.

wa_fieldcat2-seltext_l = 'PURCHASE ORDER'.

wa_fieldcat2-col_pos = 0.

append wa_fieldcat2 to it_fieldcat2.

wa_fieldcat2-fieldname = 'EBELP'.

wa_fieldcat2-seltext_l = 'ITEM NUMBER'.

wa_fieldcat2-col_pos = 1.

append wa_fieldcat2 to it_fieldcat2.

wa_fieldcat2-fieldname = 'EMATN'.

wa_fieldcat2-seltext_l = 'MATERIAL TYPE'.

wa_fieldcat2-col_pos = 2.

append wa_fieldcat2 to it_fieldcat2.

wa_fieldcat2-fieldname = 'MATKL'.

wa_fieldcat2-seltext_l = 'MATERIAL GROUP'.

wa_fieldcat2-col_pos = 3.

append wa_fieldcat2 to it_fieldcat2.

wa_fieldcat2-fieldname = 'NETPR'.

wa_fieldcat2-seltext_l = 'NET PRICE'.

wa_fieldcat2-col_pos = 4.

wa_fieldcat2-do_sum = 'X'.

append wa_fieldcat2 to it_fieldcat2.

endform. "build_fieldcatalog

&----


*& form build_layout.

&----


form build_layout.

wa_layout-zebra ='X'.

wa_layout-no_vline = ' '.

wa_layout-no_hline = ' '.

wa_layout-colwidth_optimize = 'X'.

wa_layout-window_titlebar = 'PURCHASE ORDER HEADER AND ITEM DETAILS'.

endform. "build_layout

&----


*& form append_ekkodata_to_alv_block

&----


form append_ekkodata_to_alv_block.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = wa_layout

it_fieldcat = it_fieldcat1

i_tabname ='it_ekko'

it_events = it_events[]

  • IT_SORT = IT_SORT

  • I_TEXT = ' '

tables

t_outtab = it_ekko

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.

endform.

&----


*& form append_ekpodata_to_alv_block

&----


form append_ekpodata_to_alv_block.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = wa_layout

it_fieldcat = it_fieldcat2

i_tabname ='it_ekpo'

it_events = it_events[]

  • IT_SORT = IT_SORT

  • I_TEXT = ' '

tables

t_outtab = it_ekpo

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.

endform.

&----


*& FORM display_blocked_alv.

&----


form display_blocked_alv.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

endform.

&----


*& Form GET_EVENTS

&----


form get_events .

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 2

importing

et_events = it_events[]

exceptions

list_type_wrong = 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. " GET_EVENTS

in this program i have append two blocks of data..like this u can append the other two blocks to display the four blocks of data..

former_member203501
Active Contributor
0 Kudos

hi look at this code...i was worked on recently...


REPORT yztest .

TYPE-POOLS: slis.

* Tables
TABLES: mara.

TYPES: BEGIN OF ty_name,
       name  TYPE char10,
       age   TYPE i,
       END OF ty_name.

TYPES: BEGIN OF ty_marks,
       sub1   TYPE i,
       sub2   TYPE i,
       total  TYPE  i,
       END OF ty_marks.

TYPES: BEGIN OF ty_phone,
       phnum TYPE char10,
       END  OF ty_phone.

TYPES: BEGIN OF ty_addr,
       address TYPE char20,
       END  OF ty_addr .

* Output internal table
DATA: itab TYPE TABLE OF ty_name,
      wa   TYPE ty_name,
      itab1 TYPE TABLE OF ty_marks,
      wa1  TYPE ty_marks,
      itab2 TYPE TABLE OF ty_phone,
      wa2  TYPE ty_phone,
      itab3 TYPE TABLE OF ty_addr,
      wa3  TYPE ty_addr.

* ALV Grid
DATA: r_grid  TYPE REF TO cl_gui_alv_grid,
      r_grid1 TYPE REF TO cl_gui_alv_grid,
      r_grid2  TYPE REF TO cl_gui_alv_grid,
      r_grid3  TYPE REF TO cl_gui_alv_grid,
      g_dock TYPE REF TO cl_gui_docking_container,
      g_dock1 TYPE REF TO cl_gui_docking_container,
      g_dock2 TYPE REF TO cl_gui_docking_container,
      g_dock3 TYPE REF TO cl_gui_docking_container,
      g_dock4 TYPE REF TO cl_gui_docking_container,
      it_fieldcat  TYPE lvc_t_fcat,
      it_fieldcat1 TYPE lvc_t_fcat,
      it_fieldcat2 TYPE lvc_t_fcat,
      it_fieldcat3 TYPE lvc_t_fcat,
      wa_fieldcat TYPE lvc_s_fcat.

DATA picture TYPE REF TO cl_gui_picture.

DATA url(255).
CLEAR url.
DATA  init.

START-OF-SELECTION.

  wa-name = 'test01'.
  wa-age = '1'.
  APPEND wa TO itab.

  wa-name = 'test02'.
  wa-age = '2'.
  APPEND wa TO itab.

  wa-name = 'test03'.
  wa-age = '3'.
  APPEND wa TO itab.

  wa1-sub1 = '11'.
  wa1-sub2 = '22'.
  wa1-total = wa1-sub1 + wa1-sub2.
  APPEND wa1 TO itab1.

  wa1-sub1 = '22'.
  wa1-sub2 = '33'.
  wa1-total = wa1-sub1 + wa1-sub2.
  APPEND wa1 TO itab1.

  wa2-phnum = '99999999999'.
  APPEND wa2 TO itab2.

  wa2-phnum = '888888888888'.
  APPEND wa2 TO itab2.

  wa2-phnum = '777777777777'.
  APPEND wa2 TO itab2.

  wa3-address = 'HItech City'.
  APPEND wa3 TO itab3.

  wa3-address = 'Secunderabad'.
  APPEND wa3 TO itab3.

  wa3-address = 'Hyderabad'.
  APPEND wa3 TO itab3.

  PERFORM display_image.

  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  SET PF-STATUS 'LISTOUT1'.
  SET TITLEBAR 'LIST1'.

  wa_fieldcat-fieldname = 'NAME'.
  wa_fieldcat-seltext   = 'NAME OF THE STUDENT'.
  wa_fieldcat-coltext =   'NAME OF THE STUDENT'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'AGE'.
  wa_fieldcat-seltext   = 'AGE OF THE STUDENT'.
  wa_fieldcat-coltext =    'AGE OF THE STUDENT'.
  APPEND wa_fieldcat TO it_fieldcat.

  wa_fieldcat-fieldname = 'SUB1'.
  wa_fieldcat-seltext   = 'SUBJECT1'.
  wa_fieldcat-coltext =    'SUBJECT1'.
  APPEND wa_fieldcat TO it_fieldcat1.

  wa_fieldcat-fieldname = 'SUB2'.
  wa_fieldcat-seltext   = 'SUBJECT2'.
  wa_fieldcat-coltext =    'SUBJECT2'.
  APPEND wa_fieldcat TO it_fieldcat1.

  wa_fieldcat-fieldname = 'TOTAL'.
  wa_fieldcat-seltext   = 'TOTAL'.
  wa_fieldcat-coltext =    'TOTAL'.
  APPEND wa_fieldcat TO it_fieldcat1.

  wa_fieldcat-fieldname = 'PHNUM'.
  wa_fieldcat-seltext   = 'PHONE NO'.
  wa_fieldcat-coltext =    'PHONE NO'.
  APPEND wa_fieldcat TO it_fieldcat2.

  wa_fieldcat-fieldname = 'ADDRESS'.
  wa_fieldcat-seltext   = 'ADDRESS'.
  wa_fieldcat-coltext =    'ADDRESS'.
  APPEND wa_fieldcat TO it_fieldcat3.


  IF g_dock IS INITIAL.
    CREATE OBJECT g_dock
                  EXPORTING
                  repid     = sy-repid
                  dynnr     = sy-dynnr
                  side      = g_dock->dock_at_left
                  extension = 300.

    CREATE OBJECT r_grid
              EXPORTING
              i_parent = g_dock.

  ENDIF.

  IF g_dock1 IS INITIAL.
    CREATE OBJECT g_dock1
                  EXPORTING
                  repid     = sy-repid
                  dynnr     = sy-dynnr
                  side      = g_dock1->dock_at_right
                  extension = 300.

    CREATE OBJECT r_grid1
              EXPORTING
              i_parent = g_dock1.

  ENDIF.

  IF g_dock2 IS INITIAL.
    CREATE OBJECT g_dock2
                  EXPORTING
                  repid     = sy-repid
                  dynnr     = sy-dynnr
                  side      = g_dock2->dock_at_top
                  extension = 100.

    CREATE OBJECT r_grid2
              EXPORTING
              i_parent = g_dock2.

    IF g_dock3 IS INITIAL.
      CREATE OBJECT g_dock3
                    EXPORTING
                    repid     = sy-repid
                    dynnr     = sy-dynnr
                    side      = g_dock3->dock_at_top
                    extension = 100.

      CREATE OBJECT r_grid3
                EXPORTING
                i_parent = g_dock3.

    ENDIF.

    IF NOT itab[] IS INITIAL.
      CALL METHOD r_grid->set_table_for_first_display
        CHANGING
          it_outtab       = itab
          it_fieldcatalog = it_fieldcat.
    ENDIF.

    IF NOT itab1[] IS INITIAL.
      CALL METHOD r_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = itab1
          it_fieldcatalog = it_fieldcat1.
    ENDIF.

    IF NOT itab2[] IS INITIAL.
      CALL METHOD r_grid2->set_table_for_first_display
        CHANGING
          it_outtab       = itab2
          it_fieldcatalog = it_fieldcat2.
    ENDIF.

    IF NOT itab3[] IS INITIAL.
      CALL METHOD r_grid3->set_table_for_first_display
        CHANGING
          it_outtab       = itab3
          it_fieldcatalog = it_fieldcat3.
    ENDIF.

if   g_dock4 is initial.
    CREATE OBJECT g_dock4
                  EXPORTING
                  repid     = sy-repid
                  dynnr     = sy-dynnr
                  side      = g_dock4->dock_at_bottom
                  extension = 100.

    CREATE OBJECT picture
                      EXPORTING parent = g_dock4.

    CALL METHOD picture->load_picture_from_url
      EXPORTING
        url = url.
    init = 'X'.
 endif.

  ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*&      Form  display_image
*----------------------------------------------------------------------*
FORM display_image .

  DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
  DATA html_table LIKE w3html OCCURS 1.
  DATA return_code LIKE  w3param-ret_code.
  DATA content_type LIKE  w3param-cont_type.
  DATA content_length LIKE  w3param-cont_len.
  DATA pic_data LIKE w3mime OCCURS 0.
  DATA pic_size TYPE i.

  REFRESH query_table.
  query_table-name = '_OBJECT_ID'.
  query_table-value = 'ENJOYSAP_LOGO'.
  APPEND query_table.

  CALL FUNCTION 'WWW_GET_MIME_OBJECT'
    TABLES
      query_string        = query_table
      html                = html_table
      mime                = pic_data
    CHANGING
      return_code         = return_code
      content_type        = content_type
      content_length      = content_length
    EXCEPTIONS
      object_not_found    = 1
      parameter_not_found = 2
      OTHERS              = 3.
  IF sy-subrc = 0.
    pic_size = content_length.
  ENDIF.

  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      type     = 'image'
      subtype  = cndp_sap_tab_unknown
      size     = pic_size
      lifetime = cndp_lifetime_transaction
    TABLES
      data     = pic_data
    CHANGING
      url      = url
    EXCEPTIONS
      OTHERS   = 1.

ENDFORM.                    " display_image
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE exit INPUT.

  CALL METHOD g_dock->free.
  CALL METHOD g_dock1->free.
  CALL METHOD g_dock2->free.
  CALL METHOD g_dock3->free.

ENDMODULE.                 " EXIT  INPUT

Former Member
0 Kudos

Hi,

Check the below link.

http://www.sap-basis-abap.com/abap/sample-program-on-block-lists.htm

Hope this helps you.

Anki Reddy