05-14-2007 11:35 AM
hi All,
i am working on custom control. which is new for me.
i am creating textedit control in custom container.
for that i have delared
DATA : editor type ref to cl_gui_textedit.
Data : custom type ref to cl_gui_custom_container.
now i want to create object for that editor and custom in my PBO module
wht can i do for that.
can i create it from pattarn button? if yes then how to create for above specific code, please tell me the steps.? if no then tell me the other way.
please tell me how to call methods.
thanks in advance.
vinod.
05-14-2007 11:39 AM
05-14-2007 11:40 AM
Yes, you can create it from the pattern. Go to the option AABAP Objects pattern, and then go to the create instance option for the related class.
First you have to create the container (custom control), and then the text editor with a link to the container.
regards,
Hans
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo
05-14-2007 11:40 AM
Hi Vinod,
Refer this code :
CUS_CNTR TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
SPLIT_CNTR TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER,
TREE TYPE REF TO CL_GUI_COLUMN_TREE,
TEXT TYPE REF TO CL_GUI_TEXTEDIT.
*&----CREATING OBJECT FOR MAIN CUSTOM CONTAINER HAVING NAME
*&----'CUSTOM_CONTROL'
CREATE OBJECT cus_cntr
EXPORTING
PARENT =
container_name = 'CUSTOM_CONTROL'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
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.
ENDIF.
*&-------CREATING OBJECT FOR EASY SPLITTER CONTAINER
*&-------THAT IS DIVIDED INTO TWO VERTICALLY , USING
*&-------'ORIENTATION' PARAMETERS
*&-------( 0 = HORIZONTALLY , 1 = VERTICALLY )
CREATE OBJECT split_cntr
EXPORTING
LINK_DYNNR =
LINK_REPID =
METRIC = cntl_metric_dynpro
parent = cus_cntr
orientation = 1
sash_position = 40
with_border = 1
NAME =
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.
ENDFORM. " BUILD_CONTAINER
&----
*& Form TREE_STRUCTURE
&----
text
----
--> p1 text
<-- p2 text
----
FORM tree_structure .
*FOR COLUMN HEADING OF COLUMN TREE
hhdr-heading = 'Object Name'.
hhdr-width = 40.
*&-----CREATING OBJECT FOR TREE STRUCTURE FOR TOP LEFT SPLITTER
*&-----CONTAINER
CREATE OBJECT tree
EXPORTING
LIFETIME =
parent = split_cntr->top_left_container
SHELLSTYLE =
node_selection_mode =
cl_gui_column_tree=>node_sel_mode_single
HIDE_SELECTION =
item_selection = 'X'
hierarchy_column_name = 'COLUMN1'
hierarchy_header = hhdr
NO_HIERARCHY_COLUMN =
NAME =
EXCEPTIONS
LIFETIME_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
ILLEGAL_NODE_SELECTION_MODE = 4
FAILED = 5
ILLEGAL_COLUMN_NAME = 6
others = 7
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*&----CALLING METHOD FOR ADDING COLUMN IN TREE
CALL METHOD tree->add_column
EXPORTING
name = 'COLUMN2'
HIDDEN =
DISABLED =
ALIGNMENT =
width = 40
WIDTH_PIX =
HEADER_IMAGE =
header_text = 'Description'
HEADER_TOOLTIP =
EXCEPTIONS
COLUMN_EXISTS = 1
ILLEGAL_COLUMN_NAME = 2
TOO_MANY_COLUMNS = 3
ILLEGAL_ALIGNMENT = 4
DIFFERENT_COLUMN_TYPES = 5
CNTL_SYSTEM_ERROR = 6
FAILED = 7
PREDECESSOR_COLUMN_NOT_FOUND = 8
others = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
*&-----CREATING OBJECTS FOR TEXT FOR BOTTOM RIGHT SPLITTER
*&-----CONTAINER
CREATE OBJECT text
EXPORTING
MAX_NUMBER_CHARS =
STYLE = 0
WORDWRAP_MODE = WORDWRAP_AT_WINDOWBORDER
WORDWRAP_POSITION = -1
WORDWRAP_TO_LINEBREAK_MODE = FALSE
FILEDROP_MODE = DROPFILE_EVENT_OFF
parent = split_cntr->bottom_right_container
LIFETIME =
NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
GUI_TYPE_NOT_SUPPORTED = 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.
*&--- FOR FETCHING PROGRAM SOURCE CODE
PERFORM read_source_code .
ENDFORM. " SOURCE_CODE_TEXT
&----
*& Form READ_SOURCE_CODE
&----
text
----
--> p1 text
<-- p2 text
----
FORM read_source_code.
REFRESH : i_incl , extend.
CALL FUNCTION 'RPY_PROGRAM_READ'
EXPORTING
language = sy-langu
program_name = prog_name
with_includelist = 'X'
ONLY_SOURCE = ' '
ONLY_TEXTS = ' '
READ_LATEST_VERSION = ' '
WITH_LOWERCASE = ' '
IMPORTING
PROG_INF =
TABLES
include_tab = i_incl
SOURCE = code
source_extended = extend
TEXTELEMENTS =
EXCEPTIONS
cancelled = 1
not_found = 2
permission_error = 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.
CALL METHOD text->set_comments_string
EXPORTING
comments_string = '*'
EXCEPTIONS
error_cntl_call_method = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD text->set_highlight_comments_mode
EXPORTING
highlight_comments_mode = 1
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 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.
*&----CALLING METHOD FOR SENDING SOURCE CODE ON
**----BOTTOM RIGHT SPLITTER CONTAINER
CALL METHOD text->set_text_as_r3table
EXPORTING
table = extend
EXCEPTIONS
ERROR_DP = 1
ERROR_DP_CREATE = 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.
CALL METHOD text->set_readonly_mode
EXPORTING
READONLY_MODE = 1
EXCEPTIONS
ERROR_CNTL_CALL_METHOD = 1
INVALID_PARAMETER = 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.
ENDFORM. " READ_SOURCE_CODE
Reward points if helpful.
Regards,
Hemant
05-14-2007 11:44 AM
hi Vinod,
refer the sample code below, to see how a text edit control is implemented:
data:
gi_container type ref to cl_gui_custom_container,
cl_gui_textedit type ref to cl_gui_textedit.
module pbo output.
set pf-status '9000'.
create object gi_container
exporting
container_name = gc_container
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.
call method gi_container->set_focus
exporting
control = gi_container.
call method cl_gui_cfw=>flush
exceptions
others = 1.
create object gi_te_control
exporting
parent = gi_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
others = 6 .
if sy-subrc <> 0.
else.
call method gi_te_control->set_readonly_mode
exporting
readonly_mode = cl_gui_textedit=>true
exceptions
error_cntl_call_method = 1
invalid_parameter = 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.
call method gi_te_control->set_text_as_r3table
exporting
table = gt_texttab
exceptions
error_dp = 1
error_dp_create = 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.
call method cl_gui_cfw=>flush
exceptions
others = 1.
endif.
endif.
endmodule. " PBO OUTPUT
Yes, you can use patters to create objects and call methods
Step1: create the reference variables as below:
data:
gi_container type ref to cl_gui_custom_container,
cl_gui_textedit type ref to cl_gui_textedit.
Step 2: Press CNTRL F6 to invoke the popup for patterns (or click the pattern button).
Step 3: choose the radio button for ABAP objects
Step 4: enter the instance name, and the class name for creating objects
Step 5: for calling methods, enter the instance name and class name and press
F4 for the method field, you will get the list of methods for this class, choose the
appropriate one...
Hope this helps,
Sajan Joseph.