To automatically create a subVI from some code select the code and then select the Edit->Create SubVI menu item.
The first response you will get on this forum regarding local variables: Are you absolutely certain that you need to use local variables? Local variables are typically a crutch for those who come from a text-based programming language background. In most cases they can be replaced by a simple wire. As for passing data into subVIs you do not need to resort to global variables, although LabVIEW has them. The subVIs have connector panes where you define inputs and outpus, just like the arguments of a function in, say, VB or C.
To learn more about LabVIEW it is recommended that you go through the tutorial and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials.