cancel
Showing results for 
Search instead for 
Did you mean: 

Planning function Exit

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

please use the same principle as explained in []. Instead of modifying the values append a new line to the table.

Hope this helps.

Regards Matthias Nutt

Former Member
0 Kudos

Matthias,

I tried it didn't work out.

Any other ideas to make it work out.

Please somebody look into the code and suggest me if any changes are reuired.

How to define standard internal table to assign Xth_data (Hash table)

itab_data[] = Xth_data[] in this wasy we can assign the two internal tables.

But my question is how to make both structures are same.

Since Xth_data contains all the characterstics and keyfigures of the planning area.

But for me i need to chage only two characterstics compcode and contr area.

I declated internal table like this

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.

and i assigned the itab_data[] = xth_data[]

does this make sense? Since my inernal table contains 2 fields and xth data contains almost 50 fields in <S_chas> and <S-kyf>.

Please help to me sort our this issue.

I gone thorugh the all UPFX function exists and i tried all the ways but nothig is worked.I am struggling to sort out this one.

My requirement is changesing compcode from 0353 to 2083 and contaolling aea from G353 to I083.

In my cube i have got data 107 recored for the comination 0353 and G353.

Please suggest me In my scnario do i need to write Initialization FM or only exit FM is sufficent.

when i execute the repost function its changeing records from lod values to new values.

when i execute the Repost function for same planing level it returns message like

"107 records read, 107 records changed, and 107 recoreds generated"

but i execute the EXit function it returns message like

"107 recoreds read, 107 records changed, o records generated.

So what could be the porbelm with my code in EXit function.

Please look at this code and suggest me if any chnages required.

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.

I would apprecieate if somebody reply this post.

Thanks in advance.

Best regards

Sushma

Former Member
0 Kudos

Please try something like the below mentioned code. I am sorry, I do not have a system a hand right now, so the code below may not work right now. But I think you get the rought idea.


data: ls_data like line of xth_data.

Loop at xth_data into ls_data
where compcode = '0353'
and contrarea = 'G353'.

  ls_data-compcode = '2083'.
  ls_data-contrarea = 'I083'.

  insert ls_data into xth_data.
endloop.

Former Member
0 Kudos

What exactly is the requirement?

Is it changing the company code and controlling area from existing values to new values? or

Is it copying the data from existing to new values?

In the first case, old records will be deleted. In the second case, old records will be retained.

If you want first case, this can be done by repost function which you already tested and it is working fine.

It is giving message as 107 read, 107changed and 107 generated because, repost function read all the records corresponding to this combination of comp code and controlling area, it copied these records to new values so 107 generated, and it creates negative records for the existing data, so 107 changed. If this is the requirement, why do you need to go for exit?

Former Member
0 Kudos

Hi Matthias,

Thanks for your reply.

I tried in this way already, it didn't work out.

I tried with you code also

i got he error message "The field Xth_data specified under like either no type or generic type.

Even i tried in this way like

data: data_ref type ref to data.

create data data_ref like line of xth_data.

assign data_ref->* to <ls_data>.

loop at xth_data assigning <ls_data>.

if <ls_data-S_CHAS-0COMP_CODE> = 0353.

assign component 'S_CHAS' of structure <ls_data> to <s_chas>.

assign component '0COMP_CODE' of structure <s_chas> to <value1>.

<value1> = '2083'.

assign component '0CO_AREA' of structure <s_chas> to <value2>.

<value2> = 'I083'.

endloop.

This once also not working, it goes to short dump and error message is " you are trying to change the protected value"

any other idea

the main problem is i am not declare the one standartd internal table like xth_data.

any other ideas.

thanks in advance.

Best regards

Sushma

Former Member
0 Kudos

Hi Bindu,

Thanks for your reply.

Right now my requirement is

changing the company code and controlling area from existing values to new values

Yes you are right it can done ny repost function also.

later my requirement is going includeing changeing cost centers also and those cost centers are in between 100 to 200.

because of this i am trying to develope the exit function, once i build the exit function i can easliy add my logic to this exit function for cost centers also.

Intial requirement is only changeing company code and contolling area and later i need to change the cost centers also from existing values to new values.

Is there any other way to build the code to achieve this.

send me any sample code if you have.

thanks in advance.

Best regards

Sushma

Former Member
0 Kudos

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>[].

Former Member
0 Kudos

Hi Charles,

Thanks you very much.

The code is working fine.

I assigned full points.

Best regards

Sushma

Answers (0)