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

Former Member
0 Kudos

Hi,

I created a ALV report with split containers. with 2 rows.I want to have 2 columns in the second row.

Pls can anyone help me with example?

Thanks

RAm

7 REPLIES 7

christian_wohlfahrt
Active Contributor
0 Kudos

Hi!

I'm not sure, which picture you want to get in the end, but the package SLIS contains a lot of SAP-examples for ALV programs, you will find some usefull tips in the programs of this group.

Regards,

Christian

Former Member
0 Kudos

hi,

create field catalog for that two cloumns. and pass that information to function fundule.

Former Member
0 Kudos

Hi,

Again you need to split the second row into two columns by calling split method. Check the below pseudo code

*-- Dynamic logic for container texts dependent on selection screen--*

clear: w_columns,

w_width_hdtx,

w_width_hdnt,

w_width_itmt.

w_sash = 75.

if chk_hdtx = c_check and chk_hdnt = c_check and chk_itmt = c_check.

w_width_hdtx = w_width_hdnt = w_width_itmt = 25.

w_columns = 3.

elseif chk_hdtx = c_check and chk_hdnt = c_check.

w_width_hdtx = w_width_hdnt = 50.

w_columns = 2.

elseif chk_hdtx = c_check and chk_itmt = c_check.

w_width_hdtx = w_width_itmt = 50.

w_columns = 2.

elseif chk_hdnt = c_check and chk_itmt = c_check.

w_width_hdnt = w_width_itmt = 50.

w_columns = 2.

elseif chk_hdtx = c_check.

w_width_hdtx = 100.

w_columns = 1.

elseif chk_hdnt = c_check.

w_width_hdnt = 100.

w_columns = 1.

elseif chk_itmt = c_check.

w_width_itmt = 100.

w_columns = 1.

else.

w_sash = 100.

endif.

-- Create the splitter control -


create object w_split_main

exporting

link_repid = sy-repid

parent = w_main_contnr

orientation = 0

sash_position = w_sash

with_border = 1

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

-- Get the containers of the splitter control -


-- Split main container to top left splitter -


create object w_split_top

exporting

parent = w_split_main->top_left_container

rows = 2

columns = 1

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

-- Set height for first row for top splitter -


call method w_split_top->set_row_height

exporting

id = 1

height = 0

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

-- Set container for selection screen for top splitter -


w_contnr_selscrn = w_split_top->get_container( row = 1 column = 1 ).

-- Set container for ALV Grid for top splitter -


w_contnr_grid = w_split_top->get_container( row = 2 column = 1 ).

if w_columns gt 0.

-- Split main container to bottom right splitter -


create object w_split_bottom

exporting

parent = w_split_main->bottom_right_container

rows = 1

columns = w_columns

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

clear: w_col_counter.

-- Set width for first row for bottom splitter -


if not w_width_hdtx is initial and w_col_counter lt w_columns.

w_col_counter = w_col_counter + 1.

call method w_split_bottom->set_column_width

exporting

id = w_col_counter

width = w_width_hdtx

exceptions

cntl_error = 1

cntl_system_error = 2

others = 3.

-- Set container for Header text for bottom splitter -


w_contnr_htext =

w_split_bottom->get_container( row = 1 column = w_col_counter ).

Regards,

Raghav

0 Kudos

Hi Ragavendra,

Thanks for reply

Can you pls Help me with the full sample code. Pls help. I'm new to ABAP OOP.

Thanks

Ram

0 Kudos

Hi Prabha,

for easy under stnading check this program


*&---------------------------------------------------------------------*
*& Report  RSDEMO_EASY_SPLITTER_CONTROL                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  rsdemo_easy_splitter_control         .

* splitter control
DATA splitter TYPE REF TO cl_gui_easy_splitter_container.
* container for the splitter control
DATA container TYPE REF TO cl_gui_custom_container.
* containers created by the splitter control
DATA container_1 TYPE REF TO cl_gui_container.
DATA container_2 TYPE REF TO cl_gui_container.
* picture controls
DATA picture_1 TYPE REF TO cl_gui_picture.
DATA picture_2 TYPE REF TO cl_gui_picture.
* load control framework definition
TYPE-POOLS cndp.

