cancel
Showing results for 
Search instead for 
Did you mean: 

Can i access attributes from IF_HTTP_HEADER_FIELDS ?

TMNielsen
Contributor
0 Kudos

Hello

The IF_HTTP_HEADER_FIELDS contains some attributes (like REFERER or VIA) I find interesting, but are they usable - can anyone give ex. of usage and how to?

Best regards

Thomas Madsen Nielsen

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You can read (nearly) all HTTP Header fields which the client sends; and you can set (nearly) all HTTP header fields using the appropriate methods (GET_HEADER_FIELDS method of the request object; SET_HEADER_FIELD(S) of the response object).

But you have to take care: Not every HTTP header is a must! e.g. "referrer" is an OPTIONAL header fields which the client can send or not (see http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html).

TMNielsen
Contributor
0 Kudos

Hello Stefan

Thank you for your reply.

I know the SET_ and GET_ HEADER...... methods. But they don't give me what I want.

The expl. is probably that the attributes I seek are Optional. I will have a look at the w3.org page.

Best Regards

Thomas Madsen Nielsen

former_member181879
Active Contributor
0 Kudos

Hallo Thomas,

After reading this through a few times, back and forth, I come to the conclusion that a critical part of the puzzle is missign. You write "but they don't give me what I want". What exactly do you want, or want to achieve?

As for the interface, IF_HTTP_HEADER_FIELDS, this is just a collection of strings, effectively giving you constants for well-known header fields. It does not say anything about the actual headers that are available in an incoming request.

Typical use example:

value = request->get_header_field( IF_HTTP_HEADER_FIELDS=>CONTENT_TYPE ).

If you want to see all headers available in the incoming HTTP request object, you can use either GET_HEADER_FIELD() or GET_HEADER_FIELDS() methods, both on the request object.

For a simple example, see BSP page IT00/MISC_ECHO.HTM.

Coding would be:

DATA: ffs TYPE TIHTTPNVP, ff  TYPE IHTTPNVP.

request->GET_HEADER_FIELDS( CHANGING fields = ffs ).

++bcm

TMNielsen
Contributor
0 Kudos

Hello Brian

Exactly what I want to achieve is a difficult question. At this time I'm just playing around trying to learn new stuff.

One thing I could use is the clients IP, but the REMOTE_ADDR will often give me the IP of some proxy server.

I could also use REFERER information, but .....

It would also be usefull if I could read the clients page history, but I don't yet know how this can be done with BSP.

Even better regards

Thomas

Former Member
0 Kudos

Hello,

New here and new to BSP.  I'm hoping this is a simple problem

I'd like to read a parameter from one page when I load the second page.

Similiar in JSP to request.getParameter("myfield")  however I don'T seem to be getting it. I was hoping someone could point me to a good example??

Thanks,

Craig

Former Member
0 Kudos

Hmm, just read what I wrote and I think that perhaps I should be a little clearer.

I have 2 pages.

search.htm

with a htmlb Inputfield called 'month'

When I click the go button on this page I would like to be able to read that parameter in the onInputProcessing event of the second page and assign the value from the inputfield to an attribute I use in the oncreate event.

Is that possible?

The oncreate event is a SQL statement to a table I am displaying.

former_member181879
Active Contributor
0 Kudos

Hallo Craig,

Always with people new to BSP, it is not so much help to give an answer, than to show you where to look at interesting things. Let me do both this morning (it is only 6am, so we have time).

First, examples are the best way to learn: you can look at some BSP applications HTMLB_SAMPLES, SBSPEXT_HTMLB and SBSPEXT_XHTMLB. Next, you can also inside a BSP page select a tag (click in its name), and then press F1. If the page is syntactically correct (we need the compiler to know where you click:), the help system is started with a pointer to the tag. And lastly, when inside a BSP page, double click on the name to jump directly into the BSP-Extension workbench. Here you can see the definition of the tag (attributes, etc.).

For your question, let me ignore first the two page problem (I assume you have this under control). So we have one page with one <htmlb:inputfield> and probably a button. We click the button, and on the server land back inside the BSP page. In the OnInputProcessing handler, we do the following code:

DATA: if TYPE REF TO CL_HTMLB_INPUTFIELD.

if ?= CL_HTMLB_MANAGER=>GET_DATA( request = request

                                                                 id = 'whatYouSpecifiedBefore'

                                                                 name = 'inputfield' ).

Specifically the "name" is important, as it tells the manager of what type of tag you require the data. The value can now be read from "if->value".

brian

Former Member
0 Kudos

Hello,

OK well I've figured it out.  I realized that doing the SQL in the OnCreate meant that it was happening before the value was being assigned from the Request.

So next time I will try to relate the events to normal HTML events first LOL.

Next question...

Are there methods such as substring or indexOf in BSP's like with normal Java and JSP?

