Skip to Content

Data Retraction from BW to ECC CO-PA

Hello all,

We would like to retract planned data from BW to ECC CO-PA, for the planned primary costs and planned statistical key figures, activity output, prices and quantities. We are not interested in SAP delivered retractors, SEM-BPS because our planning model is available in BW-IP. For the custom retraction we found the following approach, please see below the steps that we defined to be performed:

Step 1: Reading planned data from the InfoProvider

The first step of the program will be reading planned primary costs for the following InfoObjects: 0WBS_ELEMT (WBS Elements), 0COSTCENTER (Cost Centers), 0COORDER (Internal Orders) and 0ABCPROCESS (Business Process) from a Real-Time InfoCube . The Standard SAP function module RSDRI_INFOPROV_READ will be used for reading planned data:

REPORT Primary Cost
Retraction.
TYPE-POOLS: rs, rsdrc.
TYPES:
BEGIN OF gt_s_data,
0WBS_ELEMT TYPE /BI0/OIWBS_ELEMT,
0COSTCENTER TYPE
/BI0/OICOSTCENTER,
0COORDER TYPE
/BI0/OICOORDER,
0ABCPROCESS TYPE
/BI0/OIABCPROCESS,
0version TYPE
/bi0/oiversion,
0fiscyear TYPE /bi0/oifiscyear,
xtype(6) TYPE c,
0vtype TYPE /bi0/oivtype,
0amount TYPE bapicurr_d,
coa_curr(5) TYPE c,
obj_curr(5) TYPE c,
0currency TYPE /bi0/oicurrency,
0curtype TYPE /bi0/oicurtype,
0fiscvarnt TYPE /bi0/oifiscvarnt,
END OF gt_s_data.
TYPES: 
BEGIN OF gtype_s_values_pr,
0WBS_ELEMT TYPE /BI0/OIWBS_ELEMT,
0COSTCENTER TYPE
/BI0/OICOSTCENTER
0COORDER TYPE
/BI0/OICOORDER,
0ABCPROCESS TYPE
/BI0/OIABCPROCESS,
0version TYPE
/bi0/oiversion,
0fiscyear TYPE /bi0/oifiscyear,
xtype(6) TYPE n,
0vtype TYPE /bi0/oivtype,
0amount TYPE bapicurr_d,
0quantity TYPE mbgxxx,
coa_curr(5) TYPE c,
obj_curr(5) TYPE c,
0currency TYPE /bi0/oicurrency,
0curtype TYPE /bi0/oicurtype,
0fiscvarnt TYPE /bi0/oifiscvarnt,
END OF gtype_s_values_pr.
DATA : l_data TYPE
gt_s_data.
DATA : it_final TYPE STANDARD TABLE OF gtype_s_values_pr
WITH HEADER LINE.
DATA:
g_s_data TYPE gt_s_data,
* G_T_DATA = an internal
table that can hold the result set
g_t_data TYPE STANDARD
TABLE OF gt_s_data
WITH DEFAULT KEY INITIAL SIZE 10,
* G_S_SFC = description of
a characteristic or navigational attribute
* that is requested by a query
g_s_sfc TYPE rsdri_s_sfc,
g_th_sfc TYPE rsdri_th_sfc,
* G_S_SFK = description of
a key figure that is requested by a query
g_s_sfk TYPE rsdri_s_sfk,
g_th_sfk TYPE rsdri_th_sfk,
* G_S_RANGE = description
of a restriction on a characteristic or
* navigational attribute
g_s_range TYPE rsdri_s_range,
g_t_range TYPE rsdri_t_range.
* For the following
characteristics / navigational attributes values
* should be returned:
* 0VTYPE, 0CURRENCY, 0FISCVARNT, 0FISCYEAR, 0VERSION, 0WBS_ELEMT, 0COSTCENTER, 0COORDER,
0ABCPROCESS.
CLEAR g_th_sfc.
* 0VTYPE
CLEAR g_s_sfc.
* --- name of characteristic
g_s_sfc-chanm = '0VTYPE'.
* --- name of corresponding column in G_T_DATA
g_s_sfc-chaalias = '0VTYPE'.
* --- no ORDER-BY
g_s_sfc-orderby = 0.
* --- include into list of characteristics
INSERT g_s_sfc INTO TABLE g_th_sfc.
* 0CURRENCY
CLEAR g_s_sfc.
g_s_sfc-chanm = '0CURRENCY'.
g_s_sfc-chaalias = '0CURRENCY'.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
* 0CURTYPE
CLEAR g_s_sfc.
g_s_sfc-chanm = '0CURTYPE'.
g_s_sfc-chaalias = '0CURTYPE'.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*'0FISCVARNT'
CLEAR g_s_sfc.
g_s_sfc-chanm = '0FISCVARNT'.
g_s_sfc-chaalias = '0FISCVARNT'.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE
g_th_sfc.
ClEAR g_s_sfc.
g_s_sfc-chanm = '0FISCYEAR'.
g_s_sfc-chaalias = '0FISCYEAR'.
*g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*0VERSION
CLEARg_s_sfc.
g_s_sfc-chanm = '0VERSION'.
g_s_sfc-chaalias = '0VERSION'.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*0WBS_ELEMT
CLEAR g_s_sfc.
g_s_sfc-chanm = '0WBS_ELEMT'.
g_s_sfc-chaalias = '0WBS_ELEMT'.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*0COSTCENTER
CLEAR g_s_sfc.
g_s_sfc-chanm = '0COSTCENTER’.
g_s_sfc-chaalias = '0COSTCENTER.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*0COORDER
CLEAR g_s_sfc.
g_s_sfc-chanm = '0COORDER’.
g_s_sfc-chaalias = '0COORDER’.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
*0ABCPROCESS
CLEAR g_s_sfc.
g_s_sfc-chanm = '0ABCPROCESS '.
g__sfc-chaalias = '0ABCPROCESS '.
g_s_sfc-orderby = 0.
INSERT g_s_sfc INTO TABLE g_th_sfc.
* For the following Key
Figure should be returned: 0AMOUNT and 0QUANTITY.
CLEAR g_th_sfk.
* 0AMOUNT
CLEAR g_s_sfk.
* --- name of key figure
g_s_sfk-kyfnm = '0AMOUNT'.
* --- name of corresponding column in G_T_DATA
g_s_sfk-kyfalias = '0AMOUNT'.
* --- aggregation
g_s_sfk-aggr = 'SUM'.
* --- include into list of key figures
* 0QUANTITY
CLEAR g_s_sfk.
* --- name of key figure
g_s_sfk-kyfnm = '0QUANTITY '.
* --- name of corresponding column in G_T_DATA
g_s_sfk-kyfalias = '0QUANTITY '.
* --- aggregation
g_s_sfk-aggr = 'SUM'.
INSERT g_s_sfk INTO TABLE
g_th_sfk.
CALL FUNCTION
'RSDRI_INFOPROV_READ'
EXPORTING
i_infoprov = ' ZCIN_R01 '
i_th_sfc = g_th_sfc
i_th_sfk = g_th_sfk
i_t_range = g_t_range
i_reference_date = sy-datum
i_save_in_table = rs_c_false
i_save_in_file = rs_c_false
i_packagesize = p_packsi
i_authority_check = rsdrc_c_authchk-read
IMPORTING
e_t_data = g_t_data
e_end_of_data = g_end_of_data
CHANGING
c_first_call = g_first_call
EXCEPTIONS
illegal_input = 1
illegal_input_sfc = 2
illegal_input_sfk = 3
illegal_input_range = 4
illegal_input_tablesel = 5
no_authorization = 6
illegal_download = 8
illegal_tablename = 9
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE e398(00) WITH
'Problem on FM RSDRI_INFOPROV_READ - Subrc = '
sy-subrc
' - TREATMENT STOPED'.
ENDIF.
PERFORM wbs_retraction.
CLEAR : g_t_data.
FREE : g_t_data.
CLEAR : l_data.
FREE : l_data.
ENDWHILE.
1.      Returning selected planned
data to ECC
In the second step of the
program the standard structure (AISEM_PR_VAL) and function (AIS1_PUSHBACK_PR_VAL)
will be used for returning data to ECC.
FORM Retraction.
DATA: l_ecc_dest TYPE
rslogsysdest-destination.
CONSTANTS: ecc_dest(10)
TYPE c VALUE 'Sender Source System to be
specified'.
DATA : id_rfcdest TYPE
rfcdest,
id_sgtext TYPE upb_ci_itemtext.
DATA: lt_return
TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
DATA : ld_msg_text(200)
TYPE c.
LOOP AT g_t_data INTO
l_data.
MOVE-CORRESPONDING l_data
TO it_final.
IF sy-subrc = 0.
APPEND it_final.
ENDIF.
SELECT SINGLE destination
INTO l_ecc_dest
FROM rslogsysdest
WhERE destination = ecc_dest.
* WHERE logsys = ecc_dest.
IF sy-subrc = 0.
*-----------------------------------------------------------------

