Application Development and Automation 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: 
Read only

Need help in this code snippet for split container

Former Member
0 Likes
1,012

Hi,

I am using the following code to display two tables in report output.

using cl_salv_table.

=============================================================================================

START-OF-SELECTION.
DATA: lo_report TYPE REF TO lcl_test_class.
* create report object
CREATE OBJECT lo_report.
* call methods
lo_report->get_data( ).
lo_report->process_data( ).
lo_report->generate_output( ).

METHOD generate_output.

data: g_custom_container TYPE REF TO cl_gui_custom_container, "custom container
g_splitter_container TYPE REF TO cl_gui_splitter_container, "splitter container
g_top_container TYPE REF TO cl_gui_container, "top container
g_bottom_container TYPE REF TO cl_gui_container, "bottom one
g_display TYPE REF TO cl_salv_display_settings, " set display pattern
g_slav_table TYPE REF TO cl_salv_table,
g_table TYPE REF TO cl_salv_table.

"create custom container placed in CUSTOM AREA defined on screen
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'CUSTOM_AREA'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

"now split the container into two independent containers
CREATE OBJECT g_splitter_container
EXPORTING
parent = g_custom_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 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.

"get top container
CALL METHOD g_splitter_container->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = g_top_container.

TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = g_top_container
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = gt_itab_header. "gt_itab_header is populated with required output columns in process_data( ) method
CATCH cx_salv_msg.
ENDTRY.

g_display = g_table->get_display_settings( ).
g_display->set_striped_pattern( cl_salv_display_settings=>true ).

g_display->set_striped_pattern( cl_salv_display_settings=>true ).

*... Display table
g_table->display( ).

ENDMETHOD.

=============================================================================================

<Added code tags>

when I Execute the code, it still stay on selection screen does not display output table. If I comment out the lines

EXPORTING

r_container = g_top_container

from the Method "cl_salv_table=>factory" the output is displayed with table in required format.

Could someone help me out identifying what am I doing wrong.

Thanks,

Abhiram.

Edited by: Suhas Saha on Jan 31, 2012 9:14 PM

5 REPLIES 5
Read only

former_member591546
Participant
0 Likes
889

Try creating g_slav_table object:

CREATE OBJECT g_salv_table

EXPORTING

r_container = g_top_container.

And then methods SET_DATA and DIPLAY from this object.

Read only

0 Likes
889

Hi,

It does not allow to create instance for CL_SALV_TABLE with CREATE OBJECT. I got the below syntax error when I tried creating instance as mentioned by you. I have to use CL_SALV_TABLE=>FACTORY.

"You cannot create an instance of the class "CL_SALV_TABLE" outside the".

Thanks,

Abhiram.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
889

when I Execute the code, it still stay on selection screen does not display output table.

You need to call the screen in which you have defined the custom container 'CUSTOM_AREA'. And you need to call the method generate_output( ) in the PBO of the screen.

If I comment out the lines

EXPORTING

r_container = g_top_container

from the Method "cl_salv_table=>factory" the output is displayed with table in required format.

If you're removing the R_CONTAINER parameter, SALV framework displays the data in full-screen grid. Actually it uses REUSE_ALV_GRID_DISPLAY to display the data. Hence you are getting the data.

To be honest i'll be surprised if you are getting the splitter container, can you confirm if you are getting it?

BR,

Suhas

Read only

Former Member
0 Likes
889

Hi Suhas,

The output is displayed in full screen only I am not seeing any split container. Is there any other way I can achieve split container without PBO.

Thanks,

Abhiram.

Read only

0 Likes
889

Abhiram, insert follow code after "get top container":

"get bottom container
CALL METHOD g_splitter_container->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = g_bottom_container.

Like Suhas said, you need to create a screen with only object custom container named 'CUSTOM_AREA'. In START-OF-SELECTION from main program, do CALL SCREEN to mentioned screen. In PBO from this screen insert your code.