메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT Z19_02.

sapjoy 2012.08.02 05:56 조회 수 : 3953

REPORT  Z19_02.

 

DATA: ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm.


 

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


 


TYPES    : g_text_t(72) TYPE c OCCURS 0.


 

DATA:  g_header LIKE thead,
       g_lines  TYPE tline OCCURS 0 WITH HEADER LINE,
       text_table TYPE g_text_t,
       modi TYPE i,
       g_number(8).


 

TABLES: stxh.
PARAMETERS  p_carrid TYPE sflight-carrid OBLIGATORY.


 

START-OF-SELECTION.


 


  CALL SCREEN 100.


 


*---------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  IF init IS INITIAL.
    init = 'X'.
    CREATE OBJECT container
       EXPORTING container_name = 'TEXTEDIT'.


 

    create object editor
       EXPORTING parent = container
*       wordwrap_mode = cl_gui_textedit=>wordwrap_OFF
*       wordwrap_to_linebreak_mode = 0
*       wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
*       WORDWRAP_POSITION = 10.
.
*
*    CALL METHOD editor->set_toolbar_mode
*    EXPORTING
*      toolbar_mode = cl_gui_textedit=>false.
*
*  CALL METHOD editor->set_statusbar_mode
*    EXPORTING
*      statusbar_mode = cl_gui_textedit=>false.


 

 


 

    g_header-tdobject = 'ZSFLIGHT'.
    g_header-tdid     = 'Z01'.
    g_header-tdspras = sy-langu.


 


    SELECT SINGLE tdname INTO g_header-tdname
    FROM zcarrlt
    WHERE carrid = p_carrid.
    IF sy-subrc EQ 0.
      PERFORM read_text.
    ELSE.
      PERFORM text_init.
    ENDIF.


 

  ENDIF.


 

ENDMODULE.                    "status_0100 OUTPUT


 

*---------------------------------------------------------------------*
*  MODULE cancel INPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE cancel INPUT.


 

  CALL METHOD container->free.
  CALL METHOD editor->free.
  LEAVE PROGRAM.
ENDMODULE.                    "cancel INPUT


 

*---------------------------------------------------------------------*
*  MODULE user_command_0100 INPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'SAVE'.
      PERFORM save_text.
      PERFORM save_table.


 

    WHEN OTHERS.
      MESSAGE i888(sabapdocu) WITH text-002.
      CALL METHOD cl_gui_cfw=>dispatch.      "for application events
      MESSAGE i888(sabapdocu) WITH text-003.
  ENDCASE.
  SET SCREEN 100.
ENDMODULE.                    "user_command_0100 INPUT
*&---------------------------------------------------------------------*
*&      Form  READ_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM read_text .
  DATA : l_lines  TYPE tline.
  SELECT SINGLE * FROM stxh INTO stxh
            WHERE tdobject = g_header-tdobject
              AND tdname   = g_header-tdname
              AND tdid     = g_header-tdid
              AND tdspras  = sy-langu.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      client   = sy-mandt
      id       = g_header-tdid
      language = sy-langu
      name     = g_header-tdname
      object   = g_header-tdobject
    IMPORTING
      header   = g_header
    TABLES
      lines    = g_lines.


 

*
  LOOP AT g_lines INTO l_lines.


 

    l_lines-tdformat = '*'.
    REPLACE '*' WITH '' INTO l_lines-tdline.
    MODIFY g_lines FROM l_lines.
  ENDLOOP.


 

  IF NOT g_lines[] IS INITIAL.


 

    CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
      TABLES
        itf_text    = g_lines
        text_stream = text_table.
*
  CALL METHOD editor->set_selected_text_as_R3TABLE
      EXPORTING
        TABLE = text_table.


 


*    CALL METHOD editor->set_selected_text_as_stream
*      EXPORTING
*        selected_text = text_table.


 

    CALL METHOD editor->set_selection_indexes
      EXPORTING
        from_index = 1
        to_index   = 1.


 

 


 

  ENDIF.
