In this post, you will find the detailed exaplanation of properties (fields) KEY & COL_POS of field catalog (SLIS_T_FIELDCAT_ALV) with example.
As explained in my previous post (Introduction to Field Catalog ( SLIS_T_FIELDCAT_ALV )) :
KEY : This field indicates if the respective column is the key field in the tabular data to be displayed. The columns marked as ‘Key’ fields will always be positioned before the non-key fields.
COL_POS : Specifies the position of column in the ALV display. If this property is not specified, the columns/fields of data table will appear in ALV display in the order in which their “fieldname” appear in the field catalog. “Key” fields will always have higher priority than non-key fields. You are free to use the same position number for key fields & non-key fields. However, if two key fields or non-key fields have been assigned the same position number, they will be displayed in the order in their “fieldname” appear in the field catalog.
Here, you would be able to experience the real effect of these properties.
Lets, begin with an ALV list where only the mandatory field FIELD_NAME is provided for each of the columns in field catalog. So, the code for field catalog looks as below:
FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘PRICE’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CURRENCY’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CARRID’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CONNID’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘FLDATE’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM.
The above ALV field catalog produces the output as shown below:

ALV with only FIELDNAME specified in Field catalog
Now, lets introduce the property KEY for some of the columns to be displayed on ALV. Find below the modified code:
FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘PRICE’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CURRENCY’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CARRID’.
ls_fieldcat-key = ‘X’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-key = ‘X’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-key = ‘X’.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM.
Just, notice the effect:

ALV with KEY specified in Field catalog
You would notice two important effects:
1. All the columns marked as KEY fields are positioned before non-key fields. This preference of key fields over non-key fields can not be altered by any other property in field catalog.
2. All the columns marked as KEY fields are highlighed.
Having, understood the effect of property KEY in the field catalog, lets proceed to the usage of property COL_POS.
Property COL_POS is used to arrange the key fields and non-key fields within themselves. If specified, the columns will appear in the ascending order of COL_POS. In case of conflict e.g. two key fields or two non-key fields having same COL_POS, they will be positioned in the order in which they appear in the field catalog internal table.
Lets observe the effect of changed code with COL_POS property incorporated.
FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘PRICE’.
ls_fieldcat-col_pos = 2.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-col_pos = 1.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CARRID’.
ls_fieldcat-key = ‘X’.
ls_fieldcat-col_pos = 2.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-key = ‘X’.
ls_fieldcat-col_pos = 2.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-key = ‘X’.
ls_fieldcat-col_pos = 1.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM.

ALV with COL_POS specified in Field catalog

[...] SAP ALV Tutorial : SAP ALV programming techniques Example: Field catalog – KEY, COL_POS [...]