Can any one suggest me a function module or BAPI for the below requirement.

Hi all,
I have a requirement in which i need to send an IDoc for each item of  the delivery document linked to the shipment document.
previously i have called the function module in a BADI, but now the requirement has changed.No BADI or USEREXIT has to be used.Instead i need to create a custom program and call the function module in a form in the program.My doubt is how can i get the tables needed in the function module from the program? previously i got the tables as online parameters in the BADI.
the function module will be trigerred at the time of saving of the document.
I understand that i need to pass the tables in the program, but is there any way (function module or a BAPI) that can be used to directly get the data of the BADI?
please help me as soon as possible.


my transaction is VL02N change outbound delivery.