Setup New company. Setup Key does not exist error

sajidhanifkhansajidhanifkhan Member Posts: 182
Hi,

I made a new data base and resotre a database to make a new company. I run a code unit to clean data from table which already got some old data.
For some forms like budget , Chart of account and some others too I get error setup key does not exist. Also when I try to run a sales history report it still shows me the error of not finding the item no 4130 and item catagory ACC which used to be in item table before but I already deleted those records by running the code unit now how to run this report?

Thanks in advance for your feedbacks.

regards
Sajid

Comments

  • kapamaroukapamarou Member Posts: 1,152
    If you use File -> Database -> Information -> Tables do you see any tables that have records while they shouldn't?


    Also keep in mind that deleting the data is not enough. You may have relations to deleted data. (Field with values pointing in missing records). Have you tried performing a Test on the database?
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    Also keep in mind that deleting the data is not enough. You may have relations to deleted data. (Field with values pointing in missing records).

    How to delete the relations of the deleted data?

    regards,
    Sajid
  • kapamaroukapamarou Member Posts: 1,152
    You'll have to empty the fields... Run a test to see if you get any errors on specific tables and then debug the problem to see what's wrong..

    Also have you deleted the GLSetup to perhaps force the CompanyInitialization to execute?
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    I find no error in running the table test as you suggusted. but the problem still exists for me.
  • kapamaroukapamarou Member Posts: 1,152
    Ok.

    Regarding the Setup try to Initialize the company, Or insert a new record in the appropriate setup.

    Now, you mention that item no 4130 and item catagory ACC do not exist. However, the system asks for them. So, this means:

    a) In some table that the report uses, there is a field that contains the value: 4130 and is used to link the item table. The field might be lacking the relation, but maybe C/AL uses it.

    b) The values being asked are hard coded in the report (probably not)

    From what I understand you ran a codeunit to empty the tables and keep only the setup. Are you sure that all the tables have been emptied?

    Try using the debugger and posting here the part of the code that causes the error...
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    When I try to make a PO it gives me error there is no Location within the filter Filter Code : "Prviosu location" which I already deleted from location table.

    Please suggest.

    regards
  • kapamaroukapamarou Member Posts: 1,152
    Try again but now setting the debugger to Active.
    Then copy the code the debugger stopped and paste it here... That will show us where the problem is. (i.e. : The field "Location Code" in the Responsibility Center table is holding an old value...)
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    Dear Kapa,
    Yes I run the code unit to empty the table but not all tables but then I add the table which was not empty for example the location table. So after making empty the Location table I still get the same error as below;

    I run the Test on table 38 as you suggested by going into Database information and it gave me the same error which I get creating the new PO it says as below;

    Location does not exist;
    Code XXX

    The Location Code field in the Purchase Header table has a table relaionship to the Code field in the location table.

    Purchase Header has the following fields and Value;

    Document Type=Quote No,No=PQ00001

    Regards,
    Sajid
  • kapamaroukapamarou Member Posts: 1,152
    When this error comes from the test, it means that there is an entry with a value in a field linked to "Location". Look through all the records in that table to see if there is such a field and if it has an invalid value.

    Keep in mind that when you insert a new PO some validation of fields may fill other fields such as "Location Code" with values from some setup or master data tables. So maybe the Responsibility Center or Vendor or other table has a value linked to the location table that is missing...
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    Dear Kapa,

    What you concluded is my question since begning. I have deleted all the data from Location table, Purchase header table and there is no data at all but still when I try to create the new PO or run the test for purchase header table I get this error which I mentioned in my earlier post. Question is how to find this error since it always try to find the location which has been deleted so where can I get this link which codeunit? Table ? If I create the location with same name which it mentioned in the error it works but I dont wanna create this location since this is for an other company.
    Please guys help me.

    regards
  • kapamaroukapamarou Member Posts: 1,152
    Ok.

    Assuming that the error comes from a table relation:
    1. Open Object Designer
    2. Create (Using the wizard) a new tabular form based on Table "Field"
    3. Select all fields.
    4. Run the form.
    5. Apply a filter on Field RelationTableNo with value 14 (It is location table)
    6. When you get the filtered result check that the fields in the shown tables are empty if the tables contain records.
  • sajidhanifkhansajidhanifkhan Member Posts: 182
    Hurray!!!!!

    I solved it finally. The problem was the company setup table where the location was defined which was deleted so I changed the location there and it solved the problem now I am able to make PO and Sales Orders.

    Thank you all who tried to help me.

    regards
    Sajid
Sign In or Register to comment.