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: 

Free Flow Text Entry Box

Former Member
0 Kudos

Hello,

I am interested in adding a free flow text entry box to store notes about a specific record being accessed from a custom screen. This will be very similar to the basic data text option in the material maintenance screens under the basic data 1 tab. I know that you need to create a screen with a custom control. The question I have is what method(s)/Class(es) do I need to use to tie this all together? Also, how does the text information need to be stored in my custom table? Is this an item that would need to be stored as raw text and then converted? Any suggestions or available documentation would be very helpful.

Thanks,

Jereme

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hey Rich,

Thank you for your prompt response, I just have a couple more questions for you.

I am aiming to create this in a dialog program. Would the steps be similar except that you would create the dock in the PBO then access the information in the PAI? Also, where does the FM Save_Text actually save the text to? I am going to have several hundred records all capable of having several entries per record. I would ideally like to store the information in my custom table.

12 REPLIES 12

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You will need to use the CL_GUI_TEXTEDIT class and I suggest that you save your text as sapscript text. You can create you own text object/id via transaction SE75. You can then save the text using SAVE_TEXT.

Here is a sample program for implementing the control, and getting the text out of it.



report zrich_0001 .

data:
      dockingleft  type ref to cl_gui_docking_container,
      text_editor    type ref to cl_gui_textedit,
      repid type syrepid.

data: textlines type table of tline-tdline,
      wa_text type tline-tdline.

parameters: p_check.

at selection-screen output.

  repid = sy-repid.

  create object dockingleft
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = dockingleft->dock_at_left
                        extension = 1070.

  create object text_editor
              exporting
                   parent     = dockingleft.

start-of-selection.

  call method text_editor->get_text_as_r3table
     importing
           table              = textlines
     exceptions
           others             = 1.

  loop at textlines into wa_text.
    write:/ wa_text.
  endloop.

Regards,

Rich Heilman

0 Kudos

Here is how you would save it as sapscript text.



report zrich_0001 .

data:
      dockingleft  type ref to cl_gui_docking_container,
      text_editor    type ref to cl_gui_textedit,
      repid type syrepid.

data: begin of header.
        include structure thead.
data: end of header.

data: begin of lines occurs 0.
        include structure tline.
data: end of lines.

data: textlines type table of tline-tdline,
      wa_text type tline-tdline.

parameters: p_check.

at selection-screen output.

  repid = sy-repid.

  create object dockingleft
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = dockingleft->dock_at_left
                        extension = 1070.

  create object text_editor
              exporting
                   parent     = dockingleft.

start-of-selection.

  call method text_editor->get_text_as_r3table
     importing
           table              = textlines
     exceptions
           others             = 1.


* Set SAPscript Header
  clear header.
  header-tdname = '999999' .         "Name
  header-tdobject = 'ZPT_DET'.       "Object
  header-tdid = 'Z001'.              "Id
  header-tdspras = sy-langu.

* Move text from container to function module table

  clear  lines.  refresh lines.
  loop at textlines into wa_text .
    lines-tdline = wa_text.
    append lines .
  endloop.

  call function 'SAVE_TEXT'
       exporting
            client   = sy-mandt
            header   = header
       tables
            lines    = lines
       exceptions
            id       = 1
            language = 2
            name     = 3
            object   = 4
            others   = 5.

You can read it back using the function module READ_TEXT

Regards,

Rich Heilman

Former Member
0 Kudos

Hey Rich,

Thank you for your prompt response, I just have a couple more questions for you.

I am aiming to create this in a dialog program. Would the steps be similar except that you would create the dock in the PBO then access the information in the PAI? Also, where does the FM Save_Text actually save the text to? I am going to have several hundred records all capable of having several entries per record. I would ideally like to store the information in my custom table.

0 Kudos

First, yes the implementation in a dialog program would be roughly the same. Instead of a docking container, you can implement it in a custom control directly in the dynpro. The SAVE_TEXT function module saves the text in a couple of tables, STXH is the header, and STXL is the lines. You can not read this text in the tables themselves, you must read the text via function module READ_TEXT. This is how most if not all "long text" is stored in R/3. You can see this when you go to transaction SE75 and see all of the different objects/ids associated with standard business objects. I would hight recommend that you store your text this way and NOT in a custom table.

