긴 텍스트에 대한 ABAP 작업 SAVETEXT & READ_TEXT

REPORT   zgo_test_15.

DATA: gs_header TYPE thead .
DATA: gt_ltxts TYPE STANDARD TABLE OF tline .
DATA: lw_ltxt  TYPE tline .

START-OF-SELECTION .


  CLEAR gt_ltxts[] .
  CLEAR lw_ltxt .

   lw_ltxt-tdformat = '*' .
   lw_ltxt-tdline = 'this is create by save_text .'.
  APPEND lw_ltxt TO gt_ltxts .

  CLEAR gs_header .
   gs_header-tdobject = 'VBBK' .
   gs_header-tdid      = '0001'.
   gs_header-tdspras   = '3'.
   gs_header-tdname    = '0080000001'.

  CALL FUNCTION 'SAVE_TEXT'
    EXPORTING
      client                 = sy-mandt
      header                 = gs_header
*    INSERT                 = ' '
*    SAVEMODE_DIRECT        = ' '
*    OWNER_SPECIFIED        = ' '
*    LOCAL_CAT              = ' '
* IMPORTING
*    FUNCTION               =
*    NEWHEADER              =
    TABLES
      lines                  = gt_ltxts .
* EXCEPTIONS
*    ID                     = 1
*    LANGUAGE               = 2
*    NAME                   = 3
*    OBJECT                 = 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.



    CALL FUNCTION 'READ_TEXT'
    EXPORTING
      client                         = sy-mandt
      id                             = '0001'
      language                       = '3'
       name                           = '0080000001'
      object                         = 'VBBK'
*    ARCHIVE_HANDLE                 = 0
*    LOCAL_CAT                      = ' '
   IMPORTING
     header                         = gs_header
    TABLES
      lines                          = gt_ltxts
   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.

  LOOP AT gt_ltxts INTO lw_ltxt .

    WRITE / lw_ltxt-tdline .

  ENDLOOP.

좋은 웹페이지 즐겨찾기