In VoiceXML you can access a SIP header using the session variable session.com.cisco.proto_headers[''], for example, session.com.cisco.proto_headers['Remote-Party-ID']. Sample VoiceXML output from a custom element is attached; you can see a selection of headers being retrieved.
To get the B-channel ID itself you have to retrieve the Via header and parse the DS0 number from the x-ds0num header field. I've attached a custom element that will retrieve the headers configured in the element settings and create data for each of the fields. In the B-channel example, using this custom element, the relevant information would be written to ElementName.Via.x-ds0num. The actual value you're interested in still needs to be parsed-out but this gets you pretty close. For a BRI the DS0 field looks like this: x-ds0num="Basic Rate Interface 0/1/0 1

S0" so you just need to extract the value from the x

S0 part. It's very similar for a PRI.
In comprehensive model, the Via header on the VRU leg won't include the x-ds0num field as CVP doesn't propagate it but there's a couple of things you can do very easily provided you configure the CVP Call Server to pass the Via x-ds0num field up to ICM. In the ICM script you can either parse out the B-channel number from the x

S0 field into a call variable or just write it to a custom SIP header before invoking the SendToVRU if you don't want to use up variable space.