使用代码修改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的原创文章,请关注公众号"汪子熙":
- 计蒜客:百度的科学计算器(简单)【python神解】
- 关关的刷题日记12——Leetcode 189. Rotate Array 方法1、2、3
- 关关的刷题日记13——Leetcode 414. Third Maximum Number
- 关关的刷题日记14——Leetcode 167. Two Sum II - Input array is sorted
- 51Nod 1083 矩阵取数问题(矩阵取数dp,基础题)
- 【专知-关关的刷题日记15】Leetcode 27. Remove Element 方法1、2、3
- [接口测试 - 基础篇] 07 来来来,一起读写excel玩玩之一
- 时间序列分析算法【R详解】
- 【专知-关关的刷题日记16】Leetcode 88. Merge Sorted Array
- [接口测试 - 基础篇] 06 好吧也来解析下html
- [接口测试 - 基础篇] 05 好讨厌的xml解析
- 【专知-关关的刷题日记17】Leetcode 268. Missing Number
- 【专知-关关的刷题日记18】Leetcode 35. Search Insert Position
- [接口测试 - http.client篇] 15 常用API说明及基本的示例
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法