Padding character fields with zeros

Hello,
I need to add zeros to the end of character fields TYPE C. I know i can use the conversion routines but that only works for numeric fields.
Thanks

Thanks for all the replies.
STRLEN will give me the lenght of the field but i need the offset of the last chararcter.
Your post gave me an idea though. I'm doing the following and it's working.
value = 'Thank You          '.
tmp    = '00000000000000'.
FIND REGEX `\w[ [:space:] ][ [:space:] ]` IN value MATCH OFFSET moff.
IF SY-SUBRC = 0.
   OVERLAY value+moff WITH tmp.
ENDIF.
The find looks for the last alphanumeric char and 2 spaces after it meaning the last alphanumeric char in the string.
Thanks to all, i will reward as fairly as possible.

Similar Messages

  • Pad a field with a substring

    I need to pad these fields with zero after the substring.  How do I do that?
    Current items is:
    drvLocCode
    =
    case
    when
    Substring(EecLocation,
    1, 2)
    =
    '28'
    and
    len(EecLocation)
    = 5
    then
    Substring(EecLocation,
    3, 3)
    when
    Substring(EecLocation,
    1, 2)
    =
    '28'
    and
    len(EecLocation)
    = 6
    then
    Substring(EecLocation,
    3, 4)
    when
    Substring(EecLocation,
    1, 1)
    =
    'P'
    and
    len(EecLocation)
    = 6
    then
    Substring(EecLocation,
    2, 5)
    end

    Here's a simple example:
    SELECT LEFT('myString'+REPLICATE('0',10),10)
    We're literally adding 10 0s to the end of the string, and then taking the 10 left most characters.
    So, for your example:
    drvLocCode = LEFT(case when Substring(EecLocation, 1, 2) = '28' and len(EecLocation) = 5 then Substring(EecLocation, 3, 3)
    when Substring(EecLocation, 1, 2) = '28' and len(EecLocation) = 6 then Substring(EecLocation, 3, 4)
    when Substring(EecLocation, 1, 1) = 'P' and len(EecLocation) = 6 then Substring(EecLocation, 2, 5) end+REPLICATE('0',10),10)

  • Padding a value with zeros

    Hi,
    I am trying to pad a field with leading zeros during mapping.  I am going from an IDOC to a flat file.  Is there a function in the message mapping of XI that will help me do this?
    For example: the value of "91423" is passed in to a field of length 10. i want the value to look like this on the flat file  "0000091423".
    Is this possible?
    Thanks,
    Nate

    Hi Nathan,
    yes this is possible:
    one way - create a user defined function
    with one input value (your field)
    and check it's length and add (10 - length) zeros
    second way - without user defined function
    and use length and concat functions (build into graphical mapping functions) and if statement
    if length  = 9 then string concat 0
    else if length = 8 then string concat 00 ...
    the first way it better but if you don't want to use java you can use the second one
    Regards,
    michal

  • Pad a string with zeros ?

    Hello ABAP Experts,
    How to pad a string with zeros.. is there a direct method i can use.
    eg:
    string length is 8
    string is custnumb
    value is 588
    but i would like to see 00000588
    please suggest.

    You can simply move it to a TYPE n field also.
    data: n(8) type n.
    data: custnumb(8) type c value '588'.
    n = custnumb.
    custnumb = n.
    Regards,
    Rich Heilman

  • Hiding fields with zeros or blanks in ALV using factory classes

    Hi all,
    I am using Factory Method for displaying ALV.
    And I want to hide all the fields with Zeros or Blanks.
    Any help wud be rewarded.
    Thanks
    Preeti

    Hi,
       Below is the code used to hide a particular field ,here it is MANDT.This code is put after the factory method.
       data: lr_columns type ref to cl_salv_columns.
        lr_columns = gr_table->get_columns( ).
        lr_columns->set_optimize( abap_true ).
       data: lr_column type ref to cl_salv_column.
      try.
          lr_column = lr_columns->get_column( 'MANDT' ).
          lr_column->set_technical( if_salv_c_bool_sap=>true ).
        catch cx_salv_not_found.                          
      endtry.
    Thanks.

  • How to sort a character field with numbers and letters on the end

    I have an internal table with character field which has data like this after I sort it.  This is not what I expect from the sort.:
    13A
    15A
    29A
    30A
    31A
    33A
    123A
    125
    62 
    76 
    94A
    I expect this, which is sorted number first, then alpha.  Any ideas how to get this sort?:
    13A
    15A
    29A
    30A
    31A
    33A
    62 
    76 
    94A
    123A
    125

    Thanks for the suggestions.  After reading the suggestions and reviewing some other post threads, here's what I did to get the sort to work:
    Add a dash - to the end of any record that did not have an alphabet character at the end.  This way, all records have at least one non-numeric character at the end.  Then I overlayed zeros  '0000000'  over each record.  Then I sorted the table.  Afterwards, I removed the dashes and zeros.
    The long way around, but it worked for me.  Since the internal table is processed in memory, it doesn't add much overhead to the run time.

  • Show NUMC Type Field with Zeros in SE16

    Hi.
    Is there any way to show a field of numc type (length 9) with zeros when is shown in SE16???

    Hi
    I am not clear with your question?
    Just check the table entries in VBAP
    fields VBELN  which is of CHAR 10 and
    POSNR which of NUMC 6
    For both the fields the leading zeros are displayed in SE16
    just check it.
    so what's your question?
    Reward points if useful
    Regards
    Anji

  • Character field with date format alike & character entered

    Hi all,
    I got one character field created ( varchar2 ) for the purposed to let user the enter the date and also any character since it is a character field.
    Hence, my field may contain the following data :-
    Ship_date
    01/10/2010
    07/02/2011
    15/01/2011
    25/01/2011
    31/01/2011
    TBA
    STOP
    11/01/2011
    TBA
    Hence when come to sorting, I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
    ship_date
    01/10/2011
    11/01/2011
    15/01/2011
    25/01/2011
    31/01/2011
    07/02/2011
    STOP
    TBA
    Trying to do the normal sorting, it does not exactly sort on the date format, as it only sort on the first two character on the date hence I am not getting the correct sorting on this.
    01/10/2011
    07/02/2011
    11/01/2011
    15/01/2011
    25/01/2011
    31/01/2011
    STOP
    TBA
    Could someone help me on this. Thanks.
    Lim

    Hi, Lim,
    sm**** wrote:
    Hi all,
    I got one character field created ( varchar2 ) for the purposed to let user the enter the date and also any character since it is a character field.That's a very bad idea. Use a DATE column for storing dates. Have another, separate column for VARCHAR2 data.
    Hence when come to sorting, I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
    If you must deal with the table as it is:
    ORDER BY  CASE
              WHEN  TRANSLATE ( ship_date
                        , '012345678'
                        , '999999999'
                        ) = '99/99/9999'
              THEN  SUBSTR (ship_date, 7)
                 || SUBSTR (ship_date, 4, 2)
           END
    ,       ship_dateThe CASE expressionj sorts anything the looks like a date ('99/99/9999' where '9' stands for any digit) first, in order by the last 4 digits, then the middle 2 digits. The first 2 digits are sorted by the second ORDER BY expression.
    I will like it to be date format like sorting so that the earlier date will display first then only follow by the character. The expected result will be :-
    ship_date
    01/10/2011
    11/01/2011
    15/01/2011
    25/01/2011
    31/01/2011
    07/02/2011That must be a mistake. I don't believe you want January to come after October and before February, but if you do, you can change what comes after THEN in the CASE expression.

  • Suppressing summarized fields with zero value

    I have a report with many many fields.  I do not want to display the field if the value is zero.  Instead of me going to each field, right-clicking, going to common tab, clicking on suppress and inserting the conditional formula {summarized.fieldname}=0 for each field, is there a quicker way to do this?  Perhaps globally?
    Thanks in advance,
    Zack H.

    Select all your summary fields, right mouse click, select format objects, click on the number tab, click the customize button, then on the number tab check 'Suppress if Zero'

  • Replace a string in a character field with a amount value

    Hi,
        I have a text field in which I want to replace a string with an amount value. while am trying to replace it , it gives me some empty space.
    For example:
    amount = '1200   '
    message = 'The STIP amount is &1'
    in my code :
    replace &1 with message into message.
    the result is
    'The STIP amount is 1200   '
    I dont want the space after 1200.
    I tried for condense no-gaps also but it is not working ..
    What may be the problem?
    Can you suggest some solution for this?
    Regards,
    Vimala

    Hi,
    replace &1 with message into message.
    I guess its replace &1 with amount into message.
    Convert the amount to a character type (example move amount to amount_c ), then condense it and and then replace it using the 'REPLACE' statement.
    regards,
    Advait.

  • Guid Downloading Character field with numeric value

    Hi All,
    I am downloading one table through gui_download, file type is asc. While downloading the internal table contains one field
    w_lif(20) type c, which contains the value '1234545567' all numeric value, now in excel it is displaying as exadecimal , here i need to convert the type of the column in excel to see the actual value.
    could you please tell me ,  how to get actuall value directly to excel
    your valuable help is appreciated.
    Regards,
    Siddivinesh Jogu

    Hi,
    You can try the File Type as DBF. This retains the format of all the columns as Data.
    Please let me know if this help,
    Regards,
    Janani

  • Message Mapping, filling field with 0 (zeros) on left

    I need to fill a field with values that has variable lenght adding 0 (zeros) on the left, how can I do it ?
    I'm using the LENGHT in message mapping, with value returned by LENGHT I use FIXVALUES to map the quantity of 0 (zeros) that I need to add in the field.
    Somebody can help me with this problem ?
    Thank's.

    Hi Regis,
    You can use the Arithmetic:FormatNum built-in function for this.
    If you want to left-pad the number with zeros so that the length is always 10, then specify 10 zeros for the format, 0000000000.
    This function takes formats based on java.text.DecimalFormat so you can see all of the possibilities at:
    java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html
    Thanks,
    Jesse

  • Problem with character field

    hi experts,
    i have two character fields with legth 18 each..values are 123 and 126.
    i have to display in smartfrom as 123 to 126.
    bcoz of 18 characters leght i am facing some place adjutment problem in smartfrom
    so it is displaying as
    '   somespace             123to
        126.
    can any body plz help me how to acheive this?
    Edited by: s veena on Jan 31, 2011 12:17 PM

    gv_sernr = 123 to 126 ( it should be one line).
    but it is coming like
    somespace 123to
    126.
    >
    Abhinab Mishra wrote:
    > I think you should search the forum or google about concatenation.
    > Or do F1 on CONCATENATE.
    I'm not sure how CONCATENATE will serve here,but CONDENCE might do.
    @ S veena: Can you please check the space on the window if this is sufficient to accommodate the whole value in one line.
    Cheers,
    Amit

  • ** Please help urgently  ** Budget upload field with leading zeros

    We need to load a characteristic that has leading zeros.  For example 0000350.  When saving down to CSV, we lose the leading zeros (0000) so that only 350 is loaded into BW.  Saving the codes as 'text' in excel does not seem to help.
    We cannot therefore see the name for any of these codes when refreshing the workbook in BW.
    Could some please urgently tell us the correct method to save the file for loading into the BW infopackage, with all zeros intact ?
    Regards, Frederick

    Hi Frederick,
    Just some additional thoughts,
    assuming field A1 in Ecel contains 350 and you want to create a string with 8 digits, you could use formula '=text(A1;"00000000")' in an empty column and copy it back to column A. Then 00000350 should be provided in A1. This can be saved in a normal .csv file and be opened with a text editor (e.g. notepad) in order to check content.
    If you don't want to manipulate Excel data, transformation to a field with leading zeros can be easily be processed with a routine in transfer rules.
    Regards
    Joe

  • Padding a value with leading zeros

    Hi
    I am trying to create a filename (String) using a sequence int. I need this int to be 6 digits, with leading zeros
    i.e. if my seqence number is 23 my filename (String) should be:
    FILE000023
    Obviously I can do this by creating my own method that iterates through the number, but I was wondering if there was a simple method to change an int to a String and pad it out with leading zeros.
    Thanks
    Neil.

    import java.text.*;
    public class DecimalFormatTesting {
         public static void main( String[] args ) {
              DecimalFormat format = new DecimalFormat("###.###");
              format.setMinimumIntegerDigits( 6 );
              String integ = format.format( 123 );
              System.out.println("str: " + integ);
         } // end of main()
    }hope this helps
    partha

Maybe you are looking for

  • Hp color laserjet CP1215

    printer : hp color laserjet CP1215 why printer (colour laser jet cp1215) does not connect to my mac laptop, what can i do???

  • Can I add a Youtube video to a PDF with Acrobat 9 Pro?

    I was reading about PDF portfolios in Acrobat X Pro: http://www.adobe.com/products/acrobatpro/online-eportfolios-multimedia-presentations.html It says and I quote, "With Acrobat X Pro, you can also present live web content. For example,  you can inse

  • [AS CS3] Getting fonts of placed InDd docs (imported pages, or graphics)

    I need to get the status of fonts that are in InDd documents placed inside another InDd document. I can see the fonts in the "Find Font" window, and it shows me if the font is OK or missing. How would I get that information via script? Opening all th

  • OracleBI Discoverer error message

    Hi, I am using Discoverer with following version details OracleBI Discoverer 10g (10.1.2.3) Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26) Discoverer Model - 10.1.2.55.26 Discoverer Server - 10.1.2.55.26 End User Layer - 5.1.1.0.0.0

  • I want to change my email

    The email address I want to change it to is my "rescue email" and I can no longer access my email that I am currently using. What should I do?