cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Transformation Routine:Using Attribute Value from Characteristic

Former Member
0 Likes
1,830

Hello Xperts,

I have the following issue for which I'm looking for some help.

I have an infoobject PROMOTION. One of the attributes is DISCOUNT.

Transactional data passes through the promotionID.

Now when updating to the InfoCube I need to have access to the DISCOUNT (Master Data from PROMOTION) attribute in my transformation. I need this to compute NETPROFIT for example. It should be possible because I have the PROMOTIONID.

Question: how can I access this attribute value in the transformation?

I need it in the startroutine, since I need to do calculations to compute other characteristics.

Thx for the input!

ps I've read the SDN pdf about routines & transformations

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

you can access this from the P table of the InfoObject. You neeed to write an ABAP routine.

Else if all others to calculate are available for reporting, then you can calculate netprofit in the reporting itself.

You have some How to guide to calculate from key figures which are attributes.

Hope this gives you some clues.....

Answers (2)

Answers (2)

Former Member
0 Likes

Hi,

Sample code:

TYPES: BEGIN OF type3.

INCLUDE STRUCTURE /BI0/PPROMOTION.

TYPES END OF type3.

DATA:

ITAB3 TYPE STANDARD TABLE OF TYPE3

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

SELECT * FROM /BI0/PPROMOTION INTO CORRESPONDING FIELDS OF TABLE ITAB3 WHERE OBJVERS = 'A'.

LOOP AT DATA_PACKAGE.

READ TABLE ITAB3 WITH KEY PROMOTION = DATA_PACKAGE-PROMOTION.

IF SY-SUBRC EQ 0.

DATA_PACKAGE-NETPROFIT = DATA_PACKAGE-SALES-ITAB3-DISCOUNT .

ENDIF.

MODIFY DATA_PACKAGE.

ENDLOOP.

With rgds,

Anil Kumar Sharma .P

Former Member
0 Likes

I think your reply is pretty usefull. However it is 3.5 oriented. In 7.0 the code should nbe somehow different.

Any ideas?

PROGRAM trans_routine.

----


  • CLASS routine DEFINITION

----


*

----


CLASS routine DEFINITION.

PUBLIC SECTION.

TYPES:

BEGIN OF tys_SC_1,

  • Field: /BIC/ZCHCUSTMR Customer.

/BIC/ZCHCUSTMR TYPE C LENGTH 10,

  • Field: /BIC/ZCHPRODCT Product.

/BIC/ZCHPRODCT TYPE C LENGTH 18,

  • Field: /BIC/ZCHSHOP Shop.

/BIC/ZCHSHOP TYPE C LENGTH 10,

  • Field: /BIC/ZCHPROMOT Promotion.

/BIC/ZCHPROMOT TYPE C LENGTH 4,

  • Field: /BIC/ZCHPAYMTH Payment Method.

/BIC/ZCHPAYMTH TYPE C LENGTH 4,

  • Field: CALDAY Calendar Day.

CALDAY TYPE D,

  • Field: /BIC/ZKFQUANT Sales Quantity.

/BIC/ZKFQUANT TYPE P LENGTH 9 DECIMALS 3,

  • Field: UNIT Unit of Measure.

UNIT TYPE C LENGTH 3,

  • Field: CURRENCY Currency.

CURRENCY TYPE C LENGTH 5,

  • Field: /BIC/ZKFPURPRC Purchase Price.

/BIC/ZKFPURPRC TYPE P LENGTH 9 DECIMALS 2,

  • Field: /BIC/ZKFSALPRC Sales Price.

/BIC/ZKFSALPRC TYPE P LENGTH 9 DECIMALS 2,

  • Field: RECORD Record Number.

RECORD TYPE RSARECORD,

END OF tys_SC_1.

TYPES:

tyt_SC_1 TYPE STANDARD TABLE OF tys_SC_1

WITH NON-UNIQUE DEFAULT KEY.

PRIVATE SECTION.

TYPE-POOLS: rsd, rstr.

$$ begin of global - insert your declaration only below this line -

... "insert your code here

$$ end of global - insert your declaration only before this line -

METHODS

start_routine

IMPORTING

request type rsrequest

datapackid type rsdatapid

EXPORTING

monitor type rstr_ty_t_monitors

CHANGING

SOURCE_PACKAGE type tyt_SC_1

