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

CUSTOM CONTROL ?

Former Member
0 Likes
1,424

Hi all,

please give the idea of how to use DEMO CUSTOM CONTROL in screen painter?

Regards,

Subash.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,117

hi subasha,

see below it.. custom container program.

data : ztext_demo2 type standard table of ztext_str.

data : it_demo type standard table of ztext_str,

wa_demo type ztext_str.

DATA: V_SAVE TYPE I.

data : begin of ztext_demo1 occurs 0,

sttext type ztext_str-sttext,

counts type ztext_demo-counts,

lines type ztext_demo-lines,

end of ztext_demo1.

data: it_summ type TABLE OF ztext_demo.

data : wa_demo1 type ztext_demo.

data : it_display type standard table of ztext_str.

*

data : incr1 type i .

data: incr2 type i.

data : test type i value 1.

data : test1 type c.

data : test_char1(200).

data : incr type i.

data : line_count type i.

constants:

line_length type i value 254.

data: ok_code like sy-ucomm.

  • Create reference to the custom container

data : custom_container type ref to cl_gui_custom_container,

  • Create reference to the TextEdit control

editor type ref to cl_gui_textedit,

repid like sy-repid.

include zinput1.

include zoutput1.

zinput1

&----


*& Module USER_COMMAND_2000 INPUT

&----


  • text

----


module user_command_2000 input.

case ok_code.

when 'EXIT'.

leave to screen 0.

when 'SAVE'.

call method : editor->get_line_text exporting line_number = test

importing text = test1

exceptions

error_cntl_call_method = 0 .

call method : editor->get_text_as_r3table importing table = ztext_demo2

is_modified = test

exceptions

error_dp = 1

error_cntl_call_method = 2

error_dp_create = 3

potential_data_loss = 4.

it_demo[] = ztext_demo2[].

incr = 1.

loop at it_demo into wa_demo.

incr1 = incr1 + 1.

clear wa_demo1.

wa_demo1-sttext = wa_demo-sttext.

wa_demo1-counts = incr.

wa_demo1-lines = incr1.

insert ztext_demo from wa_demo1.

endloop.

when 'LC'.

call method : editor->get_line_count importing lines = line_count.

when 'GET_DATA'.

select sttext from ztext_demo into corresponding fields of table it_display where lines = '1'.

call method : editor->set_text_as_r3table exporting table = it_display.

when 'MODIFY'.

call method : editor->get_line_text exporting line_number = test

importing text = test1

exceptions

error_cntl_call_method = 0 .

call method : editor->get_text_as_r3table importing table = ztext_demo2

is_modified = test

exceptions

error_dp = 1

error_cntl_call_method = 2

error_dp_create = 3

potential_data_loss = 4.

it_demo[] = ztext_demo2[].

incr = 1.

loop at it_demo into wa_demo.

incr1 = incr1 + 1.

clear wa_demo1.

wa_demo1-sttext = wa_demo-sttext.

wa_demo1-counts = incr.

wa_demo1-lines = incr1.

  • modify ztext_demo from wa_demo1.

modify it_summ from wa_demo1 INDEX incr1.

endloop.

V_SAVE = 1.

when 'SETNAME'.

data : name type string value 'Hai'.

call method : editor->set_name(

exporting

name = name

exceptions

cntl_error = 1

parent_no_name = 2

illegal_name = 3

).

  • if sy-subrc <> 0.

*

  • endif.

endcase.

endmodule. " USER_COMMAND_2000 INPUT

zoutput1

&----


*& Include ZOUTPUT1

&----


&----


*& Module STATUS_2000 OUTPUT

&----


  • text

----


module STATUS_2000 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

IF editor IS INITIAL.

repid = sy-repid.

  • Create obejct for custom container

CREATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*Disabling the Textarea

*call method : custom_container->set_visible exporting visible = 'S'.

*call method : custom_container->reg_event_size_control exporting register = 0.

  • Create obejct for the TextEditor control

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = custom_container

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

  • To make invisible the buttons above the textarea(Toolbar)

CALL METHOD editor->set_toolbar_mode.

  • To make invisible the Status bar.

CALL METHOD editor->set_statusbar_mode.

DATA : V_WIDTH TYPE I VALUE 20.

CALL METHOD : editor->GET_WIDTH IMPORTING WIDTH = V_WIDTH.

  • We cant type when we give enable = ''.

CALL METHOD : editor->set_enable exporting enable = 'X'.

**

endmodule. " STATUS_2000 OUTPUT

This program for sample custom container..

Reward if useful,

regards,

s.suresh

7 REPLIES 7
Read only

Former Member
0 Likes
1,117
Read only

Former Member
0 Likes
1,117

Custom Controls

A custom control is an area on a screen. You create them in the Screen Painter, and, like all other screen objects, they have a unique name. You use custom controls to embed controls. A control is a software component on the presentation server, which can be either an ActiveX control or a JavaBean, depending on the SAPgui you are using. They allow you to perform tasks, such as editing texts, locally on the presentation server. The control is driven by the application logic, which still runs on the application server.

The SAP Control Framework

The controls on the presentation server and the ABAP application programs on the application server communicate using the Structure link SAP Control Framework. This is programmed in ABAP Objects, and contains a set of global classes that you can find in the Class Browser under Basis ® Frontend services. These classes encapsulate the communication between the application server and presentation server, which is implemented using Remote Function Call.

All application controls are encapsulated in a global class. You can find the SAP Basis controls in the Class Browser under Basis ® Frontend Services or Basis ® Component Integration. Programs that use controls on a screen work with the methods and events of the global classes that encapsulates them.

