About key fields in a table

Hi,
I'm actually finding out differences between two tables in remote systems. table name would be given as input parameter, and i'll query the remote SAP system and get the table entries in the remote system and compare them with the table entries in the logon system. Now is there any way, that I can find out which fields are the key fields of table, at run time, having in mind that since everything is at run time, i would be processing using field symbols. So is there anyway to find out which fields in any table are the key fields. Any inputs would be of great help.
Regards,
Vijay

HI vijay
use the FM
CALL FUNCTION 'GET_KEY_FIELDS_OF_TABLE'
  EXPORTING
    TABNAME             =<b> <table name></b>
  MANDT_NEEDED        = ' '
  TABLES
    KEY_FIELDTAB        = <b><table to hold the key field ex. data: itab like dfies occurs 0. ></b>
EXCEPTIONS
  NOT_SUPPORTED       = 1
  OTHERS              = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>Loop at itab.
write: itab-fieldname.
endloop.</b>
regards
kishore
Message was edited by: Harikishore Sreenivasulu

Similar Messages

  • Key fields and non-key field of condition table

    Hello Gurus,
          what is key fields and non-key field of condition table?
    thanks very much!

    Key field
    Each condition table contains keys that can be used for creating dependent condition records.
    for example let take condition type PR00.
    PR00 uses access sequence PR02 .
    Access sequence PR02 has following tables associated with it namely 304, 305 & 306
    When you create a conditon record for PR00 with transaction VK11 or VK31, you have a button 'key combination' which is nothing but fields associated with tables 304, 305 & 306.
    In brief, Condition records are always created using specific keys. Condition tables are used to define the structure of the keys of a condition record.
    Non key field
    For example take condition table 144 - sales deal basic data.
    Table 144 is associated with access sequence PBUD.
    If you check the fields associated with this table (click technical view button), there are three fields at bottom which do not have 'key' check mark -KDATU, PLTYP, KSTAF
    So, when you create a condition record for PBUD, system does not propose these 3 fields in 'key combination' and hence are non key fields.
    Please reward points for good answers as this would help increase the total donation that SAP will make to the United Nations World Food Programme.

  • Implications of adding new key fields to existing table

    Hi All,
    I have searched forum regarding this. But didn't find exact answer.
    We are planning to add new key fields to existing Ztable. I want to know the implications of this.
    I have checked the where used list of table and found no impact. Only one point is making me to think again and again.
    If we add key fields to existing table then we have to adjust the table from SE14 to activate it. But this adjustment doesn't ask for TR.
    So if i release my TR, entries in other systems will also be adjusted accordingly??? Business is OK with the new fields values to be blank for existing entries.
    Thanks,
    Vinod.

    Yes the data in transported  systems will also be adjusted. If this table contains too much data make transport at late hours because it will take long and table can't be used while it's adjusted. In this adjustment process data is copied to a temporary table and moved back to original table using move-corresponding command after key added. There will data loss if you remove a key or key fields field length but in your case it shouldn't be a problem.
    Edited by: Gungor Ozcelebi on Jul 2, 2009 9:18 AM

  • Key fields in variant tables.

    Hi masters,
    i would like to know the use of "key field" in variant tables.
    according to definition:This indicator shows whether a characteristic is used as a key field for accessing tables. Key fields have the value "X". When the table is accessed, the values assigned to the key fields infer values for the other characteristics.
    please give an example of its usage,
    thanks regards
    Rahul

    Hello Rahul,
    Please view the following link with the explaination and an example.
    http://help.sap.com/saphelp_47x200/helpdata/EN/92/58c5cd417011d189ec0000e81ddfac/frameset.htm
    Thanks
    Amber

  • Updation of Primary Key field in HR Tables (PA2001 and PA2002) - Urgent

    Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).
    I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.
    Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :
    TABLES: pa2001.
    DATA: it_pa2001 TYPE TABLE OF pa2001,
    wa_pa2001 LIKE LINE OF it_pa2001,
    DATA: date TYPE d.
    date = sy-datum - 100.
    SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
    WHERE begda BETWEEN date and sy-datum.
    WRITE:/.
    WRITE:/ 'PA 2001 Records'.
    if sy-subrc <> 0.
    WRITE:/ 'No Data Exists'.
    else.
    LOOP AT it_pa2001 INTO wa_pa2001.
    WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
    ENDLOOP.
    endif.
    LOOP AT it_pa2001 INTO wa_pa2001.
    wa_pa2001-sprps = 'X'.
    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
    infty = '2001'
    number = wa_pa2001-pernr
    SUBTYPE =
    OBJECTID =
    LOCKINDICATOR =
    VALIDITYEND =
    VALIDITYBEGIN =
    RECORDNUMBER =
    record = wa_pa2001
    operation = 'MOD'
    TCLAS = 'A'
    DIALOG_MODE = '0'
    NOCOMMIT =
    VIEW_IDENTIFIER =
    SECONDARY_RECORD =
    IMPORTING
    RETURN =
    KEY =
    ENDLOOP.
    if sy-subrc = 0.
    write:/ 'SY-subrc is zero'.
    write:/ ' Rows modified = ', sy-dbcnt.
    else.
    write:/ 'No Record(s) updated'.
    endif.
    commit work.
    WRITE: / 'Updated Records in the Internal Table IT_PA2001'.
    SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
    WHERE begda BETWEEN date AND sy-datum..
    LOOP AT it_pa2001 INTO wa_pa2001.
    WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
    ENDLOOP.

    Thanks Kiran.
    But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.
    When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.
    Is there any other alternative for this problem?
    Pls reply.
    Thanks,
    Harish

  • It is possible to assign value range to non key fields in the table?

    Hi,
    I want to give some range of values to the fields which are non key fields in the table.
    is it possible?
    can anybody tell me the procedure.
    Thanks in Advance,
    venkat

    HI,
    It is higjly possible in case of Z-table. but in standard table you can't make any modification.
    You assign the value range to the domain of field.
    go to SE11 and open the database table.
    Select the Data Element of the fieldto which  you want assign the range.
    Click on its domain .
    click on Value Range tab.
    Set the range.
    Regards,
    anirban

  • Changing the length of a key field in a table

    Hi,
    I want to increase the length of the field from 2 to 4 in a standard SAP table and deliver it to the customers. This field is a key field in table. This field from this table is also used in view and view clusters.
    What is the implication of changing the length to the customers. The customers would have already data in this field and they should not loose any data. Will the existing data for customers remain at length 2 or do they have to do some conversion?
    Regards,
    Srini.
    Edited by: Srinivasa Raghavachar on Feb 7, 2008 12:45 PM

    hi,
    The database table can be adjusted to the changed definition in the ABAP Dictionary in three different
    ways:
    By deleting the database table and creating it again. The table on the database is deleted, the inactive
    table is activated in the ABAP Dictionary, and the table is created again on the database. Data
    existing in the table is lost.
    By changing the database catalog (ALTER TABLE). The definition of the table on the database is
    simply changed. Existing data is retained. However, indexes on the table might have to be built again.
    By converting the table. This is the most time-consuming way to adjust a structure.
    If the table does not contain any data, it is deleted in the database and created again with its new
    structure. If data exists in the table, there is an attempt to adjust the structure with ALTER TABLE. If the
    database system used is not able to do so, the structure is adjusted by converting the table.
    Field 1     Field 2,    Field 3
    NUMC,6  CHAR 8    CHAR, 60
    Field 1    Field 2       Field 3
    NUMC,6 CHAR, 8     CHAR,30
    The following example shows the steps necessary during conversion.
    Starting situation: Table TAB was changed in the ABAP Dictionary. The length of field 3 was reduced
    from 60 to 30 places.
    The ABAP Dictionary therefore has an active (field 3 has a length of 60 places) and an inactive (field 3
    still has 30 places) version of the table.
    The active version of the table was created in the database, which means that field 3 currently has 60
    places in the database. A secondary index with the ID A11, which was also created in the database, is
    defined for the table in the ABAP Dictionary.
    The table already contains data.
    Step 1: The table is locked against further structure changes. If the conversion terminates due to an
    error, the table remains locked. This lock mechanism prevents further structure changes from being
    made before the conversion has been completed correctly. Data could be lost in such a case.
    Step 2: The table in the database is renamed. All the indexes on the table are deleted. The name of the
    new (temporary) table is defined by the prefix QCM and the table name. The name of the temporary
    Step 3: The inactive version of the table is activated in the ABAP Dictionary. The table is created on the
    database with its new structure and with the primary index. The structure of the database table is the
    same as the structure in the ABAP Dictinary after this step. The database table, however, does not
    contain any data.
    The system also tries to set a database lock for the table being converted. If the lock is set, application
    programs cannot write to the table during the conversion.
    The conversion is continued, however, even if the database lock cannot be set. In such a case
    application programs can write to the table. Since in such a case not all of the data might have been
    loaded back into the table, the table data might be inconsistent.
    You should therefore always make sure that no applications access the table being converted
    during the conversion process.
    Step 4: The data is loaded back from the temporary table (QCM table) to the new table (with MOVECORRESPONDING).
    The data exists in the database table and in the temporary table after this step.
    When you reduce the size of fields, for example, the extra places are truncated when you reload the
    data.
    Since the data exists in both the original table and temporary table during the conversion, the storage
    requirements increase during the process. You should therefore verify that sufficient space is available in
    the corresponding tablespace before converting large tables.
    There is a database commit after 16 MB when you copy the data from the QCM table to the original
    table. A conversion process therefore needs 16 MB resources in the rollback segment. The existing
    database lock is released with the Commit and then requested again before the next data area to be
    converted is edited.
    When you reduce the size of keys, only one record can be reloaded if there are several records whose
    key cannot be distinguished. It is not possible to say which record this will be. In such a case you should
    clean up the data of the table before converting.
    Step 5: The secondary indexes defined in the ABAP Dictionary for the table are created again.
    Step 6: The temporary table (QCM table) is deleted.
    Step 7: The lock set at the beginning of the conversion is deleted.
    If the conversion terminates, the table remains locked and a restart log is written.
    Caution: The data of a table is not consistent during conversion. Programs therefore should not access
    the table during conversion. Otherwise a program could for example use incorrect data when reading the
    table since not all the records were copied back from the temporary table. Conversions therefore
    should not run during production! You must at least deactivate all the applications that use tables to
    be converted.
    You must clean up terminated conversions. Programs that access the table might otherwise run
    incorrectly. In this case you must find out why the conversion terminated (for example overflow of the
    corresponding tablespace) and correct it. Then continue the terminated conversion.
    Since the data exists in both the original table and temporary table during conversion, the storage
    requirements increase during conversion. If the tablespace overflows when you reload the data from the
    temporary table, the conversion will terminate. In this case you must extend the tablespace and start the
    conversion in the database utility again.
    If you shorten the key of a table (for example when you remove or shorten the field length of key fields),
    you cannot distinguish between the new keys of existing records of the table. When you reload the data
    from the temporary table, only one of these records can be loaded back into the table. It is not possible
    to say which record this will be. If you want to copy certain records, you have to clean up the table
    before the conversion.
    During a conversion, the data is copied back to the database table from the temporary table with the
    ABAP statement MOVE-CORRESPONDING. Therefore only those type changes that can be executed
    with MOVE-CORRESPONDING are allowed. All other type changes cause the conversion to be
    terminated when the data is loaded back into the original table. In this case you have to recreate the old
    state prior to conversion. Using database tools, you have to delete the table, rename the QCM table to
    its old name, reconstruct the runtime object (in the database utility), set the table structure in the
    Dictionary back to its old state and then activate the table.
    If a conversion terminates, the lock entry for the table set in the first step is retained. The table can no
    longer be edited with the maintenance tools of the ABAP Dictionary (Transaction SE11).
    A terminated conversion can be analyzed with the database utility (Transaction SE14) and then
    resumed. The database utility provides an analysis tool with which you can find the cause of the error
    and the current state of all the tables involved in the conversion.
    You can usually find the precise reason for termination in the object log. If the object log does not
    provide any information about the cause of the error, you have to analyze the syslog or the short dumps.
    If there is a terminated conversion, two options are displayed as pushbuttons in the database utility:
    After correcting the error, you can resume the conversion where it terminated with the Continue
    adjustment option.
    There is also the Unlock table option. This option only deletes the existing lock entry for the table .
    You should never choose Unlock table for a terminated conversion if the data only exists in the
    temporary table, i.e. if the conversion terminated in steps 3 or 4. table for table TAB is therefore QCMTAB.
    Hope this is helpful,Do reward.

  • Fix key fields in the Table Control

    Hi,
    Is it possible to Fix Keyfields of a table contol during scrolling in webdynpro screen.
    Regards,
    Ramu N.

    Hi Muralidaran,
                   I have no idea about WebDynpro, my requirement is that,I should inform my client whether Key Fields can be fixed just like in ALV's.
    My first task is I to inform client whether it is possible or not. Please let me know it is possible or not.
    Regards,
    Ramu N.

  • Problems deleting a primary key field in a table.

    Hello Guys,
    I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What is the problem???
    How can I delete a primary key in a table??
    Please help.
    Thanks,
    Naren

    I am pasting the detail explaination over that error.
    Primary key change not permitted for value table ZTV_RANGE_NUMBER
    Message no. AD 300
    Diagnosis
    This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.
    Procedure
    If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.
    If necessary, maintain the deleted foreign keys again.

  • Key field in a table

    HI,
    I Created a Z table with a key field of type STRING when I activate the table its showing error that the field of type String not permitted can anybody help whether i should not use string for key field.
    thanks in advance,

    Hi,
    Use the data type CHAR for the Key field.
    Character string. Fields of type CHAR can have a maximum length of 255 in tables. If you want to use longer character fields in tables, you must choose data type LCHR. There are no restrictions on the length of such fields in structures.
    Regards,
    Arun

  • Problem with S001 - Key field Sequence in table

    Hi,
    We want to use the extractor 2LIS_01_S001 with Delta. But delta is not working with these extractor. When I checked LBW0, I am getting error "The LIS environment is setup incorrectly".
    According to note 115192, the key fields in tables S001, S001BIW1 and S001BIW2 have to be in the same sequence.
    But we are on 4.7 with following Support Packs:
    SAP_APPL 470 0025 SAPKH47025 Logistics and Accounting
    PI 2004_1_470 0007 SAPKIPZI57 R/3 Plug-In (PI) 2004.1 for
    R/3 Enterpri
    PI_BASIS 2004_1_620 0010 SAPKIPYI5A Basis Plug-In
    (PI_BASIS) 2004_1_620
    And according to this note, solution is delivered with this Support Packs.
    Can you please tell me that if this note is mandatory for all the releases..?
    Did any one encounter this issue before..?
    Thanks & Regards,
    Samay Mehta

    I changed my entity: unchecked the X column to be primary key added RowID as a primary key. Now it works.
    What's wrong with my CHAR(1) as a primary key ?
    I also tried to add a Refresh button:
      <af:commandButton text="Refresh" id="cb3"/>and in the table add a partialTarget to the button. Now when I add new row and press the Refresh button - then it works.
    So it seems that the problem is when I add new row and enter data, the table is not refreshed and the row is missing it's primary key.
    Any solutions?
    Edited by: a.gruev on Nov 26, 2009 4:18 PM

  • Return item (RETPO) as a key field in condition table

    Hi,
    I would like to know how we can utilize return item indicator as one of the key fields in the PO pricing condition table.
    [Requirement]
    Condition record
    Use Retrun item as a key
    e.g.) Table A999: POrg | Vendor | Return item | condition rate
    #1: 1000 | M123456789 |blank | 3%
    PO pricing
    If the PO item is NOT marked as return, #1 should be applied to that item.
    If the PO item is marked as return, no condition record should be determined.
    [Question]
    Though I've configured as above, return item indicator seems to be ignored.
    When I tick the initial indicator in access sequence, the condition rate is always applied to the PO item for both with and without return item indicator.
    When I tick-off the initial indicator in access sequence, the condition rate is not applied to the PO item for both with and without return item indicator.
    Why does it happen?
    Is it possible to apply the condition record only to the PO without return item?
    I'd like to know how to make it effective in the condition table, RETPO=blank.
    As long as searched, I couldn't find any similar question.
    Your help would be much appliciated.
    Best Regards,
    Mari

    Hi Manosij,
    Thank you for your reply.
    I've already done as your instruction.
    However, the result is not what I'm expecting.
    I believe I'm right to creating the condition table.
    But I think something wrrong in access sequence...
    Though I do as your instruction, creating the condition record in MEK1 only for blank one, the record is applied to those with X when creating PO.
    If you have another clue on my question, it would be much appreciated.
    Best Regards,
    Mari

  • Automated value generation for key field in db table

    Hi All
    I have created a table in SE11 and i want to autogenerate a value for the keyfield when the user adds a new record to the table. the keyfield is of type numc. this field represents a document id hence i do not want the user to physically enter in an id. Is it possible to achieve this without any additional coding. I am using a WDA app together with an adobe form to allow user to input data.
    Thanks in advance
    Regards
    Thashin Naicker

    There is one more method to do that.
    Write a query to fetch all the records from the table into any temporary internal table.
      Then, do a looping in that table & increment one temporary variable inside a loop.
    after this add first value of your primary field  to this temporary variable..
    Ex.: To add one more record with an increment to a primary key field  is shown below:
    DATA: TEMP type I.
    TEMP = 1.
    SELECT * FROM <TABLENAME> INTO TEMP_TABLE.
        ENDSELECT.
    LOOP AT TEMP_TABLE.
          TEMP = TEMP + 1.
        ENDLOOP.
    <Tablename>-<fieldname> = TEMP_TABLE-<fieldname> + TEMP.
    Note: temp is a temporay variable and temp_table is a temporary table.

  • Currency Field as a Key Field in Z Table

    I am creating a  z table in which i have to make a AMount field as a key field . But it is showing a warning while activating the table stating that "Key field AMTFR has num. type DEC: Buffering not possible, Transport restricted"
    How can i clear this warning.
    Thanks in advance

    In this design I suggest you add one more field to the table called SLAB Code., which will be the key. You can have it as CHAR data type of whatever length you want.
    That way its easy to handle, because tomorrow if the slabs change, you are changing the values of the key fields, this way you can avoid that.
    You can probably have composite key of Slab code and validity dates.
    Regards,
    Ravi
    Note - Please mark all the helpful answers

  • Can we change key field values in table maintenance

    Hi,
      I have created Z-table and table maintenance for the same...
    In table maintenance..Can we change key field values??
    Is there any posibility????
    Rayudu

    you can do it in this way.
    open sm30->tablname->edit
    snow select the row(s)->copy->change the keyfield values-back->save.
    no in that sm30, select records with old primary key and delete->save.
    so you got all field similar for those record under modification, only the key field changed.

Maybe you are looking for

  • Mapping in Syndicator and XI

    I am mixing up these two mapping --- in syndicator and XI What gets mapped in syndicator and what gets mapped in XI? Why do we map in syndicator,  when there is option to map in XI? I am a beginner in XI and trying to figure out MDM part of XI. Appre

  • How can I make the Norton bar larger?

    I just downloaded FF6. I was looking for a verison that supported the Norton bar, I have however it is way to small for me to see well. I need to make it larger.

  • Want to download a itunes game (slotomania)onto my computer. How do I do this??

    Hi out there How do you download a free itunes game to the computer? I want to play it but can't get it to download. Using Windows 7 Any help would be appreciated Thanks

  • Plus (+) sign in phone number ?

    I have a telephone list in Outlook with all numbers including country code with a plus(+)-sign in front of it. When I use OVI Suit to synchronize with my phone 6720c the plus-sign disappear in the phone, so I can't use them?

  • Can't get a remote to work for my 36AF41 TV! Any help please?

    I recently purchased a model 36AF41 flat screen TV and it did not come with a remote. I have tried using my cable TV universal remote and 3 other brands of universal remotes and can not get any to work. Is there some trick to getting this to work or