RAISING

cx_rsrout_abort.

METHODS

inverse_start_routine

IMPORTING

I_R_SELSET_OUTBOUND TYPE REF TO CL_RSMDS_SET

i_th_fields_outbound type hashed table

i_r_universe_inbound TYPE REF TO CL_RSMDS_UNIVERSE

CHANGING

c_r_selset_inbound TYPE REF TO CL_RSMDS_SET

c_th_fields_inbound type hashed table

c_exact type rs_bool.

ENDCLASS. "routine DEFINITION

----


  • CLASS routine IMPLEMENTATION

----


*

----


CLASS routine IMPLEMENTATION.

----


  • Method start_routine

----


  • Calculation of source package via start routine

----


  • <-> source package

----


METHOD start_routine.

*=== Segments ===

FIELD-SYMBOLS:

<SOURCE_FIELDS> TYPE tys_SC_1.

DATA:

MONITOR_REC TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line *-*

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "start_routine

----


  • Method inverse_start_routine

----


*

  • This subroutine needs to be implemented only for direct access

  • (for better performance) and for the Report/Report Interface

  • (drill through).

  • The inverse routine should transform a projection and

  • a selection for the target to a projection and a selection

  • for the source, respectively.

  • If the implementation remains empty all fields are filled and

  • all values are selected.

*

----


*

----


METHOD inverse_start_routine.

$$ begin of inverse routine - insert your code only below this line-

... "insert your code here

$$ end of inverse routine - insert your code only before this line -

ENDMETHOD. "inverse_start_routine

ENDCLASS. "routine IMPLEMENTATION

Former Member
0 Likes

I had never have worked with version 7.0, but i think method start_routine will be equevalent to start routine in 3.5.

With methods you can´t use internal tables with header line then, define a internal table without header line to store result of your select and define aone structure like your table to use it as header line in table operation.

I think you should read datapackid into the field symbols but i'm not sure at all.

Former Member
0 Likes

Hi Jvb,

Start routine is not gonna sovle your problem.

Check this code ...( can try)

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

METHOD start_routine.

*=== Segments ===

FIELD-SYMBOLS:

<SOURCE_FIELDS> TYPE tys_SC_1.

DATA:

MONITOR_REC TYPE rstmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

TYPES: BEGIN OF type3.

INCLUDE STRUCTURE /BI0/ZCHPROMOT.

TYPES END OF type3.

DATA:

ITAB3 TYPE STANDARD TABLE OF TYPE3

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

SELECT * FROM /BI0/ZCHPROMOT INTO CORRESPONDING FIELDS OF TABLE ITAB3 WHERE OBJVERS = 'A'.

LOOP AT SOURCE_PACKAGE.

READ TABLE ITAB3 WITH KEY PROMOTION = SOURCE_PACKAGE-/BI0/ZCHPROMOT.

IF SY-SUBRC EQ 0.

<i><b>SOURCE_PACKAGE-NETPROFIT</b></i> = SOURCE_PACKAGE-SALES-ITAB3-DISCOUNT .

ENDIF.

MODIFY SOURCE_PACKAGE.

ENDLOOP.

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

Y? bcoz SOURCE_PACKAGE contain field coming from Datasource..which doesnot contain...NETPROFIT.

See the bold code.

Solution is ..wat i think...You have to write in END Routine.

Why? First reason you have NETPROFIT infooject in Standard Group(right panel in transformation) which is not mapped to anyone.

I am assuming that you have /BIC/ZCHPROMOT Promotion fromm datasource which is mapped to some 0pormotion in Standard group(right panel in transformation)

Try this code in END routine.

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

METHOD end_routine.

*=== Segments ===

FIELD-SYMBOLS:

<RESULT_FIELDS> TYPE tys_TG_1.

DATA:

MONITOR_REC TYPE rstmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

TYPES: BEGIN OF type3.

INCLUDE STRUCTURE <b>/BI0/oi0PORMOTION. ''see my assumption</b>

TYPES END OF type3.

DATA:

ITAB3 TYPE STANDARD TABLE OF TYPE3

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

SELECT * FROM /BI0/P0PROMOTION INTO CORRESPONDING FIELDS OF TABLE ITAB3 WHERE OBJVERS = 'A'.

LOOP AT RESULT_PACKAGE.

