Open the text editor when click the button in table control

...Previous

Write the following code.

*----------------------------------------------------------------*
***INCLUDE LZCONTRACTI01 .
*----------------------------------------------------------------*
*&--------------------------------------------------------------*
*&      Module  TEXT_EDITOR  INPUT
*&---------------------------------------------------------------*
*       text
*----------------------------------------------------------------*
MODULE text_editor INPUT.
  DATA g_aftnr  LIKE thead-tdname.
  DATA g_vendor TYPE lifnr.
  DATA st_thead LIKE thead.
  DATA wa_lines TYPE tline.
  DATA it_lines TYPE TABLE OF tline.
  DATA g_tdname LIKE stxh-tdname.
  DATA g_lineno TYPE sy-index.
  DATA g_ok_code TYPE sy-ucomm.
  DATA g_lin_no.
  CLEAR :  g_lineno,
           g_tdname,
           st_thead,
           it_lines,
           wa_lines,
           g_lin_no.
  REFRESH it_lines.
  g_ok_code = sy-ucomm.
  CLEAR sy-ucomm.
  IF g_ok_code EQ 'PTERM'.
    GET CURSOR LINE g_lineno.
    g_lineno =  g_lineno + tctrl_zcontract-top_line - 1.
    READ TABLE extract INDEX g_lineno.
    g_vendor = extract+3(10).
    g_aftnr = extract+13(10).
    CONCATENATE g_vendor g_aftnr INTO g_tdname.
    PERFORM read_text.
    IF sy-subrc NE 0.
      PERFORM enter_st_head.
      PERFORM edit_text.
    ELSE.
      PERFORM edit_text.
    ENDIF.
  ENDIF.
  PERFORM create_text.
ENDMODULE.                 " TEXT_EDITOR  INPUT
*&----------------------------------------------------------------*
*&      Form  READ_TEXT
*&----------------------------------------------------------------*
*       text
*-----------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*-----------------------------------------------------------------*
FORM read_text .
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*     CLIENT                        = SY-MANDT
      id                            = 'ZTS'
      language                      = sy-langu
      name                          = g_tdname
      object                        = 'ZTEST_ID'
*     ARCHIVE_HANDLE                = 0
*     LOCAL_CAT                     = ' '
   IMPORTING
     header                        = st_thead
    TABLES
      lines                         = it_lines
   EXCEPTIONS
     id                            = 1
     language                      = 2
     name                          = 3
     not_found                     = 4
     object                        = 5
     reference_check               = 6
     wrong_access_to_archive       = 7
     OTHERS                        = 8
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " READ_TEXT
*&----------------------------------------------------------------*
*&      Form  ENTER_ST_HEAD
*&----------------------------------------------------------------*
*       text
*-----------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------*
FORM enter_st_head .
  st_thead-tdobject   = 'ZTEST_ID'.
  st_thead-tdid       = 'ZTS' .
  st_thead-tdspras    = sy-langu.
  st_thead-tdlinesize = '072'.
  st_thead-tdtxtlines = '1'.
ENDFORM.                    " ENTER_ST_HEAD
*&---------------------------------------------------------------*
*&      Form  EDIT_TEXT
*&---------------------------------------------------------------*
*       text
*-----------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*-----------------------------------------------------------------*
FORM edit_text .
  CALL FUNCTION 'EDIT_TEXT'
    EXPORTING
*     DISPLAY             = ' '
*     EDITOR_TITLE        = ' '
      header              = st_thead
*     PAGE                = ' '
*     WINDOW              = ' '
*     SAVE                = 'X'
*     LINE_EDITOR         = ' '
*     CONTROL             = ' '
*     PROGRAM             = ' '
*     LOCAL_CAT           = ' '
   IMPORTING
*     FUNCTION            =
     newheader           = st_thead
*     RESULT              =
    TABLES
      lines               = it_lines
   EXCEPTIONS
     id                  = 1
     language            = 2
     linesize            = 3
     name                = 4
     object              = 5
     textformat          = 6
     communication       = 7
     OTHERS              = 8
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " EDIT_TEXT
*&---------------------------------------------------------------*
*&      Form  CREATE_TEXT
*&---------------------------------------------------------------*
*       text
*----------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------*
FORM create_text .
  CALL FUNCTION 'CREATE_TEXT'
    EXPORTING
      fid         = 'ZTS'
      flanguage   = sy-langu
      fname       = g_tdname
      fobject     = 'ZTEST_ID'
      save_direct = 'X'
      fformat     = '*'
    TABLES
      flines      = it_lines
    EXCEPTIONS
      no_init     = 1
      no_save     = 2
      OTHERS      = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " CREATE_TEXT

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image