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

saving long text

Former Member
0 Likes
1,614

Hi Experts,

Iam working on dialog program and i have created long text box using "CREATE OBJECT: container EXPORTING container_name = 'TEXTEDIT'."

Now i want to save this text(unlimited text length) into SAP.Can any one tell me how to approach.

Reward guaranteed

thanks

kaki

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,115

Hi Kaki,

Check this sample Module pool program.



*--  test program to display a text area thru a custom control

PROGRAM  z_test_text    .
DATA: txt     TYPE REF TO cl_gui_textedit,
      txt_con TYPE REF TO cl_gui_custom_container.
DATA: gt_text(100) OCCURS 10 WITH HEADER LINE.
DATA: BEGIN OF it_tab OCCURS 0,
      LINE(100),
      END OF it_tab.

start-of-selection.


*&---------------------------------------------------------------------*
*&      Module  STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_1000 OUTPUT.
  SET PF-STATUS 'TEXT'.
  SET TITLEBAR 'TEXT AREA'.
it_tab-line = 'aaaaaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.
*-- test display in text area
*  gt_text = 'aaa'.
*  APPEND gt_text.
*-- populating gt_text from it_tab.
 loop at it_tab.
    gt_text = it_tab-line.
    append gt_text.
 endloop.

ENDMODULE.                 " STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo_1000 OUTPUT.
  DATA: container(30).

  container = 'TEXT'.

  IF txt IS INITIAL.
    CREATE OBJECT txt_con
     EXPORTING
       container_name = container
     EXCEPTIONS
       OTHERS = 1.

    CREATE OBJECT txt
      EXPORTING
       parent = txt_con
       wordwrap_mode  = cl_gui_textedit=>wordwrap_at_fixed_position
       wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
  ENDIF.

  CALL METHOD txt_con->link
    EXPORTING
      repid     = sy-repid
      dynnr     = '1000'
      container = container.

  CALL METHOD txt->set_toolbar_mode
    EXPORTING
      toolbar_mode = txt->true.

  CALL METHOD txt->set_statusbar_mode
    EXPORTING
      statusbar_mode = txt->true.

  CALL METHOD txt->set_wordwrap_behavior
    EXPORTING
      wordwrap_mode = txt->true.

*-- set text -------------------------------------------
  IF gt_text[] IS INITIAL.

  ENDIF.

  CALL METHOD txt->set_text_as_r3table
    EXPORTING
      table = gt_text[].

* CALL METHOD txt->set_readonly_mode.

ENDMODULE.                 " pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1000 INPUT.
  CASE sy-ucomm.
    WHEN  'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_1000  INPUT

use this code and enter your text , and then get the text as internal table and then use SAVE_TEXT Fm to save it. pass the appropriate parameters.

Regards

vijay

8 REPLIES 8
Read only

Former Member
0 Likes
1,115

Use 'Save_text' Function module for saving.

Read only

Former Member
0 Likes
1,115

You need to use a TEXT EDIT control (CL_GUI_TEXTEDIT) and place that in the container. There are GET / SET methods for this control using which you can place and get the text in the control.

Once you get the text in the control using GET_TEXT_ASR3TRABLE, pass that text to the SAVE_TEXT and follow it up by COMMIT_TEXT.

The following blog talks about this in detail.

/people/igor.barbaric/blog/2005/06/06/the-standard-text-editor-oo-abap-cfw-class

Regards,

Ravi

Read only

Former Member
0 Likes
1,116

Hi Kaki,

Check this sample Module pool program.



*--  test program to display a text area thru a custom control

PROGRAM  z_test_text    .
DATA: txt     TYPE REF TO cl_gui_textedit,
      txt_con TYPE REF TO cl_gui_custom_container.
DATA: gt_text(100) OCCURS 10 WITH HEADER LINE.
DATA: BEGIN OF it_tab OCCURS 0,
      LINE(100),
      END OF it_tab.

start-of-selection.


*&---------------------------------------------------------------------*
*&      Module  STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_1000 OUTPUT.
  SET PF-STATUS 'TEXT'.
  SET TITLEBAR 'TEXT AREA'.
it_tab-line = 'aaaaaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.
*-- test display in text area
*  gt_text = 'aaa'.
*  APPEND gt_text.
*-- populating gt_text from it_tab.
 loop at it_tab.
    gt_text = it_tab-line.
    append gt_text.
 endloop.

ENDMODULE.                 " STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo_1000 OUTPUT.
  DATA: container(30).

  container = 'TEXT'.

  IF txt IS INITIAL.
    CREATE OBJECT txt_con
     EXPORTING
       container_name = container
     EXCEPTIONS
       OTHERS = 1.

    CREATE OBJECT txt
      EXPORTING
       parent = txt_con
       wordwrap_mode  = cl_gui_textedit=>wordwrap_at_fixed_position
       wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
  ENDIF.

  CALL METHOD txt_con->link
    EXPORTING
      repid     = sy-repid
      dynnr     = '1000'
      container = container.

  CALL METHOD txt->set_toolbar_mode
    EXPORTING
      toolbar_mode = txt->true.

  CALL METHOD txt->set_statusbar_mode
    EXPORTING
      statusbar_mode = txt->true.

  CALL METHOD txt->set_wordwrap_behavior
    EXPORTING
      wordwrap_mode = txt->true.

*-- set text -------------------------------------------
  IF gt_text[] IS INITIAL.

  ENDIF.

  CALL METHOD txt->set_text_as_r3table
    EXPORTING
      table = gt_text[].

* CALL METHOD txt->set_readonly_mode.

ENDMODULE.                 " pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1000 INPUT.
  CASE sy-ucomm.
    WHEN  'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_1000  INPUT

use this code and enter your text , and then get the text as internal table and then use SAVE_TEXT Fm to save it. pass the appropriate parameters.

Regards

vijay

Read only

0 Likes
1,115

Hi Vijay,

Thanks for the good example.

Iam able to get the data into container from gt_text.

But how to get the text data(container data) into internal table? So that i can pass itab into Save text FM.

What i need to consider in PAI?

Thanks

kaki

Read only

0 Likes
1,115

Hello Kaki,

Adding to Vijay's Example

use method,

CALL METHOD txt->get_text_as_r3table

importing

table = gt_text[].

regards,

Naimesh

Read only

0 Likes
1,115

Hi Kaki,

as suggested by Naimesh you can call the method get_text_as_r3table and the internal table will have the text , use the text table and pass it to the FM save_text.

Regards

vijay D T T.

Read only

0 Likes
1,115

Hi Vijay,

Full points alloted..

Cheers

kaki