Skip to Content
avatar image
Former Member

Right Padding in FCC for target field

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;

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

10 Answers

  • Best Answer
    Mar 08, 2017 at 01:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 03, 2017 at 02:11 AM

    any suggestions..

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 03, 2017 at 07:07 AM
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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
  • avatar image
    Former Member
    Mar 06, 2017 at 06:50 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 08:34 AM

    any suggestions

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 08:34 AM

    any suggestions

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 08:54 AM
    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,

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 08:49 AM

    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;

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 08, 2017 at 03:29 AM

    Thanks Inaki this worked for me

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 08, 2017 at 02:52 PM

    Hi Inkai,

    Sorry I will mark this as answered.

    Thanks

    Add comment
    10|10000 characters needed 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.