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 Container in module pool program

Former Member
0 Likes
6,170

Hello everyone,

I have created a custom control in my module pool screen. Now I want to store the text in the container into a ztable field of type string. Could any one suggest me how to do that.

Thanks in advance,

Bhaskar.

10 REPLIES 10
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,719

Hi,

You can proceed with TEXT AREA

Refer:-

Insert a custom control area in the screen and create a object of the text editor.

Check this code for PBO and PAI.

TEDITOR is the custom contorl area name on screen:-


MODULE PBO OUTPUT.
  IF EDITOR IS INITIAL.
 
*   set status
SET pf-status '1111'.
 
*   create control container
    CREATE OBJECT TextEdit_Custom_Container
        EXPORTING
            CONTAINER_NAME = 'TEDITOR'
        EXCEPTIONS
            CNTL_ERROR = 1
            CNTL_SYSTEM_ERROR = 2
            CREATE_ERROR = 3
            LIFETIME_ERROR = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    if sy-subrc ne 0.
*      add your handling
    ENDif.
    mycontainer = 'TEDITOR'.
 
*   create calls constructor, which initializes, creats and links
*   TextEdit Control
    create object editor
          exporting
           parent = TextEdit_Custom_Container
           WORDWRAP_MODE =
*               cl_gui_textedit=>wordwrap_off
              cl_gui_textedit=>wordwrap_at_fixed_position
*              cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER
           WORDWRAP_POSITION = line_length
           wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
 
*   to handle different containers
    container_linked = 1.
 
    refresh mytable.
 
  ENDIF.
 
ENDMODULE.                 " PBO  OUTPUT
 
 
MODULE pai INPUT.
case ok_code.
 
WHEN 'SAVE'.
*   retrieve table from control
clear: txt.
      call method editor->get_text_as_r3table
              importing table = mytable.
 
      loop at mytable into wa.
 
         concatenate txt wa into txt
         separated by '|'.
      endloop.
 
      shift txt left.
      length = strlen( txt ).
 
      ztext-CLUSTR = length.
      ztext-text   = txt.
 
      modify ztext.
 
      clear: ztext.
      refresh: mytable.
        call method editor->set_text_as_r3table
              exporting table = mytable.
      Message s000(zwa).
 
when 'DISP'.
  
      select single * from
      ztext
      where fund = ztext-fund.
 
      SPLIT ztext-text AT '|' INTO TABLE mytable.
 
      call method editor->set_text_as_r3table
             exporting table = mytable.
 
endcase.
 
clear: ok_code.
 
ENDMODULE.                 " pai  INPUT

Also you can refer:-

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,719

Hi Tarun,

I have created the text editor as said by you. But when I press the save button then I need to save the text in the editor into the database table field which is of string type. I am no understanding how to do that. Please hel me in this regard.

TIA,

Bhaskar.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,719

Hi,

Refer:

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,719

Hi Tarun,

In the solution provided by Durairaj,

when the save button is clicked call the method

GET_TEXTSTREAM of textedit control object to get the text entered in the control. and the returned text is in string format.

populate this string in the wa .

wa-textid = 'someid' .
wa_desc = <string returned by method> .

append wa to itab .
modify ztable from table itab .

Hope this is clear.

Regards
Raja

How to call the method GET_TEXTSTREAM. If it is through pattern, it is saying that the method does not exist. Please suggest me what to do.

Thanks,

Bhaskar.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,719

Hi,

Refer class CL_GUI_TEXTEDIT and use method GET_TEXTSTREAM.

Click pattern button, select ABAP objects -> provide with the object name created by you for class CL_GUI_TEXTEDIT and call the method.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,719

Hi Tarun,

Thank you very much for the continues help. Apolgies if these are basic questions.

populate this string in the wa .
 
wa-textid = 'someid' .
wa_desc = <string returned by method> .
 
append wa to itab .
modify ztable from table itab .

In the solution above,

wa-textid = 'someid' .

wa_desc = <string returned by method> .

Could you please tell me where the string returned is going to be saved.

Regards,

Bhaskar.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,719

Hi,

The method will give you one string.

Assign this string to wa-desc. Append this to the internal table itab.

Now use this internal table to insert these text into Z database table.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,719

.

Edited by: Pavan@SAP on Oct 23, 2009 1:23 PM

Read only

Pawan_Kesari
Active Contributor
0 Likes
2,719

>

> Hello everyone,

>

> I have created a custom control in my module pool screen. Now I want to store the text in the container into a ztable field of type string. Could any one suggest me how to do that.

>

> Thanks in advance,

> Bhaskar.

Is there any particular reason you are using custom control and text area to display a field?

This can be easily done using a Input/Output field.

Edited by: Pawan Kesari on Oct 21, 2009 5:05 PM

Read only

0 Likes
2,719

Hi Pawan,

I want the data to be written in multiple lines which is not possible with i/o field. That's the reason Iam using a text editor.

Thanks,

Bhaskar.