u can read data by creating subroutines.please check below examples
http://wiki.sdn.sap.com/wiki/display/ABAP/Subroutines+And+Their+Use+In+SAPScript
http://wiki.sdn.sap.com/wiki/display/profile/External+Subroutines+in+SAP+Script
You can debug scripts by following ways
First u need to active debugging in scripts. then run the driver program.
First goto SE71 initial screen and enter the form name. Goto Menu Path Utilities --> Activate Debugger. and now u run the driver program. Now u get the script editor in debugging mode.
Secondly,
Program is RSTXDBUG.
Now go to SE 38 and enter ur Print Program name and execute the program.
Now you can debug the script Page wise and window wise.