Skip to Content
0

Right Padding in FCC for target field

Mar 02, 2017 at 06:41 PM

94

avatar image

Hi All,

I am working on file receiver file content conversion .

I am getting a field from source to target i.e

Source (Cell Number) 112233>>>112233 (2 space) in target side as the fixed length for this field is 8.

I tried with java code

if (str.length()<8)

{

int i=8-str.length();

for(int i =0; i<8;i++)

str=str+" ";

}

return str;

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

10 Answers

Best Answer
Iñaki Vila Mar 08, 2017 at 01:05 PM
0

Hi Riitu,

Please if your answer has been solved, close the thread in order to help more SCN user in the future:

https://blogs.sap.com/2017/02/03/understanding-the-comment-thread-structure-on-sap-community/

Regards

Share
10 |10000 characters needed characters left characters exceeded
ritu gupta Mar 03, 2017 at 02:11 AM
0

any suggestions..

Thanks

Share
10 |10000 characters needed characters left characters exceeded
Iñaki Vila Mar 03, 2017 at 07:07 AM
0
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Inaki,

below code have

2 input parameters

publicstaticString padLeft(String s,int n){returnString.format("%1$"+ n +"s", s);}
but in my scenario i have one input parameter so i have used 
for (int count=0; count < 25 - var1.length();  count++){


   var1= var1 +   " ";


}


return var1;

but some how it is not working could you pls let me know if something wrong I am doing
Thanks
0
ritu gupta Mar 06, 2017 at 06:50 AM
0

Hi Inaki,

the link you gave having 2 input parameter

publicstaticString padLeft(String s,int n)

{returnString.format("%1$"+ n +"s", s);

}

as in my case there is only 1 input parameter for which I have used

for (int count=0; count < 8 - var1.length(); count++)

{ var1= var1 + " ";

}

return var1;

but somehow it is not working

Thanks

Share
10 |10000 characters needed characters left characters exceeded
ritu gupta Mar 06, 2017 at 08:34 AM
0

any suggestions

Thanks

Share
10 |10000 characters needed characters left characters exceeded
ritu gupta Mar 06, 2017 at 08:34 AM
0

any suggestions

Thanks

Share
10 |10000 characters needed characters left characters exceeded
Iñaki Vila Mar 06, 2017 at 08:54 AM
0
queue.jpg

example.jpg

Hi Ritu,

Check the image that i attach.

In Constant, you give 8 spaces. You always set 8 spaces at right but later with substring you only take the 8 first characters:

Regards,


example.jpg (12.7 kB)
queue.jpg (34.6 kB)
Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Mar 06, 2017 at 08:49 AM
0

Try the below code

int length =8-var1.length();

String var2 ="";

for(int i=0;i<length;i++)

{

var2=var2+" ";

}

String out = var1 + var2;

return out;

Share
10 |10000 characters needed characters left characters exceeded
ritu gupta Mar 08, 2017 at 03:29 AM
0

Thanks Inaki this worked for me

Share
10 |10000 characters needed characters left characters exceeded
ritu gupta Mar 08, 2017 at 02:52 PM
0

Hi Inkai,

Sorry I will mark this as answered.

Thanks

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Ritu,

Sorry for disturb you, but you should mark the answer that helped you, not the answer that i wrote to say that you should mark one answer :)

Regards.

0