Skip to Content

Hiii,

This document used to get know how to use custom container to make an multiple lines editable text box…

INTRODUCTION: Use a custom container to get multiple text data from file, or by writing and to save data in cluster database.

Steps:

  1. Make a custom container in sceen.
  2. Make object of cl_gui_cutom container.
  3. Make object of cl_gui_textedit.
  4. Use method of class cl_gui_textedit to link subsceen container to main sceen subsceen area and to use it.
  5. Use set_text_as_r3table to set data in custom_container and use get_text_as_r3table to get data from custom_container to internal table.

Advantage:

  1. Use of objects.
  2. Use of cluster database to save data. So to increase speed and save database space also using INDX database of cluster database.
  3. Can able to get data from any document into our custom container.
  4. Can able to make document using text in custom container.
  5. Save multiple line data in the database.

Step-by-step

  1. First make a tab in which use a sub screen subl_doc for calling of sceen contains of custom container.

 

2. Second step make a sceen on which use a custom container name as TEXTEDITOR1.

  

3. Define the object refrences in top part of calling screen using below coding:

   

CONSTANTS texte TYPE n LENGTH 5 VALUE 256.

DATA: editor TYPE REF TO cl_gui_textedit,
container
TYPE REF TO cl_gui_custom_container.

DATA  g_repid TYPE sy-repid.
DATA  g_dynnr TYPE sy-dynnr.
DATA  g_mytable(256) TYPE c OCCURS 0.
DATA  t_text TYPE STANDARD TABLE OF tline.
DATA  j_text TYPE STANDARD TABLE OF tline.
DATA  w_text TYPE tline.
DATA  w_mytable(texte) TYPE c .
CLASS cl_gui_cfw DEFINITION LOAD. “to load class
DATA  v_docno(22).
DATA i_docno TYPE n LENGTH 22.
DATA: text1(132),
len
TYPE i,
len1
TYPE i,
text2(
132).

  1. Now call this sub screen using the below coding in main sceen:


PROCESS BEFORE
OUTPUT.
module clear_syucomm.

CALL SUBSCREEN subl_mat INCLUDING ‘YEXPORT_PROCES’ ‘0104’.
CALL SUBSCREEN subl_bak INCLUDING ‘YEXPORT_PROCES’ ‘0105’.
CALL SUBSCREEN subl_doc INCLUDING ‘YEXPORT_PROCES’ ‘0106’. “sub screen calling for                                                             “ custom container

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL ‘TCNTRL’
*  MODULE TCNTRL_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE TCNTRL_CHANGE_COL_ATTR.
*  LOOP AT   IT_YLCP
*       WITH CONTROL TCNTRL
*       CURSOR TCNTRL-CURRENT_LINE.
***    MODULE TCNTRL_GET_LINES.
**&SPWIZARD:   MODULE TCNTRL_CHANGE_FIELD_ATTR
*  ENDLOOP.

MODULE status_0102.
*
MODULE PBO_102.      “Use to make objects for custom container

PROCESS AFTER INPUT.

MODULE exit_prog_102 AT EXIT-COMMAND.

call SUBSCREEN subl_mat.
call SUBSCREEN subl_bak.
call SUBSCREEN subl_doc.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL ‘TCNTRL’
*  LOOP AT IT_YLCP.
*    CHAIN.
*      FIELD IT_YLCP-SRLNO.
*      FIELD IT_YLCP-MATNR.
*      FIELD IT_YLCP-MAKTX.
*      FIELD IT_YLCP-LCMAKTX.
*      FIELD IT_YLCP-VRKME.
*      FIELD IT_YLCP-FKIMG.
*      FIELD IT_YLCP-kurrf.
*      FIELD IT_YLCP-DMBTR.
*      MODULE TCNTRL_MODIFY ON CHAIN-REQUEST.
*    endchain.
*  ENDLOOP.
*  MODULE TCNTRL_USER_COMMAND.
*&SPWIZARD: MODULE TCNTRL_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE TCNTRL_CHANGE_COL_ATTR.

MODULE user_command_0102.

  1. Now, make coding under the MODULE PBO_102 of PBO.

IF container IS INITIAL.
g_repid = sy-repid.
g_dynnr  = sy-dynnr.
CREATE OBJECT container
EXPORTING
*           parent                      =
container_name              =  
‘TEXTEDITOR1’
*            style                       =
*           lifetime                    = lifetime_default
*           repid                       =
*           dynnr                       =
*           no_autodef_progid_dynnr     =
EXCEPTIONS
cntl_error                  =
1
cntl_system_error           =
2
create_error                =
3
lifetime_error              =
4
lifetime_dynpro_dynpro_link =
5
OTHERS                      = 6
.
IF sy-subrc <> 0.
*        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.

