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: 

Custom control

Former Member
0 Kudos

Hi All,

I have created a custom control in the screen.but is not showing up in the output.do i need to create a subscreen area for this?please advise.

Thanks,

Rakesh.

4 REPLIES 4

Former Member
0 Kudos

hi,

u need to assign this custom cotrol to grid or some thing?

have u done this?

what is ur exact need?

0 Kudos

my requirement is to simply display the custom control.

0 Kudos

hi,

its not posible i think u need to assign this control to some element and as per my knowledge it is used to display ALV in OOPS method...

0 Kudos

hi,

its my zreport in which i used Custom Control..

&----


*& Report ZALV_OOP

*&

&----


*&

*&

&----


REPORT zalv_oop.

----


  • CLASS lcl_event_handler DEFINITION

----


*

----


CLASS lcl_event_handler DEFINITION .

PUBLIC SECTION .

METHODS:

*--Double-click control

handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column es_row_no.

PRIVATE SECTION.

ENDCLASS. "lcl_event_handler DEFINITION

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


*

----


CLASS lcl_event_handler IMPLEMENTATION .

*--Handle Double Click

METHOD handle_double_click .

PERFORM handle_double_click USING e_row e_column es_row_no .

ENDMETHOD . "handle_double_click

ENDCLASS . "lcl_event_handler IMPLEMENTATION

TABLES : mseg.

DATA : BEGIN OF itab OCCURS 0,

mblnr LIKE mseg-mblnr,

matnr LIKE mseg-matnr,

menge LIKE mseg-menge,

END OF itab.

DATA : gr_alvgrid TYPE REF TO cl_gui_alv_grid,

gr_ccontainer TYPE REF TO cl_gui_custom_container,

gt_fcat TYPE lvc_t_fcat,

gs_layo TYPE lvc_s_layo.

DATA gr_event_handler TYPE REF TO lcl_event_handler .

DATA : ok_code LIKE sy-ucomm.

DATA : t_mat LIKE mara-matnr.

SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_mblnr FOR mseg-mblnr.

SELECTION-SCREEN : END OF BLOCK blk1.

START-OF-SELECTION.

SET SCREEN 100.

CREATE OBJECT gr_event_handler .

PERFORM get_data.

PERFORM dis_data.

&----


*& Form get_data

&----


  • text

----


FORM get_data.

SELECT mblnr matnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab

WHERE mblnr IN s_mblnr.

ENDFORM. "get_data

&----


*& Form dis_data

&----


  • text

----


FORM dis_data.

IF gr_alvgrid IS INITIAL.

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = 'CC_ALV'

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.

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.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

PERFORM create_fcat CHANGING gt_fcat.

PERFORM create_layout CHANGING gs_layo.

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE = 'A'

  • I_DEFAULT = 'X'

is_layout = gs_layo

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

it_outtab = itab[]

it_fieldcatalog = gt_fcat

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .

ENDIF.

ENDFORM. "dis_data

&----


*& Form create_fcat

&----


  • text

----


  • <--P_GT_FCAT text

----


FORM create_fcat CHANGING pt_fcat TYPE lvc_t_fcat.

DATA : ls_fcat TYPE lvc_s_fcat.

ls_fcat-fieldname = 'MBLNR'.

ls_fcat-coltext = 'Material Doc.'.

APPEND ls_fcat TO pt_fcat.

ls_fcat-fieldname = 'MATNR'.

ls_fcat-coltext = 'Material'.

APPEND ls_fcat TO pt_fcat.

ls_fcat-fieldname = 'MENGE'.

ls_fcat-coltext = 'Quantity'.

APPEND ls_fcat TO pt_fcat.

ENDFORM. " create_fcat

&----


*& Form create_layout

&----


  • text

----


  • <--P_GS_LAYO text

----


FORM create_layout CHANGING ps_layo TYPE lvc_s_layo.

ps_layo-zebra = 'X'.

ENDFORM. " create_layout

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'ZALV_OOP'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

ok_code = sy-ucomm.

CASE ok_code.

WHEN 'BACK' OR 'UP' OR 'CANC'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form handle_double_click

&----


  • text

----


  • -->I_ROW text

  • -->I_COLUMN text

  • -->IS_ROW_NO text

----


FORM handle_double_click USING i_row TYPE lvc_s_row

i_column TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE itab INDEX is_row_no-row_id .

IF sy-subrc = 0 .

IF i_column = 'MATNR'.

t_mat = itab-matnr.

SET PARAMETER ID 'MAT' FIELD t_mat.

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

SET PARAMETER ID 'MAT' FIELD space.

ELSEIF i_column = 'MBLNR'.

CALL TRANSACTION 'MIGO'.

ENDIF .

ENDIF.

ENDFORM . "handle_double_click

my custom control name is CC_ALV.