Non truncation of Leading Zero

Hi All,
  I am downloading a .xls file using the function module "GUI_DOWNLOAD".
But it is truncating the leading zero's in some fileds.
For example : in the field Account group , value is "0001" but in .xls file it is coming as "1".
Can anyone please help me on how to avoid this truncation of leading zeros.
Thanks and Regards,
Nimisha Deshpande.

Just execute this porgram and check ur result .
For this u need to handle the file type as DBF .
types: begin of t_dat,
         fld1(30) type c,
         fld2(30) type c,
       end of t_dat.
data: it_dat type table of t_dat,
      wa_dat type t_dat.
wa_dat-fld1 = '12345678901234567890'.
wa_dat-fld2 = '00000000000000043210'. "->
append wa_dat to it_dat.
wa_dat-fld1 = '12345678901234567890'.
wa_dat-fld2 = '00000000000000543210'."->ur input
append wa_dat to it_dat.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
  EXPORTING
    FILENAME                  = 'C:\test.xls'
    FILETYPE                  = 'DBF'
  CHANGING
    DATA_TAB                  = it_dat[]
  EXCEPTIONS
    FILE_WRITE_ERROR          = 1
    NO_BATCH                  = 2
    GUI_REFUSE_FILETRANSFER   = 3
    INVALID_TYPE              = 4
    NO_AUTHORITY              = 5
    UNKNOWN_ERROR             = 6
    HEADER_NOT_ALLOWED        = 7
    SEPARATOR_NOT_ALLOWED     = 8
    FILESIZE_NOT_ALLOWED      = 9
    HEADER_TOO_LONG           = 10
    DP_ERROR_CREATE           = 11
    DP_ERROR_SEND             = 12
    DP_ERROR_WRITE            = 13
    UNKNOWN_DP_ERROR          = 14
    ACCESS_DENIED             = 15
    DP_OUT_OF_MEMORY          = 16
    DISK_FULL                 = 17
    DP_TIMEOUT                = 18
    FILE_NOT_FOUND            = 19
    DATAPROVIDER_EXCEPTION    = 20
    CONTROL_FLUSH_ERROR       = 21
    NOT_SUPPORTED_BY_GUI      = 22
    ERROR_NO_GUI              = 23
    others                    = 24.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY  NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if sy-subrc eq 0.
write:/ 'Download completed'.
endif.
Hope this works for u .
Vijay

