Skip to Content
0
Former Member
Dec 12, 2003 at 01:38 PM

Mixing ABAP and Javascript... help!!!

190 Views

I want to take an ABAP internal table and use it in Javascript commands. But I can't do it, of course. So my next shot is to convert the table into a Javascript Array. The correct syntax is:

<script type="text/javascript"> var Jscripts = new Array("X","Y","Z") </script> Now, how to get my internal table involved? My approach is to simulate the var statement with a mixture of constants and ABAP code and ABAP variables. I want to comma delimit except at the end, when I terminate with a parenthesis. Let's say it's a table of strings... I tried the following (assume data is already in internal table): <% data: scripts type table of string, script type string, myindex1 type i. %> <script type="text/javascript"> var Jscripts = new Array( <% describe table scripts lines myindex1. loop at scripts into script. if sy-tabix < myindex1. %> "<%=script%>", <% else. %> "<%=script%>") <% endif. endloop. %> </script>

This doesn't work. The array apppears to contain 2 entries with weird values. The ABAP processor does not seem to be recognized, no looping is taking place! Can anyone suggest a way to do this?