Packed decimal auto conversion

Hi
I have an input field that is of type P , with decimals 3.
so if I enter 3000 , then it will take 3.000 .
I want it to be so ,, when user enters 3 , it automatically converts it to 3.000 and if the user enters 3.2 , then it converts it to 3.200 , .
How can I achieve this.
Thankyou

Hi Krish,
I understand what you need, please look this code:
DATA: lenght(2), cont(2), contv(1), teste(1), lenghtv(1).
PARAMETERS: p1(10).
lenght = strlen( p1 ).
cont = 0.
contv = 0.
DO lenght TIMES.
  teste = p1+cont(1).
  cont = cont + 1.
  IF teste = ',' OR teste = '.'.
    contv = 1.
    lenghtv = lenght - cont.
    IF lenghtv = '0'.
      CONCATENATE p1 '000' INTO p1.
    ELSEIF lenghtv = '1'.
      CONCATENATE p1 '00' INTO p1.
    ELSEIF lenghtv = '2'.
      CONCATENATE p1 '0' INTO p1.
    ENDIF.
  endif.
ENDDO.
if contv = 0.
  CONCATENATE p1 ',000' INTO p1.
endif.
WRITE p1.
Regads
Allan Cristian

Similar Messages

  • Conversion of Packed Decimal Numbers to Java Data Types

    Hi all,
    I'm working with a mainframe file which contains datas in Packed Decimal Numbers.My requirement is to convert these datas to Java datatypes and also to convert the Java datatypes to Packed Decimal Numbers before storing them in the mainframe.
    Can anyone help me out with any code for converting Java data types to/from other data formats such as: EBCDIC, IBM370 COMP (binary numbers up to 9 digits), and COMP-16 (packed decimal numbers)?
    I would hugely appreciate any response to my query.
    Thanking you all,
    Kaushik.

    Rather than go that route, I'd instead look into providing a "service" on your mainframe to:
    1) provide a textual representation of the numbers (from native to text)
    2) read text, converting to native numeric storage
    And use that service to retrieve that information by your Java app (1)Similarly, instead of trying to write natively-formatted numbers from your Java app, I'd write it as text and make that same "service" read the text (2)
    This is the kind of thing XML is for.

  • Convert Mainframe Packed Decimal to Oralce Number Format

    Dear all,
    I am having a file in which amount fields are given in a Packed Decimal format. Can anyone suggest me how I can read this data element from the file and convert it into Oracle Number datatype.
    File is a fixed length. All the amount fields are given in Packed Decimal Format and rest of the fields are given in text format.
    Thanks and regards
    Nagasayan Puppala

    Hi,
    Firstly thanks for your reply.
    Actually I am not using SQL Loader to load data from
    a flat file to Oracle table. I am writing a custom
    program that reads the file and populates the oracle
    table. I'll put aside the question of 'why' you'd want to do that. SQL*Loader's singular purpose in life is to load flat files of data into Oracle DB. Sometimes there is a reason for reinventing the wheel.
    How does your program communicate with the Oracle DB? If utilizing ESQL and Pro*Cobol (or Pro*<whatever> ) you will have read the data into a variable of some type in you host language. The variable of the host variable to hold the value (if you did a 'select from' that table) would be the correct target type for an insert statement. Whatever host language type conversion is available bewteen those two types ( if they are different at all ) is all that is needed. The precompilers have converters between certain native host and internal Oracle types built-in. It is how you get any data between the two systems. This is only a problem if the host language has no converter between the numeric types (if differnet.). When you read from the flat file are you reading it into a native packed decimal in the host language?
    ODBC/JDBC similar strategy..... cast conversion between the native type that Oracle wants and the one into which your custom program reads it into.
    So I want to know whether there are any Oracle
    utility programs that will convert the packed decimal
    to a oracle number format or not.There are Oracle routines that convert into the native Oracle DB formats. There are implicitly available through the normally utilized interfaces to OCI ( ESQL and ODBC/JDBC ) . There are none decoupled from those interfaces though (that I know of).
    There are no standalone programs that mutate a flat file into another flat file that then could be loaded. That's is typically slower and utilzes more space than most customers want than just directly inputing the data into Oracle DB.
    Message was edited by:
    lytaylor

  • Long / double value convertion to Packed Decimal

    Hi,
    Could anybody tell me how to convert a long / double value to Packed Decimal (AS400) ?
    Thanks,
    Probir

    Now I'm writing this value in a flat file by
    FileOutputStream and sending to mainframe through FTP.
    But the mainframe people said it's not converted into
    packed decimal. Is it the right way to convert ??When you say "mainframe" I assume you are referring to a machine that uses EBCDIC. Java, even on the iSeries, uses Unicode and not EBCDIC, so when you FTP anything to the mainframe it will go through an ASCII-to-EBCDIC conversion. You want this to happen for text but you don't want it to happen for packed decimals; your carefully-constructed x'12' x'3f' bytes will be dutifully converted into EBCDIC garbage.
    FTP of an iSeries file (in the QSYS.LIB file system) to a mainframe is trivial because both client and server use EBCDIC, so there are no conversion issues. So if you could do it that way, you definitely should. Otherwise you are going to have to take your packed decimal data and replace it by the bytes that would be translated into it if it were in EBCDIC. The translation table QEBCDIC in library QSYS shows you how it does that, so use that table. You can look it with the command WRKTBL QSYS/QEBCDIC. You'll notice for example that x'09' in ASCII gets converted to x'05' in EBCDIC. So if you want to get x'05' into part of a packed decimal field on the mainframe, you have to send it x'09'. And so on. Like I said, I would recommend doing something other than this. Ask the mainframe people to not make you used packed decimal, for example.
    PC&#178;

  • Parsing a packed decimal value

    I am doing an extraction of BKPF and my ETL process is failing because the data which is being returned via RFC_READ_TABLE for KURS2 is '0.1234-'
    When I go in to SE16 and look at that record, the displayed field value (based on localisation to F) is: '/0,1234'.
    KURS2 has a datatype of P. Its values also should be always unsigned (since a negative currency conversion rate doesn't make any sense). Are signed values in P fields which come out of RFC_READ_TABLE have the - sign at the end (like a BCD?) or is it returning that because the RFC is misparsing the '/' in the actual field? And why would the UI allow someone to enter such a value? (I understand that it looks like whoever entered it wanted something to divide WRBT* by KURS2 to get DMBT2 or whatever, but that seems strange to me).

    How do you store the "PACKED DECIMAL" in Oracle?
    Do you use one of the following data types:
    NUMBER(n,n)
    DECIMAL(n,n)?
    or
    is it mainframe data that is represented in PACKED DECIMAL format that you've loaded into Oracle via SQL Loader.
    P;

  • Data flow fails on packed decimal field moving iSeries DB2 data from one iSeries DB to another

    I' trying to use SSIS to move table content from one iSeries DB2 database to another.  I'm using the .Net providers for OleDb\IBM DB2 for i5/OS IBMDA400 OLE DB Provider in the connection managers for the source and destination and the test connection
    works fine.  When I try to run the data flow task however it fails on the first packed decimal field it encounters with the exceptions ...
    [select from hydro520 hydroweb2 blpmstr [16]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "component "select from hydro520 hydroweb2 blpmstr" (16)" failed because error code 0x80004002 occurred, and the error
    row disposition on "output column "MSPRIB" (55)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
    [select from hydro520 hydroweb2 blpmstr [16]] Error: The component "select from hydro520 hydroweb2 blpmstr" (16) was unable to process the data. Pipeline component has returned HRESULT error code 0xC0209029 from a method call.
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component "select from hydro520 hydroweb2 blpmstr" (16) returned error code 0xC02090F5.  The component returned a failure code when the pipeline
    engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
    ...in the progress tab.  Can someone kindly tell me what I need to do to get the connection manager to work with DB2 packed decimal fields?  Or is it a different issue all together?  Thanks tonnes for any help, Roscoe

    Hi rpfinn,
    From the Data Types mapping rules between SSIS and DB2, we can see that both the NUMERIC and DECIMAL data types in DB2 are mapped to DT_NUMBERIC data type in SSIS. Now that the source data in your DB2 database is NUMERIC data type, changing the DT_NUMBRIC
    data type to DT_DECIMAL is invalid. Besides, if we check the data types of the target External column and Output column from the Advanced Editor for ADO NET Source adapter, the data type should be defined as DT_NUMERIC with Precision as 9 and Scale as 2. I
    am not clear where you see the DT_NUMBERIC(9,0) e.g. DT_NUMERIC with Precision as 9 and Scale as 0, but it may be the cause of the issue. You need to make sure the DT_NUMERIC data type also has Scale 2 instead of 0.
    If you don’t know how to modify the data type, please elaborate the Data Flow Task of the package so that we can make further analysis. Besides, the error messages you posted are incomplete, it will be helpful if you post the complete error message.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Loading the data from a packed decimal format file using a sql*loader.

    Hi ,
    In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
    Thanks in advance ,
    Narasingarao.

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • How to move the value from a character field to numeric or packed decimal

    Hi,
    can anyone explain me on how to move the value from a character field to numeric or packed decimal.
    Please help me on this. Thanks...
    Regards,
    Rose.

    Hi ,
    if you use keyword MOVE u may loose the decimal and thoussan separator and if u don't want to loose them just call the FM ..HRCM_STRING_AMOUNT_CONVERT.
    i doubt wherther it is HRCM or HCRM just try using *
    this will suit ur requirement.
    Regards,
    KK

  • Raw auto conversion & showing items in modified folder

    Hi,
    When I shoot photo's, I let my camera create RAW and JPEG images. I manage to import those into iPhoto and show up nicely in the (event) viewer. I understand that iPhoto puts these into the original folder and while I'm also importing a RAW image, it also auto converts a JPEG copy and puts it into the modified folder.
    So far so good. However, when I need to modify a photo I normally use the RAW image file. What I would expect to happen after the RAW image modification is that :
    1)iPhoto makes an auto conversion and puts it in the modified folder (this happen and I find the modified JPEG in this folder)
    2)The original JPEG photo that is shown in the event viewer is "overlayed" with the modified one. I tried a lots of things till now but nothing seems to help?
    Does anyone know how to accomplish 2)??
    Further when I remove an event from the library (move to trash in viewer) I noticed the Photo files remain in the library package. It is possible to let iPhoto also remove the files from the library?
    Can I let iPhoto create (rebuild) a blank iPhoto library package, i.e. after I renamed the active one ( I want to create one for each year)?
    Thanks for your help

    MacFan_RJ:
    Welcome to the Apple Discussions. Regarding removing the files, are you emptying the iPhoto trash bin after moving the photo into it?
    Launch iPhoto with the Option key depressed and, when asked, select the option to create a new library. If you play on having multiple libraries I suggest you use iPhoto Library Manager to manage them and allow you to easily move between them. I have 18 libraries that I manage. With the paid version of iPLM you can copy events or album between libraries while maintaining keywords, comments and titles.
    On editing RAW and saving the new jpg, I've not found a way to get the new edited version into the correct Modified folder, replace the current modified file and update the thumbnail to reflect the edit. It appears that those edits will have to be saved to the desktop and imported a new files.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Auto conversion of planned order to production orders

    Hi Gurus,
    Few days back I posted a question on; Auto conversion of planned order to production orders.
    http://forums.sdn.sap.com/thread.jspa?threadID=2135568&tstart=0
    There is standard SAP Transaction to run a batch job. no need to use - user exit or a BAPI
    Follow this procedure:
    TCode: COHV
    on the initial screen; select "CHECK BOX" for planned orders and deselect production orders.
    select mass processing tab.
    Function: 210 Convert planned orders.
    On Menu-Programs-Execute in background
    Thanks

    HI Alok,
    I was looking at CO41 and there is only one small problem with that. You have to give an 'Order Type' as a input. And I don't see 'Execute in the background' anywhere. I think I have to create a job using wizard in SM36.
    Please correct me if I'm wrong.
    Thanks

  • DECIMAL = HEX CONVERSION PACKAGE 생성 SCRIPT

    제품 : SQL*PLUS
    작성날짜 : 2002-04-12
    DECIMAL <=> HEX CONVERSION PACKAGE 생성 SCRIPT
    ==============================================
    Purpose
    Oracle내에서는 여러가지 값을 HEX 값으로 보여주는 경우가 있다.
    이런 경우 DB내에서 decimal 값으로 변환하기 위한 방법을 알아보자.
    Explanation
    다음은 decimal <=> hexa 의 conversion을 위한 package 생성문으로서
    system user로 수행하여 사용한다.
    create or replace package support as
    function dectohex (a number) return varchar2;
    pragma restrict_references
    (dectohex, WNDS, WNPS, RNDS, RNPS);
    function hextodec (a varchar2) return number;
    pragma restrict_references
    (hextodec, WNDS, WNPS, RNDS, RNPS);
    end support;
    create or replace package body support as
    FUNCTION hextodec(a IN VARCHAR2) RETURN NUMBER IS
    x NUMBER := 0;
    y NUMBER;
    z VARCHAR2(1);
    BEGIN
    IF length(a) > 8 THEN
    RAISE invalid_number;
    END IF;
    FOR i IN 1..length(a) LOOP
    z := upper(substr(a,i,1));
    IF z = 'A' THEN
    y := 10;
    ELSIF z = 'B' THEN
    y := 11;
    ELSIF z = 'C' THEN
    y := 12;
    ELSIF z = 'D' THEN
    y := 13;
    ELSIF z = 'E' THEN
    y := 14;
    ELSIF z = 'F' THEN
    y := 15;
    ELSE
    y := to_number(z,9);
    END IF;
    x := x * 16;
    x := x + y;
    END LOOP;
    RETURN x;
    END hextodec;
    FUNCTION dectohex(a IN NUMBER) RETURN VARCHAR2 IS
    x VARCHAR2(8) := '';
    y VARCHAR2(1);
    z NUMBER;
    w NUMBER;
    BEGIN
    IF a > power(2,32) OR a < 0 THEN
    RAISE invalid_number;
    END IF;
    w := a;
    WHILE w > 0 LOOP
    z := w mod 16;
    IF z = 10 THEN
    y := 'A';
    ELSIF z = 11 THEN
    y := 'B';
    ELSIF z = 12 THEN
    y := 'C';
    ELSIF z = 13 THEN
    y := 'D';
    ELSIF z = 14 THEN
    y := 'E';
    ELSIF z = 15 THEN
    y := 'F';
    ELSE
    y := to_char(z);
    END IF;
    w := trunc(w / 16);
    x := concat(y,x);
    END LOOP;
    RETURN x;
    END dectohex;
    END support;
    drop public synonym support;
    create public synonym support for system.support;
    grant execute on support to public;

    FYI: The new xf86-video-intel (2.9) has just been released:
    http://article.gmane.org/gmane.comp.fre … xorg/40733
    According to the release announcement, the new driver fixes the backlight issue with KMS:
    * Add support for BACKLIGHT property when using kernel modesetting
      (KMS). This allows backlight adjustment with programs such as
      "xbacklight -set <percentage>" or "xrandr --set BACKLIGHT <value>".

  • Can we move char type data to packed decimal

    Hi
    can we move char type data to packed decimal??
    Thanks
    Devi

    Hi..
    that depends on the data in the character variable..
    if that character variable contains onli numbers then it is possible.
    <b>data c type c value '1'.
    data p type p.
    p = c.
    write p.</b>
    here the output is  1.
    If it contains even a single Alphabet , then it goes for a dump.
    <b>data c type c value 'A'.
    data p type p.
    p = c.
    write p.</b>
    here u will get a short dump.
    hope u understood.
    regards,
    sai ramesh

  • ASCII to EBCDIC Packed Decimal

    Hi all,
    I want to convert a 9-digit number which is in ASCII to a 5-digit EBCDIC packed decimal using OSB.
    Can anyone please help me with this?
    Thanks in advance!
    Regards,
    Karthik

    This can be done using MFL

  • Cobol Packed Decimal and Binary Compressed Numbers

    Hello!
    I am having some difficulties finding the correct datatype in Oracle for numbers in flat files coming from Cobol which are packed-decimal type and binary compressed. These are not objects, hence the use of BLOB is not appropriate?!
    Thaks for any help!!!
    null

    The sqlloader manual (i.e. utilities reference, loader chapters) tells all about how to load packaed decimal.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Adrian Zeller ([email protected]):
    Hello!
    I am having some difficulties finding the correct datatype in Oracle for numbers in flat files coming from Cobol which are packed-decimal type and binary compressed. These are not objects, hence the use of BLOB is not appropriate?!
    Thaks for any help!!!<HR></BLOCKQUOTE>
    null

  • Packed date format conversion

    I am getting the date from a third party interface in the packed form of size 4 char of bit data type. Can this be converted into the SAP format?

    HI
    When converting decimal figures with numbers following the decimal point into binary floating-point numbers, unavoidable rounding errors occur. This is because many decimals (for example, 0.1) correspond to periodic fractions, and are therefore unable to be displayed exactly.
    If you choose Calculate with Packed Numbers in the query monitor, packed numbers (ABAP data type P, with nine decimal places) are used as the internal number format for all query key figures instead of binary decimals. Rounding errors are avoided with commercial calculations with this fixed-point number, because in doing so no conversion of numbers into the dual system takes place.
    Choose this option for those application areas in which a high accuracy is required (for example, for queries in the accounting and cost accounting areas).
    Because calculating with packed numbers causes a high processing status overall, we recommend not using this number format for all query key figures, but rather only for those key figures for which a very high degree of accuracy is required.
    You have to make this setting in the InfoObject maintenance for the respective key figure:
    1)From the SAP Easy Access Menu, choose Modeling ® Object Maintenance ® InfoObject.
    2)Enter the name of the key figure and choose  Maintain.
    3)To calculate with packed numbers, choose from the Additional Properties tab page under Diverse with the option Key Figure with Maximum Accuracy.
    with regards
    vinayaka

Maybe you are looking for