on 02-04-2011 7:02 AM
Hi Everyone,
I have one input enabled table that having to field MATNR and MAKTX. when user enter MATNR (material no) its description (MAKTX) should get populated in next field of that table. how do i proceed for this.
hi jhon,
you will have to code the folloing lines of code in the onEnter method ...just check in the property of the input field in layout and double click will lead you to the method just write the following there...
first youwill get the first input field for that you will write. i have considered my node ame as matnr and attribute also matnr
DATA LO_ND_CTX_VN_matnr TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_CTX_VN_matnr TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_CTX_VN_matnr TYPE WD_THIS->ELEMENT_CTX_VN_matnr.
DATA LV_matnr TYPE WD_THIS->ELEMENT_CTX_VN_matnr-matnr.
* navigate from <CONTEXT> to <CTX_VN_matnr> via lead selection
LO_ND_CTX_VN_matnr = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_CTX_VN_matnr ).
* @TODO handle non existant child
* IF lo_nd_ctx_vn_matnr IS INITIAL.
* ENDIF.
* get element via lead selection
LO_EL_CTX_VN_matnr = LO_ND_CTX_VN_matnr->GET_ELEMENT( ).
* alternative access via index
* lo_el_ctx_vn_matnr = lo_nd_ctx_vn_matnr->get_element( index = 1 ).
* @TODO handle not set lead selection
IF LO_EL_CTX_VN_matnr IS INITIAL.
ENDIF.
* get single attribute
LO_EL_CTX_VN_matnr->GET_ATTRIBUTE(
EXPORTING
NAME = `matnr`
IMPORTING
VALUE = LV_matnr ).
you can debug to check lv_matnr it will always reflect the value you have entered.
now since you got the value with you you have just to provide that value..to the next inoput field
DATA LO_ND_CTX_VN_MAKTX TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_CTX_VN_MAKTX TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_CTX_VN_MAKTX TYPE WD_THIS->ELEMENT_CTX_VN_MAKTX.
DATA LV_MAKTX TYPE WD_THIS->ELEMENT_CTX_VN_MAKTX-MAKTX.
* navigate from <CONTEXT> to <CTX_VN_MAKTX> via lead selection
LO_ND_CTX_VN_MAKTX = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_CTX_VN_MAKTX ).
* @TODO handle non existant child
* IF lo_nd_ctx_vn_MAKTX IS INITIAL.
* ENDIF.
* get element via lead selection
LO_EL_CTX_VN_MAKTX = LO_ND_CTX_VN_MAKTX->GET_ELEMENT( ).
* alternative access via index
* lo_el_ctx_vn_MAKTX = lo_nd_ctx_vn_MAKTX->get_element( index = 1 ).
* @TODO handle not set lead selection
IF LO_EL_CTX_VN_MAKTX IS INITIAL.
ENDIF.
* @TODO fill attribute
lv_MAKTX = lv_matnr.
* set single attribute
LO_EL_CTX_VN_MAKTX->SET_ATTRIBUTE(
NAME = `MAKTX`
VALUE = LV_MAKTX ).
thanks and regards,
sahai.s
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello sahai,
sorry but i think here you are setting attribute of a diferent node on hitting the enter
you are getting the attribute matnr form node matnr and setting the attribute MAKTX of the node MAKTX.
and as we know two attributes form two different nodes cannot be shown in one table.
So, i guess this approach wont work in teh current scenario.
what he needs to do is very simple,
@john
Just get the currently selected element
data lv_el type ref to if_wd_context_element.
lv_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
and
then set the value of attribute maktx of the same element after fetching the description form the backend.
like as below.
data zmatnr type matnr.
data zmaktx type maktx.
lv_el->get_attribute(
exporting
name = 'MATNR'
IMPORTING
value = zmatnr
).
select MAKTX from makt into zmaktx where matnr = zmatnr and spras = 'E' .
endselect.
lv_el->set_attribute(
name = 'MAKTX'
value = zmaktx
).
this will do the desired thing.
Thanks
Sarbjeet Singh
ohh,
my mistake i thought john was talking about the input fields .....thanks sarb for reminding me.
anyways
while talking about the table to have column being populated in accordance with the value of one column
create an event handler first and then in the code .
read the context node .
and then set the attribute according to the value you read
all code has already been provided by sarb .
regards,
sahai.s
Hello,
Do the following to achive your requirement.
As you are saying input is in table then surely u might be using either OVS or search help for this f4 . In the case of OVS there u need to use the method Set_static_attributes or as u set the value for single attribute 'MATNR' simlarly get the MAKTX as well ans as u set of MATNR similarly set the attribute for MAKTX as well this will solve ur problem. If you are using search help then i am not sure that u can achive this functionality.
Regards,
Sana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Its very simple. You have to write your code in On ENTER event of the input fi3eld "MATNR". Here you have to get the MATNR from user and have to get the corresponding text for the material number from the TABLE and set that text into MATXT field.
to get the value you have to use get_attribute method of context node and for setting set_attribute.
Thanks
Pradeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.