g_mycontainer = ‘TEXTEDITOR1’.

CREATE OBJECT editor
EXPORTING
*           max_number_chars       =
*           style                  = 0
wordwrap_mode          =  cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position      = 
‘256’
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
*           filedrop_mode          = dropfile_event_off
parent                 = container
*           lifetime               =
*           name                   =
*         EXCEPTIONS
*           error_cntl_create      = 1
*           error_cntl_init        = 2
*           error_cntl_link        = 3
*           error_dp_create        = 4
*           gui_type_not_supported = 5
*           others                 = 6
.
IF sy-subrc <> 0.
*        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

REFRESH g_mytable.

CALL METHOD container->link
EXPORTING
repid                       =  g_repid
dynnr                       =  g_dynnr
container                   =  g_mycontainer
*    EXCEPTIONS
*      cntl_error                  = 1
*      cntl_system_error           = 2
*      lifetime_dynpro_dynpro_link = 3
*      others                      = 4
.
IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

6. Now, the container can contains the data using the two objects of container and editor:

  

7. Now in PBI using the below code you can take out data from custom container and save into cluster database as coding defined below:

               

**& FOR SAVING OF TEXT OF CUSTOM CONTAINER &**************

CLEAR g_mytable[].

CALL METHOD editor->get_text_as_r3table
*            EXPORTING
*              only_when_modified     = FALSE
IMPORTING
table                  =  g_mytable
*              is_modified            =
*            EXCEPTIONS
*              error_dp               = 1
*              error_cntl_call_method = 2
*              error_dp_create        = 3
*              potential_data_loss    = 4
*              others                 = 5
.
IF sy-subrc <> 0.
*           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

IF g_mytable[] IS NOT INITIAL.
CLEAR t_text.
CLEAR: text1,
len ,
len1,
text2.
LOOP AT g_mytable INTO  w_mytable.
CLEAR:w_text-tdline.
len =
STRLEN( w_mytable ).
text1 = w_mytable+
0(132).

w_text-tdline = text1.
APPEND w_text TO t_text.
CLEAR w_text.
IF len > 132.
len1 = len –
132.
text2 = w_mytable+
132(len1).

w_text-tdline = text2.
APPEND w_text TO t_text.
CLEAR w_text.
ELSE.
text2 = space.

w_text-tdline = text2.
APPEND w_text TO t_text.
CLEAR w_text.
ENDIF.

CLEAR : len1, len.
ENDLOOP.
ENDIF.
**& END FOR SAVING OF TEXT OF CUSTOM CONTAINER &**********
*          CLEAR temp2.
*          CONCATENATE tmp1 ylck-lcno INTO temp2.
indx-aedat = sy-datum.
indx-usera = sy-uname.
indx-pgmid = sy-repid.
EXPORT t_text TO DATABASE indx(lc) ID v_docno.
IF sy-subrc <> 0.
MESSAGE ‘Document required data is not saved’ TYPE ‘I’.
EXIT.
ELSE.
PERFORM cleardocreq.
ENDIF.
** USING OF INBUILT CLUSTER DATABASE &*************
** END OF INBUILT CLUSTER DATABSE &****************

8. At last if you want to get data from data base you want to show in custom containers you can use method as shown below:

 

**& END FOR GETING OF TEXT OF CUSTOM CONTAINER &**********
CLEAR : v_docno, j_text, t_text.
v_docno = wa_ylck-docno.
IMPORT t_text TO j_text FROM DATABASE indx(lc) ID v_docno.
IF sy-subrc <> 0.
MESSAGE ‘Document required data is not available’ TYPE ‘I’.
EXIT.
ELSE.
CLEAR: text1, g_mytable, w_mytable, g_mytable[],
len,
len1,
text2.
REFRESH : g_mytable, g_mytable[].
DATA i TYPE i VALUE 0.
LOOP AT j_text INTO w_text.

IF i = 0.
text1 = w_text-tdline.
CLEAR w_text.
i = i + 1.
ELSEIF i = 1.
text2 = w_text-tdline.
CONCATENATE text1 text2 INTO w_mytable.

APPEND w_mytable TO g_mytable.
i = 0.
CLEAR : w_mytable, text1, text2.
ENDIF.
ENDLOOP.

CALL METHOD editor1->set_text_as_r3table
EXPORTING
table = g_mytable.
ENDIF.

                

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply