Skip to Content
0
Former Member
Apr 19, 2007 at 09:03 AM

problem with the text editor (Very urgent please help me).

99 Views

Hi All,

I have two coloums in my ALV grid 1 for contract and

2. for nomination

if i click on the any of the contract 1st FM is called and a pop up screen is displayed which was designed in the dialog programing. I am using text editor in this in which the user can enter free text and press on save. if the user clicks on save using FM SAVE_TEXT we are saving this text on an particular tdname.

same functionality with the 2nd function module also, but the difference is saving in another tdname.

my problem is when i go to the contract screen and read text from the particular tdname for the first time i am getting teh correct value into teh editor but when i go to the nomination screen i am getting the values of the contract read_text.

i have used the class <b>cl_gui_textedit</b> in which i am using teh objects set_text_as_stream,

i have used the object CALL METHOD cl_gui_cfw=>flush also but my problem is not solved.

i am attaching the code for this also please check it.

event PAI

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_5000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_5000 INPUT.
  DATA:wv_tdname_nom   LIKE thead-tdname,
       wv_tdid_nom     LIKE thead-tdid,
       wv_tdobject_nom LIKE thead-tdobject.

  IF wv_subrc EQ 0.
    MOVE  wv_okcode TO wv_save_ok.
    CLEAR wv_okcode.

    CASE wv_save_ok.
      WHEN 'SAVE'.
        IF wv_aktyp EQ 'V'
        OR wv_aktyp EQ 'H'.
          PERFORM save_text
                  USING wo_editor3
                  CHANGING wv_change_text.

          PERFORM save_create_text USING  wv_langu
                                          wv_tdname
                                          wv_tdid
                                          wv_tdobject.

          PERFORM free_text_control
                  USING wo_editor3
                        wo_textedit_custom_container3.
          IF wv_flag = 1.
*Update VBAK
            UPDATE vbak
              SET zzgrupp_cm = wv_zzgrupp_cm
                  zzguarfrom = wv_zzguarfrom
                  zzguarto   = wv_zzguarto
                  zzguarref  = wv_zzguarref
                  zzguarresp = wv_zzguarresp
              WHERE vbeln = wv_vbeln.
* D3BK9A3VD2 Start of Insertion
            IF sy-subrc = 0.
              COMMIT WORK.
            ELSE.
              ROLLBACK WORK.
            ENDIF.
* D3BK9A3VD2 End of Insertion
          ELSE.
*Update only OIJNOMI
            UPDATE oijnomi
              SET zzgrupp_cm = wv_zzgrupp_cm
                  zzguarfrom = wv_zzguarfrom
                  zzguarto   = wv_zzguarto
                  zzguarref  = wv_zzguarref
                  zzguarresp = wv_zzguarresp
              WHERE nomtk = wv_nomtk
                AND nomit = wv_nomit.
* D3BK9A3VD2 Start of Insertion
            IF sy-subrc = 0.
              COMMIT WORK.
            ELSE.
              ROLLBACK WORK.
            ENDIF.
* D3BK9A3VD2 End of Insertion
          ENDIF.
          LEAVE TO SCREEN 0.
        ENDIF.
      WHEN 'CANCEL'.
        wt_tlinetab[] = wt_tlinetab_old[].
        LEAVE TO SCREEN 0.
      WHEN 'ENTER'.
        LEAVE TO SCREEN 0.

    ENDCASE.
  ENDIF.
ENDMODULE.                 " USER_COMMAND_5000  INPUT
*&---------------------------------------------------------------------*
*&      Module  check  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE check INPUT.

  MOVE  wv_okcode TO wv_save_ok.
  IF wv_save_ok NE 'CANCEL'.
*Check Risk category
    IF wv_zzgrupp_cm IS INITIAL.
      IF wv_ctlpc = '04' OR wv_ctlpc = '05' .
        MESSAGE e002(zsd) WITH text-002.
      ENDIF.