* Push back plan values on appropriation requests.

*-----------------------------------------------------------------
* destination id_rfcdest

*** RFC-Call: Write Values.
CALL FUNCTION 'AIS1_PUSHBACK_PR_VAL'
DESTINATION l_ecc_dest
EXPORTING
id_line_item_text = id_sgtext
id_post_as_budget = 'X'
* ID_POST_AS_SUP_RET = ' '
* ID_TEST_RUN = ' '
* ID_DEBUG_FLG = ' '
TABLES
it_ranges = g_t_range[]
c_values_pr = it_final[]
et_return = lt_return[]
ExCEPTIONS
communication_failure = 1 MESSAGE ld_msg_text
system_failure = 2 MESSAGE ld_msg_text
error_occured = 10
OTHERS = 11.
LOOP AT lt_return.
WRITE : 'Message type' ,
lt_return-type , 'Message ID' , lt_return-id , 'Message number' ,
lt_return-number.
WRITE :/ lt_return-message , lt_return-message_v1.
WRITE :/ lt_return-message_v2 , lt_return-message_v3.
SKIP 2.
IF lt_return-type = 'E' OR
lt_return-type = 'X' OR lt_return-type = 'A'.
MESSAGE e002(zretraction) WITH 'problem in the retraction please check the
spool'.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. 
     