ENDFORM.                    " READ_TEXT
*&---------------------------------------------------------------------*
*&      Form  TEXT_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM text_init .
  CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
      nr_range_nr             = '01'
      object                  = 'ZABAP'
      subobject               = p_carrid "'AA'
      quantity                = '1'
    IMPORTING
      number                  = g_number
    EXCEPTIONS
      interval_not_found      = 1
      number_range_not_intern = 2
      object_not_found        = 3
      quantity_is_0           = 4
      quantity_is_not_1       = 5
      interval_overflow       = 6
      buffer_overflow         = 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.
    EXIT.
  ENDIF.


 


  CONCATENATE g_header-tdobject g_header-tdid g_number
              INTO g_header-tdname.


 


  CALL FUNCTION 'INIT_TEXT'
    EXPORTING
      id       = g_header-tdid
      language = sy-langu
      name     = g_header-tdname
      object   = g_header-tdobject
    IMPORTING
      header   = g_header
    TABLES
      lines    = g_lines.
  IF sy-subrc <> 0.
    RAISE no_text_init.
  ENDIF.
ENDFORM.                    " TEXT_INIT
*&---------------------------------------------------------------------*
*&      Form  SAVE_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM save_text .
  CHECK editor IS NOT INITIAL.


 

data  g_table(256) TYPE c OCCURS 0.


 

  CALL METHOD editor->get_text_as_stream
    IMPORTING
      text                   = text_table
      is_modified            = modi
    EXCEPTIONS
      error_dp               = 1
      error_cntl_call_method = 2
      OTHERS                 = 3.


 


*  CALL METHOD editor->get_selected_text_as_r3table
*    IMPORTING
*      table = g_table.


 


*  CALL METHOD editor->get_selected_text_as_stream
*    IMPORTING
*      selected_text = text_table.


 


  IF NOT text_table[] IS INITIAL.
    g_lines[] = text_table[].
    CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
      TABLES
        text_stream = text_table
        itf_text    = g_lines.
*
    CALL FUNCTION 'SAVE_TEXT'
         EXPORTING
              header    = g_header
*              INSERT    = 'X'
         IMPORTING
              newheader = g_header
         TABLES
              lines     = g_lines
         EXCEPTIONS
              id        = 1
              language  = 2
              name      = 3
              object    = 4
              OTHERS    = 5.
  ENDIF.
  IF sy-subrc NE 0.
*MESSAGE e001  WITH 'Error occurred when saving'.
    EXIT.
  ENDIF.


 

ENDFORM.                    " SAVE_TEXT
*&---------------------------------------------------------------------*
*&      Form  SAVE_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM save_table .
  DATA : ls_tab LIKE zcarrlt.


 

  ls_tab-carrid = p_carrid.
  ls_tab-tdname = g_header-tdname.


 

  MODIFY  zcarrlt  FROM ls_tab.


 

  IF sy-subrc EQ 0.
    COMMIT WORK.
  ENDIF.


 

ENDFORM.                    " SAVE_TABLE

번호 제목 글쓴이 날짜 조회 수
671 직원 데이터 [1] file sapjoy 2024.07.02 241
670 REPORT Z99_24. sapjoy 2024.05.21 83
669 REPORT Z06_01. sapjoy 2024.04.21 60
668 REPORT  z05_36 sapjoy 2023.02.08 270
667 API sapjoy 2022.11.03 351
666  z15_21_drag sapjoy 2022.02.24 307
665 Z18_06_DRAGCLASS sapjoy 2022.02.23 334
664 REPORT Z21_01 sapjoy 2015.10.28 2276
663 subroutine pool sapjoy 2013.11.16 3314
662 REPORT Z20_01. sapjoy 2012.08.02 5097
» REPORT Z19_02. sapjoy 2012.08.02 3953
660 REPORT z19_01. sapjoy 2012.08.02 3559
659 REPORT z18_06. sapjoy 2012.08.02 3195
658 REPORT z18_05 sapjoy 2012.08.02 3384
657 REPORT z18_04 . sapjoy 2012.08.02 3388
656 REPORT z18_03. sapjoy 2012.08.02 4598
655 REPORT z18_02. sapjoy 2012.08.02 3124
654 REPORT z18_01. sapjoy 2012.08.02 3152
653 REPORT z17_23 sapjoy 2012.08.02 2538
652 REPORT z17_22 sapjoy 2012.08.02 2307