zoukankan      html  css  js  c++  java
  • WEB UI 上传URL附件(使用方法备份)

    FUNCTION zcrm_update_atta.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(NOBJECT_ID) TYPE  CRMT_PO_NUMBER_SOLD OPTIONAL
    *"     VALUE(OOBJECT_ID) TYPE  CRMT_OBJECT_ID OPTIONAL
    *"     VALUE(PROCESS_TYPE) TYPE  CRMT_PROCESS_TYPE OPTIONAL
    *"     VALUE(FILENAME) TYPE  STRING OPTIONAL
    *"     VALUE(URL) TYPE  STRING OPTIONAL
    *"     VALUE(RFIELD1) TYPE  STRING OPTIONAL
    *"     VALUE(RFIELD2) TYPE  STRING OPTIONAL
    *"  EXPORTING
    *"     VALUE(MSGINFO) TYPE  STRING
    *"     VALUE(MSGTYPE) TYPE  STRING
    *"  TABLES
    *"      FJ STRUCTURE  ZCRMS0085 OPTIONAL
    *"----------------------------------------------------------------------
      "数据定义
      TYPES:BEGIN OF ty_order,
              guid         TYPE crmt_object_guid,
              object_id    TYPE crmt_object_id,
              process_type TYPE crmt_process_type,
              object_type  TYPE crmt_subobject_category_db,
            END OF ty_order,
            BEGIN OF ty_docu,
              objtypelo TYPE skwf_ioty,
              classlo   TYPE sdok_class,
              objidlo   TYPE sdok_docid,
              objtypeph TYPE skwf_ioty,
              classph   TYPE sdok_class,
              objidph   TYPE sdok_docid,
              value     TYPE sdok_propv,
            END OF ty_docu.
      DATA:gw_order           TYPE ty_order,
           ls_business_object TYPE sibflporb,
           lt_phioloios       TYPE skwf_lpios,
           ls_phioloios       LIKE LINE OF lt_phioloios,
           lt_ios_prop_result TYPE crm_kw_propst,
           ls_ios_prop_result LIKE LINE OF lt_ios_prop_result,
           lt_prop            TYPE sdokproptls,
           ls_prop            TYPE sdokproptl,
           lt_docu            TYPE TABLE OF ty_docu,
           lt_docud           TYPE TABLE OF ty_docu, "要删除的
           ls_docu            LIKE LINE OF lt_docu,
           gt_url             TYPE sdokcntascs,
           gw_url             LIKE LINE OF gt_url,
           gt_prop            TYPE sdokproptys,
           gw_prop            LIKE LINE OF gt_prop,
           gt_dele            TYPE skwf_ios,
           gw_dele            TYPE skwf_io,
           gw_error           TYPE skwf_error,
           gw_fj              TYPE zcrms0085.
    
    
    *  IF FJ[] IS INITIAL.
    *    msgtype = 'E'.
    *    msginfo = 'CRM Attachment is required!'.
    *  ENDIF.
      IF oobject_id IS INITIAL.
        msgtype = 'E'.
        msginfo = 'CRM object id is required!'.
      ELSE.
        IF oobject_id CO '0123456789 '.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = oobject_id
            IMPORTING
              output = gw_order-object_id.
          SELECT SINGLE guid object_id process_type object_type INTO gw_order
            FROM crmd_orderadm_h WHERE object_id = gw_order-object_id AND process_type = process_type.
          IF sy-subrc <> 0.
            msgtype = 'E'.
            msginfo = 'CRM object id or type is incorrect!'.
          ENDIF.
        ELSE.
          msgtype = 'E'.
          msginfo = 'CRM object id is incorrect!'.
        ENDIF.
      ENDIF.
    
      IF msgtype = 'E'.
        EXIT.
      ENDIF.
    
      "取出工单对应的附件信息
      ls_business_object-instid = gw_order-guid.
      ls_business_object-typeid = gw_order-object_type.
      ls_business_object-catid = 'BO'.
      CALL METHOD cl_crm_documents=>get_info
        EXPORTING
          business_object       = ls_business_object
        IMPORTING
          phioloios             = lt_phioloios
          ios_properties_result = lt_ios_prop_result.
    
      "附件整理到临时表
      LOOP AT lt_phioloios INTO ls_phioloios.
        CLEAR:ls_docu.
        MOVE-CORRESPONDING ls_phioloios TO ls_docu.
    *    READ TABLE lt_ios_prop_result INTO ls_ios_prop_result WITH KEY objtype = ls_phioloios-objtypelo
    *                                                                   class   = ls_phioloios-classlo
    *                                                                   objid   = ls_phioloios-objidlo.
    *    IF sy-subrc = 0.
    *      REFRESH:lt_prop.
    *      lt_prop[] = ls_ios_prop_result-properties[]."属性表
    *      READ TABLE lt_prop INTO ls_prop WITH KEY name = 'KW_RELATIVE_URL'.
    *      IF sy-subrc = 0."不存在的。
    *      ENDIF.
    *      ls_docu-value = ls_prop-value.
    *    ENDIF.
    *    READ TABLE fj INTO gw_fj WITH KEY filename = ls_docu-value.
    *    IF sy-subrc <> 0.
        APPEND ls_docu TO lt_docu."当前文件不在传过来的文件中,需要删除
    *    ELSE.
    *      DELETE fj WHERE filename = ls_docu-value."传过来的文件已经存在,删除传过来的表,这样传过来的表都是不存在的,全部新建
    *    ENDIF.
      ENDLOOP.
      "循环需要删除的表;全部删除
      IF lt_docu[] IS NOT INITIAL.
        REFRESH:gt_dele.
        LOOP AT lt_docu INTO ls_docu.
          gw_dele-objtype = ls_docu-objtypelo.
          gw_dele-class = ls_docu-classlo.
          gw_dele-objid = ls_docu-objidlo.
          APPEND gw_dele TO gt_dele.
          CLEAR:gw_dele.
          gw_dele-objtype = ls_docu-objtypeph.
          gw_dele-class = ls_docu-classph.
          gw_dele-objid = ls_docu-objidph.
          APPEND gw_dele TO gt_dele.
          CLEAR:gw_dele.
        ENDLOOP.
        cl_crm_documents=>delete(
            EXPORTING
              business_object = ls_business_object
              ios             = gt_dele
             IMPORTING
               error           = gw_error ).
        IF gw_error-type = 'E'.
          msgtype = 'E'.
          msginfo = msginfo && ls_docu-value && ':Delete error!'.
          EXIT.
        ELSE.
          msgtype = 'S'.
        ENDIF.
      ENDIF.
    
      "循环附件表,新建批处理。
      IF fj[] IS NOT INITIAL.
        LOOP AT fj INTO gw_fj.
          REFRESH:gt_url,gt_prop.
          gw_url-line = gw_fj-url.
          APPEND gw_url TO gt_url.
          gw_prop-name = 'KW_RELATIVE_URL'. "The name of URL
          gw_prop-value = gw_fj-filename.
          APPEND gw_prop TO gt_prop.
          gw_prop-name = 'CONTENT_URL'.
          gw_prop-value = gw_fj-url.
          APPEND gw_prop TO gt_prop.
          gw_prop-name = 'BDS_KEYWORD'.
          gw_prop-value = 'TVS'.
          APPEND gw_prop TO gt_prop.
          gw_prop-name = 'DESCRIPTION'.
          gw_prop-value = gw_fj-filename.
          APPEND gw_prop TO gt_prop.
    
          cl_crm_documents=>create_url(
            EXPORTING
              url             = gt_url
              properties      = gt_prop
              business_object = ls_business_object
            IMPORTING
              error           = gw_error ).
          IF gw_error-type = 'E'.
            msgtype = 'E'.
            msginfo = msginfo && gw_fj-filename && ':create error!'.
            EXIT.
          ELSE.
            msgtype = 'S'.
          ENDIF.
        ENDLOOP.
      ENDIF.
    
    
    ENDFUNCTION.
  • 相关阅读:
    Redis
    Redis
    Redis
    linux 安装docker
    linux 安装nexus
    linux 安装jenkins
    linux 安装gitlab
    python 类的继承
    python raise & assert
    python super()
  • 原文地址:https://www.cnblogs.com/sapSB/p/10118929.html
Copyright © 2011-2022 走看看