Preparation steps before executing the program:
Before executing the program,
any yellow request must be closed that are used for ready input queries or
workbooks.
The below program should be
developed for this purpose:
PARAMETERS : lic_cube LIKE
rsapoadm-infocube.
CALL FUNCTION 'RSAPO_CLOSE_TRANS_REQUEST'
  EXPORTING 
I_INFOCUBE              
= lic_cube
EXCEPTIONS  
ILLEGAL_INPUT           
= 1
   REQUEST_NOT_CLOSED       = 2 
OTHERS                  
= 3.
 

Step 2: Returning selected planned data to ECC

In the second step of the program the standard structure (AISEM_PR_VAL) and function (AIS1_PUSHBACK_PR_VAL) will be used for returning data to ECC.

Step 3: Preparation steps before executing the program:

Before executing the program, any yellow request must be closed that are used for ready input queries or workbooks.

Step 4: Automation of the retraction process

To automate the retraction process, a process chain will be created. First step of the process chain should include the program for closing the yellow requests from the InfoProvider followed by the program which executes the retraction process.

Please let us know if the above scenario is feasible, we would like to test it in the POC phase, or if you have used any other approaches for custom retraction?

Thank you in advance,

Cristina

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Feb 08, 2019 at 11:45 AM

    Sounds feasible, but it looks like you're using very old SAP systems... also, if you have the process chain close the plan request, shouldn't you reopen a new one at the end?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.