메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT zsapdoi_001.

sapjoy 2008.12.20 12:41 조회 수 : 3135

report  zsapdoi_001.


type-pools soi.


class: c_oi_errors definition load.
data : control type ref to i_oi_container_control.
data : document type ref to i_oi_document_proxy.
data : errors type ref to i_oi_error occurs 0 with header line.
data : retcode type soi_ret_string.
data : spreadsheet type ref to i_oi_spreadsheet.
data : g_initial type c.
tables: sflight.


data:  ok_code like sy-ucomm,
       save_ok like ok_code.


data:  g_col type i,
       g_row type i.


select-options: s_carrid for sflight-carrid
       no intervals no-extension,
       s_connid for sflight-connid
       no intervals no-extension.


data: gt_sflight like sflight occurs 0 .


start-of-selection.


  select *
         from sflight
         into corresponding fields of table gt_sflight
        where carrid in s_carrid
          and connid in s_connid.


  describe table gt_sflight lines g_row.


  data : fields_table type table of rfc_fields.


  call function 'DP_GET_FIELDS_FROM_TABLE'
    exporting
      tabname = 'SFLIGHT'
    tables
      data    = gt_sflight
      fields  = fields_table.


  describe table fields_table lines g_col.


  call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'STATUS01'.
  set titlebar 'GUITEXT01'.


endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  DOI_CREATE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module doi_create output.


  if g_initial ne 'X'.
    call method c_oi_container_control_creator=>get_container_control
      importing
        control = control
        retcode = retcode.
    call method c_oi_errors=>raise_message
      exporting
        type = 'E'.


    data: container type ref to cl_gui_custom_container.
    create object container
      exporting
        container_name = 'CONTAINER'.


    call method control->init_control
      exporting
        r3_application_name = 'SAP DOI Test'
        inplace_enabled     = 'X'
        parent              = container
      importing
        retcode             = retcode.
    call method c_oi_errors=>raise_message
      exporting
        type = 'E'.


    call method control->get_document_proxy
      exporting
        document_type   = 'Excel.Sheet'
        document_format = 'OLE'
      importing
        document_proxy  = document
        retcode         = retcode.
    call method c_oi_errors=>raise_message
      exporting
        type = 'E'.



    call method document->open_document
      exporting
        document_url  = 'FILE://C:DOI_001.xls'
        open_inplace  = 'X'
        open_readonly = ' '
      importing
        retcode       = retcode.
    call method c_oi_errors=>raise_message
      exporting
        type = 'E'.



    data: has type i.



    call method document->has_spreadsheet_interface
      importing
        is_available = has.
    retcode      = retcode.
    call method c_oi_errors=>raise_message
      exporting
        type = 'E'.


    if not has is initial.
      call method document->get_spreadsheet_interface
        importing
          sheet_interface = spreadsheet.
      retcode         = retcode.


      call method c_oi_errors=>raise_message
        exporting
          type = 'E'.
    endif.
    g_initial = 'X'.
  endif.


  call method spreadsheet->insert_range_dim
    exporting
      name    = 'sflight'
      top     = 1
      left    = 1
      rows    = g_row
      columns = g_col
    importing
      retcode = retcode.


  call method c_oi_errors=>raise_message
    exporting
      type = 'E'.


  call method spreadsheet->set_selection
    exporting
      left    = 1
      top     = 1
      rows    = g_row
      columns = g_col
    importing
      retcode = retcode.


  call method c_oi_errors=>raise_message
    exporting
      type = 'E'.


 



  call method spreadsheet->insert_one_table
    exporting
      rangename    = 'sflight'
      data_table   = gt_sflight
      fields_table = fields_table
      wholetable   = 'X'
    importing
      retcode      = retcode.


  call method c_oi_errors=>raise_message
    exporting
      type = 'E'.



endmodule.                 " DOI_CREATE  OUTPUT


*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module exit input.
  case ok_code.
    when 'EXIT'.


      leave to screen 0.
      if not document is initial.
        call method document->close_document.
        free document.
      endif.


      if not control is initial.
        call method control->destroy_control.
        free control.
      endif.


  endcase.


