zoukankan      html  css  js  c++  java
  • 使用代码修改SAP CRM附件的属性

    In our CRM social integration project we extract the picture of one tweet from twitter website and store them in CRM system as attachment.

    We are creating attachment in CRM via the approach described in this blog.

    However, we found the Create by property for an attachment is always hard coded with sy-uname, even we explicitly specify the created_by property when calling
    cl_crm_documents=>create_with_table. However our requirement is it should be filled by the screen name in twitter website who posts the tweet.


    After some debugging I found the created_by property could only be modified after the attachment is created.
    First I query all attachments of a given tweet:

    DATA(ls) = VALUE SIBFLPORB( INSTID = iv_guid typeid = iv_bor_type catid = 'BO' ). 
    
    CALL METHOD CL_CRM_DOCUMENTS=>get_info
      EXPORTING
         BUSINESS_OBJECT = ls
      IMPORTING
         LOIOS = LOIOS
         phios = phios.
    

    Then I use FM SDOK_PHIO_PROPERTIES_SET to change the property:

    DATA(ls_property) = VALUE SDOKPROPTY( name = iv_attr_name value = iv_new_value ).
    
    APPEND ls_property TO lt_properties.
    
    LOOP AT phios ASSIGNING FIELD-SYMBOL(<ios>).
      ls_header-class = <ios>-class.
      ls_header-objid = <ios>-objid.
      CALL FUNCTION 'SDOK_PHIO_PROPERTIES_SET'
        EXPORTING
          object_id = ls_header
        TABLES
          properties = lt_properties
        EXCEPTIONS
          NOT_EXISTING = 1
          BAD_PROPERTIES = 2
          NOT_AUTHORIZED = 3
          EXCEPTION_IN_EXIT = 4.
    ENDLOOP.
    

    I have put the code into a utility class and test it:

    And that’s done:

    Never forget to activate internal mode, or else you will fail with an error message that created_by field is read only.

    要获取更多Jerry的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    c语言中的隐式函数声明(转)
    static关键字
    Eclipse中spring项目的XML文件的问题
    spring 中c3p0的优化配置
    Mysql通过SQL脚本复制表
    tomcat 设置内存
    删除无限循环的文件夹-删除递归文件夹
    使用cnpm代替npm
    数据库框架的log4j日志配置
    Win7删除远程连接历史记录
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13447605.html
Copyright © 2011-2022 走看看