Regards,

Rich Heilman

0 Kudos

Here is the same thing implemented into a custom container in dynpro. Create screen 100, put a custom container in the dynpro and name it as TEXT_CONTAINER, set the gui status with the save button as SAVE for the function code.



report zrich_0001 .

data: text_container type ref to cl_gui_custom_container,
      text_editor    type ref to cl_gui_textedit.

data: ok_code type sy-ucomm,
      save_ok type sy-ucomm.

start-of-selection.

  call screen 100.

************************************************************************
*      Module  STATUS_0100  OUTPUT
************************************************************************
module status_0100 output.
  set pf-status '0100'.
*  SET TITLEBAR 'xxx'.

  check text_container is initial.

  create object text_container
     exporting
       container_name    = 'TEXT_CONTAINER'.

  create object text_editor
              exporting
                   parent     = text_container.

endmodule.                 " STATUS_0100  OUTPUT
************************************************************************
*      Module  USER_COMMAND_0100  INPUT
************************************************************************
module user_command_0100 input.

  save_ok = ok_code.

  case ok_code.
    when 'SAVE'.
      clear ok_code.

      perform save_the_text.

    when 'EXIT'.
      leave program.
  endcase.

endmodule.                 " USER_COMMAND_0100  INPUT
************************************************************************
*      Form  save_the_text
************************************************************************
form save_the_text.

  data: begin of header.
          include structure thead.
  data: end of header.

  data: begin of lines occurs 0.
          include structure tline.
  data: end of lines.
  data: textlines type table of tline-tdline,
        wa_text type tline-tdline.

  call method text_editor->get_text_as_r3table
importing
     table              = textlines
exceptions
     others             = 1.


* Set SAPscript Header
  clear header.
  header-tdname = '999999' .         "Name
  header-tdobject = 'ZPT_DET'.       "Object
  header-tdid = 'Z001'.              "Id
  header-tdspras = sy-langu.

* Move text from container to function module table

  clear  lines.  refresh lines.
  loop at textlines into wa_text .
    lines-tdline = wa_text.
    append lines .
  endloop.

  call function 'SAVE_TEXT'
       exporting
            client   = sy-mandt
            header   = header
       tables
            lines    = lines
       exceptions
            id       = 1
            language = 2
            name     = 3
            object   = 4
            others   = 5.

endform.


Regards,

Rich Heilman

Former Member
0 Kudos

Hey Rich,

Thanks so much for your help on that. I have the solution implemented for the single entry screen and everything works great.

I do have another question for you. I have a table entry screen and would like to implement the notes entry for each record in the table. The trouble I am having is that when I call the texteditor the entry from the previous record is still there. I tried deleting the entries in the table that I pass. I also called the method delete_text and neither worked. Is there something I can do to clear this out after each entry>

Message was edited by: Jereme Ebaugh

0 Kudos

Try passing a empty table to the SET_TEXT_AS_R3_TABLE method of the text editor.

Regards,

Ravi

Note :Please mark the helpful answers

Former Member
0 Kudos

Hey Ravi,

I tried that as well and am still getting the same result.

Thanks,

Jereme

0 Kudos

I am sure it has to do with the refresh of the internal table in which you have the text. Just make sure that you are clearing all the related internal tables.

Regards,

Ravi

0 Kudos

Hello again,

I have cleared out every conceivable variable associated with the text editor method call. I even stepped through the call to the method and all the data is blank. Yet when the actual editor is displayed on the screen it has the previous entries data in it. Any help on this matter would be much appreciated.

Thanks,

Jereme

Message was edited by: Jereme Ebaugh

0 Kudos

Jereme,

You need to free your container in between records. Here is the code.

CALL METHOD text_editor->free

EXCEPTIONS

OTHERS = 1.

CALL METHOD text_container->free

EXCEPTIONS

OTHERS = 1.

0 Kudos

Thanks Mary Kerschke .Your suggestion worked for me...Its such a relief.

Delete_text must also be accompanied by "free the container object". That works as refresh the container.

It worked for me....

BR,

Krishna.