CRM_ORDER_MAINTAIN 修改订单简单示例
2015-09-01 08:40
459 查看
转载来自SCN:
This blog will show you how to UPDATE an order in CRM using ABAP.
I’ve tried to make this as simple as possible but while including the most important (useful) information.
In this example I will only update the orderadm and opport (opportunity) tables.
include crm_object_names_con.
data:
lt_opport_h type crmt_opport_h_comt,
ls_opport_h type line of crmt_opport_h_comt,
lt_orderadm_h type crmt_orderadm_h_comt,
ls_orderadm_h type crmt_orderadm_h_com,
*Other important things
lt_input_fields type crmt_input_field_tab,
ls_input_fields type crmt_input_field,
lt_nametab type crmt_input_field_names_tab,
ls_nametab type crmt_input_field_names,
lt_save_guid type crmt_object_guid_tab,
ls_save_guid type crmt_object_guid,
lt_saved_objects type crmt_return_objects,
ls_saved_objects type crmt_return_objects_struc,
lv_lin type i,
lv_order_object_id type crmt_object_id,
lv_order_object_guid type crmt_object_guid32.
* 1. Update the description of the opportunity
clear: ls_nametab, lt_nametab[],
ls_input_fields.
ls_orderadm_h-description = ‘this is the new description’.
ls_nametab = 'DESCRIPTION'.
append ls_nametab to lt_nametab.
*** for help on how to change a CHAR32 to a RAW16 see my CRM_ORDER_READ blog ***
ls_orderadm_h-guid = ‘this is the GUID type RAW16’.
append ls_orderadm_h to lt_orderadm_h.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-ref_guid = ‘this is the GUID again, in RAW16’.
ls_input_fields-objectname = 'ORDERADM_H'.
ls_input_fields-field_names[] = lt_nametab[].
insert ls_input_fields into table lt_input_fields.
* 2. Update the opportunity data in opport_h table – update the current phase and end date
clear: ls_nametab, lt_nametab[], ls_input_fields.
ls_opport_h-curr_phase = ‘code for new sales stage’.
ls_nametab = 'CURR_PHASE'.
append ls_nametab to lt_nametab.
ls_opport_h-expect_end = ‘new date for expected end date’.
ls_nametab = 'EXPECT_END'.
append ls_nametab to lt_nametab.
ls_opport_h-ref_guid = ‘this is the GUID again, in RAW16’.
append ls_opport_h to lt_opport_h.
ls_input_fields-ref_guid = ‘this is the GUID again, in RAW16’.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'OPPORT_H'.
ls_input_fields-field_names[] = lt_nametab[].
insert ls_input_fields into table lt_input_fields.
* 3. DONE, call CRM_ORDER_MAINTAIN on this information
call function 'CRM_ORDER_MAINTAIN'
exporting
it_opport_h = lt_opport_h
importing
et_exception = lt_exception1
changing
ct_orderadm_h = lt_orderadm_h
ct_input_fields = lt_input_fields
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
case sy-subrc.
when 0.
ls_save_guid = iv_guid.
append ls_save_guid to lt_save_guid.
endcase.
* 4. SAVE the changes (all updates must be saved and committed before they change in CRM)
call function 'CRM_ORDER_SAVE'
exporting
it_objects_to_save = lt_save_guid
importing
et_saved_objects = lt_saved_objects
exceptions
document_not_saved = 1
others = 2.
case sy-subrc.
when '0'.
clear lv_lin.
describe table lt_saved_objects lines lv_lin.
if lv_lin = 1.
read table lt_saved_objects into ls_saved_objects index 1.
lv_order_object_guid = ls_saved_objects-guid.
lv_order_object_id = ls_saved_objects-object_id.
* 5. Call the function to COMMIT the changes to CRM.
call function 'BAPI_TRANSACTION_COMMIT'.
endif.
endcase.
*DONE, your opportunity has now been updated.
This blog will show you how to UPDATE an order in CRM using ABAP.
I’ve tried to make this as simple as possible but while including the most important (useful) information.
In this example I will only update the orderadm and opport (opportunity) tables.
include crm_object_names_con.
data:
lt_opport_h type crmt_opport_h_comt,
ls_opport_h type line of crmt_opport_h_comt,
lt_orderadm_h type crmt_orderadm_h_comt,
ls_orderadm_h type crmt_orderadm_h_com,
*Other important things
lt_input_fields type crmt_input_field_tab,
ls_input_fields type crmt_input_field,
lt_nametab type crmt_input_field_names_tab,
ls_nametab type crmt_input_field_names,
lt_save_guid type crmt_object_guid_tab,
ls_save_guid type crmt_object_guid,
lt_saved_objects type crmt_return_objects,
ls_saved_objects type crmt_return_objects_struc,
lv_lin type i,
lv_order_object_id type crmt_object_id,
lv_order_object_guid type crmt_object_guid32.
* 1. Update the description of the opportunity
clear: ls_nametab, lt_nametab[],
ls_input_fields.
ls_orderadm_h-description = ‘this is the new description’.
ls_nametab = 'DESCRIPTION'.
append ls_nametab to lt_nametab.
*** for help on how to change a CHAR32 to a RAW16 see my CRM_ORDER_READ blog ***
ls_orderadm_h-guid = ‘this is the GUID type RAW16’.
append ls_orderadm_h to lt_orderadm_h.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-ref_guid = ‘this is the GUID again, in RAW16’.
ls_input_fields-objectname = 'ORDERADM_H'.
ls_input_fields-field_names[] = lt_nametab[].
insert ls_input_fields into table lt_input_fields.
* 2. Update the opportunity data in opport_h table – update the current phase and end date
clear: ls_nametab, lt_nametab[], ls_input_fields.
ls_opport_h-curr_phase = ‘code for new sales stage’.
ls_nametab = 'CURR_PHASE'.
append ls_nametab to lt_nametab.
ls_opport_h-expect_end = ‘new date for expected end date’.
ls_nametab = 'EXPECT_END'.
append ls_nametab to lt_nametab.
ls_opport_h-ref_guid = ‘this is the GUID again, in RAW16’.
append ls_opport_h to lt_opport_h.
ls_input_fields-ref_guid = ‘this is the GUID again, in RAW16’.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'OPPORT_H'.
ls_input_fields-field_names[] = lt_nametab[].
insert ls_input_fields into table lt_input_fields.
* 3. DONE, call CRM_ORDER_MAINTAIN on this information
call function 'CRM_ORDER_MAINTAIN'
exporting
it_opport_h = lt_opport_h
importing
et_exception = lt_exception1
changing
ct_orderadm_h = lt_orderadm_h
ct_input_fields = lt_input_fields
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
case sy-subrc.
when 0.
ls_save_guid = iv_guid.
append ls_save_guid to lt_save_guid.
endcase.
* 4. SAVE the changes (all updates must be saved and committed before they change in CRM)
call function 'CRM_ORDER_SAVE'
exporting
it_objects_to_save = lt_save_guid
importing
et_saved_objects = lt_saved_objects
exceptions
document_not_saved = 1
others = 2.
case sy-subrc.
when '0'.
clear lv_lin.
describe table lt_saved_objects lines lv_lin.
if lv_lin = 1.
read table lt_saved_objects into ls_saved_objects index 1.
lv_order_object_guid = ls_saved_objects-guid.
lv_order_object_id = ls_saved_objects-object_id.
* 5. Call the function to COMMIT the changes to CRM.
call function 'BAPI_TRANSACTION_COMMIT'.
endif.
endcase.
*DONE, your opportunity has now been updated.
相关文章推荐
- CRM_ORDER_MAINTAIN 创建订单简单示例
- epoll源码实现分析[整理] http://blog.csdn.net/fengwen168168/article/details/48103009
- Epoll实现原理解析 http://blog.csdn.net/wangxiaoqin00007/article/details/14450021
- epoll_create函数实现源码分析 http://blog.csdn.net/lmh12506/article/details/7556188
- poll&&epoll实现分析(二)——epoll实现 http://blog.csdn.net/fengwen168168/article/details/48091599
- poll&&epoll实现分析(一)—poll实现 http://blog.csdn.net/fengwen168168/article/details/48091793
- 根文件系统的构建与分析(一)之流程分析 http://blog.csdn.net/jianchi88/article/details/7682901
- Linux--根文件系统的挂载过程分析 http://blog.csdn.net/guopeixin/article/details/5962482
- [LeetCode#263]Factorial Trailing Zeroes
- [LeetCode#204]Factorial Trailing Zeroes
- xml解析及编译汇总 valgrind检测内存泄露 http://blog.csdn.net/lifan5/article/details/8030285
- Drainage Ditches 最大流入门练习题,各种算法
- ld: library not found for -lAFNetworking clang: error: linker command failed with exit code 1 (use -
- [LeetCode#172]Factorial Trailing Zeroes
- 【转】使用AIDL实现进程间的通信之复杂类型传递
- 错误 1 error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
- HDU 1702 ACboy needs your help again!(模拟 队列 栈)
- 浅谈raid各个级别的特性
- 博客8:RAID阵列的实现
- RAII