hi,
You cannot write own code in script to fetch value from a database table. Instead you have to use PERFORM statememnt in script.
Yu have to call a sub-routine from scirpt. U need to pass paramters to it which will be used in include where u write FORM...ENDFORM of the sub-routine.
You can fetch detials from table and pass it back to the script where u will show in output.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
...
ENDFORM.