READ TABLE ITAB3 WITH KEY PROMOTION = RESULT_PACKAGE-/BI0/opromotion.

IF SY-SUBRC EQ 0.

RESULT_PACKAGE-NETPROFIT = RESULT_PACKAGE-ITAB3-DISCOUNT .

ENDIF.

MODIFY RESULT_PACKAGE.

ENDLOOP.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "end_routine

ENDCLASS. "routine IMPLEMENTATION

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

Hope i m Clear.

Regards,

San!

Message was edited by: San!

Former Member
0 Likes

Why are you guys using a start routine, new concept in NW 04s is that the start routine is used for filtering. Use an end routine to manipulate the table, i.e think of it like modifying the data_package 3.x.

Works so much more better and using a DTP is quicker rather than taking the hit on the start routine in NW 04s.

Works for us.

cheers,

Sarah

Former Member
0 Likes

End Routine is the deal yeah.

What do I put in? I'm not a coding junkie (with all do respect

So all I need is the value of attribute of ZCHRPROMOT,ZKFDISPCT put in the IO ZKFDISPCT in the infocube.

For reference: the IO ZCHPROMOT:

/BIC/ZCHPROMOT CHAR 4 Promotion

OBJVERS CHAR 1 Object version

CHANGED CHAR 1 Change flag ( I inserted / D deleted )

VALIDFROM DATS 8 Valid From

VALIDTO DATS 8 Valid To

/BIC/ZKFDISPCT DEC 17 Discount Rate

/BIC/ZCHPROMTP CHAR 4 Promotion Type

PROGRAM trans_routine.

----


  • CLASS routine DEFINITION

----


*

----


CLASS routine DEFINITION.

PUBLIC SECTION.

TYPES:

BEGIN OF tys_TG_1,

  • InfoObject: 0CHNGID Change Run ID.

CHNGID TYPE /BI0/OICHNGID,

  • InfoObject: 0RECORDTP Record type.

RECORDTP TYPE /BI0/OIRECORDTP,

  • InfoObject: 0REQUID Request ID.

REQUID TYPE /BI0/OIREQUID,

  • InfoObject: ZKFPURPRC Purchase Price.

/BIC/ZKFPURPRC TYPE /BIC/OIZKFPURPRC,

  • InfoObject: ZKFSALPRC Sales Price.

/BIC/ZKFSALPRC TYPE /BIC/OIZKFSALPRC,

  • InfoObject: ZCHCUSTMR Customer.

/BIC/ZCHCUSTMR TYPE /BIC/OIZCHCUSTMR,

  • InfoObject: ZCHPRODCT Product.

/BIC/ZCHPRODCT TYPE /BIC/OIZCHPRODCT,

  • InfoObject: ZCHPROMOT Promotion.

/BIC/ZCHPROMOT TYPE /BIC/OIZCHPROMOT,

  • InfoObject: ZCHSHOP Shop.

/BIC/ZCHSHOP TYPE /BIC/OIZCHSHOP,

  • InfoObject: ZCHPAYMTH Payment Method.

/BIC/ZCHPAYMTH TYPE /BIC/OIZCHPAYMTH,

  • InfoObject: 0CALDAY Calendar Day.

CALDAY TYPE /BI0/OICALDAY,

  • InfoObject: 0CALYEAR Calendar Year.

CALYEAR TYPE /BI0/OICALYEAR,

  • InfoObject: 0CALMONTH Calendar Year/Month.

CALMONTH TYPE /BI0/OICALMONTH,

  • InfoObject: ZKFQUANT Sales Quantity.

/BIC/ZKFQUANT TYPE /BIC/OIZKFQUANT,

  • InfoObject: 0CALWEEK Calendar Year/Week.

CALWEEK TYPE /BI0/OICALWEEK,

  • InfoObject: 0CURRENCY Currency Key.

CURRENCY TYPE /BI0/OICURRENCY,

  • InfoObject: 0UNIT Unit of Measure.

UNIT TYPE /BI0/OIUNIT,

  • InfoObject: ZKFGRSPRF Gross Profit.

/BIC/ZKFGRSPRF TYPE /BIC/OIZKFGRSPRF,

  • InfoObject: ZKFDISPCT Discount Rate.

/BIC/ZKFDISPCT TYPE /BIC/OIZKFDISPCT,

  • InfoObject: ZKFGRSSAL Gross Sales.

