BCD to decimal and viceversa

Hi,
Am working on conversion of decimal to BCD (Binary coded decimal) and viceversa. I require BCD for calling Cobol from Java using JNI.
Can anybody help me out in giving a pointer or an algorithm for doing the same.
I Googled on the web for any info on BCD conversion, but all in vain. Even Java Forums here in Sun also donot have any info on the same.
Please help me out.
TIA,
Prashanth Babu.

You'll have to adjust this to do put the output where you want. Surely not the only (and maybe not elegant):
   /** Write specified string into stream as two Binary-Coded Decimal (BCD)
    *     digits.
   private static void writeTwoBCDDigits(DataOutputStream stream,
                                         String           twoDigits)
          throws IOException
      // Convert two digits to Binary-Coded Decimal (BCD).
      // The "write(int)" function writes a numeric value in binary to the
      //    stream.
      // If the twoDigits string is parsed as a hexadecimal integer, then
      //    writing the equivalent decimal integer using "write(int)" will
      //    generate the correct BCD numbers.
      // For example, if twoDigits is "54", parsing this as the hexadecimal
      //    integer 54 results in twoBCDDigits as the decimal integer 84.
      //    Then, "write(84)" will write the correct bits to the stream:
      //    "0101 0100" (space not included).
      //    "0101" = BCD '5' and "0100" = BCD '4'.
      int twoBCDDigits = Integer.parseInt(twoDigits, 16);
      // Write out the numeric value of twoBCDDigits in one byte.
      stream.write(twoBCDDigits);
   }

Similar Messages

  • How to convert a BCD to Decimal?

    Hi,
          I am using a LabVIEW code for Interfacing a channel selection box.In that output am getting is in the format of BCD.I want to convert that BCD to decimal.Can you Plz tell me to convert this BCD to Decimal?
    Please Mark the solution as accepted if your problem is solved and donate kudoes
    Solved!
    Go to Solution.

    You can use the Boolean operators and the Rotate function to select the hi and low nibbles. Use the In Range and coerce function to limit the range of the nibbles to zero through nine.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    U8 to BCD Hi and Low.PNG ‏20 KB
    U8 to BCD Hi and Low.vi ‏7 KB

  • Sap Script : getting comma in place of decimal point & viceversa

    Hi experts
    In one Sap script for 2 currency fields comma is there in place of decimal point & viceversa.(But rest of currency fields are getting displayed correctly.)
    ex: 1426.88  is printed as 1.426,88
    please provide me solution as early as possible
    Thanks & Regards
    Swathi Vuddala

    Hi Swathi,
    Check this info.
    I am providing two ways with some sample code, you modify it accordingly to your code.
    THIS PROCEDURE IS BY CHANGING SETTINGS :
    In your user profile, change the decimal format you are currently using.
    System->User Profile->Own data.
    Go to defaults tab and then change your decimal notation.
    THIS PROCEDURE IS WITHOUT CHANGING DEFAULT SETTINGS:
    Report YH642_TEST.
    TABLES:
    mard.
    DATA : W_mard_labst type p decimals 3,
    w_dt1(18).
    data:
    W_N TYPE I.
    SELECT SINGLE * FROM MARD INTO MARD WHERE LABST = '10000.00'.
    WRITE: mard-labst .
    W_mard_labst = mard-labst.
    WRITE:/ W_mard_labst .
    w_dt1 = w_mard_labst .
    write W_mard_labst to w_dt1.
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • External table.How to load numbers (decimal and scientific notation format)

    Hi all, I need to load inside an external table records that contain 7 fields. The last field is called AMOUNT and it's represented in some records with the decimal format, in others records with the scientific notation format as, for example, below:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Jan;11200100;'60800;CYZ900;41380,77
    The External table's script is the following:
    CREATE TABLE HYP_DATA
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY HYP_DATA_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'HYP_BAD_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'HYP_DISCARD_DIR':'HYP_LOAD.dsc'
    LOGFILE 'HYP_LOG_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (HYP_DATA_DIR:'Total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;
    If, for the field AMOUNT I use the datatype VARCHAR (as above), the table is loaded but I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation as:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Feb;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Mar;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Dec;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    All the others records with a decimal AMOUNT are loaded correctly.
    So, my problem is that I NEED to load all the records (with the decimal and the scientific notation format) together (without records rejected), but I don't know which datatype I have to use for the AMOUNT field....
    Anybody has any idea ???
    Any help would be appreciated
    Thanks in advance
    Alex

    @OP,
    What version of Oracle are you using?
    Just cut'n'paste of you script and example woked FINE for me.
    however my quation is... An external table will LOAD all data or none at all. How are you validating/concluding that...
    I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation
    select * from v$version where rownum <2;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    select * from mydata;
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Feb     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77
    CY001_STATU     2009     Mar     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Dec     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77MYDATA table script is...
    drop table mydata;
    CREATE TABLE mydata
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY IN_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'IN_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'IN_DIR':'HYP_LOAD.dsc'
    LOGFILE 'IN_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (IN_DIR:'total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;vr,
    Sudhakar B.

  • How to know corresponding info object for R/3 field and viceversa

    Hi....
    How to know corresponding object for a filed in r/3 data source and viceversa..While defining transformations.
    We can't do mapping of all objects to fields with the definition......!!!
    In 'rsosfieldmap'' what information we should give to know the proper tranformation...?
    thank u.....

    Hi,
    There are two ways to know the corresponding info objects in R/3 fields:
    1)  goto se11 t-code, enter RSOSFIELDMAP and enter display button. in the next screen click contents and give the field name or info object name as per your requirement, and excute.
    2)  first go through the field description in r/3 and identify the similar description in BI. For your easy understanding use excel sheet , in that you can copy the data source fields and target info objects ( master data or transaction data ). then it will be easy to identify the similar description.
    Thank you.

  • Vendor as customer and viceversa

    Hello,
    My scenario is that i have several vendors that are customers at the same time. And viceversa, several customers that are vendors too. I have made the customizing, into the customer I have put the vendor nr and the check 'clearing with vendor', and into the vendor the customer nr and the check 'clearing...'. I have anyway two problems:
    1) When i execute f-28 (incoming payments) or f-53 (outgoing payments), i see the items of the customer/vendor both. No problem.  But i can't clear different amounts. I have:
    Customer: +232 EUR
    Vendor:    -136 EUR
    And i can't clear these.
    2) My second problem comes when i execute F110 (automatic payments). At the end of the process i see the payment to make to vendor and one exeption for the customer incoming payment.
    > Bank details are being checked                                       
    >   System reads house banks and checks if they are allowed            
    > Our bank DUMMY is being checked                                      
    > Bank different from the specified bank AA in master record or items  
    >   House bank is selected ...                                         
    > No permitted payment method exists                                   
    Information re. vendor 1 / customer 2 / paying company code 01 ...
    ... payment not possible because of reported error            
    Thank you all the experts.

    In the example you have a payment will need to be received sent - therefore a payment method needs to be applied to the customer and vendor master.
    If you want to offset the customer invoice against the vendor invoice - you can clear it via F-32, and then add other items "K" for account group and then the Vendor number.

  • Different decimal and thousand separators in contract items

    Hello!
    I have problem with printing contract in SmartForm. Contract consists of  many items and values are printed with different decimal and thousand separators. For example value in first item is printed as "40.000,00" and in second item as "40,000.00". All items are in same currency and belongs to same vendor.
    The same happens if I format the output by using the <b>write</b> command into character field.
    Why it happens and how can I solve it?
    Thanks in advance!
    Kind regards.
    Vlasta

    Hi
    Thank you for your help. I tried with SET COUNTRY 'xx' and get after that all items in same format (problem was that first item is different that others, very strange), but problem was still that now I have different format if I write number directly from internal table or from variable after used WRITE command (I have point as decimal separator for example for quantity and comma as decimal separator for example for price in one item line for invoice).
    Then I used SET COUNTRY SPACE which reset to user settings, and this solve problem - now I have all numbers written in same way, with one sign (for example comma) as decimal separator.
    It works now, but I still dont understand why that happens.
    I tried to give you reward points, but I don't see where can I do that (I'm new here).
    Yesterday I saw that place, but today I click everywhere on your answer and can't see where are that, I remember tree kind of points???

  • Smartforms - dealing with decimal and thousand separators

    Hi,
    trying to reuse one of the standard SAP Smartforms - LB_BIL_INVOICE in an ECC 6.0 Unicode system I faced a problem with decimal and thousand separators for currency/quantity fields. In fact, default settings in User profile are not taken in consideration when printing this form. I have changed all the possible settings in the user profife and (after logoff/logon) nothing changes in my output.
    Just to be sure I tried to output the invoice with the original SAP smartform LB_BIL_INVOICE and the things were the same - means output takes wrong settings for decimal/thousand separators.
    For clarity I created a simple form with a single currency field and everything behaves well as expected. So this points me to the direction fo find out what is wrong with the LB_BIL_INVOICE. I downloaded the form into XML and checked the code, further uploaded it into a new one - no success.
    My question is:
    Is there a way to manipulate or overwrite default settings for decimal/thousand separators within smartform, and if yes - how to do this?
    I almost finished my quite complex form and wouldn't like to rewrite it from scratch.
    FYI: I'm not a Smartform expert, by have created/overwiten more than 15 different forms accros different systems - 4.6 C/D, 4.7, ECC 6.0 non-Unicode/Unicode, and never faced such an issue.
    I faced significant smartform 'improvement' in the ECC 6.0 release - especialy for text elements. The new integrated MS word control gives me a lot of throubles. According to this - is there an up-to-date documentation (even link to SAP course is acceptable) according to Smartform development in ECC 6.0?
    Thanks in advance.
    Regards,
    Ivaylo Mutafchiev
    Senior SAP Abap Consultant

    Hi,
    I took a quick glance into the print program, and the print program do a set country setting to reciving country. This will give you the separators that are confugured for this country.
    But if you change the print program and clear parameter country, the smartform will use the users settings instead.
    Regards
    Åsa Thenstedt

  • After having updated Ipad2 to IOS7 I can't change Video to Photo and viceversa on photocamera. Solutions?

    After having updated Ipad2 to IOS7 I can't change Video to Photo and viceversa on photocamera. Solutions?

    Have you tried swiping up or down on the screen in the photos app? When you swipe up or down, that cycles through the Photo, Video and Square modes in the app. The current mode appears in yellow type.
    The screen on the iPad in photos App is going to look different that what you see if you click on the link that was posted for you above - that link shows what the screen will look like on the iPhone, but they are similar.

  • Read and write(control should act as indicator and viceversa)

    control(input) should act as indicator(output) and viceversa for a string transmission.is it possible
    kudos welcome
    Solved!
    Go to Solution.

    Yes you can.  But property nodes are much slower than local variables.  For simple programs, you won't notice the difference.  But sooner or later, you will encounter a case where too many property nodes will noticeably slow down the code.  It is considered bad programming style to use property nodes instead of local variables.  Property Nodes work through the UI thread.  Locals do not.  So locals present a lot less overhead. 
    It is best to not get into a bad habit from the start.  Use local variables instead of property nodes.
    I do use local variables and think it is ok but there are the people on here that think they are the worst thing ever invented. Also it is not bad to show a couple of different way to do things so the OP can learn different ways to do things. Property nodes are something that you will inevitably have to learn if the OP wants to do real programming.
    Tim
    Johnson Controls
    Holland Michigan

  • Convert hex to Decimal and keep leading zeros..

    Hi,
    I hope you can help?
    How to convert hex to Decimal and keep leading zeros
    I read 002C, hex, and I want to convert it to 0044 decimal.
    sscanf (MyNum, "%4x", &DecNum); will only give me 44.
    It have been working up till I started to get leading zeros.
    We will always have a 4 digit hex input in a range
    We must have the leading 00 in this case.
    How is this best done?
    Thanks for the help
    Simon
    Solved!
    Go to Solution.

    Hi,
    I don't really understand your problem. Is this stuff what you need ?
    int main (int argc, char *argv[])
    const char MyNum[] = "002C";
    int DecNum;
    sscanf (MyNum, "%4x", &DecNum);
    printf ("%04d", DecNum);
    getchar ();
    return 0;
    "0044" appears on standard output when printf function executes...

  • Mail suddenly marks as spam what is not and viceversa. It has worked perfectly until a few days ago. How can I restore the old junk "learnt" list? Where is it to be found?

    Mail suddenly marks as spam what is not and viceversa.
    It has worked perfectly until a few days ago. How can I restore the old junk "learnt" list, since it is marking as SPAM senders who have been my correspondants for years?? Where is the old junk pref file to be found?

    Why start a new and very similar thread to your other one which you have not responded to (have you read the replies?)
    I suggest that no response is made to this duplicate thread. 

  • Send information from Oracle DB - PI - NW 7.0 BI and viceversa

    Hello,
    I need to send information from Oracle DB to SAP NW 7.0 BI passing through a SAP PI and viceversa.
    Ho can I do that?
    I need help
    Best Regards...
    Pablo Mortera.

    As the sender is ORacle you can use a sender adapter which is JDBC in XI.
    As the receiver is BI system, try to use either Proxy or RFC or Idoc as a receiver adapter.
    Regards
    Krish

  • Celsius to Farenheit and viceversa

    Hello everyone, I hope someone can help me with a project I am working on.
    I need to do a simple VI that converts from degrees C to degrees F and viceversa. In the front panel, the user should be able to convert from one to the other. For example, if there are 2 thermometers and the user slides the Celsius degrees down to 0, the other thermometer should move to 32 degrees. However, the user should ALSO be able to go the opposite direction while the VI is running. In other words, the user should be able to change the temperature in EITHER thermometer and the OTHER should change accordingly. I am only able to go ONE direction because I think I should be able to have some sort of control that also works as an indicator. Please let me know if there is a way to do this!!! THANKS.

    You can also use "units" for each control (degF and degC, resp.), no more conversion math needed.
    Message Edited by altenbach on 02-18-2007 07:51 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DualT.vi ‏14 KB
    DualT.png ‏6 KB

  • FLOWS_020200 decimal and comma setting, wrong definition for Croatian lang

    Hi!
    In what table (view) is definition that define for certain language that decimal point and comma.
    Problem is that for Croatian language these two items are flipped. When we change language to German, these two chars are OK.
    So we'd like to change value in some system table where is definition for Croatian language.
    P.S.
    For future versions please put that decimal point =',' and comma ='.' (opposite to current setting)
    THX

    Scott,
    we have successfully solved NLS problem in a way that I have described before.
    Now remaining problem is when we change language (hr-en) with code like:
      IF #OWNER#.tool.get_lang='hr' THEN
        :FSP_LANGUAGE_PREFERENCE := 'en';
        :G_PLEASE_WAIT := 'Searching...please wait!';
      ELSE
        :FSP_LANGUAGE_PREFERENCE := 'hr';
        :G_PLEASE_WAIT := 'Pretražujem...molim pričekajte!';
      END IF;
      htmldb_application.g_unrecoverable_error := true;
      htp.init;
    owa_util.redirect_url('f?p='||:APP_ID||':'||:APP_PAGE_ID||':'||:APP_SESSION);then we get an error because it seems that redirect_url is noto working with alter session (which execute Before page header and Before computations and validations for the same page).
    ORA-06502: PL/SQL: numeric or value error: character to number conversion errorlanguage change process is fired before "alter session" proceses...
    For us it is unacceptable to show wrong number format signs on WEB page.
    Is there any way to solve this problem?
    So please is there any table where we can replace that ...
    Just want to say that when we define "de" (German) as primary language (without our NLS_SETTING processes), that decimal and group format are OK as well as date format (DD.MM.YYYY).
    So please, these settings are placed somewher in Apex table...which one?
    THX!
    Message was edited by:
    Funky

Maybe you are looking for

  • "wrinkle" in text when importing from Motion to DVDSP

    I created a motion menu in Motion and imported in DVDSP. Looks great in Motion. In DVDSP the largest title is not clean. It has a "jag" through several letters along the same horizontal line. Anybody have an idea? thanks

  • Batch-input to transaction SM34

    Hello, I need to create a batch-input for the transaction SM34. I have done a recording but there is a screen(dialog structure) that only appeares when I call the transaction without batch-input mode. So, I have done the recording with the option "No

  • Self-Register user workflow add user to Group

    Hi, I have a fairly basic Self-Register user workflow that I am playing with in OAM. I am wondering if I can somehow add a step(s) into my workflow that will add the user to be a member of a Group in OAM during registration? If so, can this be done w

  • Bug? advanced TDMS on sbRIO9636

    Hi everyone, the problem comes from a sbRIO system using VxWorks. If I want to log the measurement data on a USB storage, it takes to long to sue the normal TDMS VIs, as it take much time for saving the file. So I decided to use advanced TDMS VI to s

  • Where can I find mounting rail hardware for single CPU G4 Xserve?

    I am wanting to mount my G4 single CPU 1 GHz in a four post rack now where I have a new G5 (keep them all together). I however cannot find the rest of the hardware for it that I got when I bought it several years ago, all I have are the dog ears that