*Check guarantee type
    ELSE.
      SELECT SINGLE grupp
             INTO wv_temp
             FROM t691b
             WHERE grupp = wv_zzgrupp_cm
             AND   kkber = wv_bukrs.
      IF sy-subrc NE 0.
        SELECT grupp UP TO 1 ROWS INTO wv_temp FROM t691b
           WHERE grupp = wv_zzgrupp_cm.
        ENDSELECT.
        IF sy-subrc NE 0.
          MESSAGE e002(zsd) WITH text-003.
        ENDIF.
      ENDIF.
    ENDIF.

    IF wv_zzgrupp_cm IS INITIAL AND ( wv_zzguarfrom = '00000000' OR
         wv_zzguarto = '00000000' OR wv_zzguarref IS INITIAL ).
      MESSAGE e002(zsd) WITH text-001.
    ENDIF.

    IF NOT wv_zzgrupp_cm IS INITIAL AND ( wv_zzguarfrom = '00000000' OR
         wv_zzguarto = '00000000' OR wv_zzguarref IS INITIAL ).
      MESSAGE e002(zsd) WITH text-004.
    ENDIF.
  ENDIF.

ENDMODULE.                 " check  INPUT
*&---------------------------------------------------------------------*
*&      Module  INIT  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init OUTPUT.
  CLEAR wv_lib_id.

  SELECT SINGLE bname name1 name2
         INTO (wv_zzguarresp , wv_name1 , wv_name2)
         FROM zv_usr03
         WHERE bname = wv_zzguarresp.
  IF sy-subrc = 0.
    CONCATENATE wv_name1 wv_name2 INTO wv_lib_id SEPARATED BY space.
  ELSE.
    SELECT SINGLE bname name1 name2
       INTO (wv_zzguarresp , wv_name1 , wv_name2)
       FROM zv_usr03
       WHERE bname = sy-uname.
    IF sy-subrc = 0.
      CONCATENATE wv_name1 wv_name2 INTO wv_lib_id SEPARATED BY space.
    ENDIF.
  ENDIF.

  CASE wv_flag.
*Init Contract
    WHEN  '1' .
      LOOP AT SCREEN.
        IF screen-name = 'W_SITYP' OR screen-name = 'WV_SITYP'
           OR screen-name = 'W_UOM' OR screen-name = 'WV_UOM'
           OR screen-name = 'W_LOCID' OR screen-name = 'WV_LOCID'
           OR screen-name = 'W_DATE' OR screen-name = 'WV_DATE'.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
      CLEAR wv_lib_guarantee.
      SELECT SINGLE gtext INTO wv_lib_guarantee FROM t691c
      WHERE spras = sy-langu
      AND   grupp = wv_zzgrupp_cm
      AND   kkber = wv_bukrs.
      IF sy-subrc NE  0.
        SELECT gtext UP TO 1 ROWS
        INTO wv_lib_guarantee FROM t691c
        WHERE spras = sy-langu
        AND   grupp = wv_zzgrupp_cm.
        ENDSELECT.
      ENDIF.
*Display Comments for contract
    WHEN '2'.
      LOOP AT SCREEN.
        IF screen-name = 'W_SITYP' OR screen-name = 'WV_SITYP'
           OR screen-name = 'W_UOM' OR screen-name = 'WV_UOM'
           OR screen-name = 'W_LOCID' OR screen-name = 'WV_LOCID'
           OR screen-name = 'W_DATE' OR screen-name = 'WV_DATE'.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      IF screen-name = 'WV_ZZGRUPP_CM' OR screen-name = 'WV_ZZGUARFROM'
         OR screen-name = 'WV_ZZGUARTO' OR screen-name = 'WV_ZZGUARREF'.
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
*Init Nomination
    WHEN '0'.
      LOOP AT SCREEN.
       IF screen-name = 'W_CONTRACT_NUMBER' OR screen-name = 'WV_VBELN'
         OR screen-name = 'W_CONTRACT_TYPE' OR screen-name = 'WV_AUART'
                  OR screen-name = 'W_PAID' OR screen-name = 'WV_KUNNR'.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
      SELECT SINGLE sityp locid unit_i idate
             INTO (wv_sityp , wv_locid , wv_uom , wv_date)
             FROM oijnomi
             WHERE nomtk = wv_nomtk
               AND nomit = wv_nomit.
