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

problem with splitter!!!

Former Member
0 Likes
665

Hi,

i have written a program to display 2 grids on a screen using splitter. the code is shown below. it has no errors but does not show anything but 2 boxes. in one box i am displaying the contents of table 'kna1' and in the other i am not displaying anything. can someone tell me please what is wrong with the code and y it is not working ????

thanks in advance,

pushpa

tables kna1.

data: BEGIN OF itkna1 OCCURS 0,

ktokd like kna1-ktokd,

kunnr like kna1-kunnr,

name1 like kna1-name1,

name2 like kna1-name2,

ktokd_hdl type int4,

END OF itkna1.

data splitter type ref to cl_gui_splitter_container.

data container type ref to cl_gui_custom_container.

data container_1 type ref to cl_gui_container.

data container_2 type ref to cl_gui_container.

data grid_1 type ref to cl_gui_alv_grid.

data grid_2 type ref to cl_gui_alv_grid.

data i_layout type lvc_s_layo.

data i_fcat type lvc_t_fcat.

data init.

data ok_code type sy-ucomm.

SELECT ktokd kunnr name1 name2 from kna1 into CORRESPONDING FIELDS OF TABLE itkna1

where ktokd = 'ZCRM'.

call screen 100.

module status_0100 output.

set pf-STATUS 'STATUS'.

if init is INITIAL.

create OBJECT container

EXPORTING container_name = 'CUSTOM'.

create OBJECT splitter

EXPORTING parent = container

rows = 1

columns = 2.

call METHOD splitter->get_container

EXPORTING row = 1

column = 1

RECEIVING container = container_1.

call METHOD splitter->get_container

EXPORTING row = 1

column = 2

RECEIVING container = container_2.

create OBJECT grid_1 EXPORTING i_parent = container_1.

CREATE OBJECT grid_2 EXPORTING i_parent = container_2.

call METHOD grid_1->set_table_for_first_display

EXPORTING

is_layout = i_layout

CHANGING

it_outtab = itkna1[]

it_fieldcatalog = i_fcat

EXCEPTIONS

invalid_parameter_combination = 1

others = 2.

endif.

ENDMODULE.

module exit INPUT.

call METHOD container->free.

leave PROGRAM.

ENDMODULE.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
607

So if you modify your program like so, it will work.



report zrich_0001.


tables kna1.
data: begin of itkna1 occurs 0,
ktokd like kna1-ktokd,
kunnr like kna1-kunnr,
name1 like kna1-name1,
name2 like kna1-name2,
ktokd_hdl type int4,
end of itkna1.


data splitter type ref to cl_gui_splitter_container.
data container type ref to cl_gui_custom_container.
data container_1 type ref to cl_gui_container.
data container_2 type ref to cl_gui_container.
data grid_1 type ref to cl_gui_alv_grid.
data grid_2 type ref to cl_gui_alv_grid.
data i_layout type lvc_s_layo.
data i_fcat type lvc_t_fcat.

data init.
data ok_code type sy-ucomm.

select ktokd kunnr name1 name2 from kna1 into corresponding fields of
table itkna1
*where ktokd = 'ZCRM'.
  up to 100 rows.

call screen 100.

*---------------------------------------------------------------------*
*       MODULE status_0100 OUTPUT                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'STATUS'.
  if init is initial.
    create object container
    exporting container_name = 'CUSTOM'.
    create object splitter
    exporting parent = container
    rows = 1
    columns = 2.
    call method splitter->get_container
    exporting row = 1
    column = 1
    receiving container = container_1.
    call method splitter->get_container
    exporting row = 1
    column = 2
    receiving container = container_2.
    create object grid_1 exporting i_parent = container_1.
    create object grid_2 exporting i_parent = container_2.

    perform get_fieldcatalog..

    call method grid_1->set_table_for_first_display
    exporting
    is_layout = i_layout
    changing
    it_outtab = itkna1[]
    it_fieldcatalog = i_fcat
    exceptions
    invalid_parameter_combination = 1
    others = 2.


  endif.
