Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9071

Long Text Input in table control of dialog program

$
0
0

Dear experts,

 

My requirement is to have a long text column in table control. Once user click
the button of a line item, the text editor will open. On the text editor screen,
if user clicks back button, program will save the text into internal table. Then
the user may click another editor button of another line item and do the same
thing. Multiple long text will be saved into internal table by line items. I am
using CL_GUI_TEXTEDIT to do it. My problem is only the first item’s long text
can be get by using CL_GUI_TEXTEDIT ->get_text_as_r3table. While
the second cannot get the text but SY-SUBRC = 0. I have referred demo program SAPTEXTEDIT_DEMO_3 but it has only one single editor.

Below is my code:

 

 

Data declarations:

 

DATA: go_mdcontainer TYPE REF TO cl_gui_custom_container.
DATA: go_text_editor      TYPE REF TO cl_gui_textedit.
CLASS cl_gui_cfw DEFINITION LOAD
.

 

 

PBO:

 

 

DATA: lo_text_editor      TYPE REF TO cl_gui_textedit.


*create container

  IF go_mdcontainer IS INITIAL.

  CREATE OBJECT go_mdcontainer

    EXPORTING
      container_name              = 'TEXTEDITOR'

  ENDIF.

*clear previous text

  LOOP AT gt_textdata INTO ls_textdata WHERE textobj IS NOT INITIAL.

    CALL METHOD ls_textdata-textobj->delete_text.

    CALL METHOD cl_gui_cfw=>flush

          EXCEPTIONS

            OTHERS = 1.

  ENDLOOP.

 

 

*read selected line item

 

  CLEAR ls_milestone_data.

 
READ TABLE gt_milestone_data INDEX gv_lineno

  
INTO ls_milestone_data.

 
IF sy-subrc = 0.

   
CLEAR ls_textdata.

 

*read internal table of long text

   
READ TABLE gt_textdata INTO ls_textdata

   
WITH KEY milestone_code = ls_milestone_data-milestone_code.

   
IF sy-subrc = 0.

     
IF ls_textdata-textobj IS NOT INITIAL. “text object exists

*display saved text

       
IF ls_textdata-longtext IS NOT INITIAL.

         
CALL METHOD ls_textdata-textobj->set_text_as_r3table

           
EXPORTING

             
table           = ls_textdata-longtext

           
EXCEPTIONS

              error_dp       
= 1

              error_dp_create
= 2

             
OTHERS          = 3.

       
ENDIF.

       
EXIT"exit subroutine

     
ENDIF.

   
ELSE. “text object not exists


*create text editor object

     
CREATE OBJECT ls_textdata-textobj

       
EXPORTING

          parent               
go_mdcontainer

         wordwrap_mode         
= cl_gui_textedit=>wordwrap_at_fixed_position

         wordwrap_to_linebreak_mode
= cl_gui_textedit=>true

       
EXCEPTIONS

          error_cntl_create     
= 1

          error_cntl_init       
= 2

          error_cntl_link       
= 3

          error_dp_create       
= 4

          gui_type_not_supported
= 5

         
OTHERS                 = 6.


      ls_textdata
-milestone_code ls_milestone_data-milestone_code.

     
APPEND ls_textdata TO gt_textdata.

     
CLEAR  ls_textdata.

   
ENDIF.

 
ENDIF.

 

 

PAI:

 

  *read selected line item

READ TABLE gt_milestone_data INDEX gv_lineno

  INTO ls_milestone_data.

  IF sy-subrc = 0.
*read internal table of long text

 

    lv_idx = sy-tabix.
*get text from editor

     
CALL METHOD ls_textdata-textobj->get_text_as_r3table

       
IMPORTING

         
table                  = lt_mdtext

       
EXCEPTIONS

          error_dp              
= 1

          error_cntl_call_method
= 2

          error_dp_create       
= 3

          potential_data_loss   
= 4

         
OTHERS                 = 5.


*save text into internal table

      ls_textdata
-longtext = lt_mdtext.

     
MODIFY gt_textdata INDEX lv_idx FROM ls_textdata TRANSPORTING longtext.

     
CLEAR ls_textdata.

   
ENDIF.

 
ENDIF.


 
CALL METHOD cl_gui_cfw=>flush

   
EXCEPTIONS

      cntl_system_error
= 1

      cntl_error       
= 2

     
OTHERS            = 3.

 

 

 


Viewing all articles
Browse latest Browse all 9071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>