cancel
Showing results for 
Search instead for 
Did you mean: 

Unit calculation at routine in update rule

Former Member
0 Kudos

Hello,

Can anybody explain me how to calculate unit in update rule routine.

In update rule routine how to access infocube keyfigure like we access communication structure as comm_structure.

Is there any sample code?

Please help me out.

Thanks,

Regards,

Steve

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Steve,

In Update Rule Change transaction, you can select the Key Figure you want to add an update rule. If you double click the key figure you want, a dialog box will appear which has 3 tabs (Key Fig. Calculation, Characteristic, and Time Ref.). You can select update type and also the update method. If you select Routine as you update method, you can check the "Unit Calculation in the Routine" which will enable you to compute specify the correct Unit in the abap routine. If you create the ABAP routine (click the paper like button), you can specify the unit by assigning a value to the "UNIT" variable in the ABAP editor. Here is an example of the ABAP code you can place there:

clear unit.

  • Get correct unit of material from master data table

select base_uom from /bi0/pmaterial into table t_pmat where material = comm_structure-material and objvers = 'A'.

  • If unit is found in master data then assign it to the unit result

if sy-subrc eq 0.

UNIT = t_pmat-base_uom.

endif.

Former Member
0 Kudos

Hi,

You can find out the no of routines with standard Update rules.

one of them is :

<i>for 'Net weight in kilograms' 2LIS_13_VDITM-->0SD_C03</i>

IF COMM_STRUCTURE-UNIT_OF_WT NE 'KG'.

WEIGHT = COMM_STRUCTURE-GRS_WGT_DL.

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'

EXPORTING

INPUT = COMM_STRUCTURE-GRS_WGT_DL

UNIT_IN = COMM_STRUCTURE-UNIT_OF_WT

UNIT_OUT = 'KG'

IMPORTING

OUTPUT = WEIGHT

EXCEPTIONS

CONVERSION_NOT_FOUND = 1

DIVISION_BY_ZERO = 2

INPUT_INVALID = 3

OUTPUT_INVALID = 4

OVERFLOW = 5

TYPE_INVALID = 6

UNITS_MISSING = 7

UNIT_IN_NOT_FOUND = 8

UNIT_OUT_NOT_FOUND = 9

OTHERS = 10.

IF SY-SUBRC NE 0.

CLEAR MONITOR.

MONITOR-msgno = '009'.

MONITOR-msgid = 'SDBW'.

MONITOR-msgty = c_msgty_e.

MONITOR-msgv1 = COMM_STRUCTURE-UNIT_OF_WT.

append MONITOR.

RETURNCODE = 4.

WEIGHT = 0.

ELSE.

RESULT = WEIGHT.

RETURNCODE = 0.

ENDIF.

ELSE.

RESULT = COMM_STRUCTURE-GRS_WGT_DL.

RETURNCODE = 0.

ENDIF.

With rgds,

Anil Kumar Sharma .P

Former Member
0 Kudos

Hi Steve,

In update rules ,under update method you will get check box unit calculation in the routine.