今天,春雨绵绵,公司临时通知因为疫情全部远程办公。新的项目还没启动。
自我学习为主。每天提交学习内容。昨天我们讲到了PS模块的项目创建。
今天我们就学习温故一下PS模块的WBS创建BAPI函数。
前台我们可以使用事务代码TCODE CJ01创建WBS CJ02更改WBS CJ03显示WBS.
批量创建的BAPI函数是BAPI_BUS2054_CREATE_MULTI。
首先,我们看这个函数的使用的时候,需要注意她的导入参数:
参数名称 | 关联类型 | 可选的 | 说明 |
I_PROJECT_DEFINITION | BAPI_BUS2001_NEW-PROJECT_DEFINITION | 必选 | 项目定义 |
还有表参数:
参数名称 | 关联类型 | 可选的 | 说明 |
IT_WBS_ELEMENT | BAPI_BUS2054_NEW | 可选 | 创建WBS元素 |
ET_RETURN | BAPIRET2 | 可选 | 返回参数 |
EXTENSIONIN | BAPIPAREX | 可选 | 增强,扩展字段 |
然后,我们在使用的时候,一定要注意代码的大小写规范化。
注意容错和捕捉成功/失败的消息。有的S4HANA的新语法和ECC或者R3不一样。
自己注意一下哦~
对于初级SAP ABAP顾问来说,是不容易的。
作者曾经也是SAP ABAP beginners ,到处去找Tutorial for Constant。
需要自学很久,没人给咱免费培训。
能够直接使用的示例demo代码如下:
DATA: lv_project TYPE bapi_bus2001_new-project_definition,
lt_wbs_element TYPE TABLE OF bapi_bus2054_new,
lt_extensionin TYPE TABLE OF bapiparex,
lt_return TYPE TABLE OF bapiret2,
lv_desc TYPE bapi_bus2054_new-description,
lv_message TYPE string.
DATA: ls_ci_prps TYPE bapi_te_wbs_element,
lv_str(960) TYPE c.
CHECK iv_project IS NOT INITIAL AND
iv_up_wbs IS NOT INITIAL AND
iv_new_wbs IS NOT INITIAL.
“获取参考WBS信息,iv_up_wbs参考的WBS
SELECT SINGLE *
INTO @DATA(ls_up_prps)
FROM prps
WHERE posid = @iv_up_wbs.
“iv_project 新建WBS对应的项目定义编码
lv_project = iv_project.
“复制WBS信息
lt_wbs_element = VALUE #( (
wbs_element = iv_new_wbs “新建WBS编号
description = |参考新建WBS测试|
responsible_no = ls_up_prps-vernr “负责人编号
applicant_no = ls_up_prps-astnr “申请人号
company_code = ls_up_prps-pbukr ”
business_area = ls_up_prps-pgsbr ”
controlling_area = ls_up_prps-pkokr ”
profit_ctr = ls_up_prps-prctr “利润中心
proj_type = ls_up_prps-prart “项目类型
wbs_planning_element = ls_up_prps-plakz
wbs_account_assignment_element = ls_up_prps-belkz
wbs_billing_element = ls_up_prps-fakkz
cstg_sheet = ls_up_prps-kalsm
overhead_key = ls_up_prps-zschl
res_anal_key = ls_up_prps-abgsl
request_cctr_controlling_area = ls_up_prps-akokr
request_cctr = ls_up_prps-akstl
respsbl_cctr_controlling_area = ls_up_prps-fkokr
respsbl_cctr = ls_up_prps-fkstl
calendar = ls_up_prps-fabkl
priority = ls_up_prps-pspri
equipment = ls_up_prps-equnr
funct_loc = ls_up_prps-tplnr
currency = ls_up_prps-pwpos
plant = ls_up_prps-werks
user_field_key = ls_up_prps-slwid
user_field_char20_1 = ls_up_prps-usr00
user_field_char20_2 = ls_up_prps-usr01
user_field_char10_1 = ls_up_prps-usr02
user_field_char10_2 = ls_up_prps-usr03
user_field_quan1 = ls_up_prps-usr04
user_field_unit1 = ls_up_prps-use04
user_field_quan2 = ls_up_prps-usr05
user_field_unit2 = ls_up_prps-use05
user_field_curr1 = ls_up_prps-usr06
user_field_cuky1 = ls_up_prps-use06
user_field_curr2 = ls_up_prps-usr07
user_field_cuky2 = ls_up_prps-use07
user_field_date1 = ls_up_prps-usr08
user_field_date2 = ls_up_prps-usr09
user_field_flag1 = ls_up_prps-usr10
user_field_flag2 = ls_up_prps-usr11
wbs_cctr_posted_actual = ls_up_prps-kostl
wbs_summarization = ls_up_prps-clasf
objectclass = |PROFT|
statistical = ls_up_prps-xstat
wbs_basic_start_date = sy-datum
wbs_basic_finish_date = sy-datum
wbs_left = iv_left_wbs
“父层WBS
wbs_up = iv_up_wbs ) ).
“附加字段增强,扩展标准结构CI_PRPS
ls_ci_prps-wbs_element = iv_new_wbs.
lv_str = ls_ci_prps.
lt_extensionin = VALUE #( ( structure = |BAPI_TE_WBS_ELEMENT|
valuepart1 = lv_str+0(240)
valuepart2 = lv_str+240(240)
valuepart3 = lv_str+480(240)
valuepart4 = lv_str+720(240) ) ).
CALL FUNCTION ‘BAPI_PS_INITIALIZATION’.
CALL FUNCTION ‘BAPI_BUS2054_CREATE_MULTI’
EXPORTING
i_project_definition = lv_project
TABLES
it_wbs_element = lt_wbs_element
et_return = lt_return
extensionin = lt_extensionin
.
LOOP AT lt_return INTO DATA(ls_return) WHERE type CA ‘AEX’.
IF lv_message IS INITIAL.
lv_message = ls_return-message.
ELSE.
lv_message = |{ lv_message }/{ ls_return-message }|.
ENDIF.
ENDLOOP.
IF lv_message IS INITIAL.
CALL FUNCTION ‘BAPI_PS_PRECOMMIT’.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
ENDIF.
编码时,特别注意事项:
- 调用BAPI:BAPI_BUS2054_CREATE_MULTI之前必须先调用BAPI:BAPI_PS_INITIALIZATION。
- 调用BAPI:BAPI_BUS2054_CREATE_MULTI执行成功之后,不能直接调用BAPI: BAPI_TRANSACTION_COMMIT,会导致DUMP,应该先调用BAPI:BAPI_PS_PRECOMMIT
- 创建WBS的时候,注意参数 wbs_left和 wbs_up,这个是创建有层级的WBS必须要填写的。
本文链接 : http://www.hot583.com/2022/03/31/bapi-create-wbs/
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
我的微信公众号【hot583】 或者在这个链接联系我
微信原文《全文完》