Skip to Content

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

Planning function Exit

Hi Friends,

let me explain my requirement.

At the moment I need to change the company code from 0353 to 2083 and contolling area form G353 to I083 (Later i need to change the cost centers also). Right now i am developeing the Exit functionfor changeing company code and controlling area.

I developed the code in the Exit FM like

FUNCTION Z_CONVERSION_EXIT.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA

*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL

*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE

*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD

*" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM

*" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA

*" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF

*" EXPORTING

*" REFERENCE(ET_MSG) TYPE UPC_YT_MESG

*" CHANGING

*" REFERENCE(XTH_DATA) TYPE HASHED TABLE

*"----


data : begin of itab_data occurs 0,

compcode like /BI0/PCOMP_CODE-COMP_CODE,

contrarea like /BI0/PCO_AREA-CO_AREA,

end of itab_data.

itab_data[] = xth_data[].

Loop at itab_data where compcode = '0353' and contrarea = 'G353'.

itab_data-compcode = '2083'.

itab_data-contrarea = 'I083'.

modify itab_data.

endloop.

refresh itab_data.

xth_data[] = itab_data[].

ENDFUNCTION.

When i execute the planning function i got message like

107 data records were read, 107 of them were changed, 0 generated

it is reading the records from cube and changeing the recored also but not generating record.

As with SAP:

Using a function module for initialization is useful if you not only want to change data records with the exit function, but also want to create new ones. Initialization then makes sure that the key of the new data records to be created is transferred to the main function module via a parameter designated for this. This ensures that this function module is processed in any case, even if no data records exist yet.

I created another Exit FM with Init

i didn't write any code in the Init FM.

FUNCTION Z_CONVERSION_INIT.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA

*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL

*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE

*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD

*" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM

*" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA

*" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF

*" EXPORTING

*" REFERENCE(ET_MESG) TYPE UPC_YT_MESG

*" REFERENCE(ETO_CHAS) TYPE ANY TABLE

*"----


ENDFUNCTION.

I selected fields to be changed two characteristics comopany code and contalloing area in the Planning function.

Please suggest me how to proceed further to generate the new records

do i need add some code in the Init FM also.

do i need to pass any parametrs in the planning function.

Please share ur ideas on this.

Please share with me if you have any sample code.

Thanks in advance

Best regards

SS

replied

The thing to keep in mind is that you are not really changing the characteristic values from one company to another. What you will do is create a new record with all of the characteritic values the same as the old record except for the ones that you want to change. Then setting the keyfigures of the old record to 0. What you will see in listcube is a new record with the reverse image for those records that you set to 0, and new records for the ones you create where company code is changed. You can use field symbols to address the characteristics you want to change and the key figures. You can try doing something like the following except for changing the fields to your needs:

data: lr_xdata type ref to cl_sem_planarea_attributes,

lt_xdata type ref to data,

ls_xdata type ref to data.

field-symbols: <xacttype> type /bi0/oiacttype,

<xcostctr> type /bi0/oicostcenter,

<xcostelmnt> type /bi0/oicostelmnt,

<xcoarea> type /bi0/oico_area,

<xcurr> type /bi0/oicurrency,

<xempgrp> type /bi0/oiemplgroup,

<xfiscper> type /bi0/oifiscper,

<xfiscper3> type /bi0/oifiscper3,

<xfiscvarnt> type /bi0/oifiscvarnt,

<xfiscyear> type /bi0/oifiscyear,

<xunit> type /bi0/oiunit,

<xvers> type /bi0/oiversion,

<xarea> type UPC_Y_AREA,

<xamt> type /bi0/oiamount,

<xcap> type /bi0/oiact_capact,

<xqty> type /bi0/oiquantity,

<area> type UPC_Y_AREA,

<charng> type UPC_YT_CHARNG,

<lth_data> type hashed table,

<t_xdata> type hashed table,

<xdata> type any,

<xchas> type any,

<xkey> type any,

<chas> type any,

<key> type any.

*set up work area for existing planning data

call method cl_sem_planarea_attributes=>get_instance

EXPORTING

i_area = i_area

RECEIVING

er_instance = lr_xdata.

  • create a table like xth_data

create data lt_xdata type (lr_xdata->typename_th_data).

assign lt_xdata->* to <t_xdata>.

clear: <t_xdata>.

*create a work area

create data ls_xdata type (lr_xdata->typename_s_data).

assign ls_xdata->* to <xdata>.

assign component 'S_CHAS' of structure <xdata> to <xchas>.

assign component 'S_KYFS' of structure <xdata> to <xkey>.

assign component '0ACTTYPE' of structure <xchas> to <xacttype>.

assign component '0COSTCENTER' of structure <xchas> to <xcostctr>.

assign component '0COSTELMNT' of structure <xchas> to <xcostelmnt>.

assign component '0CO_AREA' of structure <xchas> to <xcoarea>.

assign component '0CURRENCY' of structure <xchas> to <xcurr>.

assign component '0EMPLGROUP' of structure <xchas> to <xempgrp>.

assign component '0FISCPER' of structure <xchas> to <xfiscper>.

assign component '0FISCPER3' of structure <xchas> to <xfiscper3>.

assign component '0FISCVARNT' of structure <xchas> to <xfiscvarnt>.

assign component '0FISCYEAR' of structure <xchas> to <xfiscyear>.

assign component '0UNIT' of structure <xchas> to <xunit>.

assign component '0VERSION' of structure <xchas> to <xvers>.

assign component '_AREA_____' of structure <xchas> to <xarea>.

assign component '0AMOUNT' of structure <xkey> to <xamt>.

assign component '0QUANTITY' of structure <xkey> to <xqty>.

assign component '0ACT_CAPACT' of structure <xkey> to <xcap>.

loop at xth_data into <xdata>.

  • change key figure values to 0

<xamt> = 0.

<xqty> = 0.

collect <xdata> into <t_xdata>.

endloop.

loop at xth_data into <xdata>.

*change characteristics

if <xcostctr> = '1000'.

<xcostctr> = '2000'.

endif.

collect <xdata> into <t_xdata>.

endloop.

xth_data[] = <t_xdata>[].

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question