go through these link

http://help.sap.com/saphelp_47x200/helpdata/en/e4/6013361d5af835e10000009b38f839/frameset.htm

/people/ravikumar.allampallam/blog/2005/06/01/alv-reporting-using-controls--part-i

/people/ravikumar.allampallam/blog/2005/06/01/alv-reporting-using-controls-control-layouts--part-ii

also check report.

DEMO_CUSTOM_CONTROL

Reward points if useful

Read only

Former Member
0 Likes
1,117
Read only

Former Member
0 Likes
1,117

Pls Refer the program 'RSDEMO_CUSTOM_CONTROL'

Read only

0 Likes
1,117

Hi Rengith Skariah,

how is the display for image?

what code for it??

reply me soon,

s.suresh

Read only

0 Likes
1,117

You can display the image by calling the method load_picture_from_url

if you want to load the image from local system give the image path as url.

eg:

call method pic1->load_picture_from_url

exporting

url = 'file://C:\WINDOWS\Web\Wallpaper\home.jpg'

Where pic1 is the object of picture control.

Read only

Former Member
0 Likes
1,118

hi subasha,

see below it.. custom container program.

data : ztext_demo2 type standard table of ztext_str.

data : it_demo type standard table of ztext_str,

wa_demo type ztext_str.

DATA: V_SAVE TYPE I.

data : begin of ztext_demo1 occurs 0,

sttext type ztext_str-sttext,

counts type ztext_demo-counts,

lines type ztext_demo-lines,

end of ztext_demo1.

data: it_summ type TABLE OF ztext_demo.

data : wa_demo1 type ztext_demo.

data : it_display type standard table of ztext_str.

*

data : incr1 type i .

data: incr2 type i.

data : test type i value 1.

data : test1 type c.

data : test_char1(200).

data : incr type i.

data : line_count type i.

constants:

line_length type i value 254.

data: ok_code like sy-ucomm.

  • Create reference to the custom container

data : custom_container type ref to cl_gui_custom_container,

  • Create reference to the TextEdit control

editor type ref to cl_gui_textedit,

repid like sy-repid.

include zinput1.

include zoutput1.

zinput1

&----


*& Module USER_COMMAND_2000 INPUT

&----


  • text

----


module user_command_2000 input.

case ok_code.

when 'EXIT'.

leave to screen 0.

when 'SAVE'.

call method : editor->get_line_text exporting line_number = test

importing text = test1

exceptions

error_cntl_call_method = 0 .

call method : editor->get_text_as_r3table importing table = ztext_demo2

is_modified = test

exceptions

error_dp = 1

error_cntl_call_method = 2

error_dp_create = 3

potential_data_loss = 4.

it_demo[] = ztext_demo2[].

incr = 1.

loop at it_demo into wa_demo.

incr1 = incr1 + 1.

clear wa_demo1.

wa_demo1-sttext = wa_demo-sttext.

wa_demo1-counts = incr.

wa_demo1-lines = incr1.

insert ztext_demo from wa_demo1.

endloop.

when 'LC'.

call method : editor->get_line_count importing lines = line_count.

when 'GET_DATA'.

select sttext from ztext_demo into corresponding fields of table it_display where lines = '1'.

call method : editor->set_text_as_r3table exporting table = it_display.

when 'MODIFY'.

call method : editor->get_line_text exporting line_number = test

importing text = test1

exceptions

error_cntl_call_method = 0 .

call method : editor->get_text_as_r3table importing table = ztext_demo2

is_modified = test

exceptions

error_dp = 1

error_cntl_call_method = 2

error_dp_create = 3

potential_data_loss = 4.

it_demo[] = ztext_demo2[].

incr = 1.

loop at it_demo into wa_demo.

incr1 = incr1 + 1.

clear wa_demo1.

wa_demo1-sttext = wa_demo-sttext.

wa_demo1-counts = incr.

wa_demo1-lines = incr1.

  • modify ztext_demo from wa_demo1.

modify it_summ from wa_demo1 INDEX incr1.

endloop.

V_SAVE = 1.

when 'SETNAME'.

data : name type string value 'Hai'.

call method : editor->set_name(

exporting

name = name

exceptions

cntl_error = 1

parent_no_name = 2

illegal_name = 3

).

  • if sy-subrc <> 0.

*

  • endif.

endcase.

endmodule. " USER_COMMAND_2000 INPUT

zoutput1

&----


*& Include ZOUTPUT1

&----


&----


*& Module STATUS_2000 OUTPUT

&----


  • text

----


module STATUS_2000 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

IF editor IS INITIAL.

repid = sy-repid.

  • Create obejct for custom container

CREATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*Disabling the Textarea

*call method : custom_container->set_visible exporting visible = 'S'.

*call method : custom_container->reg_event_size_control exporting register = 0.

  • Create obejct for the TextEditor control

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = custom_container

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 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

  • To make invisible the buttons above the textarea(Toolbar)

CALL METHOD editor->set_toolbar_mode.

  • To make invisible the Status bar.

CALL METHOD editor->set_statusbar_mode.

DATA : V_WIDTH TYPE I VALUE 20.

CALL METHOD : editor->GET_WIDTH IMPORTING WIDTH = V_WIDTH.

  • We cant type when we give enable = ''.

CALL METHOD : editor->set_enable exporting enable = 'X'.

**

endmodule. " STATUS_2000 OUTPUT

This program for sample custom container..

Reward if useful,

regards,

s.suresh