I’m not sure I totally understand your question, but to get the number of unique deliveries you would use something like:
SELECT COUNT ( DISTINCT vbeln )
to get the number of records with a specified delivery number you could use something like:
SELECT COUNT ( DISTINCT BCODEL )
WHERE vbeln EQ p_vbeln
Hopefully one of these is what you are looking for. If not they should at least get you pointed in the right direction.