/BIC/ZKFGRSSAL TYPE /BIC/OIZKFGRSSAL,

  • InfoObject: ZKFNETPRF Net Profit.

/BIC/ZKFNETPRF TYPE /BIC/OIZKFNETPRF,

  • InfoObject: ZKFNETSAL Net Sales.

/BIC/ZKFNETSAL TYPE /BIC/OIZKFNETSAL,

  • Field: RECORD.

RECORD TYPE RSARECORD,

END OF tys_TG_1.

TYPES:

tyt_TG_1 TYPE STANDARD TABLE OF tys_TG_1

WITH NON-UNIQUE DEFAULT KEY.

PRIVATE SECTION.

TYPE-POOLS: rsd, rstr.

$$ begin of global - insert your declaration only below this line -

... "insert your code here

$$ end of global - insert your declaration only before this line -

METHODS

end_routine

IMPORTING

request type rsrequest

datapackid type rsdatapid

EXPORTING

monitor type rstr_ty_t_monitors

CHANGING

RESULT_PACKAGE type tyt_TG_1

RAISING

cx_rsrout_abort.

METHODS

inverse_end_routine

IMPORTING

I_R_SELSET_OUTBOUND TYPE REF TO CL_RSMDS_SET

i_th_fields_outbound type hashed table

i_r_universe_inbound TYPE REF TO CL_RSMDS_UNIVERSE

CHANGING

c_r_selset_inbound TYPE REF TO CL_RSMDS_SET

c_th_fields_inbound type hashed table

c_exact type rs_bool.

ENDCLASS. "routine DEFINITION

----


  • CLASS routine IMPLEMENTATION

----


*

----


CLASS routine IMPLEMENTATION.

----


  • Method end_routine

----


  • Calculation of result package via end routine

----


  • <-> result package

----


METHOD end_routine.

*=== Segments ===

FIELD-SYMBOLS:

<RESULT_FIELDS> TYPE tys_TG_1.

DATA:

MONITOR_REC TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line *-*

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "end_routine

----


  • Method inverse_end_routine

----


*

  • This subroutine needs to be implemented only for direct access

  • (for better performance) and for the Report/Report Interface

  • (drill through).

  • The inverse routine should transform a projection and

  • a selection for the target to a projection and a selection

  • for the source, respectively.

  • If the implementation remains empty all fields are filled and

  • all values are selected.

*

----


*

----


METHOD inverse_end_routine.

$$ begin of inverse routine - insert your code only below this line-

... "insert your code here

$$ end of inverse routine - insert your code only before this line -

ENDMETHOD. "inverse_end_routine

ENDCLASS. "routine IMPLEMENTATION

Message was edited by: JvB

Former Member
0 Likes

HI Jvb,

Try this....lemme know it worked or not.

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

METHOD end_routine.

*=== Segments ===

FIELD-SYMBOLS:

<RESULT_FIELDS> TYPE tys_TG_1.

DATA:

MONITOR_REC TYPE rstmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

TYPES: BEGIN OF type3.

INCLUDE STRUCTURE /BIC/0IZCHPROMOT.

TYPES END OF type3.

DATA:

ITAB3 TYPE STANDARD TABLE OF TYPE3

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

SELECT * FROM /BI0/PZCHRPROMOT INTO CORRESPONDING FIELDS OF TABLE ITAB3 WHERE OBJVERS = 'A'.

LOOP AT RESULT_PACKAGE.

READ TABLE ITAB3 WITH KEY /BIC/ZCHRPROMOT = RESULT_PACKAGE-/BIC/ZCHPROMOT.

IF SY-SUBRC EQ 0.

RESULT_PACKAGE-/BIC/ZKFDISPCT = ITAB3-/BIC/ZKFDISPCT .

ENDIF.

MODIFY RESULT_PACKAGE.

ENDLOOP.

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

Try this code.... it just bring value of attribute of ZCHRPROMOT (ZKFDISPCT) and put in the to ZKFDISPCT in the infocube.

if there are some Sytnax error ..contact your abap team. or me.

Needless to say..if helped..assign points dude.

Regards,

San!

Former Member
0 Likes

In characteristic definition, look the name of the table in wich master data is stored, then in infocube update rules read the table with ID to get discount attribute