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.

Similar Messages

  • As being a novice with my Mac Pro computer and Cannon 5D mark 3 camera my issue has arisen while over the last year and half, when down loading into my Photoshop Lightroom 4, my 18,000  photograph were not catalogued correctly, or hardly at all, so now ov

    As being a novice with my Mac Pro computer and Cannon 5D mark 3 camera my issue has arisen while over the last year and half, when down loading into my Photoshop Lightroom 4, my 18,000  photograph were not catalogued correctly, or hardly at all, so now over several months time my photos have apparently been redirected in my libraries and have begun not appearing in their allotted frames next to their number in the library they are in. they also have a small question mark (?) next to the photo space. The frames are blank but indicates that there is a photo there. The majority of photos are blank but about a tenth are seen . i apparently need to retrace where they went but do not know how to get that done . can someone help please?

    It would be difficult to tell you where to begin. If you moved photos around to different folders and didn't use Lightroom to move them, that would cause Lightroom to lose track of where they are. You have to remember that your images are not "in" Lightroom. Lightroom simply points to them wherever they are on your computer. All of the location information as well as the changes that you make to your images is stored in the catalog, which is a database. This catalog is central to the operation of Lightroom, and it's essential that you understand how it works and how to make it work for you. For all of those images that have "?" On them, or the folders that have the same, you will have to go through the process of locating them and showing Lightroom where they are located. With 18,000 images, and many of them missing, it might just be easier to start a new catalog and organize things properly from the beginning in that catalog.

  • Adding leading zeros before data loaded into DSO

    Hi
    In below PROD_ID... In some ID leading zeros are missing before data loaded into BI from SRM into PROD_ID. Data type is character. If leading zeros are missing then data activation of DSO is failed due to missing zeros and have to manually add them in PSA table. I want to add leading zeros if they're missing before data loaded into DSO.... total character length is 40.. so e.g. if character is 1502 then there should be 36 zeros before it and if character is 265721 then there should be 34 zeros. Only two type of character is coming either length is 4 or 6 so there will be always need to 34 or 36 zeros in front of them if zeros are missing.
    Can we use CONVERSION_EXIT_ALPHPA_INPUT functional module ? As this is char so I'm not sure how to use in that case.. Do need to convert it first integer?
    Can someone please give me sample code? We're using BW 3.5 data flow to load data into DSO.... please give sample code and where need to write code either in rule type or in start routine...

    Hi,
    Can you check at info object level, what kind of conversion routine it used by.
    Use T code - RSD1, enter your info object and display it.
    Even at data source level also you can see external/internal format what it maintained.
    if your info object was using ALPHA conversion then it will have leading 0s automatically.
    Can you check from source how its coming, check at RSA3.
    if your receiving this issue for records only then you need to check those records.
    Thanks

  • Se16 down load into excel sheet problem with PO number

    Dear All,
    While I download vbak table data using se16 from table VBAK ( using System > List> save --> local File --> Spreadsheet ), I get the PO number converted as error like at it's end, the last digit is becoming zero when po number is of 16 digits.  means only the last digit is converted to 0.
      For example : se16 -> vbak table -> the po numbers
    1238643210249039, when I down load in the excel sheet it is appearing as 1238643210249030
    (I means the last digit of the PO number is downloaded with error, it is always a u201C0u201D.
    if the PO number is of less than 16 digits... the above problem is not there )
    How to correct the error ? How to tell solution to functional consultant ? Can you please suggest me
    Do we need to apply any OSS message ?
    Thanks in ADVANCE.
    Edited by: sam kumar on Dec 8, 2008 5:40 PM

    Hi,
    Just found that 'Numbers in Microsoft Excel can never have more than 15 significant digits'.
    check this link from Microsoft: [http://support.microsoft.com/kb/158071|http://support.microsoft.com/kb/158071]
    check this  [http://office.microsoft.com/en-us/excel/HA102748231033.aspx|http://office.microsoft.com/en-us/excel/HA102748231033.aspx]
    [http://office.microsoft.com/en-us/excel/HA102748231033.aspx#5|http://office.microsoft.com/en-us/excel/HA102748231033.aspx#5]
    What i can suggest is, put a apostrophe (') for the value of first cell content at the beginning.
    Use Format painter to apply the same for all values in that column.
    Regards
    Raj
    Edited by: Rajasekhar Dinavahi on Dec 8, 2008 10:59 PM
    Edited by: Rajasekhar Dinavahi on Dec 8, 2008 11:00 PM
    Edited by: Rajasekhar Dinavahi on Dec 8, 2008 11:05 PM

  • Preserving prefixed zeros  in down load to excel file

    In My application lot of character field have character zero as the starting characters. Like Company code= 0600, Property= 00390898 .
      When I do a download from Internal table to excel sheet, this character fields are showing with the zeros in front like 600 & 390898. Is there any way preserve the zeros in the excel sheet ?
      Also I would Like to know How can I move the character ( '  ) . If I used ''' then it gives compile error.
        If I can prefix this character ( ' ) , the field's will be shown with the zeros.
    Thanks for your help.
    Manoranjan

    Hi Manoranjan,
    What is the data type you are using for the Company Code in your internal table?
    You can try this way.Suppose your main internal table is itab1 where in the company code is refering the database table (T001-BUKRS).
    Declare one more internal table itab2 with company code as Character data type.
    Before downloading to excel move itab1 to itab2 and then try to use that itab2 for downloading. Now your excel sheet will have the numbers with zeros preceeding.
    Another option is after downloading to excel, I think you can change the properties of the column through Format Cells->Number tab->Text.
    Thanks,
    Srinivas

  • Down load into excel file

    Hi gurus,
                 I wanna generate a report that should download the data from the internal table to the presentation server in word formart, but the length of the word file should not be greater than 156 characters as the downloaded data is sent to RBI.
    Thanks and Regards,
    Alson.

    Hi Alson,
    you can wrap the text to a length of 156 chars using the function module:-
                CALL FUNCTION 'RKD_WORD_WRAP'
    for eg if u have any variable v_text which is 1000 chars long then u can give the outputlen = 100. This way u can split 1000 chars into 1000/100 = 10 rows. you can either store these lines in an internal table or it is also possible to store these as separate variables each of length 100 chars .
    you can refer to the following code:-
                CALL FUNCTION 'RKD_WORD_WRAP'
                      EXPORTING
                          textline                  =  v_text
                        DELIMITER                 = ' '
                          outputlen                 = 156
                      TABLES
                          out_lines                 =  i_long_text
                      EXCEPTIONS
                          outputlen_too_large       = 1
                          OTHERS                    = 2.
    Plz reward points if useful.
    Thanks
    Rahul

  • Leading zeroes when loading data

    Hi ,
    I have infobject 0gl_account being used in production . I am now using it in a custom ods also.
    however , when i load data into the ods , GL account field gets loaded with leading zeroes.
    when i load master data to 0gl_account, there are no leading zeroes . My ODS activation gives
    an error saying NO SID exists for gl acct 000999999 , whereas gl acct 999999 exists in the
    master data.
    I can change settings of 0gl_account as it is already being used in production . is there
    a way to resolve this without creating a custom infoobject .
    pls guide
    thanks

    Hi,
    this sounds very strange, because normally the master data should come with leading zeroes. Additionally the conversion exit ALPHA is switched on for infoobject 0gl_account. Make sure that everything is set up correctly and your master data gets loaded correctly.
    regards
    Siggi

  • 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

  • How do you prevent the organizer from mixing the order of pictures when down loading off the memory card?

    @How do you prevent the organizer from mixing the order of pictures when down loading off the memory card?

    This sounds like you are using Photoshop Elements, and the Photoshop Elements forum would be best at answering that.
    Photoshop Elements
    Gene

  • EMF images embedded in Excel 2010 documents don't display when the same document is loaded into Excel 2013

    I have a fairly large spreadsheet which creates layout floorplan maps based on a table of 3,000+ room locations and various cross-referenced attribute lookup tables which add flags & colour coding to the individual rooms. The maps also
    include a few graphic elements beyond simple cells and borders, such as EMF images to indicate stairways, etc.
    The sheet works perfectly on my Win7 desktop in Excel 2010:
    However when loaded into Excel 2013 on my Win7 laptop, all of the images show as a red cross with the wording "This image cannot currently be displayed", thus:
    Any ideas, as this looks like a bug in Excel 2013? Thanks.
    Andre

    Hi Andre,
    What happens if you reimport the images from original source?
    Try Running Excel Program firstly, and then open this file within Excel (File->Open).Also if you have Excel 2010 installed , try to open the file using Excel 2010, copy an paste the content to a blank Excel file.
    You can also try to check the option 'Disable hardware graphics acceleration'. File->Options->Advanced ...
    Wind Zhang
    TechNet Community Support

  • Is it possible to tag a pdf with 'reject', so when it loads into Bridge, it will be pre-rejected?

    Is it possible to tag a pdf with 'reject', so when it loads into Bridge, it will be pre-rejected and not view (so long as 'show reject files' is unchecked in Bridge)? - Please see screen shot.
    We're wanting to have all pdf's initially set, so they don't view in Bridge, until the 'reject' tag is then removed.
    Any help would be great! Thanks.

    Well, not possible directly because the Acrobat interface doesn't allow changing Bridge's ratings and labels.  But as Omke Oudeman showed over in the Bridge Scripting forum, they are stored in the XMP metadata, where "Reject" seems to be an xmp:Rating of -1.  Thus you may be able to add this bit of metadata within Acrobat Pro by using the Append... [XMP template] command -- assuming you can come up with an XMP template, and can find the command buried in the interface (in Acrobat 9 it is behind the Additional Metadata button on the Properties/ Description tab, and then from there under Advanced).  Another route might be via Javascript.  Either way, before investing much time you should consider that most software won't see labels and ratings you add to the XMP metadata, and, as Omke mentions in that thread, their rendering seems somewhat fragile even in Bridge.
    Another route might be adapting a metadata category already available in Acrobt's interface: Keywords, say, "Approved" and "NotApproved".  (If you can't touch the Keywords, maybe you could re-purpose another of Acrobat's categories; and of course my suggestions are not related to Acrobat's stock stamps "Approved" and "Not Approved," a different kettle of fish).  Keywords might suffice for you to filter views in Bridge, but if you really want Bridge to show files with "Reject" then they must carry that tag.  If neither an XMP template nor an Acrobat Javascript serves, I imagine a Bridge script could apply "Reject" to files with the keyword NotApproved.  Of course, for any PDFs whose status changes you'd need to adjust both the Reject (xmp:Rating -1) and the keyword; perhaps another script could un-Reject and change the keyword to Approved in one step.

  • 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};

  • When down loading updates, im ask what program to open it up with

    when down loading the updates my computer ask me what program i want to open it with?

    Firefox updates automatically - see [[Updating Firefox]] - but if you want to update to the latest Firefox version (currently 9.0.1) by downloading the installer .dmg file, just save it to your computer then start the installation by double-clicking the .dmg file. See [[Installing Firefox on Mac]] if you need more help.

  • HT201303 When down loading a free app from the App Store it is asking the credit card entries

    When  down loading a free app from App Store it is asking the credit card informations at  present I do not have credit card what have to do
    Ajithkumar

    Maybe this will help:
    https://discussions.apple.com/message/22110989#22110989

Maybe you are looking for