Things that may seem rather obvious to experienced users/developers, may be rather less obvious to the less experienced amongst us in the SAP Developers Network community. One reason could be a lack of information. Its a fact that (online) bookshops have loads of books on Java, for example, but not many are available on Web AS. Of course there is always the F1 key on your keyboard and help.sap.com to consult as a first resort, but here one needs to know what to look for in the first place. Sometimes help is limited to a syntax description, and good examples or best practices arent always provided. The SAP Developers Network with its sharing of information and experience is very handy in this case. But this community is constantly growing (the Web Application Server has > 1000 posts in a week) and information is widely scattered some times. This series tries to concentrate information in small, quick win code samples. Some topics have already been touched on in spread forum posts, some havent.
My first example deals with the request->get_form_field(s) method. This method lets you retrieve HTM form fields in name/value pairs. It seems a bit like going back to the olden days where one needed to investigate the HTTP header in order to know how to fill in a form. Working with page attributes for example, is indeed the more advanced and best method in most cases. But there are some circumstances where page attributes arent needed and the request->get_form_field(s) method is nice and handy. A search on SDN gives you some sample uses. Most people are using it as a kind of debugging tool in order to see how a field is filled
DATA: somevalue type string.
somevalue = server->request->get_form_field('somefield').
Craig Cmehil used it to devise this nifty way to redirect a page. Check this forum thread for details.
We use the request->get_form_field method for large lists which need to be processed in a fast and easy way. There are situations where the (unknown) amount of data prevents the use of page attributes. Lets take an online bookshop as an example. We want to provide a search function where the user can select multiple books for processing (comparing/viewing details, ordering, etc.) in bulk. Whatever we show, we are only interested in the ISBN numbers of the selected books. Thats easily done.
DATA: table_fields type TIHTTPNVP,
wa_fields type IHTTPNVP.
* clear our previous selections.
* retrieve the form fields
call method request->get_form_fields
fields = table_fields.
* and put them in our table
loop at table_fields into wa_fields.
append wa_fields-value to application-> WEB_TAB_ISBN.
After this you can supply this table to a/multiple FM, store it in a server cookie,