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

QM02 Text Functionality

Former Member
0 Likes
1,136

Hi Folks,

If you go into QM02, there is some very nifty text functionality where the user is able to read only the text that was saved before them, but still write new text in the same text box. Our users have that requirement in a custom transaction that we are building, before I go debugging through the standard code, can anyone advise me on how SAP managed this, anything from code snippets to words of encouragement that this is possible would be appreciated!!

Thanks for any help,

Colm

1 ACCEPTED SOLUTION
Read only

former_member197622
Participant
0 Likes
993

Hi Colm

to save text in the way you want you must use the format ">X"

lw_lines-tdformat = '>X'.

lw_lines-tdline = '* text'.

append lw_lines to lt_lines.

       CALL FUNCTION 'SAVE_TEXT'

         EXPORTING

           header          = l_header

           savemode_direct = 'X'

         TABLES

           lines           = lt_lines.

if you want to create a history line in the format: * 04.07.2014 11:11:58  USER (USER)

use the FM TEXT_CREATE_HISTORY_LINE

Regards

MC

2 REPLIES 2
Read only

former_member197622
Participant
0 Likes
994

Hi Colm

to save text in the way you want you must use the format ">X"

lw_lines-tdformat = '>X'.

lw_lines-tdline = '* text'.

append lw_lines to lt_lines.

       CALL FUNCTION 'SAVE_TEXT'

         EXPORTING

           header          = l_header

           savemode_direct = 'X'

         TABLES

           lines           = lt_lines.

if you want to create a history line in the format: * 04.07.2014 11:11:58  USER (USER)

use the FM TEXT_CREATE_HISTORY_LINE

Regards

MC

Read only

0 Likes
993

Hi Marco,

Thanks for your help, that is part of the solution but not the full part. So if you save the text with the TDFORMAT of >X, then you need to use the method protect_selection of the class c_textedit_control,


*  This is for the comments box

   CREATE OBJECT go_editor

     EXPORTING

       repid                      = sy-repid

       dynpro_container           = 'P_COMMENTS'

       wordwrap_mode              = c_textedit_control=>wordwrap_off

       wordwrap_position          = gc_line_length

       wordwrap_to_linebreak_mode = c_textedit_control=>true.

* Don't have tool-bar or status bar

   CALL METHOD go_editor->set_toolbar_mode

     EXPORTING

       toolbar_mode = c_textedit_control=>false.

   CALL METHOD go_editor->set_statusbar_mode

     EXPORTING

       statusbar_mode = c_textedit_control=>false.

   CALL FUNCTION 'CONTROL_FLUSH'.

*    intialize variables displayed on dynpros

   CLEAR gv_from_line.

   CLEAR gv_from_pos.

   CLEAR gv_line_text.

   "Read the existing comments

   CLEAR: lv_name, lt_lines.

   CONCATENATE gs_final_text_left-vbeln gs_final_text_left-posnr gs_final_text_left-etenr

   INTO lv_name.

   CALL FUNCTION 'READ_TEXT'

     EXPORTING

       id                      = gs_final_text_left-txt_id

       language                = sy-langu

       name                    = lv_name

       object                  = gs_final_text_left-txt_obj

     TABLES

       lines                   = lt_lines

     EXCEPTIONS

       id                      = 1

       language                = 2

       name                    = 3

       not_found               = 4

       object                  = 5

       reference_check         = 6

       wrong_access_to_archive = 7

       error_message           = 9

       OTHERS                  = 8.

   "Loop at the text that we read back

   CLEAR: ls_lines, ls_comments, lt_comments.

   LOOP AT lt_lines INTO ls_lines.

     ls_comments = ls_lines-tdline.

     APPEND ls_comments TO lt_comments.

   ENDLOOP.

   "Prefix All Comments with a ---------- and date time"

   WRITE sy-datum TO lv_datum.

   WRITE sy-uzeit TO lv_uzeit.

   CONCATENATE '--------' lv_datum lv_uzeit '--------'

   INTO ls_comments SEPARATED BY space.

   APPEND ls_comments TO lt_comments.

   "Also prefix the LT_LINES table, so we can compare the before and after

   "text to ensure text is changed on closure

   ls_lines-tdline = ls_comments.

   APPEND ls_lines TO lt_lines.

   gt_existing_comments[] = lt_lines[].

   "Pop the text onto the Container

   CALL METHOD go_editor->set_text_as_r3table

     EXPORTING

       table           = lt_comments

     EXCEPTIONS

       error_dp        = 1

       error_dp_create = 2

       OTHERS          = 3.

   CALL METHOD go_editor->select_lines

     EXPORTING

       from_line = 1

       to_line   = 3.

   CALL METHOD go_editor->protect_selection

     EXPORTING

       protect_mode = 1.

   CALL METHOD go_editor->set_selection_pos

     EXPORTING

       from_line = 6

       from_pos  = 1

       to_line   = 6

       to_pos    = 1.