cancel
Showing results for 
Search instead for 
Did you mean: 

Exit Function

former_member192125
Participant
0 Kudos

Hi, I am converting FOX code to ABAP code. I am trying to read a Price from one cube (based on key fields) and updating a total field in another cube (material row based on the key fields). The xth_data table is populated with the material fields but the price row is not populated in the xth_data table. Does anyone how to fix this? Thanks in advance,

Finbarr

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member192125
Participant
0 Kudos

Cheers All,

Thanks very much for all the help.

The problem was: I was restricting the reference data being entered byt my planning level selection. I had to set some of them to # and this enabled the data to entered into xth_data.

Again,

thanks all.

former_member192125
Participant
0 Kudos

Hi,

I am trying to read reference data in an exit function by using the init function and passing in, the relevant characteristic combinations. However, the reference row is not being returned. When i debug the code before the init function runs, the reference row is not contained in the xth_data table either.

how do i get the reference row into my main exit function?

any help would be much appreciated.

thanks,

ilen

Former Member
0 Kudos

Brendan,

You need to do like you say and read the reference data in the init function specifying the particular characteristic combinations that you do in your FOX.

I am including some code below demonstrating how to read some reference data using BPS classes.

  • Start code snippet

data:

lr_plarat type ref to cl_sem_planarea_attributes,

lr_chalev type ref to if_sem_chalev,

lr_kyflev type ref to if_sem_kyflev,

lr_chasel_ref type ref to if_sem_chasel,

lr_chasel type ref to if_sem_chasel,

lto_chasel_ref type upc_yto_chasel,

lr_ref_data type ref to if_sem_data,

l_ref type ref to data.

field-symbols:

<lth_refdata> type hashed table.

  • class and types for the data we are selecting

lr_plarat =

cl_sem_planarea_attributes=>get_instance( i_area ).

lr_kyflev = lr_plarat->r_factory->create_kyflev( ito_kyf ).

lr_chalev =

lr_plarat->r_factory->create_chalev( ito_cha ).

lto_chasel_ref = ito_chasel.

*****************************************

*Modify the values for lto_chasel_ref so that it is *specific to the characteristic combinations that are *specified in your fox statement to retrieve your price.