Similar Messages

  • Need to truncate extra leading zeros

    Post Author: dougatrueb
    CA Forum: Formula
    Dear Crystal Report Gurus,  I am trying to trucate the leading zeros in a feild that I am pulling from and ODBC table name {Inventory.ItemNumber}.  The item number will be similiar to 0000003785768 as an example, and I need it to trancate the leading zeros so the data looks like; 3785768.  Is there such a way to this easily? Thanks. Dougatrueb 

    Post Author: SKodidine
    CA Forum: Formula
    I am assuming that the itemnumber is a string.  If you want it as a string but truncate the leading zeros then do this:
    If NumericText({Inventory.ItemNumber}) thentotext(tonumber({Inventory.ItemNumber}),0,'','')else{Inventory.ItemNumber};

  • Truncating the leading zeros which has both numbers and characters

    Hello Everyone,
    Can anybody pls help me to truncate the leading zeros in the incoming file structure which has both the numbers and characters.
    Thanks,
    Chinna

    HI,
    Write a UDF like this ..
    public class test {
    public static void main(String[] args) {
    System.out.println(args[0].replaceAll("^0*",""));
    Also you can use XSLT for this.
    Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros won't appear.
    Use it ike this
    <xsl:variable name="a">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of select="EVENT/ContactPhone"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:template name="removeLeadingZeros">
    <xsl:param name="phone"/>
    <xsl:message>
    <xsl:value-of select="$phone"/>
    </xsl:message>
    <xsl:choose>
    <xsl:when test="starts-with($phone,'0')">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of
    select="substring-after($phone,'0' )"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$phone"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Regards
    Aashish Sinha
    PS : Reward Point if Helpful

  • Truncating the leading zeros

    hi,
    Could anybody pls tell me how do i truncate the leading zeros in the incoming file structure.
    Thanks,
    Chinna

    Hi,
    Check this thread, i laready answered it there.
    Suppressing leading zeroes during mapping
    For you i pasting the solution here.
    Write a UDF like this ..
    public class test {
    public static void main(String[] args) {
    System.out.println(args[0].replaceAll("^0*",""));
    Also you can use XSLT for this.
    Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros won't appear.
    Use it ike this
    <xsl:variable name="a">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of select="EVENT/ContactPhone"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:template name="removeLeadingZeros">
    <xsl:param name="phone"/>
    <xsl:message>
    <xsl:value-of select="$phone"/>
    </xsl:message>
    <xsl:choose>
    <xsl:when test="starts-with($phone,'0')">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of
    select="substring-after($phone,'0' )"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$phone"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Regards
    Aashish Sinha
    PS : Reward Point if Helpful

  • Truncation of leading Zeros when Down Loading into Excel - OLE Objects

    Hi,
    Can any one help me on this.
    I am using <b>OLE Objects</b> to download Data into Excel Sheet. Data with leading Zeros is getting truncated in Excel.
    Ex: Report Output is showing Plant Number as 0002. But when i am downloading to Excel Plant value will become 2 .
       I would like to have it as 0002 in Excel.
    I have declared Werks as CHAR of 4.I am using OLE Obects for Downloading into Excel Sheet.
    I am using "OLE2_OBJECT" I can not use any other FMs to down load to Excel.As i am modifying this program not creating.
    Thanks In Advance.
    K.Nirmala
    Message was edited by: Nirmala Reddy

    Hi Nirmala,
    While downloading to excel sheet, u need to change the number format of cell from General to Text, then leading zero's won't get deleted. For that u need to set the property of the cell. Please check this sample code,
    INCLUDE OLE2INCL.
    tables : zobrent.
    data : it_kna1 type table of zobrent with header line.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    DATA  H TYPE I.
    DATA: cell1 TYPE ole2_object.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
      select * from zobrent into table it_kna1
               where zopanid = '10001'
                and zo_brent = '050'.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'EDate'.
      PERFORM FILL_CELL USING 1 2 1 'Brent'.
      PERFORM FILL_CELL USING 1 3 1 'Zopanid'.
      PERFORM FILL_CELL USING 1 4 1 'Contract Type'.
      PERFORM FILL_CELL USING 1 5 1 'Price Type'.
      PERFORM FILL_CELL USING 1 6 1 'Installation Type'.
      PERFORM FILL_CELL USING 1 7 1 'Volume'.
      PERFORM FILL_CELL USING 1 8 1 'AQ'.
      PERFORM FILL_CELL USING 1 9 1 '00000123'.
      LOOP AT IT_KNA1.
    copy values to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_KNA1-zo_effdat.
        PERFORM FILL_CELL USING H 2 0 IT_KNA1-zo_brent.
        PERFORM FILL_CELL USING H 3 0 IT_KNA1-zopanid.
      ENDLOOP.
      CALL METHOD OF h_excel 'Cells' = cell1
        EXPORTING
          #1 = 1
          #2 = 1.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
      if sy-subrc eq 0.
       write : / 'year'(001).
      endif.
         FORM FILL_CELL
    sets cell at coordinates i,j to value val boldtype bold
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ***Changing the format of the cell from General to Text
      <b>SET PROPERTY OF H_ZL 'NumberFormat' = '@'.</b>
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    U just paste this code in a sample program & see.
    Please reward, if found helpful.

  • Truncation of leading zero's for a numeric field

    How to truncate leading zeros for numeric key figure field. The field value shows 0.0000000000000000E+00. Why the value shows like this??? Plz explain.
    Draj S

    Hi,
    I guess the Infoobj is FLOATING POINT. So its displaying that way.

  • Truncates the leading zeros even though the member is text type

    We have members with data type “TEXT” in planning database. When user enters something with leading zero, it saves the same in relational but not showing the same in planning. It truncates the zero even though it is a text member.
    Planning version 11.1.2
    Example:
    Member name : Issue code (TEXT type)
    Entered value : 011_Issue (saves the same in relational)
    Display value : 11_Issue (Drops the zero)
    is there any workaround?
    Thanks

    I've opened a SR and here is the reply from MOS.
    Apply a fix for Bug 12422049 - DATA TYPE TEXT MEMBER DOES NOT DISPLAY VALUE STARTING WITH ZERO CORRECTLY when its available.
    The issue has been identified as a code bug and development team will fix it in future releases.
    Thanks
    Poorna

  • Truncating the leading zero's

    Hi experts,
    I have an ALV output, in which one of the fields is equipment number (equi-equnr).
    There are some leading zero's that I need to truncate from the ALV output.
    How can I achieve this? The code is as given below:
      fieldcatalog-fieldname   = 'EQUIPMENT_NUMBER'.
      fieldcatalog-seltext_m   = 'Equipment Number'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    Thanks,
    Ajay.

    Hello,
    Your requirement is that you need to display the equipment number in the ALV without the leading zeroes.
    Ypur code is
    fieldcatalog-fieldname = 'EQUIPMENT_NUMBER'.
    fieldcatalog-seltext_m = 'Equipment Number'.
    fieldcatalog-col_pos = 5.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    Just before append statement add the following
    fieldcatalog-no_zero = 'X'.
    Now try the same it should solve your problem.
    Regards,
    Sachin
    Edited by: Sachin Dargan on Jan 19, 2010 7:34 AM

  • Need help on avoid truncation of leading zeros while export to Excel

    Hi
    I am using crystal reports XI version and facing numerical format issue while exporting data from crystal report viewer to excel file, it is removing leading zeros in a alphanumeric field (String field from DB)
    Thanks
    Nagamani

    The only thing that might do this would be to append an apostrophe (') to the beginning of the field.  What I would try is:
    1. Add a text object to the report where you want this string to appear.
    2. Type an apostrophe in the text box.
    3. Drag the field into the text box so that it's to the right of the apostrophe.
    If you don't want the apostrophe to appear when viewing the report, try this:
    1.  Right-click on the text box and select "Format Object".  Set the font color to be the same as the background color.
    2.  Double-click in the text box.
    3.  Select the field, right-click on it and select the "Format..." option.  Set the font color to black or whatever other color you're using in your report.
    -Dell

  • IR truncating leading zeros in my popup window report

    Hello,
    I am using IR_columnname, for one of the columns in my report which is a popup window report.
    My problem is that IR_column search filter in my popup window is truncating the leading zeros.
    I am getting the value but it is truncating the leading zeros.
    like say if the deptno is something like 020 or 0020 in the parent window.
    the IR_columnname value is taking '20' (its truncating leading zeros) with this filter its not dispalying the result in my popup window.
    can anyone help me out with this.
    thanks.

    How are you passing values to the IR filter? There could be a possibility that you source logic is truncating the leading zeros.
    Thanks,
    Manish

  • Leading zeroes truncated in Write statement

    Hi,
    I want to maintain leading zeroes into an variable
    but the following statement
    write (<char_from>) to l_char22. truncates the leading zeroes.
    Please let me know if there is any way that I could acheive this.
    Best Regards,
    Arun

    Ex: <ls_guidconv>-partner has a value of '000071'
    Consider the following code,
    l_char23 = '<ls_guidconv>-partner'.
    Assign l_char23 to <l_char24>.
    Write (<l_char24>) To l_char25
    This will give me a value of 71
    If I use move 
    Move (<l_char24>) To l_char25 >> syntax error
    Move <l_char24> To l_char25
    I get the result as a string <ls_guidconv>-partner
    <ls_guidconv>-partner can have values maximum of length 10
    since a variable we use is of 25 chars (l_char25)
    if i use the FM CONVERSION_EXIT_ALPHA_INPUT it does puts
    the leading 0's but for the maximum length of 25 instead
    of 10.
    Thanks for your quick response.
    Arun.

  • Leading zero being truncated on IRECORDSET return data

    I am using EP6 SP14.  I have a RFC call from the portal to R/3 that brings back a table (availresult).  One of the elements in the table is the UPC code.  When I run the bapi using SE37 in R/3 the UPC code has a leading zero(s).  However, when the iview displays the UPC code the leading zero(s) are truncated.  The data is processed as type IRECORDSET. All the other data on the iview is correct just the UPC code is truncating the leading zero(s). 
    Here's a sampling of my code.
    IRecordSet availResult = (IRecordSet)output.get("AVAIL_RESULT");
    lvecAvailResColNm.add(1,"EAN_UPC");
    int counter = 0;
    if(!availResult.isAfterLast()){
         availResult.beforeFirst();
         while(availResult.next()){
    lvedAvailResDataRecord = new Vector();
    lvedAvailResDataRecord.add(1,availResult.getString("EAN_UPC"));
    lvecAvailResData.add(counter++, lvedAvailResDataRecord);
    The availResult.getString("EAN_UPC")); comes back with a UPC code with the leading zeroes truncated.
    Any suggestions would be greatly appreciated.
    Thanks
    Angie.

    I'm having the exact same problem with UPC codes being returned by an RFC, did you ever find a solution?

  • XL Reporter - item code starting with leading zeros was truncated

    Hi,
    Anybody knows how to prevent XL reporter from truncating the leading zero(s) in the item code?
    I had done a XL report where one of the field is to retrieve Item Code. In the report generated, the formula was as below:
    =ixDimGet("00100068")
    However, when MS Excel display it in the spreedsheet, the item code becomes "100068" where the leading zeros was truncated. The correct item code was supposed to be "00100068". I had tried to change the cell format to "text", "number", "general" and etc, but it doesn't work. Any method to correct the item code display in the Excel spreadsheet?
    Thanks,
    sianghing

    Chan,
    There is a simple solution for this.  Highlight the cell with the Item Code selection in it.
    Click the formula builder icon in Excel to open the formula builder
    In the bottom box, type TRUE
    This tells Excel that you want to display exactly what comes out of the database, without having to predetermine it with a Custom format, etc.
    I think that will solve your issue.
    Let me know if this needs further explanation.
    Regards,
    Brad Windecker
    [Orchestra Team|http://www.orchestrateam.com]

  • Truncating Leading Zeroes

    Hi,
    What is the best method to truncate the leading zeroes of an alphanumeric data item? Is there an expression editor function that could do this?
    I have come up with a logic involving 3 - 4 actions that could do this for a specific data item. The problem is I have got about 5 different data items in the same transaction that need leading zeroes truncated. Whats the best thing to do here?
    Do I need to build a custom action or expression editor function?
    Regards,
    V M.

    Well, there are equivilants in every database. I think Oracle has something like LTRIM(value, '0')
    If your application doesn't use any databases and you are on 12.0 + you could estabish a connection to the neweaver db.
    You could also look into and xsl solution using the XSL Transformation action.
    I often do this to create/format lists for query filters or similar tasks.
    For some background this issue often comes up when pulling data from standard SAP interfaces. In sap Order and Material numbers are typically trimmed automagically by the gui. But when pulling those data elements from sap you get the full monty. This is ok because you often need the full untrimmed value to use with other interfaces, but users still expect the values to be trimmed when displayed. There are a lot of solutions to this issue in regards to the front end (xsl, Javascript, SQL in cases where the data is stored/cached in a local database ) but it would be convienent to have this level of formatting built into the link editor. Maybe even something that accepts a regular expression?
    Regards,
    Christian

  • Procedure truncating leading zeros

    Hello,
    I'm setting up sequences for my sample database, in my design I have my ID columns in this format Staff: S110001, Parents: P110001 etc.
    When I try to implement this in a sequence like:
    create sequence Pnt_seq1 start with 0001;
    insert into parents
    (parent_id, f_name, m_init, l_name, house_n, street, city, postcode)
    values
    (('P' || to_char(sysdate, 'yy')|| Pnt_seq1.nextval), 'Jim', 'I', 'Brown', 34, 'Barker St', 'Wrexham', 'LL11 8UH');
    It trims or truncates the leading zeros giving me P111 instead of P110001. Is there a way around this or am I better off changing my domain definitions/schema to start at P111001 or something?
    Thanks a lot
    Mike

    A sequence is always numeric, so leading zeros have no place
    Nothing is trimmed.
    If you want leading zeros in the code you posted use
    to_char(Pnt_seq1.nextval,'fm0009')
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • How to send a mail as an attachment in a mail with AppleScript?

    Hi, I want to manage my spam using the advices found in support.apple website : OS X Mail Open the message and choose “Forward as Attachment” from the Message menu. Forward the message to iCloud [email protected]. Forward the message again to abuse@dom

  • Trying to backup a (network) hard drive connected to TC

    Hi, I have a simple home network with a TC and an external hard drive connected to this. TC is used to backup my mac and laptop. All of my work is stored on the drive connected to TC. I know that TC won't back this drive up so i purchased Chronosync.

  • Java Server Pages

    I am using JSP. I am using TOMCAT on Windows NT. I want to do some events (like counting the hits) whenever an user requests for a JSP Page. All the details are available in jasper.log. But I need an event where I can write my own code, which has to

  • JSP - Displaying Graphs and Charts.

    Can any body help to display a Graph or a Chart in a JSP. The source data can be static or dynamic data. TIA shrini

  • Changing timing on a group of stills

    HD 6.03 is not updating the length of my stills in groups... I have to do them one by one. Occasionally using the "Show Photo Settings" slider works, but usually not. What's going on? 2.33 ghz dual core Intel Imac   Mac OS X (10.4.9)