endmodule.
*---------------------------------------------------------------------*
*       MODULE exit INPUT                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
module exit input.
  call method container->free.
  leave program.
endmodule.

************************************************************************
*      Form  Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.

  data: ls_fcat type lvc_s_fcat.
  refresh: i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Account Group'.
  ls_fcat-fieldname  = 'KTOKD'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '4'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer'.
  ls_fcat-fieldname  = 'KUNNR'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '10'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Name'.
  ls_fcat-fieldname  = 'NAME1'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '20'.
  append ls_fcat to i_fcat.


  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Name'.
  ls_fcat-fieldname  = 'NAME2'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '20'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Account Group'.
  ls_fcat-fieldname  = 'KTOKD_HDL'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '4'.
  append ls_fcat to i_fcat.

endform.

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
607

The problem is that you are not filling your field catalog, i_fcat

Regards,

Rich Heilman

Read only

Former Member
0 Likes
607

Here is an example of a container using a splitter. I hope this helps:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2ec457c4-0a01-0010-2bbc-c6e03a4a...

- April King

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
608

So if you modify your program like so, it will work.



report zrich_0001.


tables kna1.
data: begin of itkna1 occurs 0,
ktokd like kna1-ktokd,
kunnr like kna1-kunnr,
name1 like kna1-name1,
name2 like kna1-name2,
ktokd_hdl type int4,
end of itkna1.


data splitter type ref to cl_gui_splitter_container.
data container type ref to cl_gui_custom_container.
data container_1 type ref to cl_gui_container.
data container_2 type ref to cl_gui_container.
data grid_1 type ref to cl_gui_alv_grid.
data grid_2 type ref to cl_gui_alv_grid.
data i_layout type lvc_s_layo.
data i_fcat type lvc_t_fcat.

data init.
data ok_code type sy-ucomm.

select ktokd kunnr name1 name2 from kna1 into corresponding fields of
table itkna1
*where ktokd = 'ZCRM'.
  up to 100 rows.

call screen 100.

*---------------------------------------------------------------------*
*       MODULE status_0100 OUTPUT                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'STATUS'.
  if init is initial.
    create object container
    exporting container_name = 'CUSTOM'.
    create object splitter
    exporting parent = container
    rows = 1
    columns = 2.
    call method splitter->get_container
    exporting row = 1
    column = 1
    receiving container = container_1.
    call method splitter->get_container
    exporting row = 1
    column = 2
    receiving container = container_2.
    create object grid_1 exporting i_parent = container_1.
    create object grid_2 exporting i_parent = container_2.

    perform get_fieldcatalog..

    call method grid_1->set_table_for_first_display
    exporting
    is_layout = i_layout
    changing
    it_outtab = itkna1[]
    it_fieldcatalog = i_fcat
    exceptions
    invalid_parameter_combination = 1
    others = 2.


  endif.
endmodule.
*---------------------------------------------------------------------*
*       MODULE exit INPUT                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
module exit input.
  call method container->free.
  leave program.
endmodule.

************************************************************************
*      Form  Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.

  data: ls_fcat type lvc_s_fcat.
  refresh: i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Account Group'.
  ls_fcat-fieldname  = 'KTOKD'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '4'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer'.
  ls_fcat-fieldname  = 'KUNNR'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '10'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Name'.
  ls_fcat-fieldname  = 'NAME1'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '20'.
  append ls_fcat to i_fcat.


  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Name'.
  ls_fcat-fieldname  = 'NAME2'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '20'.
  append ls_fcat to i_fcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Customer Account Group'.
  ls_fcat-fieldname  = 'KTOKD_HDL'.
  ls_fcat-ref_table  = 'ITKNA1'.
  ls_fcat-outputlen  = '4'.
  append ls_fcat to i_fcat.

endform.

Regards,

Rich Heilman

Read only

0 Likes
607

thank u Rich and April, the program is working correctly now...:)))