cancel
Showing results for 
Search instead for 
Did you mean: 

About space padding in message mapping

Former Member
0 Kudos

Hi,

Somebody please tell me how to do the mapping for the following mapping description .

If data length is less than indicated length then padded to length of 10 spaces at the end

Thanks,

Ramya

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Ramya,

You can write simple UDF and achieve the same!!

int len=a.length();

if(a.length() <10)

{

for(int i=len; i<=10;i++)

{

a=a+" ";

}

return a;

}

else

{

return a;

}

Hope it helps!!

raj.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ramya,

We can do easily in Graph Mapping,Please do the following steps.

Step 1: Select the both fields (Source and Target) in ur Mapping.

Step 2: Select the Text func node functions and Click the Length and then assign the Source field to Length Function.

Step 3: Select the Less function from the Arithmetic node functions and then Join the Length and Less function.and then declare the constant(specify ur indicated length) and assign that to less function.Less function comapres and gives you the true or false

Step 4: Join the that Less function to the IfWithoutelse fucntion in the Boolean function.

Step 5: Again click/take the Source field and then declare the Constant (Specify the 10 spaces)

Step 6: Declare the Cancat function from Text function and then join the source field and Constant which we daclared in the Step 5 and then join that Cancat function to IfWithoutelse fucntion.

Step 7: Finally join the IfWithoutelse fucntion to Target Field.

Sure it will work for you, i have implemente the same one of my scenerio.

Thanks and Rgds,

Kamal

Former Member
0 Kudos

I think "FormatNum" node function wll work for your requirement

prabhu_s2
Active Contributor
0 Kudos

u mean u need to do a kind of shifting operation? if yes then check then check the lkength of the string in the udf and make use of the shift operation accordingly. this shud work.

aashish_sinha
Active Contributor
0 Kudos

Hi,

Try to find the length using String Length utility in graphical mapping, then use if else to proceed and finally use concat to pad the spaces at end.

if (str.length < 5) // that is ur length to be checked. 5 is for example

str = concat(str," ") // 10 spaces

or you can write an UDF for the same or you can implement this logic in graphical mapping also using the given functions in Message Mapping

Regards

Aashish Sinha

PS : reward points if helpful