DATA  init.
DATA ok_code TYPE sy-ucomm.

CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS'.
  IF init is initial.
* create a container for the splitter control
    CREATE OBJECT container
                  EXPORTING container_name = 'CUSTOM'.
* create the splitter control
    CREATE OBJECT splitter
                  EXPORTING parent = container
                            orientation    = 1.
* get the containers of the splitter control
    container_1 = splitter->top_left_container.
    container_2 = splitter->bottom_right_container.
* create the picture controls inside the containers of the splitter
    CREATE OBJECT picture_1
                  EXPORTING parent  = container_1.

    CREATE OBJECT picture_2
                  EXPORTING parent  = container_2.
* Request an URL from the data provider by exporting the pic_data.
    DATA url(255).
    CLEAR url.
    PERFORM load_pic_from_db CHANGING url.

* load picture
    CALL METHOD picture_1->load_picture_from_url
        EXPORTING url = url.

    CALL METHOD picture_2->load_picture_from_url
        EXPORTING url = url.

    init = 'X'.

    CALL METHOD cl_gui_cfw=>flush
         EXCEPTIONS cntl_system_error = 1
                    cntl_error = 2.
    IF sy-subrc <> 0.
* error handling
    ENDIF.
  ENDIF.
ENDMODULE.                             " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE exit INPUT.
  CALL METHOD container->free.
  LEAVE PROGRAM.
ENDMODULE.                             " EXIT  INPUT

*&---------------------------------------------------------------------*
*&      Form  LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM load_pic_from_db CHANGING url.
  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.

Former Member
0 Kudos

Hi Prabha,

Split the Bottom Containter again Vertically....

Hope this helps.

Manish

Former Member
0 Kudos

Hi Ragvendra,

Thanks for the reply.

Inm my example, I have created 3 rows. In the third row. i want to split to 3 columns. So in this case how to code. Pls help me. I'm struggling .My part of the code is here:

FORM CREATE_AND_INIT_ALV .

DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.

DATA: G_GRID1 TYPE REF TO CL_GUI_ALV_GRID.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER.

  • Create TOP-Document

CREATE OBJECT O_DYNDOC_ID

EXPORTING STYLE = 'ALV_GRID'.

  • Create Splitter for custom_container

CREATE OBJECT O_SPLITTER

EXPORTING PARENT = G_CUSTOM_CONTAINER

ROWS = 3

COLUMNS = 1.

CALL METHOD O_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 1

COLUMN = 1

RECEIVING

CONTAINER = O_PARENT_TOP.

  • Set height for g_parent_html

CALL METHOD O_SPLITTER->SET_ROW_HEIGHT

EXPORTING

ID = 1

HEIGHT = 20.

CALL METHOD O_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 2

COLUMN = 1

RECEIVING

CONTAINER = O_PARENT_GRID.

  • Set height for g_parent_html

CALL METHOD O_SPLITTER->SET_ROW_HEIGHT

EXPORTING

ID = 1

HEIGHT = 25.

CREATE OBJECT G_GRID

EXPORTING I_PARENT = O_PARENT_GRID.

CREATE OBJECT G_HANDLER.

SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.

*Calling the Method for ALV output

CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

CHANGING

IT_OUTTAB = IT_FLIGHT[].

CALL METHOD O_SPLITTER->GET_CONTAINER

EXPORTING

ROW = 3

COLUMN = 1

RECEIVING

CONTAINER = O_PARENT_GRID1.

CREATE OBJECT G_GRID1

EXPORTING I_PARENT = O_PARENT_GRID1.

*Calling the Method for ALV output

CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'SFLIGHT'

CHANGING

IT_OUTTAB = IT_FLIGHT1[].

CALL METHOD O_DYNDOC_ID->INITIALIZE_DOCUMENT

EXPORTING

BACKGROUND_COLOR = CL_DD_AREA=>COL_TEXTAREA.

  • Processing events

CALL METHOD G_GRID->LIST_PROCESSING_EVENTS

EXPORTING

I_EVENT_NAME = 'TOP_OF_PAGE'

I_DYNDOC_ID = O_DYNDOC_ID.

ENDFORM. "CREATE_AND_INIT_ALV