I went thro the material but still not clear..
What part of the material was not clear? If the manual is not clear to you, i'd suggest maybe looking at a different way to implement your requirement.
Is there some business reason that your code needs to call itself or might you accomplish the same thing by using some array(s)?
We don't have any sample/pseudo code, but if you search the web for "bill of materials processing" (BOMP), you will find multiple examples. BOMP processing has been around for a long, long time.