Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting data from dynamic inputfields using class cl_input_element

Former Member
0 Likes
3,290

Hi.

I have made a screen with dynamic inputfields using the class cl_input_elements. The fields are created using data from an internal table, but now im having problems getting the data from the inputfields, can anybody help me please. Im very new to ABAP i only got my certification a month ago, so please have patioens with me.

Here is the code where i generate the inputfields:


LOOP AT it_zkeydef INTO wa_zkeydef.
    index = temp_index.
    length = wa_zkeydef-pto - wa_zkeydef-pfrom + 1.
    CONCATENATE fieldname index INTO field.
    fieldname2 = field.
    labeltext = wa_zkeydef-fname.
    CALL METHOD form_area->add_text
      EXPORTING
        text         = labeltext
        sap_fontsize = cl_dd_area=>large.

    CALL METHOD form_area->add_input_element
      EXPORTING
        name          = fieldname2
        size          = length
        maxlength     = length
      IMPORTING
        input_element = input_element.

    CALL METHOD form_area->new_line.

    temp_index = temp_index + 1.
  ENDLOOP.
  CALL METHOD document->merge_document.

  CALL METHOD document->display_document
    EXPORTING
      container = 'CONTAINER200'.

I sure hope somebody can help me, i have been fighting with this problem for a wile now.

Liselotte

22 REPLIES 22
Read only

Former Member
0 Likes
2,968

Sorry the class is of course called cl_dd_input_element.

-Liselotte-

Read only

Former Member
0 Likes
2,968

After reading your message, I feel that I am new to ABAP.

Look for similar programs in Development class(or Package) <b>SDYNAMICDOCUMENTS</b>.

Also refer http://help.sap.com/saphelp_470/helpdata/en/f0/edd938d8dbe93de10000000a11405a/frameset.htm

Regards,

Subramanian V.

Read only

andreas_mann3
Active Contributor
0 Likes
2,968

..

.After reading your message, I feel that I am new to ABAP.

...

-> I agree with Subramanian

Im very new to ABAP i only got my certification a month ago, so please have patioens with me.

...

-> Liselotte, this is <b>understatement pure</b> - whatever - welcome to SDN-Abap-Forum !

Andreas

Read only

0 Likes
2,968

Im sorry if you think that about me, but it <b>is</b> true that i have only been working with ABAP for 4 weeks and this is my first project. I dont like beeing called a liar.

-Liselotte-

Message was edited by: Liselotte Hjelmbjerg

Read only

0 Likes
2,968

Hi Liselotte,

Please don't take it the wrong way. It is a way of saying that, even though you have just 4 weeks of experience in ABAP, you are quite/very good at it and to be already working in such advanced topics. We don't dare to call anyone liar.

Please let us know, if your problem got solved , or if you found some way to solve it, do share it with us.

Regards,

Subramanian V.

Read only

0 Likes
2,968

Thanks for your reply, im sorry i went off like that but i have been fighting with this problem for 3 days and im absolutly lost, i think im in over my head :). I found out how to get the data from a field, the problem is that all fields have the same object reference so when i get the data it is only the data from the last inputfield.

-Liselotte-

Read only

0 Likes
2,968

....more focusing on your problem - I think you have to define an event handler to check the input of the fields.

Program DD_ADD_FORM_INPUT illustrates how.

Christian

Read only

Former Member
0 Likes
2,968

After having a glance at your code, I find that, using index, fieldname, field2 and concatenate, you are trying to create a new fieldname. I suspect that, this fieldname is not created properly.

instead of using the logic for creating newfields, I suggest, you do something similar to this :

<b>
data: lv_c_tabix(2) type c.

loop at it_skeydef into wa_skeydef.

lv_c_tabix = sy-tabix.

concatenate fieldname lv_c_tabix into field.

* Your logic here
endloop.</b>

You have also suggested that , this problem is due to all fieldnames being created with the same name, despite, your logic. Suggest you to dig deep and debug this.

Regards,

Subramanian V.

Read only

Former Member
0 Likes
2,968

Hallo All,

unfortunely no one has had an answer for liselotte and now also for me.

The question is:

How to get data from the input_element at any time, that means if the user just put something in the field and press NOT <enter>, F1 or F4 which are covered by the events of the input_element

Please help !

Uwe

Read only

0 Likes
2,968

Uwe,

nobody can help with that.

For reaons I do not fully or partially understand, events for controls cover only a couple of keystrokes like ENTER, ESCAPE and function keys as well as mouse (double) clicks.

With todays ABAP there is no way of reacting on any key stroke.

small addition: I just checked the class and I saw what I guessed: Just a few events

<pre>

BUTTON_CLICKED

ITEM_SELECTED

INPUT_ENTERED

INPUT_HELPF1

INPUT_HELPF4

ENTERED

HELP_F1

HELP_F4

</pre>

You have to create a method get_input as a handler for event ENTERED (or INPUT_ENTERED?). This method should just return the value of attribute VALUE. Use SET HANDLER to activate the method.

Regards,

Clemens

Message was edited by: Clemens Li

Read only

Former Member
0 Likes
2,968

