Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to rearrange table fields and add key field?

former_member625844
Participant
0 Kudos

I have a customized table z01. The fields are zf01,zf02,zf03,zf04,zf05 and zf01 and zf02 are key fields. Now I want to add zf04 to key fields but error occurred in activation because zf03 is not key and all key fields must be together. So is there a way to do so and without empty table content first? Thx.

1 ACCEPTED SOLUTION

VXLozano
Active Contributor

If you are using SAPGui, in SE11 you must insert the new field as the last one in the key, not before zf03, but before zf02.

The sad part is you will not be able to activate it "as is", because with the changes, SAP will not be able to do it properly.

Menu Utilities->Database object->Database utilities (or something like that, I am not in EN now)

There you will have a nice screen with a last button "activate and adapt database" with a couple of radiobuttons "keep data" and "delete data"

You must use that button to activate the table.

(I assume if you are using Eclipse, it will give you a tool to do it, if not, just open SE11 there :P)

Addition: because the answer from felipe.dimmu23 I must add this:

be careful because if there is data in the new table, you will end with empty key fields. This usually is sign of bad design (as Matt would say).

8 REPLIES 8

rajgaaj
Participant
0 Kudos

Please make sure you check the initial value column in the table field when adding key.

Could you please share the error log screen shot?

VXLozano
Active Contributor

If you are using SAPGui, in SE11 you must insert the new field as the last one in the key, not before zf03, but before zf02.

The sad part is you will not be able to activate it "as is", because with the changes, SAP will not be able to do it properly.

Menu Utilities->Database object->Database utilities (or something like that, I am not in EN now)

There you will have a nice screen with a last button "activate and adapt database" with a couple of radiobuttons "keep data" and "delete data"

You must use that button to activate the table.

(I assume if you are using Eclipse, it will give you a tool to do it, if not, just open SE11 there :P)

Addition: because the answer from felipe.dimmu23 I must add this:

be careful because if there is data in the new table, you will end with empty key fields. This usually is sign of bad design (as Matt would say).

0 Kudos

This field was already in the table and after zf03.So is there a way to rearrange it? Can I just cut zf03 and paste under zf04?

VXLozano
Active Contributor
0 Kudos

I guess you can, yes. Just keep the name and the data element and SAP's workbench will notice it properly.

felipe_dimmu23
Participant

Key fields must come at the beginning so you will need to re-arrange them and then use se14 to activate the table. Vicenc Lozano is right, you need to be careful with the values you have in the new key field. They must be unique (among same zf01 and z02). Make sure you test the procedure before going forward if this is already holding data in live systems 😉

0 Kudos

Also...Depending on why you need this, a new index could be enough...same restrictions would apply about the z04 field if you go for a new unique index. But, if you are trying to improve performance probably a non-unique index with the fields you need can do the trick.

matt
Active Contributor

Put the key fields together. Create a view with the order of fields that you want.

Why you care about the order of the key fields, I've no idea. You're probably designing things incorrectly.

former_member625844
Participant
0 Kudos

Looks like just cut zf03 and paste it below zf04 work.