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: 

BDC

Former Member
0 Kudos

can anyone plz tell me,how to do bdc using custom container with example.

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

Hi Ajaya,

We cannot do a BDC for a Customer Container.

Regards,

Ravi kanth Talagana

former_member202957
Contributor
0 Kudos

Hi Ajaya,

We can use ALV using Custom container.

Regards,

sunil kairam.

Former Member
0 Kudos

Hi Ajaya,

Check the below code on how to create ALV with custom container:

You can create editable ALV using CL_GUI_CUSTOM_CONTAINER.

you need to create a screen and drag a custom control in it and name it as you want (like in my case its is "cc_alv" ).

Include file is just only PBO event in which i call "display_alv".

Code:

INCLUDE zsb_edit_alv_oops_display_po01.

*-- Global data definitions for ALV

*--- ALV Grid instance reference

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

*--- Name of the custom control added on the screen

DATA gc_custom_control_name TYPE scrfname VALUE 'cc_alv'.

*--- Custom container instance reference

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .

*--- Field catalog table

DATA gt_fieldcat TYPE lvc_t_fcat .

*--- Layout structure

DATA gs_layout TYPE lvc_s_layo .

*--- Internal table holding list data

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE sflight .

*--In further sections, some additional fields will added here

*--for some functionality

DATA END OF gt_list .

START-OF-SELECTION.

CALL SCREEN 400.

&----


*& Form display_alv

&----


  • Display ALV Grid in container

----


FORM display_alv .

IF gr_alvgrid IS INITIAL .

*----Creating custom container instance

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

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.

*--Exception handling

ENDIF.

*----Creating ALV Grid instance

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

*----Preparing field catalog.

PERFORM prepare_field_catalog CHANGING gt_fieldcat .

*----Preparing layout structure

PERFORM prepare_layout CHANGING gs_layout .

*----Here will be additional preparations

*--e.g. initial sorting criteria, initial filtering criteria, excluding

*--functions

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

CHANGING

it_outtab = gt_list[]

it_fieldcatalog = gt_fieldcat

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ELSE .

CALL METHOD gr_alvgrid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

EXCEPTIONS

finished = 1

OTHERS = 2 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ENDIF .

ENDFORM . "exclude_tb_functions

&----


*& Form prepare_layout

&----


  • text

----


  • -->PS_LAYOUT text

----


FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.

ps_layout-zebra = 'X' .

ps_layout-grid_title = 'Flights' .

ps_layout-smalltitle = 'X' .

ENDFORM. " prepare_layout

&----


*& Form exclude_tb_functions

&----


  • text

----


  • -->PT_EXCLUDE text

----


FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions .

DATA ls_exclude TYPE ui_func.

ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_sum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_average .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_sum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_subtot .

ENDFORM . "exclude_tb_functions

*code part 9 – filling the table to exclude unwanted s

&----


*& Form prepare_field_catalog

&----


  • text

----


  • <--P_GT_FIELDCAT text

----


form prepare_field_catalog changing pt_fieldcat TYPE lvc_t_fcat.

DATA ls_fcat TYPE lvc_s_fcat .

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = pt_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

  • LOOP AT pt_fieldcat INTO ls_fcat .

  • CASE pt_fieldcat-fieldname .

  • WHEN 'CARRID' .

  • ls_fcat-outpulen = '10' .

  • ls_fcat-coltext = 'Airline Carrier ID' .

  • MODIFY pt_fieldcat FROM ls_fcat .

  • WHEN 'PAYMENTSUM' .

  • ls_fcat-no_out = 'X' .

  • MODIFY pt_fieldcat FROM ls_fcat .

  • ENDCASE .

  • ENDLOOP .

endform. " prepare_field_catalog

<b>Kindly Reward points if you found this reply helpful</b>,

Cheers,

Chaitanya.