endmodule.                 " EXIT  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  save_ok = ok_code.
  clear: ok_code.
  case save_ok.
    when 'SAVE'.
      perform save_excel_to_sap.
    when 'INSERT'.
      g_row = g_row + 1.
    when 'DELETE'.
      g_row = g_row - 1.
  endcase.


endmodule.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  SAVE_EXCEL_2_SAP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form save_excel_to_sap .



  data : lt_sflight    like sflight occurs 0 with header line.
  data : ranges         type soi_range_list,
         range_item     type soi_range_item.
  data : contents       type soi_generic_table,
         generic_item   type soi_generic_item.



  refresh: contents, ranges.
  range_item-name = 'sflight'.
  append range_item to ranges.


  data : table type soi_cell_table.



  call method spreadsheet->get_ranges_data
    exporting
      all      = ' '
      no_flush = 'X'
    importing
      contents = contents
    changing
      ranges   = ranges.
  call method c_oi_errors=>raise_message
    exporting
      type = 'E'.



  loop at contents into generic_item.
    if generic_item-column is initial.
      continue.
    endif.
    case generic_item-column .
      when '1'.
        lt_sflight-mandt      = generic_item-value.
      when '2'.
        lt_sflight-carrid     = generic_item-value.
      when '3'.
        lt_sflight-connid     = generic_item-value.
      when '4'.
        lt_sflight-fldate     = generic_item-value.
      when '5'.
        lt_sflight-price      = generic_item-value.
      when '6'.
        lt_sflight-currency   = generic_item-value.
      when '7'.
        lt_sflight-planetype  = generic_item-value.
      when '8'.
        lt_sflight-seatsmax   = generic_item-value.
      when '9'.
        lt_sflight-seatsocc   = generic_item-value.
      when '10'.
        lt_sflight-paymentsum = generic_item-value.
      when '11'.
        lt_sflight-seatsmax_b = generic_item-value.
      when '12'.
        lt_sflight-seatsocc_b = generic_item-value.
      when '13'.
        lt_sflight-seatsmax_f = generic_item-value.
      when '14'.
        lt_sflight-seatsocc_f = generic_item-value.
    endcase.


    at end of row .
      append lt_sflight. clear lt_sflight.
    endat.


  endloop.


  refresh contents.



endform.                    " SAVE_EXCEL_TO_SAP

번호 제목 글쓴이 날짜 조회 수
649 <b>ABAP SOURCE는 교재에 사용된 소스들입니다.</b> [1] sapjoy 2006.12.02 3618
648 REPORT z19_01. sapjoy 2012.08.01 3526
647 z_exception_test sapjoy 2010.10.10 3520
646 report zsalv_036 . sapjoy 2010.08.20 3472
645 REPORT ZSMARTFORMS_03. sapjoy 2008.11.28 3345
644 REPORT z18_04 . sapjoy 2012.08.01 3344
643 REPORT z18_05 sapjoy 2012.08.01 3328
642 Sub DOI_EXCEL_MACRO() sapjoy 2008.12.26 3312
641 REPORT z18_003 sapjoy 2007.03.05 3281
640 subroutine pool sapjoy 2013.11.15 3273
639 REPORT z19_004 sapjoy 2007.03.27 3230
638 REPORT Z_WHEREUSEDLIST [4] sapjoy 2011.03.28 3215
637 REPORT ZALVCOLOR sapjoy 2010.10.09 3212
636 REPORT ZSAPTIP_002. sapjoy 2009.02.20 3206
635 zsalv_edit [1] sapjoy 2010.08.20 3205
634 REPORT Z06_001 MESSAGE-ID ZTEST . [1] sapjoy 2006.12.05 3205
633 REPORT z18_06. sapjoy 2012.08.01 3147
» REPORT zsapdoi_001. [2] sapjoy 2008.12.20 3135
631 report zsalv_042 . sapjoy 2010.08.20 3132
630 REPORT z18_01. sapjoy 2012.08.01 3108