I'd like to be able to multiple a string but I'm having trouble locating examples or documentation for that.

Thanks a million,

Craig

Former Member
0 Kudos

Hello Brian,

I agree with you that giving an answer is not much help and I thank you for not just throwing one out.

Since my last post I had managed to find all of the examples and the F1 help you talked about, maybe I should have tried the more obvious things before posting LOL.  However I'm still struggling with this one problem.

Page 1:

InputField: id=month

Page 2:

InputField: id=month

On page 2 I have the value from page one by using the OnInputProcessing, that much I figured since my last post.

Also on page 2 I'm using a tableview and I have a table set as a Page Attribute and I create the SQL/table in the OnCreate. Without using a where clause it works and I get output. The problem I am having is using the attribute myMonth in the where clause during the OnCreate event.  I want myMonth to have the value from the InputField but no matter what I try I can't get it in there. Is there an example that I have not seen or maybe overlooked where I can see this part?

The values on the page itself seem to be no problem, but the values in the code seem to be a big problem.

Or maybe I'm going about it all the wrong way?

Thanks!!!

Craig

former_member181879
Active Contributor
0 Kudos

Hallo Craig,

Yes, you seems to be a candidate one should leave struggle for a few hours The answers comes by themselfs (or via the debugger).

It is interesting to see a (ex?) Java programmer asking ABAP questions. My answer is again going to be, please read the documentation. There is no way around this. Simplest way, somewhere in one of the event handlers of the BSP page (not the layout!), select the ABAP keyword and press F1. Sorry to say, but nothing beats good online help, and although the ABAP help takes slightly getting used to, it is really good.

Of course, if one knows a few interesting keywords, searching is much easier. So here a few keywords I often use.

FIND/SEARCH

REPLACE

TRANSLATE, both the UPPER/LOWER CASE variants, and the USING form

SPLIT

CONCATENATE

And the very best, are the new string operators! You can use them in IF statements. For example:

IF STRLEN( s ) > 10.

IF s CS 'xyz'.     " contains string

IF s CA 'abc'.     " contains any off

IF s CP '*abc+'.  " contains pattern

There are 8 of these. Check the documentation.

And then you can do things such as relative string indexing and length computation. Examples:

s(7)     " string in length of 7 bytes

s+7     " offset from 7 further

s+7(7) " both

Becareful that "STRLEN( s) >= n" before you do "s(n)", and you can check ST22.

Finally, but please don't tell anyone, here one trick

DATA: s TYPE STRING.

CONCATENATE s ' ' s INTO s. " this gives you "ss" in string

CONCATENATE s ` ` s INTO s. " this gives you "s s" in string!

For ABAP trailing spaces have no meaning and they are ignored. So you can use the `` sequence to handle spaces in strings. Much easier.

And with this, I will leave you do documentation reading, and hope that on your next return you can help one of us with something interesting that you have learned.!

regards, brian

Former Member
0 Kudos

Brian,

I am pulling my hair out trying to get through a problem and it seems that you may be able to help me out.

I am creating a BSP with an htmlb button element.  I fully expect to land in the OnInputProcessing event handler when I press the button, but I do not. I also do not land in this event in any of the sample BSP's that you specified. Rather, I get only a "javascript:void(0)" message.

Conversely, if I set "submitonEnter" to "TRUE" for the input field, I land in OnInputProcessing.  I've proven this in debug mode.

How can I land in OnInputProcessing when pressing a button?  Also, the help text (perhaps for someone who knows nothing about web programming like me) is not very helpful regarding the OnClick property of a button. Can you shed some light on that?

Thanks,

Manny

former_member181879
Active Contributor
0 Kudos

Hallo Manny,

Yes are welcome to start a new thread for new questions

Now let us look at the button code. You effectively have three permutations you can write, and their meanings. Here "..." is for the id, text, tooltip etc parameters.

(1) <htmlb:button ... onClick = "myHandler" />

This onClick here is just a symbolic string. It means you are interested in the event of the button at the server. The myHandler is a string you can use to dispatch events somewhere, etc. (Sending events to server is just a submit of the HTML form.)

(2) <htmlb:button ... onClientClick = "alert('Hit me more!');"  />

In this case no onClick handler is set. Thus no event is required at the server. When the user clicks the button, the onClientClick string is executed in the browser. This must be JavaScript code.

(3) <htmlb:button ... onClick = "myHandler"  onClick="alert('Hang 10, we going to roundtrip')" />

This does both of the above. First execute the Javascript, and then send the event to the server (if not canceled).

(4) <htmlb:button ... />

This button has no events, and it will not help to be pressed. So effectively we render this button as disabled.

I would seriously recommend that you play with our test BSP applications. They all use buttons. See BSP applications: HTMLB_SAMPLES, SBSPEXT_HTMLB, SBSPEXT_XHTMLB and SBSPEXT_PHTMLB (>sp30).

brian