*Display Comments for nomination
    WHEN '3'.
      LOOP AT SCREEN.
      IF screen-name = 'WV_ZZGRUPP_CM' OR screen-name = 'WV_ZZGUARFROM'
         OR screen-name = 'WV_ZZGUARTO' OR screen-name = 'WV_ZZGUARREF'.
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
       IF screen-name = 'W_CONTRACT_NUMBER' OR screen-name = 'WV_VBELN'
         OR screen-name = 'W_CONTRACT_TYPE' OR screen-name = 'WV_AUART'
                  OR screen-name = 'W_PAID' OR screen-name = 'WV_KUNNR'.
          screen-active = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
  ENDCASE.
ENDMODULE.                 " INIT  OUTPUT
* D3BK9A3VD2 Start of Insertion
*&---------------------------------------------------------------------*
*&      Module  check_gaurantee  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE check_gaurantee INPUT.

*  IF NOT wv_okcode = 'CANCEL'.
*    AUTHORITY-CHECK OBJECT 'ZSDGUARNOM'
*               ID 'ACTVT' FIELD '02'
*               ID 'WV_CREDITGA' FIELD wv_creditga.
*    IF sy-subrc NE 0.
*      MESSAGE e002(zsd) WITH 'Authorisation missing'.
*    ENDIF.
*  ENDIF.
  IF wv_okcode = 'F001' AND wv_creditga = 'X'.
    MOVE: wv_zzgrupp_cm1 TO wv_zzgrupp_cm,
          wv_zzguarfrom1 TO wv_zzguarfrom,
          wv_zzguarto1   TO wv_zzguarto,
          wv_zzguarref1  TO wv_zzguarref,
          wv_locid1      TO wv_locid,
          wv_uom1        TO wv_uom,
          wv_date1       TO wv_date,
          wv_sityp1      TO wv_sityp.

  ELSEIF wv_okcode = 'F001' AND wv_creditr = 'X'.
    MOVE: wv_zzgrupp_cm TO wv_zzgrupp_cm1,
          wv_zzguarfrom TO wv_zzguarfrom1,
          wv_zzguarto   TO wv_zzguarto1,
          wv_zzguarref  TO wv_zzguarref1,
          wv_locid      TO wv_locid1,
          wv_uom        TO wv_uom1,
          wv_date       TO wv_date1,
          wv_sityp      TO wv_sityp1.

    CLEAR: wv_zzgrupp_cm,
           wv_zzguarfrom,
           wv_zzguarto,
           wv_zzguarref,
           wv_locid,
           wv_uom,
           wv_date,
           wv_sityp.
  ENDIF.

ENDMODULE.                 " check_gaurantee  INPUT







Event PBO

*&---------------------------------------------------------------------*
*&      Module  text_control_5000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE text_control_5000 OUTPUT.
  CLEAR: wv_subrc ,
         ws_thead_new.

  IF wo_editor3 IS INITIAL.

*   create control container
    CREATE OBJECT wo_textedit_custom_container3
        EXPORTING
            container_name = 'TEXTEDITOR2'
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5.
    MOVE sy-subrc TO wv_subrc.
    IF wv_subrc NE 0.
      RAISE others .
    ENDIF.
    IF wv_subrc EQ 0.
      wv_mycontainer2 = 'TEXTEDITOR2'.

*   create calls constructor, which initializes, creats and links
*   TextEdit Control
      CREATE OBJECT wo_editor3
            EXPORTING
             parent = wo_textedit_custom_container3
             wordwrap_mode =
                cl_gui_textedit=>wordwrap_at_fixed_position
             wordwrap_position = wc_line_length
             wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

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

      CALL METHOD wo_editor3->set_statusbar_mode
          EXPORTING
             statusbar_mode = wo_editor3->true.
    ENDIF.
  ENDIF.


