Skip to Content
author's profile photo Former Member
Former Member

Pass parameter from OnInitialisation to OnInputProcessing

Hi,

I have asked this before but I closed that thread and awarded all the points.

I'm still having trouble with it, so I post it again for clarification.

I have a BSP, a.bsp

in the Page Attributes I have a parameter error1 which is a string with the AUTO box checked

in the OnInitialisation Event I set error1 = 40

in the layout error1=40 is used as a trigger

in the layout there is a submit button which leads to the OnInputProcessing Event for the same page

in the OnInputProcessing Event I have an if statement with the criteria if error1 = 40

my problem is when I debug, error1 has not value assigned in the OnInputProcessing Event so my if statement gets ignored

why is that ? surely the value of the string parameter should be automatically carried from the OnInitialisation Event to the OnInputProcessing Event - because it is correctly defined in the page attributes with auto checked.

Anybody any ideas ?

Thanks,

Tomas.

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • Best Answer
    Posted on Feb 08, 2005 at 02:42 PM

    Hi Tomas,

    that's not necessary. Let me give you some pieces of source code:

    <b>Layout:</b>
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    
    <htmlb:content design="design2003">
      <htmlb:page title = " ">
        <htmlb:form>
    
          <htmlb:inputField   id      = "var1"
                              visible = " "
                              value   = "<%= value %>" />
    
          <htmlb:button       id      = "submit"
                              text    = "Press Me <%= value %>"
                              onClick = "myClickHandler" />
    
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    
    <b>onInitialisation:</b>
    
    value = value + 1.
    
    <b>onInputProcessing:</b>
      DATA: event TYPE REF TO CL_HTMLB_EVENT.
      event ?= CL_HTMLB_MANAGER=>GET_EVENT_EX( runtime->server->request ).
    
      IF event->id = 'submit' AND event->event_type = 'click'.
    
        DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
        data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
                                               name     = 'inputField'
                                               id       = 'var1'
                                            ).
        IF data IS NOT INITIAL.
          value = data->value.
        ENDIF.
    
      ENDIF.
    

    Page attribute: value type string

    Instead of a counter you can use your your number as value.

    Hoping that helps.

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Rainer,

      are you therefore confirming that setting a page attribute to Auto does not necessarily mean it will be possible to pass that attribute from Event to Event ?

      isn't the sequence:

      onInitialisation

      Layout

      onInputProcessing

      my scenario is:

      onInitialisation

      get some info from R/3

      and if info meets certain criteria

      error1 = 40

      Layout

      if error1 = 40

      render certain htmlb within

      the main htmlb for the general screen

      onInputProcessing

      if error1 = 40

      do stuff

      except error1 has lost its value 😔

      I will try what you say, but if I understand correctly,

      for your example my error1 will have to become a hidden input field in the Layout - which is ok, but it is a shame that this seems to contradict the doco with regard to automatically passing attributes of the same name between events in the same page and between pages.

      Thanks, I'll give it a try with a hidden input field.

      Tomas.

  • Posted on Feb 09, 2005 at 08:03 AM

    Hi Tomas,

    it depends if you run stateless or statefull. Here is the control flow of a BSP:

    http://help.sap.com/saphelp_47x200/helpdata/en/a3/4b9afa7aa511d5992e00508b6b8b11/frameset.htm

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Rainer,

      thank you very much for your patience, you are indeed correct, I was mistaken and I accept my mistake.

      The problem is solved your way with the:

      DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.

      data ?= CL_HTMLB_MANAGER=>GET_DATA(

      request = runtime->server->request

      name = 'inputField'

      id = 'rejectReason'

      ).

      IF data IS NOT INITIAL.

      rejectReason = data->value.

      ENDIF.

      and I continue my path the BSP enlightenment.

      I think all points have been awarded to you, if not let me know I'll award them.

      Thanks again and sorry for having my head in the sand,

      Tomas.

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2005 at 12:32 PM

    For the OnInputProcessing you have to read the value of the error1 I would suggest you set the value of error1 in a hidden form field in your layout and then use the get_form_field to read that value in the OnInputProcessing.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2005 at 01:52 PM

    could it be that you use a stateless application and you navigate between to pages? Normaly it is not a problem to set one field in the OnInitialisation and the value is also available in the onInputProccessing(as long you dont navigate to another page)

    What about an initialize statement for your error1 field?MAybe there is one you didnt realize?(only a hint)

    Message was edited by: Thorsten Blechinger

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      well it's just a,

      <% if error1 = 40. %>

      some htmlb

      <% endif. %>

      but the 40 value which was calculated and assigned in the onInitialisation event is also useful in the subsequent onInputProcessing - after the User hits the Submit button in the layout.

      I have solved it by doing the same logic calculations in the onInputProcessing event, but it would have been easier to just continue using the value of the ERROR1 parameter in the onInputProcessing event - which is how I interpreted the doco that it should work.

      Thanks,

      Tomas.

  • Posted on Feb 08, 2005 at 03:12 PM

    Hi Tomas,

    the Auto attribute should also work. Try my example above without OnInputProcessing and with the following layout:

    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    
    <htmlb:content design="design2003">
      <htmlb:page title = " ">
        <htmlb:form>
    
          <htmlb:inputField   id            = "value"
                              visible       = " "
                              value         = "<%= value %>" />
    
          <htmlb:button       id            = "submit"
                              text          = "Press Me <%= value %>"
                              onClick       = "myClickHandler" />
    
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    

    Important is now, that the id of the inputfield has the same name as the page attribute (in my case 'value').

    Sorry for that mistake.

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Rainer,

      thanks, your example works, I have that working too already, just to clarify, I have no problem passing the value from the onInitialisation to the Layout, it is getting the value from the Layout with the Submit to the onInputProcessing event which cause me the problem, so the onInputProcessing is the most important part for me.

      I try your suggestion for getting the value in the onInputProcessing event using the:

      DATA: event TYPE REF TO CL_HTMLB_EVENT.

      event ?= CL_HTMLB_MANAGER=>GET_EVENT_EX( runtime->server->request ).

      IF event->id = 'submit' AND event->event_type = 'click'.

      DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.

      data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request

      name = 'inputField'

      id = 'var1'

      ).

      IF data IS NOT INITIAL.

      value = data->value.

      ENDIF.

      ENDIF.

      will report back the results.

      Thanks,

      Tomas.

      Message was edited by: Tomas Altman

  • Posted on Feb 08, 2005 at 03:34 PM

    Tomas,

    the value is also in OnInputProcessing available. Just add the line:

    value = value + 1.

    in OnInutprocessing and you will see that the counter increses by 2. First comes the OnInitialisation, then the OnInputProcessing (if you click on the button) and finally the Layout.

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I've got some stupid error,

      DATA: event1 TYPE REF TO CL_HTMLB_EVENT.

      event1 ?= CL_HTMLB_MANAGER=>GET_EVENT_EX( runtime->server->request ).

      IF event1->id = 'submit' AND event1->event_type = 'click'.

      DATA: data1 TYPE REF TO CL_HTMLB_INPUTFIELD.

      data1 ?= CL_HTMLB_MANAGER=>GET_DATA( request =

      runtime->server->request

      name = 'inputField'

      id = 'error1'

      ).

      IF data1 IS NOT INITIAL.

      error1 = data1->error1.

      ENDIF.

      ENDIF.

      I get the error:

      Field error1 is unknown. it is neither in one of the specified tables nor defined by a data statement.

      Which is strange because I have it in the page attributes and, in the layout I have:

      <htmlb:inputField id = "error1"

      type = "string"

      required = "false"

      visible = "false"

      value = "<%= error1 %>" />

      Thank you for your input, if I can't get this to work I'll do it the long way.

      But I think, a lesson for everybody we are concluding that it is not true that by setting an attribute to Auto you make it available to all events and other pages where the same attribute name is set.

      Thanks,

      Tomas.

  • Posted on Feb 08, 2005 at 04:10 PM

    Tomas,

    the AUTO attribute wors correctly. Please read my last reply.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Rainer,

      can I just clarify for the record, you said:

      "First comes the OnInitialisation, then the OnInputProcessing (if you click on the button) and finally the Layout.",

      for me it works like this:

      Page A - onCreate

      Page A - onRequest

      Page A - onInitialisation

      Page A - Layout

      Page A - onInputProcessing - potentially with a redirect calling again this same page

      Page A - onCreate

      Page A - onRequest

      Page A - onInitialisation

      Page A - Layout

      Also, for me, as we have to go to all of this trouble with event handlers to retrieve the value of the Page Attribute, it means the Auto functionality is not working - as described in the documentation.

      From the documentation one would interpret the description to mean if you set Auto on the Page Attribute then you can access the value of that attribute throughout the BSP events and / or other BSP's - no where is it described that you have to create event handlers to get to the value of the Page Attribute.

      Mine though is still not working because of the problem described above, so for the time being I will discout this method as not being possible to pass newly assigned Page Attributes from the onInitialisation event to the onInputProcessing event via the Layout on the same page.

      Thanks,

      Tomas.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.