KF value missmatch due to conversion

Hi All,
In one of my Keyfigures of DSO showing varience in values because of Conversion.
Case I: Value displayed by selecting  Check  box : Do not use any conversion
KF Value Displayed as below:
Case II:  Uncheck - Do not use any conversion
KF Value displayed:
Here although correct value is 562500.00 value Bex Report output is Displaying 56250000.00. Which is multiplied with 100.
There is 0 decimal value at TCURX table. Still facing miss match.
Expert's suggestions are welcome.
Regards,
Vijay

Vijay,I think its a known behaviour because all sap currencies are stored with 2 decimal places.So if any currency is stored with 0 decimal places then it multiples the amount by 100 while displaying the result at query level.Same is happening in your case as well.
There is a detailed document on the same which covers this situation and also provide solution for it.
Please check this.
Exceptional Currency Handling in BW
Hope this resolves your issue.
Regards,
AL

Similar Messages

  • Example of using VALUE/AMOUNT in transformation conversion?

    Does anyone have a good example of using the AMOUNT keyword in a transformation conversion section and the corresponding VALUE keyword in the conversion file formula column? 
    I have a situation where I am running the LoadInfoProvider package and I want to avoid loading records where the Signeddata value is less than zero. 
    Thanks.
    -Amy

    Sorry  Amy,
      I thght you  were using the direct transactional loading from the infocube...as in  here..
    Is there a way to enable delta for BPC transaction loads ?
    -vishal.

  • Key field values for file content conversion at sender communicationchannel

    Hi all,
    I am working on  scenario File to Idoc.In this scenario at the sender side we configure the file content conversion for .CSV file.
    In the flat file i am having more than one orders, XI will pick the file and creates a separate Idoc for each sales order at r/3.
    We have similar fields "Order Item Number" both header and item.
    If we got '00000' on the Header item then it should create a new idoc at the r/3 side other wise it will create line item.
    Order item number will be 00000 for header but it will differ from order item to item.
    source structure
    Order Header
    Order type
    Sold-to-code
    PO number
    Order item number
    Order date
    AdresName1
    AdresName2
    Street and House number
    Postal Code
    City
    Country Code
    Filler
    Order Item
    Order type
    Sold-to-code
    PO  number
    Order item number
    Order date
    Product code
    Order quantity
    Item text
    Filler
    Now I have some questions....
    I don't have standard filed values to give the key fileds at source structure.
    I need to create the Idoc at r/3 system for each individual record.
    Is it possible to create new idoc with out using the Key filed value?
    If it is possible then how can i proceed with fcc?
    please give me your valuable suggestions
    Best Regards,
    satya
    Edited by: satyatanuku on Mar 3, 2010 1:41 PM
    Edited by: satyatanuku on Mar 3, 2010 1:42 PM
    Edited by: satyatanuku on Mar 3, 2010 1:44 PM

    Hi,
    Just check the Content Conversion Parameters-  Recordset Structure.
    If you have filled in this parameter with
    Header,1,Item,1
    then change it to
    Header,1,Item,3
    Regards
    Chandra

  • How to avoid record rejection due to conversion failed for dirty data

    There is a source delimited flat file created with codepage CP936, simplified
    Chinese. Data Services XI on HP Unix has to extract this file to a UTF-8 db2
    table.
    However, because the flat file contains a lot of dirty or corrupted
    characters for Chinese word columns, some records are failed to convert and being
    rejected by DS to load to db2. Typically the error is the corrupted character
    causes DS to think there is less delimiters on the record then it should be.
    I use less perfect workaround to cheat DS to tell it is UTF8 codepage input file
    instead of CP936 codepage file, and DS doesn't complain missing delimiters no more, but the
    extracted Chinese columns are not readable.
    However, problem resurfaces again when DS encounters this gibberish data value in
    one column of the record:
      u20AC\ \u2021 u20ACxu2019 u20AC     
    The record will be rejected entirely and no error and no warning being generated
    by DS to explain the rejection. Even I try to use Text delimiter of double qoute to enclose
    this data value, but DS still unable to extract it and rejects the whole record without warning.
    Is there a way to use Validation Transform or other transforms to catch all the conversion
    errors before hand, and assign null value for dirty data values, rather then
    letting the records being rejected?
    Or there is a way to set the options and relax the conversion errors to let
    all data records successfully extracted? Currently at Error handling section
    of flat file format object, all error handling and logging options are
    selected Yes.
    Edited by: Chow Ming Darren Cheeng on Aug 7, 2009 10:31 AM

    Thank you for your reply. Currently I am using this ifthenelse function to check wheter the data value contains
    escape character and set the whole value to null to avoid data rejection.
    ifthenelse(index(column_value, '
    ', 1) IS NOT NULL, NULL, column_value)
    The source file team says that whenever they have nonprintable characters inside the data value, the character will be escaped with
    I agree with what you said if record is broken up too much, DS has no choice but to skip it.

  • Short dump due to conversion error on screen

    Hello all,
    I have designed one screen, and throwing error message if perticular filed is blank as (message e002(z2)). If i keep the filed blank system is throwing error message but giving short dump because of 'Conversion error' .
    Error analysis : 'The program has been interrupted and cannot resume.                                           |
    Program "SAPMZTIMECOLLECT_NEW" attempted to display fields on screen 0101.
    |    An error occurred during the conversion of this data. '
    Please, could you help to understand why system is giving short dump.
    Thanks in advance..!!

    Solved for me.
    If we don't have value for the field which we are passing it to tablecontrol, then declare the variable with the same type and assigned space for the same and submit it to table control output. then the error is not coming.
    Ex: If we dont have the value for the table control field (KOSTL), then declare one constant K_KOSTL LIK below,
    DATA:K_KOSTL TYPE KOSTL.
    K_KOSTL = ' '.
    IF the value of table control field is initial, then pass K_KOSTL to it.
    This what I have done.
    Regards
    Ramesh.

  • Value error during type conversion (KONP-KBETR to packed nos).

    Hi,
    I am using TYPE KONP-KBETR whose data element is 'KBETR_KOND'. Its Length is 11 and decimal Places is 2.
    Now I want to store this value in a variable with 3 decimal places.
    For this I have taken a variable with type P.
    Eg : DATA  : VALUE2(7) type P decimals 3.
    When I store the value of KONP-KBETR in var VALUE2, I get some confusing value.
    For Eg: if KONP-KBETR = 300.00 and I pass this value to var VALUE2, then VALUE2 becomes 30.000.
    Ideally VALUE2 should have been 300.000.
    Can anybody tell why this is so and what needs to be done to get the correct value.?
    Thanks.

    Hi Kumar,
    TABLES KONP.
    data: val1 TYPE KONP-KBETR value '300.00',
          VALUE2(7) type P decimals 3.
    value2 = val1.
    write: val1,
           value2.
    the output of the above code, 300.00     300.000.
    i didn't get any problem.. check it out once..
    Ram

  • Conversion failed when converting the varchar value 'undefined' to data typ

    Conversion failed when converting the varchar value 'undefined' to data type int.
    hi, i installed oracle insbridge following the instruction in the manual. in rate manager, when i tried to create a new "Normal rating" or "Underwriting", im getting the following exception
    Server Error in '/RM' Application.
    Conversion failed when converting the varchar value 'undefined' to data type int.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'undefined' to data type int.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [SqlException (0x80131904): Conversion failed when converting the varchar value 'undefined' to data type int.]
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
    System.Data.SqlClient.SqlDataReader.HasMoreRows() +157
    System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +197
    System.Data.SqlClient.SqlDataReader.Read() +9
    System.Data.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) +50
    System.Data.SqlClient.SqlCommand.ExecuteScalar() +150
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +110
    [Exception: Cannot Execute SQL Command: Conversion failed when converting the varchar value 'undefined' to data type int.]
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +265
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQueryProc(String subscriber, String datastore, String identifier, String command, Transaction transType, Object[] procParams) +101
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQuery(String subscriber, String identifier, String command) +22
    Insbridge.Net.RM.IBRM.ExeScalar(String cmd, Object[] paramsList) +99
    Insbridge.Net.RM.Components.Algorithms.AlgEdit.Page_Load(Object sender, EventArgs e) +663
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    my insbridge versions are as follows
    IBRU 4.0.0 Copyright ©2010, Oracle. All rights reserved. - Version Listing
    RMBUILD.DLL 4.0.0.0 (x86)
    SRLOAD.DLL 3.13.0 (x86)
    IBRM v04.00.0.17
    IB_CLIENT v04.00.0.00
    RM.DLL 4.00.0 (x86)
    IBFA 3.0.2
    OS: Windows Server 2003
    DB: Sql Server 2008
    Browser: IE8
    how do i solve this, please help

    This is an error due to conversion failed from character string to int datatype. Infact, the table column contains "NO" value which you are trying to convert to Int/SUM which is illegal. Without your code and table structure, its difficult to pinpoint your
    actual issue. But check, all columns for value "NO". 

  • Retrieving values from a table

    Hi all,
    I need to retrieve values from CSKS-KOSTL for values containing the pattern entered by the user. For example, if the user enters 1, need to retrieve all the KOSTL values starting with 1. But when i write a SELECT statement mentioning where kostl in '1', it is ignoring all the values like (0000001, 00001034, 0012334, and others). Only values starting with 1 is only retrieved as this is a character field and due to conversion routine, zeroes are prefixed while storing in the database.
    Could any one let me know how to retrieve the values from the database in this situation?

    If you want to use IN operator in your where clause then you should define a range variable(R_KOSTL) which refers to CSKS=KOSTL and populate the range as below
    R_KOSTL-SIGN = 'I'.
    R_KOSTL-OPTION = 'CP'.
    R_KOSTL-LOW = '1*'.
    APPEND R_KOSTL.
    and then write your select statement as .... WHERE kostl IN r_kostl.
    The approach suggested by Amit should also work fine.
    Thanks
    Kiran

  • Recalculation of Value field in COPA

    Hi,
    We have a value field in COPA which derives its value from the UoM conversion maintained in Material Master,
    we have now realized that incorrect conversion factors were maintianed in some material master records due to which incorrect values are being displayed in COPA reports.
    We have corrected the Material Master records, but how can we update the existing COPA values ?
    Regards
    Sachin Bhutani

    Hi ,
    You cannot revalue value fields in COPA. You can however derive the characteristics derivation using Realignment functionality. In order to overcome your problem , you may have to resort to differential postings generation through KE21N.
    Enjoy
    Venkat.

  • Conversion in sales order

    Hi,
    I am creating sales order for exprt sales. The currency for the customer is "USD" I have maintained the exchange rate between INR & USD.
    1. When i create the sales order without any reference, the system in the pricing conditions shows me values in 2 columns. In the condition value columns - <b>KOMV - KWERT</b> the system displays me values according to USD. Also in the next condition value column <b>KOMV - KWERT_K</b> the system displays values in INR after conversion.
    2. But when i create the sales order with respect to quotation  or if Inquiry - Quotation wrt inquiry - Sales order wrt to quotation then the system does not display the values in the <b>KOMV - KWERT_K</b> field. I am facing problems with this as i am not able to prepare the excise invoice as the values are not there in INR.
    Is there any setting in the condition type or document type which controls the conversion in the repsective sales document? I have checked but not found any.
    Regards,
    Allabaqsh G. Patil

    Hi Allabaqsh
    It is not necessary the INR value should flow in KOMV - KWERT_K to generate excise invoice.  If this is zero, you can very well prepare excise invoice.  Why I am confidently telling you is that I do make lot of export invoices where the said field is ZERO only but I could generate excise invoices all these years.
    If you face any problem in generating excise invoice, it could be due to
    1)  Material and Chapter ID combination not maintained in J1ID
    2)  Customer code not maintained in J1ID
    3)  Plant not flowing in Sale order / Billing
    4)  Excise Group / Series Group not assigned to plant
    5)  TAXINN / TAXINJ  are assigned
    Check all these parameters and confirm.  I am sure, you would have missed out any of the above.
    Thanks and dont forget to reward points if this helps you.
    G. Lakshmipathi

  • Alfa conversion

    Hi,
    what is alfa conversion and what its usage.
    thaks for ur answers
    regards
    ram

    hi,
    https://websmp102.sap-ag.de/~sapidb/011000358700000167472003
    Frequently Asked Questions - ALPHA Conversion
    Questions
    What is the "ALPHA conversion" about?
    Why is the "ALPHA conversion" necessary?
    Where do I find detailed information?
    What are the prerequisites for the "ALPHA conversion"?
    What effects does the "ALPHA conversion" have on my SAP NetWeaver BI system?
    How long does the conversion take?
    What is the interrelation between a SAP NetWeaver BI upgrade and the "ALPHA conversion"?
    Answers
    <i>What is the "ALPHA conversion" about?
    A characteristic in SAP NetWeaver BI can use a conversion routine like the conversion routine called ALPHA. A conversion routine converts data that a user enters (in so called external format) to an internal format before it is stored on the data base.
    The most important conversion routine - due to its common use - is the ALPHA routine that converts purely numeric user input like '4711' into '004711' (assuming that the characteristic value is 6 characters long). If a value is not purely numeric like '4711A' it is left unchanged.
    We have found out that in customers systems there are quite often characteristics using a conversion routine like ALPHA that have values on the data base which are not in internal format, e.g. one might find '4711' instead of '004711' on the data base.
    It could even happen that there is also a value '04711', or ' 4711' (leading space).
    This possibly results in data inconsistencies, also for query selection; i.e. if you select '4711', this is converted into '004711', so '04711' won't be selected.</i>
    Why is the "ALPHA conversion" necessary?
    In such a case, a number of problems can arise in reporting like wrong values of key figures, no data found for certain filter values...
    The "conversion of internal characteristic values", in short term: "ALPHA conversion", is a transaction (transaction code RSMDCNVEXIT) that checks the format of all values of characteristics that use one of the conversion routines ALPHA, GJAHR and NUMCV.
    If values are found that do not have the correct internal format it can replace them by correct value and update all dependant SAP NetWeaver BI objects (like InfoCubes, Hierarchies, master data of other characteristics...).
    This transaction potentially has to touch a very significant part of all the data in SAP NetWeaver BI. While running the check or conversion phase of RSMDCNVEXIT no data loads of any kind are possible; the conversion part of it cannot be interrupted. Therefore you should never start the conversion part without having thoroughly read the documentation.
    We recommend to run the conversion as soon as possible.
    Where do I find detailed information?
    The "ALPHA conversion" transaction RSMDCNVEXIT has online documentation which you reach via its "Help" button.
    OSS note 447341 is about the ALPHA conversion in general and has attached to it a number of other OSS notes describing solutions to known problems.
    What are the prerequisites for the "ALPHA conversion"?
    Before running ALPHA conversion, apply SP 26 (SAP BW 2.0B) resp. SP 18 (SAP BW 2.1C) resp. SP 11 (SAP BW 3.0A).
    If you have large ODS Objects (> 50 mio records in all) we recommend to apply Support Package 27 (SAP BW 2.0B) resp. 19 (SAP BW 2.1C) or the coding correction of OSS note 548122.
    If you are unsure if the conversion has already been executed in your system (in a SAP BW 3.0A system it probably has already been done during the upgrade to SAP BW 3.0A) start transaction RSMDCNVEXIT and look at the system status: if it says "All characteristic only have correct internal values" you do not need to run it.
    We recommend a database backup before you run the transaction.
    If you have strong reasons not to apply the named support packages, please note that you can run the ALPHA conversion starting from SP 22 (SAP BW 2.0B) resp. SP 14 (SAP BW 2.1C). If your support package level is strictly smaller than 25 (SAP BW 2.0B) resp. 17 (SAP BW 2.1C) you have to apply the coding correction of OSS note 528381. If you have SID tables with more than several millions of records you have to be on SP 25 (SAP BW 2.0B) resp. 17 (SAP BW 2.1C) and also apply a correction described in OSS note 543482.
    What effects does the "ALPHA conversion" have on my SAP NetWeaver BI system?
    No data loads are possible while the transaction is checking or converting.
    Once the conversion part has been started the conversion has to be completed. The system is in an inconsistent state in the mean time!
    How long does the conversion take?
    Usually, the alpha conversion requires between 3 and 20 hours for production systems. For very big systems (>1TB) , it could also take up several days.
    From our experience, the most decisive factor for the duration is the size of the ODS objects. As a rough rule of thumb, approximately 2.5 mio. Records per hour can be converted within ODS objects (status SAP BW 2.0B SP 27 resp. SAP BW 2.1C SP 19). To improve the conversion for ODS objects, keep the change log small (i.e. delete old entries) because all change log records will be converted, too. Furthermore, the size of the master data tables (which include characters with one of the ALPHA, NUMCV or GJAHR conversions) has impact on the runtime of the upgrade.
    As of SAP BW 2.0B SP 29 resp. SAP BW 2.1C SP 21, ODS objects can be converted in parallel. Please see note 559524 for details how to set up this parallelism.
    As of SAP BW 2.0B SP 29 resp. SAP BW 2.1C SP 21, transaction RSMDCNVEXIT is enhanced by a workload estimate. This preliminary check lists all characteristics, database tables and the size of the tables that will be converted during the alpha conversion. Furthermore, possible meta data inconsistencies are found and the possibility of aborts during the conversion is reduced.
    During the conversion process, you can check the state of the conversion in the log.
    This estimate can be executed without locking the system. We recommend to run it before starting the conversion.
    Please see the enhanced online help in transaction RSMDCNVEXIT for more details.
    What is the interrelation between a SAP NetWeaver BI upgrade and the "ALPHA conversion"?
    During the prepare phase of an upgrade to SAP BW 3.0B it is checked that the "conversion of internal characteristic values", also called "ALPHA conversion", has been successfully completed. This "ALPHA conversion" is time-consuming. Therefore we strongly recommend to separate this conversion from the actual upgrade process.

  • Get the values from a table comparing fields of different data types

    Hi Experts,
    I want to fetch AFVC-AUFPL and AFVC- APLZL by passing WBS element from a ztable.
    select aufpl aplzl
      from  afvc
      into TABLE gt_afvc
      FOR ALL ENTRIES IN gt_boq
      where projn = gt_boq-posid.
    AFVC-PROJN - NUMC 8  (WBC ELEMENT)
    ZTABLE-POSID - CHAR24 (WBC ELEMENT)
    How to get aufpl and aplzl by comparing those 2?
    Regards
    Mani

    WBS element does have an conversion routine at the domain level. So sometimes you work with one format (8 digits) and sometimes with 24 digits.
    You use FMs
    CONVERSION_EXIT_ABPSP_INPUT
    CONVERSION_EXIT_ABPSP_OUTPUT
    to convert between values. Do your conversion before your select and do not forget to use a large enough data element for the field, which gets the 24-digits long value of the field.

  • SSRS - Expression to color column value dynamically in Matrix

    Hi ,
    I have a matrix which looks like :
    The <<Expr>> value can be 1 /0 /"-" .
    The Expr value is being calculated dynamically.
    The data set query I am using has a column called due_days.
    In the color expression of the <<Exp>> box I am using the expression as :
    =IIf(Fields!Due_Days.Value>14  and Fields!Notes_Count.Value>0,"Blue",(Iif(Sum(Fields!Notes_Count.Value)=0 ,"Red","Black")))
    My requirement is if the Due_Days column value is >14 then I need to highlight the value as blue else black and if value is 0 then red. When I use the above query it is just highlighting the color blue for 1st column only. Eg: 4th row . Due days for month
    of Oct and Nov is > 14 but it shows blue only for month of oct.
    How can i resolve the issue?

    In select query i have 5 columns:
    Due days(Which is difference between 2 dates) ,
    Notes count (Which is just a count of notes  entered or not having value 0/1  and value '-' if another column CRD is greater than the matrix month and year.)Eg: below date 11/12/2014 is greater than Oct 2014 hence Oct 2014 should have "-"
    Month Name , Year , Month Nbr (last 6 months which I cross joined with the table to get counts for each month)
    The matrix has year and last 6 month  as column groups
    Color coding should be if notes count is 0 then red  ,if notes count is 1 and due_days> 14 then blue else black . When i try to use expression for color as i mentioned above, it colors only 1st colum.eg:  2nd row
    Nov 2014 is blue but for jan 2014 also it should show blue as due days>14 .
    Is there any way i can do that ??
    Eg: data set returns value as :
    Due Days        CRD                              Month         
    Month_Nbr    Year   Notes _Count
    5             2014-11-28 00:00:00.000    December          12         2014       
    0
    5               2014-11-28 00:00:00.000    February           2         2015        
    0
    5             2014-11-28 00:00:00.000    January              1           2015      
    0
    5            2014-11-28 00:00:00.000    November          11          2014       1
    5            2014-11-28 00:00:00.000    October              10          2014        0
    5            2014-11-28 00:00:00.000    September          9           2014         0
    Matrix is of the form :
                  YEAR
                  MONTH
    CRD        Notes_count

  • Retrieve front end values of editable alv in same format

    I have a problem to retrieve the front end values in editable alv filled by user.
    I am able to get it from MODIFIED CELL method but it gives the values after
    alv automatically conversion. For example if user filled 1 in cell of type numc
    then i want to keep it as 1 not as 00..001 format of numc.
    Same for when user fill alphbets in small letter the alv convert it in CAPS.
    I want to retain it as it as filled by user.
    Example: User filled aAbBcFG in a cell
    then it should update in database in same format not like AABBCFG as alv did
    <offer removed by moderator>
    Edited by: Rocky_S on Jan 20, 2011 7:50 AM
    Edited by: Rocky_S on Jan 20, 2011 7:51 AM
    Edited by: Thomas Zloch on Jan 20, 2011 11:24 PM

    Hi Srinivas I have used CONVERSION_EXIT_ALPHA_OUTPUT for number input. My problem is that
    when user fill 0 in the alv cell then alv automatically convert it into 00000000. My field is of type numc
    that why it converts in 00000000. I want to retrieve it as the user fill in alv cell. Through this function
    module the import parameter parameter is of numc format not as filled by user. In my case if it is 0
    then then i should retrieve it as it is.
    My actual scenario is i have a numc type field in alv and i want to keep it as mandatory. For which i am
    writing a logic. Because in my table there is a valid entry of 0. If user do not fill 0 then it takes automatically
    0 as input because of initial value of numc field. I want to restict it. I can not convert this field as char.
    Give me some logic to make numeric field mandatory.

  • I cannot remove embedded barcode from the image. Due to saving compression.

    Hi guys,
    I recreate a thread to prevent confusing on my previous one. Please only reply to this thread thanks.
    Ok, for a start I will give some general description about the application I made.
    I had some problem with the image being compressed while it is saved.
    Because saving an image will cause it to compress and had its pixel valued changed, I could not successfully remove the bardcode that is embedded inside a image(although some of the pixel value will be returned to original normally). I had placed my code below and will accept any opinion that will help me solve the removal of barcode problem.
    What my application does is actually very simple. It will take the pixel value of the area inside the image that will be embed with the barcode first, then it will take the pixel value of the barcode and use the formula (1-alpha * Image pixel value) + (alpha * barcode pixel value) = new pixel value which will contain the barcode that had been embedded inside. The formula works great but when I saved the image the pixel value will change due to compression. On the removal of barcode my application will read every pixel value from the image embedded with barcode (only the area with barcode embedded), then it will go on to read every pixel value of the barcode used for embedding and then use the formula (Embedded image pixel value - (alpha * Barcode pixel value) - (1 - alpha) = original pixel value. But due to the reason that compression will change some of the pixel inside the saved image to drop in its value, the result from the removal formula will be negative and hence caused my result image to become wierd as it will red colors instead of original color on some of its pixel. I tried saving under PNG format which people said to be lossless compression but the result is still the same.
    So I need to ask you guys for opinion or help me find the part where I actually did wrongly and caused the image pixel value to change.
    Thanks. Please proceed and read below for the codes that I used. It is messy and I will sort it out later.
    When alpha is set as 1 the barcode will appear to be overwrite onto the image. But when alpha is set as 0.1 the barcode will appear to be transparent and almost seems to be not there on the image when embedded.
    This is the code I used to retrieve image pixel when embedding:
    public static int[] getImagePixelValue(BufferedImage image, int x, int y){
              //Create an array to store image RGB value
              int[] imageRGB = new int[3];
              //Get height and width from input image
              int imageWidth = image.getWidth();
              int imageHeight = image.getHeight();
              //Get raw RGB value from image
              int imageValue = image.getRGB(x, y);
              //Convert image raw RGB value
              int imageRed = ((image.getRGB(x, y) >> 16) & 0xff);
              int imageGreen = ((image.getRGB(x, y) >> 8) & 0xff);
              int imageBlue = image.getRGB(x, y) & 0xff;
              //Input the converted RGB value into the array
              imageRGB[0] = imageRed;
              imageRGB[1] = imageGreen;
              imageRGB[2] = imageBlue;
              /*//Print out the pixel value to check
              System.out.println("Image red pixel: "+imageRGB[0]);
              System.out.println("Image green pixel: "+imageRGB[1]);
              System.out.println("Image blue pixel: "+imageRGB[2]);*/
              //Return image RGB value
              return imageRGB;
    }This is the code I used to retrieve barcode pixel for embedding:
    public static int[] getWatermarkPixelValue(BufferedImage watermark, int x, int y){
              //Create an array to store watermark RGB value
              int[] watermarkRGB = new int[3];
              //Get height and width from input watermark
              int watermarkWidth = watermark.getWidth();
              int watermarkHeight = watermark.getHeight();
              int watermarkValue = watermark.getRGB(x, y);
              //Convert watermark raw RGB value
              int watermarkRed = ((watermark.getRGB(x, y) >> 16) & 0xff);
              int watermarkGreen = ((watermark.getRGB(x, y) >> 8) & 0xff);
              int watermarkBlue = watermark.getRGB(x, y) & 0xff;
              //Input the converted RGB value into the array
              watermarkRGB[0] = watermarkRed;
              watermarkRGB[1] = watermarkGreen;
              watermarkRGB[2] = watermarkBlue;
              /*//Print out the pixel value to check
              System.out.println("Watermark red pixel: "+watermarkRGB[0]);
              System.out.println("Watermark green pixel: "+watermarkRGB[1]);
              System.out.println("Watermark blue pixel: "+watermarkRGB[2]);*/
              //Return watermark RGB value
              return watermarkRGB;
         }This is the code I used for merging the image pixel and barcode pixel to get the embedded pixel value:
    public static int[] getEmbeddedPixelValue(int[] imagePixelValue, int[] watermarkPixelValue, double alpha){
              //Create a object to hold embedded pixel value
              int[] embeddedRGBValue = new int[3];
              //Change image pixel value into double calculating equation
              double imgRedValue = (double) imagePixelValue[0];
              double imgGreenValue = (double) imagePixelValue[1];
              double imgBlueValue = (double) imagePixelValue[2];
              //Change watermark pixel value into double calculating equation
              double wmRedValue = (double) watermarkPixelValue[0];
              double wmGreenValue = (double) watermarkPixelValue[1];
              double wmBlueValue = (double) watermarkPixelValue[2];
              //Equation for embedding image and watermark together
              double embeddedRed = ((1.0 - alpha) * imgRedValue) + (alpha * wmRedValue);
              double embeddedGreen = ((1.0 - alpha) * imgGreenValue) + (alpha * wmGreenValue);
              double embeddedBlue = ((1.0 - alpha) * imgBlueValue) + (alpha * wmBlueValue);
              //Changing embedded value from double to int
              int embeddedRedValue = (int) embeddedRed;
              int embeddedGreenValue = (int) embeddedGreen;
              int embeddedBlueValue = (int) embeddedBlue;
              //input the embedded RGB value into the array
              embeddedRGBValue[0] = embeddedRedValue;
              embeddedRGBValue[1] = embeddedGreenValue;
              embeddedRGBValue[2] = embeddedBlueValue;
              //Return embedded pixel value
              return embeddedRGBValue;
         }This is the code where I used for the embedding process:
    else if(target == embedButton){
                   String xCoordinate = JOptionPane.showInputDialog(embedButton, "Enter coordinate X", "When you want to embed the watermark?", JOptionPane.QUESTION_MESSAGE);
                   String yCoordinate = JOptionPane.showInputDialog(embedButton, "Enter coordinate Y", "When you want to embed the watermark?", JOptionPane.QUESTION_MESSAGE);
                   int xValue = Integer.parseInt(xCoordinate);
                   int yValue = Integer.parseInt(yCoordinate);
                   int wCounter = 0;
                   int hCounter = 0;
                   //Create file object to be used in embedding and removing watermark
                   File inputImage = new File(imagePath);
                   File inputWatermark = new File(watermarkPath);
                   //Convert string into double for calculation of embedded pixel value
                   try {
                        alphaDouble = Double.valueOf(alphaValue).doubleValue();
                   catch (NumberFormatException nfe) {
                        System.out.println("NumberFormatException: " + nfe.getMessage());
                   try{
                        //Define selected image as testPic and make java read the file selected
                        BufferedImage image= ImageIO.read(inputImage);
                        BufferedImage watermark= ImageIO.read(inputWatermark);
                        BufferedImage testing;
                        //Get height and width value from the selected image
                        int imageWidth = image.getWidth();
                        int imageHeight = image.getHeight();
                        //Get height and width value from the selected barcode
                        int watermarkWidth = watermark.getWidth();
                        int watermarkHeight = watermark.getHeight();
                        int totalWidth = watermarkWidth + xValue;
                        int totalHeight = watermarkHeight + yValue;
                        //Use nested for loop to get RGB value from every pixel that the barcode will be embedded in the selected image
                        if(totalWidth <= imageWidth && totalHeight <= imageHeight){
                             for (int h = yValue ; h < totalHeight; h++){
                                  for (int w = xValue; w < totalWidth; w++){
                                       int[] imagePixelValue = getImagePixelValue(image, w, h);
                                       int[] watermarkPixelValue = getWatermarkPixelValue(watermark, wCounter, hCounter);
                                       int[] embeddedPixelRGBValue = getEmbeddedPixelValue(imagePixelValue, watermarkPixelValue, alphaDouble);
                                       setRed(image, w, h, embeddedPixelRGBValue[0]);
                                       setGreen(image, w, h, embeddedPixelRGBValue[1]);
                                       setBlue(image, w, h, embeddedPixelRGBValue[2]);
                                       wCounter++;
                                       if(wCounter == watermarkWidth){
                                            wCounter = 0;
                                            hCounter++;
                        else{
                             JOptionPane.showMessageDialog(embedButton, "The watermark cannot be embedded at the coordinates.");
                        tempImage = image;
                        imageIcon = new ImageIcon(tempImage);
                        labelImage.setIcon(imageIcon);
                        imagePanel.add(labelImage);
                        container.add(imagePanel, BorderLayout.CENTER);
                        setVisible(true);
                        System.out.println("Embedding completed");
                   catch(Exception errorEmbedding){
                        //If there is any error, the try and catch function will tell you the error
                        System.out.println("The following error occured: "+errorEmbedding);
              }This is the code I use to save the image that had been embedded with the barcode:
    else if(target == saveAction){
                   JFileChooser chooser = new JFileChooser();
                   FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
                   chooser.setFileFilter(filter);
                   chooser.setCurrentDirectory(new File("."));
                   int returnVal = chooser.showSaveDialog(getParent());
                   if(returnVal == JFileChooser.APPROVE_OPTION) {
                        String name = chooser.getSelectedFile().getAbsolutePath();
                        //Create a string instant to hold outputImage path name
                        String saveFile = chooser.getSelectedFile().getName()+"."+fileType;
                        //Create file output to decide what name will be used to save the file
                        File outputImage = new File(saveFile);
                        try{
                             //Save the file with the name used
                             ImageIO.write((RenderedImage) tempImage,fileType,outputImage);
                        catch(Exception errorSaving){
                             //If there is any error, the try and catch function will tell you the error
                             System.out.println("The following error occured: "+errorSaving);
                   else{
              }This is the code I used for removal process of barcode:
    else if(target == removeButton){
                   //Create file object to be used in embedding and removing watermark
                   File inputImage = new File("removalTesting.jpg");
                   //File inputWatermark = new File(watermarkPath);
                   //Used a defined barcode for testing of removing barcode from embedded image
                   File inputWatermark = new File("barcode.jpg");
                   /*//Convert string into double for calculation of embedded pixel value
                   try {
                        alphaDouble = Double.valueOf(alphaValue).doubleValue();
                   catch (NumberFormatException nfe) {
                        System.out.println("NumberFormatException: " + nfe.getMessage());
                   //Used a defined alpha value for testing of removing barcode from embedded image
                   //alphaDouble = 0.5;
                   //Create x and y value for the starting coordinates of barcode embedded in the embedded image
                   int xValue = 0;
                   int yValue = 0;
                   int wCounter = 0;
                   int hCounter = 0;
                   try{
                        //Define selected image as testPic and make java read the file selected
                        BufferedImage image= ImageIO.read(inputImage);
                        BufferedImage watermark= ImageIO.read(inputWatermark);
                        //Get height and width value from the selected image
                        int imageWidth = image.getWidth();
                        int imageHeight = image.getHeight();
                        //Get height and width value from the selected barcode
                        int watermarkWidth = watermark.getWidth();
                        int watermarkHeight = watermark.getHeight();
                        int totalWidth = watermarkWidth + xValue;
                        int totalHeight = watermarkHeight + yValue;
                        //Use nested for loop to get RGB value from every pixel that the barcode had been embedded in the embedded image
                        if(totalWidth <= imageWidth && totalHeight <= imageHeight){
                             for (int h = yValue ; h < totalHeight; h++){
                                  for (int w = xValue; w < totalWidth; w++){
                                       int[] imagePixelValue = getImagePixelValue(image, w, h);
                                       int[] watermarkPixelValue = getWatermarkPixelValue(watermark, wCounter, hCounter);
                                       int[] removedPixelRGBValue = getOriginalImagePixelValue(imagePixelValue, watermarkPixelValue, alphaDouble);
                                       setRed(image, w, h, removedPixelRGBValue[0]);
                                       setGreen(image, w, h, removedPixelRGBValue[1]);
                                       setBlue(image, w, h, removedPixelRGBValue[2]);
                                       wCounter++;
                                       if(wCounter == watermarkWidth){
                                            wCounter = 0;
                                            hCounter++;
                        tempImage = image;
                        imageIcon = new ImageIcon(tempImage);
                        labelImage.setIcon(imageIcon);
                        imagePanel.add(labelImage);
                        container.add(imagePanel, BorderLayout.CENTER);
                        setVisible(true);
                        System.out.println("Embedding completed");
                   catch(Exception errorEmbedding){
                        //If there is any error, the try and catch function will tell you the error
                        System.out.println("The following error occured: "+errorEmbedding);
              }Sorry if the codes are in a mess, I did not had the time to sort it out yet but most likely do it when I got the removal of barcode done.
    Follow this link to have a look of the result I see in my application when I got the barcode embedded into the image I selected:
    [http://img356.imageshack.us/my.php?image=beforeremovalresultmg2.jpg]
    Follow this link to have a look of the result I see in my application after I got the barcode removed:
    [http://img523.imageshack.us/my.php?image=removalresultmx4.jpg]
    As you can see from the link, after I remove the barcode from the image. Some of the pixel actually went back to normal in the barcode area when the the barcode is embedded into the image. But some pixel in the barcode area had its value changed due to compression when I save the image file I think.
    Anyone can help me find out the problem?
    Thanks.

    KamenRider wrote:
    I suspect the problem lies in the code when I save the image. Because people said that PNG was loseless compression but when I saved in PNG some of the pixel went back to normal while some did not. This is obviously the cause from changing of pixel value when I saved the image.You are almost certainly wrong. This is trivially easy to check. Print out the color of a certain pixel immediately before you save it. Open the saved PNG in your favorite image manipulation program and check the saved value of that same pixel. When you re-load the saved PNG, print out the color again. It should be unchanged.
    Thanks you for trying to help me spot the problem but the formula is correct. The alpha value i used in my application is used to set the transparency of the barcode that will be embedded in the image. Hence, when alpha = 1 the new pixel value should be the barcode value. ^^The formula isn't wrong, it's just not doing what you think it's doing. Remember that you're working with ints here, not floating point numbers, so they have finite precision. When you case from double to int, fractions are dropped. As morgalr pointed out, your formula is:
    (1-alpha * Image pixel value) + (alpha * barcode pixel value) = new pixel value You didn't show us the code for getOriginalImagePixelValue but I imagine it's:
    original pixel value = (new pixel value - alpha * barcode pixel value) / (1 - alpha)On a piece of paper, take alpha = 0.9, image pixel = 17 and barcode pixel = 100. Calculate out what you should get for new pixel value and then calculate what you should get for original pixel value. You will find they don't match.

Maybe you are looking for

  • Acrobat 5.0

    I have a document that has a field. In that field I have text and everywhere I hit ENTER there is a box. I need to figure out how to get rid of the boxes. They show on screen and in print. Thanks,

  • Applying with panels doesn't work

    Hi, I've had this problem for a while now and no update seems to solve it. When i try to apply a style / color or anything by first selecting and then clicking on the panel nothing happens. For example, I create a text box with a filler text, select

  • Label Based menu not working in ppt

    I have created an xlf file with label based menu and added it to a ppt containing several slides. Now when I run the slide show, it goes to the next slide if I do not click any other label. But if I click one of labels and then want to move to the ot

  • Soundtrack Pro / Flash problems

    Since installing Soundtrack Pro, I have had problems with Macromedia Flash. I installed Soundtrack Pro yesterday and imported MP3 voice-over files for correction & improvement and saved them as .aiff files for import into a Flash .FLA file on my MacB

  • Function Module for TECO(technically complete) a maintenance work order

    Hi, Please let me know if there is any FM for TECO(technically complete) a maintenance work order. Regards, Vimal