ENDMODULE.                 " text_control_5000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  init_screen_5000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init_screen_5000 OUTPUT.
  IF wv_subrc EQ 0.

    IF wv_aktyp EQ 'A'.
      CALL METHOD wo_editor3->set_readonly_mode
           EXPORTING
                readonly_mode = wo_editor3->true
           EXCEPTIONS
                error_cntl_call_method = 1
                invalid_parameter      = 2
                OTHERS                 = 3.
      MOVE sy-subrc TO wv_subrc .
      IF wv_subrc NE 0.
        RAISE others .
      ENDIF.
    ELSE.
      CALL METHOD wo_editor3->set_readonly_mode
           EXPORTING
                readonly_mode = wo_editor3->false
           EXCEPTIONS
                error_cntl_call_method = 1
                invalid_parameter      = 2
                OTHERS                 = 3.
      MOVE sy-subrc TO wv_subrc .
      IF wv_subrc NE 0.
        RAISE others .
      ENDIF.
    ENDIF.

  ENDIF.
ENDMODULE.                 " init_screen_5000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  read_text_5000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE read_text_5000 OUTPUT.
  IF wv_subrc EQ 0.

    REFRESH: wt_mytable,
             wt_tinlinetab,
             wt_tlinetab.

    CALL METHOD wo_editor3->empty_undo_buffer.
    CLEAR wv_thead.

    CALL FUNCTION 'READ_TEXT_INLINE'
         EXPORTING
              id              = wv_tdid
              inline_count    = 1
              language        = wv_langu
              name            = wv_tdname
              object          = wv_tdobject
         IMPORTING
              header          = wv_thead
         TABLES
              inlines         = wt_tinlinetab
              lines           = wt_tlinetab
         EXCEPTIONS
              id              = 1
              language        = 2
              name            = 3
              not_found       = 4
              object          = 5
              reference_check = 6
              OTHERS          = 7.

    MOVE sy-subrc TO wv_subrc.
* D3BK9A3VD2 Start of Insertion
    IF wv_subrc = 0.
      IF wv_creditr = 'X'.
        READ TABLE wt_tlinetab INDEX 1.
        IF NOT wt_tlinetab-tdline(15) = 'Credit Released'.
          MOVE: '*' TO wt_tlinetab-tdformat,
                'Credit Released by AUTHORIZED AUTHORITY' TO
                        wt_tlinetab-tdline.
          INSERT wt_tlinetab INDEX 1.
        ENDIF.
      ELSEIF wv_creditga = 'X'.
        READ TABLE wt_tlinetab INDEX 1.
        IF NOT wt_tlinetab-tdline = 'Credit Guarantee'.
          MOVE: '*' TO wt_tlinetab-tdformat,
                'Credit Guarantee' TO wt_tlinetab-tdline.
          INSERT wt_tlinetab INDEX 1.
        ENDIF.
      ENDIF.
    ENDIF.
* D3BK9A3VD2 End of Insertion
    CASE wv_subrc .
      WHEN 0. wt_tlinetab_old[] = wt_tlinetab[].
      WHEN 1. RAISE id .
      WHEN 2. RAISE language .
      WHEN 3. RAISE name .
      WHEN 4. CLEAR wv_subrc.
      WHEN 5. RAISE object .
      WHEN 6. RAISE reference_check .
      WHEN 5. RAISE others  .
    ENDCASE.
    IF wv_subrc EQ 0.
      CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
           TABLES
                itf_text    = wt_tlinetab
                text_stream = wt_mytable.

      CALL METHOD wo_editor3->set_text_as_stream
           EXPORTING
                text = wt_mytable
           EXCEPTIONS
                error_dp        = 1
                error_dp_create = 2
                OTHERS          = 3.

      MOVE sy-subrc TO wv_subrc.
      IF wv_subrc NE 0.
        RAISE others .
      ENDIF.
    ENDIF.
  ENDIF.

ENDMODULE.                 " read_text_5000  OUTPUT