Your program should write all backup commands to a temp table, then read and execute those command one at a time. Do not hard code the backup commands as your db structure might change over time.
Below is pseudo code. It requires you be in archive log mode since you can only backup a live database in archive log mode. Don't backup on-line redo logs, since you cannot restore them from a hot backup. Also, backup datafiles but don't backup tempfiles, since they are not read during recovery and are much faster to recreate manually.
Fetch a list of your tablespaces into a cursor.
looping through above list ...
write "begin backup" command as a string to a temp table.
Fetch a list of datafiles per tablespace into cursor2.
looping through cursor2...
write your backup command (an operating system command like Copy as a string to your temp table.)
wite a command to backup your controlfile to trace.
wite a command to backup your initSID.ora and pwdSID.ora, if you use these files.
read the commands from your temp table execute them. (I spool the command listing to a file that I read back into SQL*Plus, which executes all commands for me.
Another idea is to use RMAN (Oracle's facility for backing up databases). Once you understand how RMAN works and how to set it up, all your code has to do is start the RMAN executable - RMAN will do the rest.