*PRICE = {ZCONDPERC,#,#,#,#,#,CURSEQ,CURCOND,#,ZBPSPR01}.

***************************************************

lr_chasel_ref =

lr_plarat->r_factory->create_chasel( lto_chasel_ref ).

lr_ref_data = lr_plarat->r_factory->create_data(

ir_chalev = lr_chalev

ir_chasel = lr_chasel_ref

ir_kyflev = lr_kyflev ).

  • read db table

call method lr_ref_data->read

exporting

i_enqmode = ' '

exceptions

foreign_lock = 4.

  • Create and assign a data type to hold our reference data

create data l_ref type (lr_plarat->typename_th_data).

assign l_ref->* to <lth_refdata>.

  • Get the data

call method lr_ref_data->get_data

exporting

ir_chasel = lr_chasel_ref

importing

eth_data = <lth_refdata>.

  • End code snippet

Brendan, you need to make sure you are specifying EXACTLY the same characteristic combinations that you do within the FOX...

Hope this helps,

Cheers,

Scott

Former Member
0 Kudos

Passing the data in the init function doesn't help as long as it isn't contained in the planning level. Check your planning level functions to see if you don't exclude the reference data.

Even if you include them in the init package be aware that the records will then come in two different calls of the exit function.

Best regards

Dirk

Former Member
0 Kudos

Hello All,

One more comment...

Reference data is brought in from outside the planning level restrictions in FOX functions. The data is specified distinctly and read from outside the level (You can see the multiple reads with a trace). When using a Planning Function type Exit, you can mimic this feature by specifying distinctly the characteristic values in a read in the init function and saving the reference data to a global variable / table in the Function Group once. You can then in each Function Module call reference that global variable / table.

Something to remember is that you cannot generate data outside the characteristic combinations specified within the Planning level however you can use this reference data for calculations.

Cheers,

Scott

former_member192125
Participant
0 Kudos

Hi,

I was told that reference data is not automatically pulled into an exit function. you need to program the exit function or init function to read the reference data.

Does anyone know how to do this?

An example would be great.

Any help would be much appreciated

Regards,

Former Member
0 Kudos

From the FOX documentation at

http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm

BEGIN OF QUOTE

For the formula calculation, the values of the characteristic that you are using for addressing are not restricted to the values in the package.

This is how formula Plan = 1.15 * actual, for example, works even if the package is restricted to data of type Plan, data of type Actual is read automatically too.

END OF QUOTE

So I guess that PRICE is not available in your planning package. FOX is smart enough to read the data anyway, the Exit function does not read it (because it doesn't know what you need in the exit).

Best regards

Dirk

former_member192125
Participant
0 Kudos

Hi,

I am using the Exit Functions instead of Fox functions.

The xth_data contains all the transactional data but in this case, the Price row is not being populated.

Here is the fox code which does this..

DATA BUS TYPE 0BUS_AREA.

*DATA CST TYPE 0CUST_SALES.

DATA MAT TYPE 0MAT_SALES.

DATA PLN TYPE 0PLANT.

DATA RTO TYPE 0ROUTE.

DATA SLO TYPE 0SALES_OFF.

DATA SEQ TYPE ZACCSEQNC.

*DATA ADJ TYPE ZADJTYPE.

DATA CND TYPE ZCONDTYPE.

DATA FSW TYPE ZFISCWEEK.

*DATA SHP TYPE ZSHIPSALE.

DATA VOLAREA TYPE AREA____.

DATA VALAREA TYPE AREA____.

DATA CURSORG TYPE 0SALESORG.

DATA CURSEQ TYPE ZACCSEQNC.

DATA CURCOND TYPE ZCONDTYPE.

DATA DCH TYPE 0DISTR_CHAN.

DATA KFN TYPE KEYFIGURE_NAME.

DATA TVAL TYPE F.

DATA RVAL TYPE F.

DATA PRICE TYPE F.

  • Current Access Sequence Number, Condition Type, key Fig.

CURSEQ = 20.

CURCOND = 'ZREM'.

KFN = '0G_AVV208'.

  • Current Sales Organization

CURSORG = VARV(ZSALORGN).

IF CURSORG = 'CHIL'.

  • PLANNING AREAS : 'ZBPSVO02', 'ZBPSVA02'

VOLAREA = 'ZBPSVO02'. VALAREA = 'ZBPSVA02'.

ELSEIF CURSORG = 'DAIR'.

  • PLANNING AREAS : 'ZBPSVO01', 'ZBPSVA01'

VOLAREA = 'ZBPSVO01'. VALAREA = 'ZBPSVA01'.

ENDIF.

PRICE = 0.

  • Calculate Price

BREAK-POINT.

PRICE = {ZCONDPERC,#,#,#,#,#,CURSEQ,CURCOND,#,ZBPSPR01}.

IF PRICE <> 0.

*Proceed if a Condition Record exists

FOREACH

BUS,MAT,PLN,RTO,SLO,CND,FSW,SEQ.

RVAL = 0. TVAL = 0.

  • Calculate reference value

RVAL =

{ZSEMTOTAL,BUS,MAT,PLN,RTO,SLO,#,SEM2,FSW,VALAREA}.

  • Calculate Value

{KFN,BUS,MAT,PLN,RTO,SLO,CURSEQ,CURCOND,FSW,

VALAREA} = (RVAL * PRICE) / 100 .

  • Update Reference Value

{ZSEMTOTAL,BUS,MAT,PLN,RTO,SLO,CURSEQ,CURCOND,FSW,VALAREA}

= RVAL.

ENDFOR.

ENDIF.

Former Member
0 Kudos

I've written lots of exit functions and I never had problems with the populated fields. Here are some ideas:

It seems like you have a multi planning area. The S_CHAS structure of the XTH_DATA contains a field __AREA (or similar, I can't check it now). This contains the original planning area. Check if your data is from the right cube/area.

You also need to check if your planning level contains the key figure PRICE.

If PRICE is a virtual key figure it might not work correctly.

Best regards

Dirk

former_member192125
Participant
0 Kudos

Dirk,

Yes, we are using a multi planning area. When changing from FOX to ABAP (Exit function), does any of the planning area / level have to change to reflect this? It is strange as the FOX function gets the price value but the Exit function does not.

P.S. When the report finishes both functions show he number of records read to be the same. E.g. If you have two material rows, both will show 2 rows read. The only difference is when you use Trace, the FOX shows Price as Reference data but the Exit does not.

Also, Price is not based on an individual customer but set at a high level,irrelevant to customers while the material is based on individual customer.

Any help would be much appreciated.

Finbarr.

Former Member
0 Kudos

Hi,

are you saying, that you're reading and updating InfoCubes using your own abap-programs instead of using the update rules?

I think that what you're trying to do is also possible using the update rules.

regards

Siggi