For a complete list of all my blogs regarding content management, please see here.
I create a utility class with method CREATE_DOC. It has following four input parameters:
- iv_data type xstring – the binary data which you would like to store as attachment
- iv_bor_type type string – the BOR type of your business object. You can view view business object model in tcode SWO1
- iv_guid type raw16 – the guid of your business object instance
- iv_file_name type string – the file name which will appear in attachment assignment block.
The source code of method below: ( in fact all attributes for an attachment could be available in the input parameters of this method. For simplicity reason I just hard code them in the sample code )
DATA:ls_bo TYPE sibflporb,
ls_prop TYPE LINE OF sdokproptys,
lt_prop TYPE sdokproptys,
lt_properties_attr TYPE crmt_attr_name_value_t,
ls_file_info TYPE sdokfilaci,
lt_file_info TYPE sdokfilacis,
lt_file_content TYPE sdokcntbins,
lv_length TYPE i,
lv_file_xstring TYPE xstring,
ls_loio TYPE skwf_io,
ls_phio TYPE skwf_io,
ls_error TYPE skwf_error.
ls_prop-name = 'DESCRIPTION'.
ls_prop-value = 'created by Tool'. " replace it with your own description for attachment
APPEND ls_prop TO lt_prop.
ls_prop-name = 'KW_RELATIVE_URL'.
ls_prop-value = iv_file_name. " in the sample code I just reuse file name as relative url
APPEND ls_prop TO lt_prop.
ls_prop-name = 'LANGUAGE'.
ls_prop-value = sy-langu.
APPEND ls_prop TO lt_prop.
lv_file_xstring = iv_data.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_file_xstring
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_file_content.
ls_file_info-binary_flg = 'X'.
ls_file_info-file_name = iv_file_name.
ls_file_info-file_size = lv_length.
ls_file_info-mimetype = 'image/jpeg'. "use the correct mime type for your attachment
APPEND ls_file_info TO lt_file_info.
ls_bo-INSTID = iv_guid.
ls_bo-typeid = iv_bor_type.
ls_bo-catid = 'BO'.
CALL METHOD cl_crm_documents=>create_with_table
EXPORTING
business_object = ls_bo
properties = lt_prop
properties_attr = lt_properties_attr
file_access_info = lt_file_info
file_content_binary = lt_file_content
raw_mode = 'X'
IMPORTING
loio = ls_loio
phio = ls_phio
error = ls_error. " evaluate if there is anything wrong during creation
COMMIT WORK.
I write a piece of code to test it. After report runs I could see the generated attachment.
You can also test whether the attachment is created successfully in the backend. Test class method get_info in SE24. Specify importing parameter BUSINESS_OBJECT:
Execute and you should get result as below: one physical object and one logical object according to how-is-attachment-physically-stored-in-database-table-in-cm-framework.
Never forget to call COMMIT WORK in your code, since the persistence of the relationship between attachment and your business object are implemented via generic object service in a update process.You could easily find this via SAT trace on your code
or switch on update debugging in your debugger settings.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
SAP ABAP 代码备份下载到本地程序代码
SAP ABAP Query 是 SAP 系统中一种用于创建自定义报表的强大工具,尤其适合那些对 SQL 不太熟悉或者没有数据库直接访问权限的用户。它提供了丰富的功能,使得开发人员可以构建复杂的数据查询,而无需编写大量的 ABAP...
SAP ABAP(Advanced Business Application Programming)是SAP公司开发的一种编程语言,主要用于在其ERP(企业资源规划)系统中创建和定制业务逻辑。在SAP ABAP 1.4.4版本的代码下载中,我们可以深入探讨这个版本的...
针对这种需求,我们可以利用SAP的ABAP编程环境,通过OLE(Object Linking and Embedding)技术来启动Outlook并发送邮件。以下是实现这一功能的关键知识点: 1. **SAP OLE配置**: 在SAP系统中,首先需要进行OLE...
在 SAP 系统中,开发环境和开发工具是必不可少的组件,开发者可以使用这些工具来创建、测试和部署 ABAP 程序。ABAP WORKBENCH 是 SAP 系统中最常用的开发环境之一,它提供了一个集成的开发环境,包括编辑器、调试器...
SAP HANA will soon celebrate its second birthday. Hard to believe, but this technology has been on the market for almost two years now. During this time, its use potential increased significantly: ...
与SAP ECC(Enterprise Core Component)和SAP BW(Business Warehouse)一样,SAP CRM 是一个独立的产品而非ECC的组成部分。尽管SAP CRM 和 ECC 在某些功能上有重叠,例如CRM 的 SALES 功能类似于ECC 的 SD(Sales ...
SAP ABAP(Advanced Business Application Programming)是SAP公司推出的一种高级业务应用编程语言,用于开发在SAP R/3和SAP NetWeaver平台上的应用程序。这些电子书提供了全面的资源,帮助学习者深入理解并掌握SAP ...
ABAP(Advanced Business Application Programming)是SAP系统中用于开发应用的主要编程语言,而SAP HANA是一款高性能的内存计算平台,能够处理大量实时数据并快速执行复杂分析。 在文件的【描述】中提到,这是SAP...
在SAP ABAP环境中,使用SE11事务代码进行数据库表的创建是常见的数据库管理任务。下面是通过SE11创建自定义表的详细步骤,这些步骤由河南心创明天科技有限公司的专业顾问李彪提供。 首先,打开SAP系统并输入事务...
ABAP(Advanced Business Application Programming)是SAP系统中的主要编程语言,用于开发企业级应用,如业务流程自动化、数据处理和报告等。虽然这份教程为英文版,但其深入浅出的讲解和丰富的实例仍能为中文使用者...
SAP+ ABAP开发实用教程:顾问培训资料,含实例代码和教程,详细描述ABAP开发过程:数据表读法、程序规范、代码实例、调试方法以及ABAP开发环境和总体介绍、 ABAP语法示例 、ALV控件的使用、 实战Form设计 ,分基础、...
标题中的"SAP_ABAP.rar"表明这是一个与SAP ABAP相关的压缩文件,可能包含了关于SAP ABAP开发的文档或代码示例。ERP SAP ABAP指的是SAP企业资源规划系统中的ABAP编程语言,它是SAP系统核心开发的重要工具。"ERP_SAP...
ABAP(Advanced Business Application Programming)是SAP公司推出的一种编程语言,主要用于开发SAP系统中的业务应用程序。SAP系统在全球企业资源规划(ERP)领域有着广泛的应用,而ABAP则是其核心开发语言,使得...
标签"源码"表明内容可能涉及到SAP CRM系统的一些底层代码或者数据结构的实现细节,这对于开发者来说是非常有价值的。"工具"可能指的是用于查询、分析或维护这些CRM表格的实用程序,比如ABAP开发环境、SQL查询工具...
Advanced ABAP Programming for SAP (SAP R/3) (Paperback) by Gareth M. De Bruyn (Author), Robert Lyfareff (Author), Ken Kroes (Author) <br>Editorial Reviews <br>Advanced ABAP Programming for ...
ABAP(Advanced Business Application Programming)是SAP系统的核心编程语言,用于开发SAP应用程序。 面向对象编程是SAP ABAP语言的一个重要组成部分,它允许开发者以更接近现实世界的方式来设计、组织和编写软件...
SAP变式配置-相关性程序...* 实现相关性程序调用ABAP函数需要三个步骤:创建函数输入特性和输出特性、编写ABAP代码、定义自己的功能。 * 使用ABAP语言编写代码,可以实现灵活的业务逻辑和算法,满足不同的行业需求。
ABAP Development for SAP HANA 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
在交易代码PFCG(Role Maintenance)中,你可以创建和编辑角色,然后分配给特定用户。这样,用户通过登录的角色来获取其在系统中的操作权限。 总的来说,SAP权限对象的创建和使用是一个细致且关键的过程,它涉及到...