Check

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/de/0b/11e1cb04b311d4a7400000e83dd863/frameset.htm">http://help.sap.com/saphelp_nw2004s/helpdata/de/0b/11e1cb04b311d4a7400000e83dd863/frameset.htm</a>

If you want to react on events create a (local) eventhandler for the events. Import the special parameter 'sender' in order ot get the input field, which threw the event.

In the event handler method you get via sender->value the value of the input field.

Best regards,

Thomas

Read only

Former Member
0 Likes
2,968

Hallo Thomas,

that's not the question.

I just know how to react on events.

I want to read out the input field at any time, but as Clemens mentioned there is no way to do that.

Is the probably a way to simalate the pressing of <enter> in the input_field to fire the event ????

Uwe

Read only

Former Member
0 Likes
2,968

Hi,

it can not be possible. All the dynamic GUI elements are components of the frontend and are thus running on your local PC and not on the application server. What you therefore need is a sort of synchronisation event as the flushes for the GUI Control Framework. Thus the only way to get the screen data is to fire an event.

By the way, you have the same problem with the modifiable ALV.

Best regards,

Thomas

Read only

0 Likes
2,968

But which event to fire ?

with the modifiable ALV you have only to "event" something e.g. leave the modified field, so you get notice of the modification in the events data_changed and data_cahnged_finished

BR

Uwe

Read only

0 Likes
2,968

Just maybe worth a try:

CALL METHOD cl_gui_cfw=>flush.

after entering something in the field before an event is raised.

FLUSH method is designed to clean up the automation queue to synchronize SAP server with client-run control.

Possibly you get the actual field content by reading the inputfield attribute after flushing.

Sorry, I won't try now; other tasks waiting.

Let me know what's happening.

Regards,

Clemens

Read only

Former Member
0 Likes
2,968

Hi Clemens,

the dynamic documents are not part of the GUI framework. Therefore I think, flushing will have no effect. But I am not sure.

Best regards,

Thomas

Read only

0 Likes
2,968

since its a HTML form you have two options,

1. use javascript along with CL_JAVA_SCRIPT class to read the form field value and pass it to ABAP varialbe.

2. you have to submit the form using js/or button (user interaction) and read and pass the value back to abap vairalbe. only after submit the < cl_dd_input_element>->value will hold the value entered by the user.

Regards

Raja

Read only

0 Likes
2,968

just to inform you:

as Thomas mentioned: FLUSH doesn't work !

I checked that 3 days ago, just before wasting your time with this problem

Uwe

Read only

0 Likes
2,968

Hello Duraiaj,

i'm not common with Cl_JAVA_SCRIPT. Do you have an code example for "read the form field value and pass it to ABAP varialbe"

Thx

Uwe

Read only

0 Likes
2,968

check demo programs starting with DEMO_JAVA_SCRIPT*

in particularly DEMO_JAVA_SCRIPT_EXECUTE

(this is not for getting form field value but for buliding js and running it from ABAP environment)

if you have trouble following that let me know.

Regards

Raja

Read only

0 Likes
2,968

Hallo Durairaj,

seems to be on the right way now.

I unterstand that I must "connect" the value of the input field to an ABAP variable via BIND as in e.g. DEMO_JAVA_SCRIPT_BIND_METH_VAL

But there is one (or more ) essential question:

How to reference the input_field ????

Thies is the code i wrote to create to the inpu_fields g_input1 and g_input2:

CREATE OBJECT g_dyn_doc

EXPORTING

background_color = g_dyn_doc->col_background_level2.

CALL METHOD g_dyn_doc->add_table

EXPORTING

no_of_columns = 2

border = '1'

IMPORTING

table = g_table.

  • set columns

CALL METHOD g_table->add_column

IMPORTING

column = g_col1.

CALL METHOD g_table->add_column

IMPORTING

column = g_col2.

text = 'Weiterbildung'.

CALL METHOD g_col1->add_text

EXPORTING

text = text

sap_emphasis = 'strong'.

text = 'geplante Tage'.

CALL METHOD g_col2->add_text

EXPORTING

text = text.

CALL METHOD g_table->new_row.

text = 'fachlich'.

CALL METHOD g_col1->add_text

EXPORTING

text = text.

value = '0'.

      • ADD_INPUT_ELEMENT -> ***

CALL METHOD g_col2->add_form

IMPORTING

formarea = g_form1.

CALL METHOD g_form1->add_input_element

EXPORTING

name = 'FACHLICH'

size = 2

maxlength = 2

IMPORTING

input_element = g_input1.

      • <- ADD_INPUT_ELEMENT ***

CALL METHOD g_table->new_row.

text = 'außerfachlich'.

CALL METHOD g_col1->add_text

EXPORTING

text = text.

      • ADD_INPUT_ELEMENT -> ***

CALL METHOD g_col2->add_form

IMPORTING

formarea = g_form2.

CALL METHOD g_form2->add_input_element

EXPORTING

name = 'AUSSERFACHLICH'

size = 2

maxlength = 2

IMPORTING

input_element = g_input2.

Regards

Uwe

Read only

Former Member
0 Likes
2,968

Hi

Did you have a look at the SAP standard example <b>DD_ADD_TABLE</b> in se38.This might solve your purpose