CO-PA derivation using table lookup is usually a single derivation step defined in transaction KEDR. For example to derive country, city and postal code of customer from table KNA1, we define a single step as shown below.

In case of derivation from table VBKD, we need to define two steps. If you take a look at the line items in table VBKD, some of the items have “POSNR” – line item number from sales order and some of the line items doesn’t have. If the line item information differ to that of header in the order, then line item number is populated and if it is similar to the information on header, then line item number is “blank”. So line item number information in table VBKD is inconsistent. Values in CO-PA could be missing or wrong in some cases if only one single derivation rule is defined.
First step:
Table lookup from VBKD when line item number exists. POSNR exists only if the line item is different from the sales order header information. If you are deriving from table VBKD, I expect that you need line item information in CO-PA. So make sure that this is your first step in the derivation rules. In this step define rule as shown below.

Source field POSNR is mapped to KDPOS. This rule works only if VBKD-POSNR has the line item information.
Second Step:
Table lookup from VBKD when line item number doesn’t exist.

POSNR is mapped to USERTEMP field which is “blank”. USERTEMP fields are generally used as value carriers from one rule to another, so make sure that the USERTEMP field used in this step is not used in any prior steps or user exits. Also you might want to make sure that the second step does not overwrite the values if derived from the first step.
