sap strans 表格

sandong8發表於2023-11-07

<?sap.transform simple?>

<tt:transform xmlns:tt="

<tt:root name="userInf"/>

<tt:template>

<header>

<sid>

<tt:value ref="userInf.sid"/>

</sid>

<pwd>

<tt:value ref= "userInf.pwd"/>

</pwd>

</header>

</tt:template>

</tt:transform>


*&---------------------------------------------------------------------*
*& Report  YSTRANS001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  ystrans002 .

data gv_xml  type string ,
      li_binary_tab   type  standard  table  of char255  with  header  line .


data lv_filename  type string ,
      lv_path  type string ,
      lv_fullpath  type string ,
      lv_user_action  type  i .

data : begin  of it_mara  occurs   0 ,
          matnr  like mara -matnr ,
          laeda  like mara -laeda ,
          maktx  like makt -maktx ,
          end  of it_mara .

select a ~matnr a ~laeda b ~maktx
    into corresponding  fields  of  table it_mara  up  to  50  rows
   from mara  as a inner  join makt  as on a ~matnr  b ~matnr
   where spras  sy -langu .


call transformation ytest0003
  source it_mara  it_mara[]
  result xml gv_xml .

call  function  'CONVERT_STRING_TO_TABLE'
   exporting
    i_string          gv_xml
    i_tabline_length  '255'
   tables
    et_table          li_binary_tab .



concatenate  '財務月度報表' sy -datum  into lv_filename .

call  method cl_gui_frontend_services =>file_save_dialog
   exporting
    default_extension     'xlsx'
    file_filter           cl_gui_frontend_services =>filetype_excel
    default_file_name     lv_filename
   changing
    fullpath              lv_fullpath
    filename              lv_filename
    path                  lv_path
    user_action           lv_user_action
   exceptions
    cntl_error            1
    error_no_gui          2
    not_supported_by_gui  3
     others                4 .

call  function  'GUI_DOWNLOAD'
      exporting
*     BIN_FILESIZE                    =
       filename                         lv_fullpath
       filetype                         'BIN'
        append                           ' '
*     WRITE_FIELD_SEPARATOR           = ' '
*     HEADER                          = '00'
*     TRUNC_TRAILING_BLANKS           = ' '
*     WRITE_LF                        = 'X'
*     COL_SELECT                      = ' '
*     COL_SELECT_MASK                 = ' '
*     DAT_MODE                        = ' '
*     CONFIRM_OVERWRITE               = ' '
*     NO_AUTH_CHECK                   = ' '
*     CODEPAGE                        = ' '
*     IGNORE_CERR                     = ABAP_TRUE
*     REPLACEMENT                     = '#'
*     WRITE_BOM                       = ' '
*     TRUNC_TRAILING_BLANKS_EOL       = 'X'
*     WK1_N_FORMAT                    = ' '
*     WK1_N_SIZE                      = ' '
*     WK1_T_FORMAT                    = ' '
*     WK1_T_SIZE                      = ' '
*     WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
*     SHOW_TRANSFER_STATUS            = ABAP_TRUE
*   IMPORTING
*     FILELENGTH                      =
      tables
       data_tab                         li_binary_tab[]
*     FIELDNAMES                      =
     exceptions
      file_write_error                 1
      no_batch                         2
      gui_refuse_filetransfer          3
      invalid_type                     4
      no_authority                     5
      unknown_error                    6
      header_not_allowed               7
      separator_not_allowed            8
      filesize_not_allowed             9
      header_too_long                  10
      dp_error_create                  11
      dp_error_send                    12
      dp_error_write                   13
      unknown_dp_error                 14
      access_denied                    15
      dp_out_of_memory                 16
      disk_full                        17
      dp_timeout                       18
      file_not_found                   19
      dataprovider_exception           20
      control_flush_error              21
       others                           22
              .

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9522162/viewspace-2993196/,如需轉載,請註明出處,否則將追究法律責任。

相關文章