Chinaunix首页 | 论坛 | 博客
  • 博客访问: 464477
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-09-16 10:43:52


点击(此处)折叠或打开

*&---------------------------------------------------------------------*
*& Report  ZGOS_ATTACHMENT
*&
*&---------------------------------------------------------------------*
*&this program will attach documents to SAP documents.
*&
*&---------------------------------------------------------------------*

report  zgos_attachment.

*Macros.
include .

swc_container lt_message_container.

*top dec.
type-poolsslisabaptruxs.
datag_objid     type borident,
      gt_filename type standard table of dxfilep with header line,
      wa_filename type dxfilep,
      gt_bin      type solix occurs 0,
      wa_bin      type solix,
      g_filename  type string,
      l_obj       type swc_object,
      gs_obja     type borident,
      gs_objb     type borident,
      gs_binrel   type gbinrel,
      gt_binatt   type standard table of brelattr,
      g_attsize   type int4."wsrm_error-wsrm_direction.

selection-screen begin of block b0 with frame title text-001.
parametersp_file  type rlgrap-filename,
            p_vbeln type vbak-vbeln.
selection-screen end of block b0.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN  on                                  *
*----------------------------------------------------------------------*
at selection-screen on p_file.
  if p_file is initial.

  endif.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN  on HELP-REQUEST|VALUE-REQUEST                   *
*----------------------------------------------------------------------*
at selection-screen  on value-request for p_file.
  call function 'F4_FILENAME'
    exporting
      program_name  syst-cprog
      dynpro_number syst-dynnr
      field_name    'P_FILE'
    importing
      file_name     p_file.

start-of-selection.
* this step can be replace to get file from app server as well.
*uploading [file: EXT is TXT].
  move  p_file to g_filename.
  call function 'GUI_UPLOAD'
    exporting
      filename                g_filename
      filetype                'BIN'
    importing
      filelength              g_attsize
    tables
      data_tab                gt_bin
    exceptions
      file_open_error         1
      file_read_error         2
      no_batch                3
      gui_refuse_filetransfer 4
      invalid_type            5
      no_authority            6
      unknown_error           7
      bad_data_format         8
      header_not_allowed      9
      separator_not_allowed   10
      header_too_long         11
      unknown_dp_error        12
      access_denied           13
      dp_out_of_memory        14
      disk_full               15
      dp_timeout              16
      others                  17.
  if sy-subrc <> 0.
  else.
*file Uploaded successfully.
*convert uploaded file contents into BIN format.
    datal_seq type i.
    swc_container      l_cont.
    swc_create_object  l_obj  'MESSAGE'       ''.
    swc_set_element    l_cont 'NO_DIALOG'     'X'.
    swc_set_element    l_cont 'DOCUMENTTITLE' g_filename.
    swc_set_table      l_cont 'Content_Hex'   gt_bin.
    swc_set_element    l_cont 'DOCUMENTTYPE'  'TXT'.
    swc_set_element    l_cont 'DOCUMENTSIZE'  g_attsize.
    swc_refresh_object l_obj.
    swc_call_method    l_obj  'CREATE'        l_cont.
    swc_get_object_key l_obj  gs_objb-objkey.

    gs_objb-objtype 'MESSAGE'.   "type of attach document
    gs_obja-objtype 'BUS2032'.      "BO of SAP Document.
    gs_obja-objkey p_vbeln.
    call function 'BINARY_RELATION_CREATE_COMMIT'
      exporting
        obj_rolea      gs_obja
        obj_roleb      gs_objb
        relationtype   'ATTA'
      importing
        binrel         gs_binrel
      tables
        binrel_attrib  gt_binatt
      exceptions
        no_model       1
        internal_error 2
        unknown        3
        others         4.
    if sy-subrc eq 0.
      message s043(sgos_msg).
    endif.
  endif.




阅读(1491) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~