作者 idan lian 如需转载备注出处如果对你有帮助,请点赞收藏~~~ 用途:创建程序,跑BPC包,把数据从BW应用层跑到BPC,程序可放到处理链或自动作业中,实现定时跑包。 1.步骤首先需要BPC顾问创建一个他们手动执行的包,维护好相关的参数 在BW系统参考标准程序直接copy后面的代码出来,一些变量需要替换,需要替换的在下面的程序里标黄 可以打断点debug,参考程序 UJD_TEST_PACKAGE 里面有需要的变量 也可以直接看一下BPC是不是在这个程序创建了变式,变式里选值可以copy出来 |
如原始PROMPT
%InforProvide%#ZCPBPC0001##%SELECTION%#<?xml version="1.0" encoding="utf-16"?><Selections xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Selection Type="Selection"><Attribute><ID>ZTIME</ID><Operator>1</Operator><LowValue>2023.01</LowValue><HighValue /></Attribute></Selection><Selection Type="FieldList"><FieldID>0DATAPAKID</FieldID><FieldID>0INFOPROV</FieldID><FieldID>0RECORD</FieldID><FieldID>0RECORDMODE</FieldID><FieldID>0RECORDTP</FieldID><FieldID>0REQTSN</FieldID><FieldID>ZACCOUNT</FieldID><FieldID>ZAUD_RAIL</FieldID><FieldID>ZCATEGORY</FieldID><FieldID>ZENTITY</FieldID><FieldID>ZFLOW</FieldID><FieldID>ZINTERCO</FieldID><FieldID>ZMISC</FieldID><FieldID>ZOBJECT</FieldID><FieldID>ZPROJECT</FieldID><FieldID>ZRPT_CURR</FieldID><FieldID>ZSCOPE</FieldID><FieldID>ZSUBJECT</FieldID><FieldID>ZTIME</FieldID><FieldID>ZTYPE</FieldID></Selection></Selections>
2.程序
*&---------------------------------------------------------------------*
*& Report ZBWR_BPC_ZCPBPC0001
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZBWR_BPC_ZCPBPC0001.
DATA : USER TYPE UJ_USER_ID, " 执行包用户
LO_PACKAGE TYPE REF TO CL_UJD_PACKAGE,
LT_CONSTANT TYPE UJD_TH_VALUE,
LO_PACKAGE_CONTEXT TYPE REF TO CL_UJD_PACKAGE_CONTEXT,
LV_RSPC_LOGID TYPE RSPC_LOGID,
PACKAGE1 TYPE UJ_PACKAGE_ID, "执行包 通用模型
TEAM TYPE UJ_TEAM_ID, "团队
GROUP TYPE UJ_PACK_GRP_ID, "组,包所在的组(默认都是COPM )
SCHEDULE TYPE UJ_STRING,
PROMPT TYPE STRING, "执行包的条件
LT_PROMPT TYPE STRING_TABLE,
IF_MSG TYPE UJ_BOOL, "默认N
LTH_ANSWER_PROMPT TYPE UJD_TH_VALUE,
LS_ANSWER_PROMPT LIKE LINE OF LTH_ANSWER_PROMPT,
L_ERRORMSG TYPE UJ_STRING,
L_OX TYPE REF TO CX_ROOT,
LT_MESSAGE TYPE UJ0_T_MESSAGE,
LS_SCHEDULE_INFO TYPE UJD_S_SCHEDULE_INFO,
LS_SCHEDULE_INFO2 TYPE UJD_S_SCHEDULE_INFO2,
LF_SCHEDULE TYPE UJ_FLG,
LF_DEBUG TYPE UJ_FLG,
LV_FISCYEARPE TYPE ZEL_ZDATE,
L_TIME TYPE CHAR32.
“BPC报表取数日期”
SELECT SINGLE ZDATE FROM ZBWT_REPORT_DATE INTO LV_FISCYEARPE.
* IF LV_FISCYEARPE IS NOT INITIAL.
L_TIME = LV_FISCYEARPE+0(4) && '.' && LV_FISCYEARPE+4(2).
USER = SY-UNAME.
CREATE OBJECT LO_PACKAGE.
CREATE OBJECT LO_PACKAGE_CONTEXT.
PACKAGE1 = 'S_01'."Package ID
GROUP = 'YH_CONSOLIDATION'."Package group ID
SCHEDULE = '<SCHEDULING><IMMEDIATE>Y</IMMEDIATE><STATE>0</STATE><PERIOD>N</PERIOD></SCHEDULING>'."SCHEDULE
CONCATENATE
'%InforProvide%' CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB 'ZCPBPC0001'"CP名称
CL_ABAP_CHAR_UTILITIES=>CR_LF
'%SELECTION%' CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
"PROMPT,太长了得换行,从变式里面 点值可以copy出来
'<?xml version="1.0" encoding="utf-16"?>'
'<Selections xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
'<Selection Type="Selection">'
'<Attribute><ID>ZTIME</ID><Operator>1</Operator><LowValue>' L_TIME '</LowValue><HighValue /></Attribute></Selection>'
'<Selection Type="FieldList">'
'<FieldID>0DATAPAKID</FieldID>'
'<FieldID>0INFOPROV</FieldID>'
'<FieldID>0RECORD</FieldID>'
'<FieldID>0RECORDMODE</FieldID>'
'<FieldID>0RECORDTP</FieldID>'
'<FieldID>0REQTSN</FieldID>'
'<FieldID>ZACCOUNT</FieldID>'
'<FieldID>ZAUD_RAIL</FieldID>'
'<FieldID>ZCATEGORY</FieldID>'
'<FieldID>ZENTITY</FieldID>'
'<FieldID>ZFLOW</FieldID>'
'<FieldID>ZINTERCO</FieldID>'
'<FieldID>ZMISC</FieldID>'
'<FieldID>ZOBJECT</FieldID>'
'<FieldID>ZPROJECT</FieldID>'
'<FieldID>ZRPT_CURR</FieldID>'
'<FieldID>ZSCOPE</FieldID>'
'<FieldID>ZSUBJECT</FieldID>'
'<FieldID>ZTIME</FieldID>'
'<FieldID>ZTYPE</FieldID>'
'</Selection></Selections>'
INTO PROMPT.
SPLIT PROMPT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE LT_PROMPT.
* SPLIT l_prompt AT cl_abap_char_utilities=>cr_lf INTO TABLE lt_prompt.
"end frp270312
LOOP AT LT_PROMPT ASSIGNING FIELD-SYMBOL(<LS_PROMPT>).
SPLIT <LS_PROMPT> AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO LS_ANSWER_PROMPT-FIELDNAME LS_ANSWER_PROMPT-VALUE.
INSERT LS_ANSWER_PROMPT INTO TABLE LTH_ANSWER_PROMPT.
ENDLOOP.
TRY.
CL_UJD_SCHEDULE_PARSE=>PARSE_7X_FORMAT( EXPORTING I_SCHEDULE_STR = SCHEDULE
IMPORTING ES_SCHEDULE_INFO = LS_SCHEDULE_INFO
ES_SCHEDULE_INFO_NEW = LS_SCHEDULE_INFO2 ).
IF LS_SCHEDULE_INFO-IFIMMEDIATE = UJ00_CS_BOOL-YES.
LF_SCHEDULE = ABAP_FALSE.
ELSE.
LF_SCHEDULE = ABAP_TRUE.
LS_SCHEDULE_INFO2-MODULE_ID = UJD0_CS_MODULE_ID-PACKAGE.
ENDIF.
CREATE OBJECT LO_PACKAGE.
CALL METHOD LO_PACKAGE->RUN_PACKAGE
EXPORTING
I_APPSET_ID = 'YH_BPC' "Environment
I_APPL_ID = 'Consolidation' "Model ID
I_TEAM_ID = TEAM
I_GROUP_ID = GROUP
I_PACKAGE_ID = PACKAGE1
ITH_ANSWER_PROMPT = LTH_ANSWER_PROMPT
IS_SCHEDULE_INFO = LS_SCHEDULE_INFO2
IF_SCHEDULE = LF_SCHEDULE
IF_DEBUG = 'X'.
"Begin XUQIA 19122017 Note 2579937
CL_UJA_ACTVTY_MGR=>RECORD_LOGON_ACTIVITY(
EXPORTING
I_APPSET_ID = ' YH_BPC '"Environment
I_ACTIVITY = CL_UJA_ACTVTY_MGR=>GC_ACT_REPORT_UJD_TEST_PACKAGE ).
"End XUQIA 19122017 Note 2579937
****************************************************************************************
***************************************************************************************************
CATCH CX_ROOT INTO L_OX. "#EC CATCH_ALL
CALL FUNCTION 'UJ0_CONV_EX2MSG'
EXPORTING
IO_EXCEPTION = L_OX
IMPORTING
ET_MESSAGE_LINES = LT_MESSAGE.
CALL FUNCTION 'UJ0_CONV_MSG2STR'
EXPORTING
IT_MSG = LT_MESSAGE
IMPORTING
E_STR = L_ERRORMSG.
CALL FUNCTION 'DB_ROLLBACK'.
MESSAGE '清包失败!' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDTRY.
以上为上数包程序,清数同理,让BPC顾问建一个清数包即可,参照以上创建清数程序。
将程序放到处理链或设置定时job即可。