FUnction to calculate unique key

Hi All,
I have a situation where my source is 32 char length and destination InfoObject is only 20 char length. I want to derive a 20 char or less key from 32 char and store it in my InfoObject. The key should be unique to a char sequence.
I should also be able to derive the 32 char from 20 char key generated. Does ABAP have any standard functions which would derive a hash value which is unique and from which you can again derive the original value.
Please help.
Devang.

Hi Deva,
if you can create the uinique key yourself, you can use FM GUID_CREATE: You will get a unique identifier in 16 bytes raw hex  format, 22 character upper/lower case ASCII char format and in 32 character uppercase ASCII format..
They are mutually convertible by FM GUID_CONVERT.
So you can use GUID_CREATE to get the 32 char source key  - you can convert it to a 16 byte hex value for your object.
I don't know if this works as you did not say what it is all about.
Regards
Clemens

Similar Messages

  • Function Module to calculate unique key

    Hi All,
    I have a situation where my source is 32 char length and destination InfoObject is only 20 char length.  I want to derive a 20 char or less key from 32 char and store it in my InfoObject. The key should be unique to a char sequence.
    I should also be able to derive the 32 char from 20 char key generated. Does ABAP have any standard functions which would derive a hash value which is unique and from which you can again derive the original value.
    Please help.
    Devang.

    Hi Deva,
    if you can create the uinique key yourself, you can use FM GUID_CREATE: You will get a unique identifier in 16 bytes raw hex  format, 22 character upper/lower case ASCII char format and in 32 character uppercase ASCII format..
    They are mutually convertible by FM GUID_CONVERT.
    So you can use GUID_CREATE to get the 32 char source key  - you can convert it to a 16 byte hex value for your object.
    I don't know if this works as you did not say what it is all about.
    Regards
    Clemens

  • FUNCTION IN UNIQUE KEY

    Hi,
    We have a timestamp column.
    We must put a unique key on it but without the milliseconds
    Is it possible to create a unique key with a function inside ?
    The function will return the date without milliseconds ?
    We see it's possible to create unique index with function but we didn't find example with unique key.
    Thanks
    Alexandre

    Hmmm, a nice suggestion Laurent but it's not quite right on my 9.2 db...
    SQL> create table t02 as select current_timestamp t from dual;
    Table created.
    SQL> create unique index i02 on t02(cast(t as date));
    Index created.
    SQL> insert into  t02  select current_timestamp t from dual;
    1 row created.
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    1 row created.
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    1 row created.
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    insert into  t02  select current_timestamp t from dual
    ERROR at line 1:
    ORA-00001: unique constraint (APC.I02) violated
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    1 row created.
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    1 row created.
    SQL> r
      1* insert into  t02  select current_timestamp t from dual
    insert into  t02  select current_timestamp t from dual
    ERROR at line 1:
    ORA-00001: unique constraint (APC.I02) violated
    SQL> SELECT to_char(t, 'DD-MON-YYYY HH24:MI:SS') FROM t02;
    TO_CHAR(T,'DD-MON-YY
    02-DEC-2005 09:55:11
    02-DEC-2005 09:55:46
    02-DEC-2005 09:55:48
    02-DEC-2005 09:55:48
    02-DEC-2005 09:55:54
    02-DEC-2005 09:55:55
    6 rows selected.
    SQL> Cheers, APC

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • Null Values in a unique key in a Merge????

    We have OWB 9.2.0.2.8 and Oracle 9i
    I have a Mapping with a Source table (A), a Target table (B) and an Insert/Update Loading Type.
    I make a Match by constraint with a “unique key” in the Target table with two Fields: Field1 and Field2
    The problem is the Field2 could be NULL then If I have In TABLE A (Field1: XXX and Field2: NULL) and in TABLE B (Field1: XXX and Field2: NULL) it don’t match because Field2 has NULL value and the INSERT fails.
    I need to use a NVL function. For example:
    UPDATE
    ….
    ….
    ….
    Where nvl(A.Field2,’*’) = nvl(B.Field2,’*’)
    I could create a NVL to TABLE A (Source) with a “Expression object” but How can I create a NVL to TABLE B.
    I need to generate the nvl(B.Field2,’*’) part of the instruction nvl(A.Field2,’*’) = nvl(B.Field2,’*’).
    How can I do it???
    Thanks very much!

    Hi Claudio,
    well, I have an solution although it is neither nice nor clean...
    * Add a column Field2_notnull to Table B with not null-constraint and same type as Field2
    * Add a check-constraint to Table B like this: "nvl(Field2,'*') = Field2_notnull"
    * Create a UNIQUE KEY on Table B's Field1 and Field2_notnull and use this constraint for the MERGE-Load (INSERT/UPDATE)
    * Coming from Table A, use Field1 and nvl(Field2,'*') for the match
    As I said, neither nice nor clean, but it works, as long as you can manage to fill Field2_notnull in Table B correctly.
    Best regards
    Andreas

  • How to use case when function to calculate time ?

    Dear All,
    May i know how to use case when function to calculate the time ?
    for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.  
    CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
    THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
    THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
    ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
    ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOUR

    Do not use computations in a declarative language.  This is SQL and not COBOL.
    Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton. 
    CREATE TABLE Timeslots
    (slot_start_time TIME(1) NOT NULL PRIMARY KEY,
     slot_end_time TIME(1) NOT NULL,
     CHECK (start_time < end_time));
    INSERT INTO Timeslots  --15 min intervals 
    VALUES ('00:00:00.0', '00:14:59.9'),
    ('00:15:00.0', '00:29:59.9'),
    ('00:30:00.0', '00:44:59.9'),
    ('00:45:00.0', '01:00:59.9'), 
    ('23:45:00.0', '23:59:59.9'); 
    Here is the basic query for rounding down to a time slot. 
    SELECT CAST (@in_timestamp AS DATE), T.start_time
      FROM Timeslots AS T
     WHERE CAST (@in_timestamp AS TIME)
           BETWEEN T.slot_start_time 
               AND T.slot_end_time;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to create a unique key using two or more attributes?

    how to create a unique key using two or more attributes ?

    The following example illustrate how to create a unique key using two or more attributes/fields
    Scenario: Implementing Unique Key on ManagerID & Location ID in DepartmentEO(Department Table)
    Step#1: Open the Desired Entity Object “DepartmentEO”. Go to Overview tab & Click “General” Finger tab.
    Step#2: Expand “Alternate Keys” section & click “+”.
    Step#3: In the Pop-up wizard, Enter a name for alternate Key “Unique_Manager_X_Location”.
    Step#4: Select the desired attributes/fields from available list & Shuffle to right side.
    Step#5: Now go to “Business Rules” finger tab.
    Step#6: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#7: In the Pop-up, Select “Rule Type” as Unique Key
    Step#8: In the “Rule Definition” tab select the key “Unique_Manager_X_Location”created.
    Step#9: Now go to “Failure Handling” tab, and click the Magnifier Icon .
    Step#10: If the key is not already created then in the “Select Text Resource” Popup, Using the functional design document, Enter display value, Key and Description. And click “Save & Select” Button.
    Step#11: Now Click “OK”.

  • How to control unique key target table mapping!

    Hi all,
    Is there any way to map a source table to target,the source table contains some duplicate rows,and only one of them is needed for the target table,can OWB manage to insert only one of these duplicate rows and ignore other rows according to an unique key and continue to execute the map?
    Thanks in advance!

    If you have duplicates and want to filter them out, try creating a view on the target table and use the rownum() function in the view.
    Than in your mapping use this view as you source and put a filter on it where the rownumber = 1. This will only select the unique records.

  • Strange Unique Key Error When Copying Cube

    I have an empty cube (cube2) I checked it many times. I am copying data from cube1 using an info package. In Info Package I set delete option, i.e., delete existing data in cube2 before loading.
    As soon as loading starts, I get a short dump with error message:
    An entry was to be entered into the table                                                     |
    "\FUNCTION=RSAR_ODS_GET\DATA=L_TH_ISOSMAP" (which should have
    had a unique table key (UNIQUE KEY)).
    However, there already existed a line with an identical key.
    The insert-operation could have occurred as a result of an INSERT- or
    MOVE command, or in conjunction with a SELECT ... INTO.
    The statement "INSERT INITIAL LINE ..." cannot be used to insert several
    |     initial lines into a table with a unique key.     
    I tried other cubes, same error occurs. I checked on SN, people have encountered this error but solution is not posted. Any idea, how can I get rid of the error.
    Thanks a lot.

    Hi
    Try to load from Cube1 to cube2 without using that option and see if it loads. If that works then add an extra step on the
    process chain ' Delete overlapping requests from the target ' after the infopackage load .
    Thanks
    Jay.

  • Assign unique key

    Hi,
    we have the requirment to add an unique key to each position in the planing item. The idea is now, to define a number range object to get a unique number. When the user is adding an new position in his planning sheet an InfoObject should get get this number. But how can I fill this this InfoObject with a number from number range object. I was thinking about useing a Fox-Formula and calling a function modul, but I has no idea how to fill a InfoObject in the planning layout. Maybe someone of you has an idea?
    Thanks,
    Thomas

    Hello Thomas,
    I had done it for a layout, but not for a single line.
    I had a ztable with columns counter &  username.
    Call a Fox function which has a Call function, which in turn reads the ztable and increments it by 1
    and
    SAVE_DATA.
    Hope it helps,
    Krishna

  • Primary/Unique key for GL_IMPORT_REFERENCES

    Hi all,
    We are on EBS11.5.10. I have the following requirement. I need to put a snapshot log on GL_IMPORT_REFERENCES which we will use to interface data to out reporting environment. Therefore i need to set a primary key on GL_IMPORT_REFERENCES, this is required for creating the snapshot log.
    Can anyone suggest what combination of fields would be unique for this table, as no unique key is set.
    TIA

    mma,
    but do you tie them in with ETL? or they're simply uniqe auto-number-like?
    Thanks
    I just found this:
    http://datawarehouse.ittoolbox.com/groups/technical-functional/informatica-l/re-about-oracle-bi-and-fact-tables-and-image-tables-1515935
    Looks like there's a new methodology for extending the DWH. I'm still looking into this, but I still think auto-numbering ROW_WID is a good idea.
    Mma, perhaps - could you provide me with an example or two to present this change. Thanks

  • Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems n

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

  • Difference between Unique key and Unique index

    Hi All,
    I've got confused in the difference between unique index & unique key in a table.
    While we create a unique index on a table, its created as a unique index.
    On the other hand, if we create a unique key/constraint on the table, Oracle also creates an index entry for that. So I can find the same name object in all_constraints as well as in all_indexes.
    My question here is that if during creation of unique key/constraint, an index is automatically created than why is the need to create unique key and then two objects , while we can create only one object i.e. unique index.
    Thanks
    Deepak

    This is only my understanding and is not according to any documentation, that is as follows.
    The unique key (constraint) needs an unique index for achieving constraint of itself.
    Developers and users can make any constraint (unique-key, primary-key, foreign-key, not-null ...) to enable,disable and be deferable. Unique key is able to be enabled, disabled, deferable.
    On the other hand, the index is used for performance-up originally, unique index itself doesn't have the concept like constraints. The index (including non-unique, unique) can be rebuilded,enabled,disabled etc. But I think that index cannot be set "deferable-builded" automatic.

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • Difference between Primary Key and Unique Key with NOT NULL constraint

    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?

    PARAG_C wrote:
    As both can be referred to another table.
    Apart from the difference that Primary Key can be only 1 and Unique keys can be multiple,
    is there any difference?
    Like in terms of type of Index?Technically there is almost no difference. Logically the two are often used for slightly different concepts.
    The PK (and with it the index) is often an ID column filled by a seqeunce. This key can then be refenced by foreign key constraints on other tables. it is very useful to have this as a meaningless technical construct. Because then the chance that such a ID needs to be changed is extremly slim.
    The UK (and with it the index) is often one or several columns that represent the logical key for the entity. Foreign key constriants should not point to this. THe chance that this attribute will be changed at some point in time is way higher then for a meaningless number (ID).

Maybe you are looking for