Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Enhancement for 0PROFIT_CTR_ATTR problem

Dears,

I appened a structure to 0PROFIT_CTR_ATTR, I added a element in this appened structure named ZZPBU(profit center group name). And I enhanced the extraction assisgnment EXIT_SAPLRSAP_002 to get the profit center group name information. Below is the source code.

This enhancement works well in our DEV system, however, doesn't work in QAS system. Also, I test this Datasource in TC:RSA3 in QAS system, it works. However, when I execute an InfoPackage from BW QAS to extract this data, the job in R3 system will be cancelled for system exception. What's going on? Any suggestions are appreciated.

WHEN '0PROFIT_CTR_ATTR'.

DATA: BEGIN OF lw_prctr,

prctr TYPE prctr,

pbu TYPE bapiset_groupname,

sort_ix TYPE i,

END OF lw_prctr,

c_kokrs_cs10 TYPE kokrs VALUE 'CS10',

c_groupname_std_hier TYPE pcgrp VALUE 'STD_HIER',

c_hier_level_pbu TYPE bapiset_level VALUE 3,

lt_prctr LIKE lw_prctr,

lt_hier_nodes LIKE STANDARD TABLE OF bapiset_hier,

lw_hier_node LIKE LINE OF lt_hier_nodes,

lt_hier_values LIKE STANDARD TABLE OF bapi1116_values,

lw_hier_value LIKE LINE OF lt_hier_values,

lw_val_ix TYPE i,

lw_bapi_return LIKE bapiret2.

STATICS: lt_prctrs LIKE HASHED TABLE OF lw_prctr

WITH UNIQUE KEY prctr,

lx_hier_read TYPE flag.

*- Hierarchy not yet read

*--- Read hierarchy and load profit center buffer

CALL FUNCTION 'BAPI_PROFITCENTERGRP_GETDETAIL'

EXPORTING

controllingarea = c_kokrs_cs10

groupname = c_groupname_std_hier

IMPORTING

return = lw_bapi_return

TABLES

hierarchynodes = lt_hier_nodes

hierarchyvalues = lt_hier_values.

IF NOT lw_bapi_return IS INITIAL.

MESSAGE e864(md) WITH 'Error reading profit center hierarchy'

c_groupname_std_hier

'for controlling area'

c_kokrs_cs10.

ENDIF.

LOOP AT lt_hier_nodes INTO lw_hier_node.

IF lw_hier_node-hierlevel EQ c_hier_level_pbu.

*----- Hit a PBU node

*------- Store PBU value for following values

lw_prctr-pbu = lw_hier_node-groupname.

ENDIF.

DO lw_hier_node-valcount TIMES.

*----- Hit a node with values

*------- Process values

ADD 1 TO lw_val_ix.

READ TABLE lt_hier_values INTO lw_hier_value INDEX lw_val_ix.

IF lw_hier_value-valfrom NE lw_hier_value-valto.

*------- Value range

*----


Read actual values from database

SELECT prctr

INTO lw_prctr-prctr

FROM cepc

WHERE prctr BETWEEN lw_hier_value-valfrom

and lw_hier_value-valto

and KOKRS eq C_KOKRS_CS10.

ADD 1 TO lw_prctr-sort_ix.

INSERT lw_prctr INTO TABLE lt_prctrs.

ENDSELECT.

ELSE.

*------- Single value

*----


Just add to table

lw_prctr-prctr = lw_hier_value-valfrom.

ADD 1 TO lw_prctr-sort_ix.

INSERT lw_prctr INTO TABLE lt_prctrs.

ENDIF.

ENDDO. " LW_HIER_NODE-VALCOUNT TIMES

ENDLOOP. " LT_HIER_NODES

CLEAR w_tabix.

LOOP AT i_t_data INTO l_bwec_md_profit_ctr.

w_tabix = sy-tabix.

READ TABLE lt_prctrs INTO lt_prctr

WITH TABLE KEY prctr = l_bwec_md_profit_ctr-prctr.

IF sy-subrc NE 0.

" ERROR

ENDIF.

l_bwec_md_profit_ctr-pbu = lt_prctr-pbu.

MODIFY i_t_data FROM l_bwec_md_profit_ctr INDEX w_tabix.

ENDLOOP.

B.R

Gerald

Former Member
Not what you were looking for? View more on this topic or Ask a question