cancel
Showing results for 
Search instead for 
Did you mean: 

How To Display ABAP Variable Value

Former Member
0 Kudos

Hi,

I have a BSP and am using ABAP for scripting. I have a variable and I want to display the value on the webpage. What's the ABAP scripting syntax?

I tried:

<%

DATA: l_dat TYPE string.

l_dat = request->get_form_field( 'SELECTION' ).

WRITE: l_dat.

%>

I need the syntax to display l_dat.

Also, is there a ABAP scripting reference that shows syntax?

Thanks!

Accepted Solutions (0)

Answers (5)

Answers (5)

maximilian_schaufler
Active Contributor
0 Kudos

Hi Audrey,

it seems to me that you are new to BSP programming, so I hope you let me give you some starting advice.

Give the help on BSP a good read:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/e9/bb153aab4a0c0ee10000000a114084/frameset.htm">Business Server Pages</a>

While you can still come here for questions anytime, you might be better off doing some research on your own first.

Because even though the answers above are right and they do work, they will only confuse you, because there are many different ways to achieve the same goal - and without a proper understanding of the concepts it will be hard for you to find out by yourself which is the right way for your goal.

Therefore don't hesitate to ask, but be ready to get an overview yourself, as this will improve your understanding and answer most questions you have already.

Cheers,

Max

Former Member
0 Kudos

HI Audrey,

In the code you are using ,in layout itself,you just change your code as

<% DATA: l_dat TYPE string.

l_dat = request->get_form_field( 'SELECTION' ).

if l_dat is not initial.

%>

<htmlb:textView text = "<%= l_dat %>"

design = "EMPHASIZED" />

<%

endif.

%>

Regards,

Siddhartha

athavanraja
Active Contributor
0 Kudos

within the layout you have to have to sections , one for scripting and one for writing.

this is the general server side pages (BSP, ASP,JSP,etc) methodology.

Regards

Raja

Former Member
0 Kudos

yes there is a way to put the things in one abap section.

but for that you have to use MVC.

since a controller class has a method write(). using that you can write to the view i.e html page.

e.g.

in do_request method of controller:

-


DATA: l_dat TYPE string,

fields type TIHTTPNVP,

wa_fields like line of fields.

CALL METHOD request->if_http_entity~get_form_fields

CHANGING

fields = fields.

loop at fields into wa_fields where name = 'SELECTION'.

l_dat = wa_fields-value.

endloop.

write( '<html><body><H1>' ).

WRITE( l_dat ).

write( '</H1></body></html>' ).

-


everything else is already mentioned.

regards,

Hemendra

Former Member
0 Kudos

HI Audrey,

You can't use

<b>write: l_dat <b> in Web Pages,the syntax to display a variable in ABAP would be

<%=l_dat%> or via using a textview as

<htmlb:textView text = "<%=l_dat %>"

id = "txt1"

design = "EMPHASIZED" />

in your layout.

If you are submitting the value on same page and want to show it then in the onInputProcessing or onrequest,depending on requirement ,you have to use

l_dat = request->get_form_field( 'txt1' )

where l_dat is a page attribute.

Hope this helps,

Regards,

Siddhartha

Former Member
0 Kudos

Hi Audrey,

Did you try this way

<%= I_data %>

Shailaja

Former Member
0 Kudos

That way does work but is there a way to put the statment in one ABAP section?

Using <%= l_data %> would make me have 2 sections.

Thanks

Former Member
0 Kudos

Hi Audrey,

What do you mean 'to put the statement in one ABAP section?'.

Regards,

Ravikiran.