cancel
Showing results for 
Search instead for 
Did you mean: 

Cube Routine issue

Former Member
0 Kudos
65

Hi Guys

Here is the problem, I have an update rule its has Charecteristic "Customer Number". The file coming in has customer numbers obviously. A few customer number coming in are correct which should go through and few are not correct. Now i should run a validation to accept the correct number and if there are any wrong customer number i shuld update it with the new number given.

I need to write a routine which does this validations. Could some one help me with the code ASAP.

Regards

Chris

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi chris,

if you have stored Correct (A) and Not Correct (B) Customer Number in a Master Data (C) to make the check you can use Start Routine of the Update Rules. Here a sample code.

data: begin of t_C occurs 0,

B like C-B,

A like C-A,

end of t_C.

select * into corresponding fields of table t_C

from C where not B is null and OBJVERS = 'A'.

LOOP AT DATA_PACKAGE.

IF DATA_PACKAGE-B IS NOT INITIAL.

read table t_C with key B = DATA_PACKAGE-B.

IF sy-subrc = 0.

DATA_PACKAGE-B = t_C-A.

ENDIF.

MODIFY DATA_PACKAGE.

ENDIF.

ENDLOOP.

Ciao.

Riccardo

Former Member
0 Kudos

Hi Riccardo

Thank you for the response, will the code given work to replace the wrong customer number..

Chris

Former Member
0 Kudos

Hi Chris,

logically you have to create a Master Data based on InfoObject B, that map the Non Correct, and with the attribute InfoObject A that map the Correct, but I think it is the best solution.

In particular consider that a Start Routine has better performance respect to a single Update Roules.

Ciao.

Riccardo.

Former Member
0 Kudos

Hi Chris,

in startroutine:

data begin of t_cust,

old(10),

new(10),

end of t_cust.

data indx like sy-tabix.

  • fill old new customer

t_cust-old = '0000004711'. t_cust-new = '1000004711'.

append t_cust.

t_cust-old = '0000004714'. t_cust-new = '1000004714'.

append t_cust.

sort t_cust.

loop at data_package.

indx = sy-tabix.

read table t_cust with key old = data_package-customer

binary search.

if sy-subrc = 0. "found cust to replace.

data_package-customer = t_cust-new.

modify data_package index indx.

endif.

endloop.

/manfred

Former Member
0 Kudos

Anyway, you should insert this type of cleansing operation in your transfer rules...

What I'm not exactly understanding is why you cannot solve your issue at the root...it seems that, since if you can recognize a specific kind of error (otherwise how are you able to give the correct number in your code ???), it would be better to adjust directly customer field when records coming into BW...

Bye,

Roberto

Former Member
0 Kudos

Hi Chris,

The code would be similar to this:

If comm_structure-Customer No = 'wrong no 1' or 'wrong no 2' or 'wrong no 3'.
Result = 'new number'.
endif.
else.
Result = comm_structure-Customer No.
endif.

Bye

Dinesh