cancel
Showing results for 
Search instead for 
Did you mean: 

How to display data in inputfields whenuser entersdata inanother inputfield

Former Member
0 Kudos

Hi all,

i have a requirement that i have three fileds named

1)costcentre , 2)description 3)function.

when user enters value on cost centre description and function should be displayed.?

can u tell me how to acheive this functionality.? and kindly for reference can u send me the logic in step by step.?

can u tell me should i use inputfield ui elements for these . and beside inputfields i should provide a searchhelp icon. ?

kindly send me the how to achieve this functionality.

Thanks & Regards,

Naveen

Accepted Solutions (1)

Accepted Solutions (1)

sahai
Contributor
0 Kudos

HI NAVEEN,

FOR THIS REQUIREMENT YOU MUST BE BINDING THE INPUT FIELDS WITH THREE DIFFERENT ATTRIBUTES....RITE?

now you will have to read the first input attribute using the code wizard this will give you the value which is entered on screen...now according to the entered value you again set the other two attribute by the code wizard to generate the code.

regards,

sahai.s

Former Member
0 Kudos

Hi Sahai Can u send me the sample code actually i am doing in bw system that is for

cost centre the table name is /BIC/AGLDCPRTS00

fieldname is COSTCENTER

dataelement is /BI0/OCOSTCENTER

domain is /BI0/OCOSTCENTER and for these i have created a node name ccinputfield and i add this field as dictionary structure.

and for function the the table name is /BIC/AGLDCDRTS00

fieldname is /BIC/CSERVAREA

the dataelement for function is /BI0/OICHRT_ACCTS

and the domain assigned for this field is /BI0/OCHRT_ACCTS and for this i created a node name funcinputfieldnode and i add this field as a dictionary structure.

and for description i dont know the fieldname for that purpose i have created one attribute with name

function and type i have aassigned for this attribute is CHAR0010.

but for the above sample code u have send to me with the 3attributes created separately. while creating a attribute can we assign the dictionarystructure of the table field name properties.

can u send me the samplecode according to the above requirement.

Thanks & Regards,

Naveen

sahai
Contributor
0 Kudos

hi naveen,

my first suggestion is that please check se11 and check whether /BIC/AGLDCPRTS00

is a transp. table ......i guess it is not so. rite?

now,

you make a node first in the context....add attribute to this node now add attribute to it ....

once you start adding the attribute a pop up screen comes...here you are making a mistake by choosing type ref to...instead use type....in the type assignment field and in type define the data type.......

also look here you will find field for search help...in input help mode choose dictionary help and enter the name of search help you want to provide....

now regarding the code

write this code onEnter method of thefirst input field....._also note that my node name is node....ERNAM LAEDA AENAM are my attributes in the node_ you will read the first attribute by code wwizard ...

DATA LO_ND_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

    DATA LO_EL_NODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.
    DATA LS_NODE TYPE WD_THIS->ELEMENT_NODE.
    DATA LV_ERNAM TYPE WD_THIS->ELEMENT_NODE-ERNAM.

*   navigate from <CONTEXT> to <NODE> via lead selection
    LO_ND_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_NODE ).

*   get element via lead selection
    LO_EL_NODE = LO_ND_NODE->GET_ELEMENT( ).
*   @TODO handle not set lead selection
    IF LO_EL_NODE IS INITIAL.
    ENDIF.

*   get single attribute
    LO_EL_NODE->GET_ATTRIBUTE(
      EXPORTING
        NAME =  `ERNAM`
      IMPORTING
        VALUE = LV_ERNAM ).

now you will get the value entered in first input field and

DATA LS_NODE TYPE WD_THIS->ELEMENT_NODE.
      DATA LV_LAEDA TYPE WD_THIS->ELEMENT_NODE-LAEDA.

*     navigate from <CONTEXT> to <NODE> via lead selection
      LO_ND_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_NODE ).

*     @TODO handle non existant child
*     IF lo_nd_node IS INITIAL.
*     ENDIF.

*     get element via lead selection
      LO_EL_NODE = LO_ND_NODE->GET_ELEMENT( ).

*     @TODO handle not set lead selection
      IF LO_EL_NODE IS INITIAL.
      ENDIF.

*     @TODO fill attribute
*     lv_laeda = 1. "  "you will set the value for second field here......either hardcode it or use logic


*     set single attribute
      LO_EL_NODE->SET_ATTRIBUTE(
        NAME =  `LAEDA`
        VALUE = LV_LAEDA ).
      
        DATA LS_NODE TYPE WD_THIS->ELEMENT_NODE.
        DATA LV_AENAM TYPE WD_THIS->ELEMENT_NODE-AENAM.

*       navigate from <CONTEXT> to <NODE> via lead selection
        LO_ND_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_NODE ).

*       @TODO handle non existant child
*       IF lo_nd_node IS INITIAL.
*       ENDIF.

*       get element via lead selection
        LO_EL_NODE = LO_ND_NODE->GET_ELEMENT( ).

*       @TODO handle not set lead selection
        IF LO_EL_NODE IS INITIAL.
        ENDIF.

*       @TODO fill attribute
       lv_aenam = 1. "you will set the value for third field here......either hardcode ity or use logic

*       set single attribute
        LO_EL_NODE->SET_ATTRIBUTE(
          NAME =  `AENAM`
          VALUE = LV_AENAM ).

thanks and regards,

sahai.s

Answers (3)

Answers (3)

Former Member
0 Kudos

hi gurus,

