I am explaining with inconsistent
Mobile Number data but you can use it for inconsistent
Zip code also.
BASE_USER_DEFINED Transform:-
As we already discussed how to use User_Defined Transform in
http://scn.sap.com/community/data-services/blog/2013/01/31/how-to-use-userdefined-transform-in-sap-b...
Please follow the same steps and write the following code in Python Editor
Fields:-
Input:-
Mobile_No to get Field value in Transform.
Output:-
STD_Mobile_No to Return the updated Value.
Local Variable:- Mobile , STD_Mobile
CODE
|
Description
|
import re
Mobile = record.GetField(u'Mobile_No')
STD_Mobile = re.sub("[^0-9]","",Mobile)
STD_Mobile = STD_Mobile[-10:]
record.SetField(u'STD_Mobile_No',STD_Mobile)
del Mobile
del STD_Mobile
|
Importing Package Regular Expression
#getting Mobile Number into local variable
It will Replace Non Digit Char with BLANK""
It will take 10 digit from the right side
#update the output fields STANDARD Mobile Number
Initializing the variables
|
RESULT:-
QUERY Transform:-
BASE_USER_DEFINED Transform will give us consistent and clean data, now we have to convert it into
XXXX-XXX-XXX
PATTERN using Query Transform.
Mapping Code:-
substr( Base_UserDefined.STD_Mobile_No,0,4)||'-'|| #will give XXXX-
substr( Base_UserDefined.STD_Mobile_No,5,3)||'-'|| #will give XXX-
substr( Base_UserDefined.STD_Mobile_No,8,3) #will give XXX
RESULT:-
Complete Process:-
FINAL OUTPUT AFTER EACH PROCESS:-
DESIRED RESULT:-
We can use the combination of
User_defined Transform and
Custom function for different country's ZIP CODE .
If possible then please Give the
Rating and Feedback so that i can continue......
Thanks & Regards,
Kamal
Utopia India Pvt. Ltd.
EY