I am new to webdynpro.I have the same requirement.The code is working fine,but the value entered in the input field is refreshed i.e., it is again set to the initial default value.

Could anybody help me plz...

Thanks & regards

Vamshi kishore

Former Member
0 Kudos

Hi naveen ,

1. You can achieve the required by following process:-

Take three input field in layout.

Every input field have some action ON_ENTER ( i.e. after entering the value in input field and after pressing enter).

Here you have to put your logic.

Get the value of the coast center. ( code wizard read attribute )

accoerding to the value you select the value for description and function. ( get some value from table or writ eyour own value based on the values of coast center )

Set the values in the respective attribute description and function. ( code wizard set attribute )

2. Wheather you want use input field or search help is based on ur requiment.

remember in case of later you you have to select among some already present value.

In case of search help you can do the same as previous.

But remember that in case of search help if you want scenario like after selecting the other field should get populated ( not after pressing enter) then you have to do the required coding in WDDOMODIFYVIEW.

Reply in case of any issue.

Regards,

Monishankar C

Former Member
0 Kudos

Hi naveen ,

Hey i have that much idea about your BW tables .

But i can suggest you like You can add three attribute in a single node . Just get the attribute name and its type as the data element.

if you are adding from dictionary structurethen after adding you can remove the dictionary structure.

For the set and get ( write and read ) you dont have to code .

Just in code wizard select the appropriate node and the select appropriate attribute . You will get the required coding automaticallly.

regards,

Monishankar C

Former Member
0 Kudos

Hi Monishankar can u send me any sample code so that it will be helpful for me

actually when i am creating a attribute in type assignment i have used type ref to

and then under the type i have assigned the data element for example for field function the dataelemnt is /BIC/OICSERVAREA

but when i am trying to bind this attribute to input field it is giving message that

property value is not compatiable with context element Cost centre.

But kindly send me any sample code i am new to this webdynpro.

Thanks & Regards,

Naveen

gill367
Active Contributor
0 Kudos

Dont use type ref to use typoe only and in the data type give /BI0/OICHRT_ACCTS

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Naveen,

In Costcentre input field, contains ON ENTER Event, in that you have to write code for displaying description and function.

For example you have 3 attributes in context input1,2,3. Try with this example code.Write this code ONENTER event of input1.

Make changes according to your requirement, it may solve yours.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->Element_context.

DATA lv_input1 TYPE wd_this->Element_context-input1.

DATA lv_input2 TYPE wd_this->Element_context-input2.

DATA lv_input3 TYPE wd_this->Element_context-input3.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `INPUT1`

IMPORTING

value = lv_input1 ).

lv_input2 = 'ABC'.

lv_input3 = 'CCC'.

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `INPUT2`

value = lv_input2 ).

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `INPUT3`

value = lv_input3 ).

Thanks,

Kris.

Edited by: kissnas on Feb 8, 2011 7:59 AM

Edited by: kissnas on Feb 8, 2011 8:00 AM

Former Member
0 Kudos

Hi Kris,

Can u send me the sample code actually i am doing in bw system that is for

cost centre the table name is /BIC/AGLDCPRTS00

fieldname is COSTCENTER

dataelement is /BI0/OCOSTCENTER

domain is /BI0/OCOSTCENTER and for these i have created a node name ccinputfield and i add this field as dictionary structure.

and for function the the table name is /BIC/AGLDCDRTS00

fieldname is /BIC/CSERVAREA

the dataelement for function is /BI0/OICHRT_ACCTS

and the domain assigned for this field is /BI0/OCHRT_ACCTS and for this i created a node name funcinputfieldnode and i add this field as a dictionary structure.

and for description i dont know the fieldname for that purpose i have created one attribute with name

function and type i have aassigned for this attribute is CHAR0010.

but for the above sample code u have send to me with the 3attributes created separately. while creating a attribute can we assign the dictionarystructure of the table field name properties.

can u send me the samplecode according to the above requirement.

Thanks & Regards,

Naveen

Former Member
0 Kudos

Hi Kris,

i have tried your code it is working but

in the input field i click on enter on remaining fields it is displaying ABC CCC In another inputfields.

but my requirement is if suppose on 1st inputfield if user enters 1 then abc ccc should be displayed in another input fields.

if suppose on 1st inputfield if user enters 2 then def ggg should be displayed in another input fields.

like this based upon on the value enters dynamically by user that value should be displayed. can u send me the code according to this requirement.

Thanks & Regards,

Naveen

Former Member
0 Kudos

Hi Naveen,

While creating attribute you have to give type right, actually i created above attributes of type char10, you use your data element there. For Example you created node NODE with three attributes input1,input2,input3.

ONENTER of input1- use wizard for reading that node attribute.

For second and thrid input field, you want data from data base, means write select statement accordigly. For example you get values through select in input2 and input3.

See.. in above my code:

lv_input2 = 'ABC'.

lv_input3 = 'CCC'. here i am giving hard coded values, you have to use select statement accoding to your requirement.

And Now use set_attrubite method to display this values in output.

Thanks,

Kris.

Edited by: kissnas on Feb 8, 2011 8:38 AM

Edited by: kissnas on Feb 8, 2011 8:40 AM

Former Member
0 Kudos

Hi,

In the ONEnter field, you have written the code right...In this event itself, 1st get the value in the

input field, Based on the value Either write the CASE statement or IF ENDIF..and update teh other input fields/elements uusing SET_ATTRIBUTES or SET_STATIC_ATTRUBUTES of the if_wd_context_element...

Regards,

Lekha.