on 06-25-2012 7:34 PM
I have a requirement to maintain a default value in a standard webdynpro screen. this is SRM 7.0 system, while creating shopping carts with service lines, we want the default value of the Unit to be 'EA'.
I have written this piece of code to achieve the same:
DATA: context_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
lv_text TYPE char2.
context_node = wd_context->get_child_node( name = 'GENERAL_DATA' ).
*
lr_element = context_node->get_element( ).
context_node->get_attribute( EXPORTING name = 'UNIT'
IMPORTING value = lv_text ).
IF lv_text = space.
lv_text = 'EA'.
* Set single attribute
lr_element->set_attribute(
name = `UNIT`
value = 'EA ' ).
ENDIF.
As you can see, the field in which the default value of 'EA' is needed in the UNIT field.
The code is not throwing any error - but at the same time its not showing the default value also.
Can you please advice.
Hi, have you solved this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Anuradha,
The code which you have used is correct one only. Please check in other part of code where the code may be overwritten
Regards
Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Srinivas.
As mentioned i am using this code in the POSTEXIT section of the WDINIT method. The reason I am using the POSTEXIT method is because I am trying to set the default value of 'EA' to a standard web dynpro screen.
I checked the SET ATTRIBUTE method and inside this method I am getting a SY-SUBRC <> 0. I am guessing the error could be because of that. But I dont know how to correct the issue.
Thanks.
Anuradha.
Hi Anuradha ,
Sorry i did not look at your first message propery , if you are working in SRM you cannot change the values directly in WD methods because after that change badi will get trigger and it will over write ,
so go and set the value of unit in in change badi of the Shopping cart i will automatically get refelect in WD screen .
regards
Chinnaiya Pandian .
I dont have SRM system access now .you can check the below
run t-code SPRO ,navigate to SRM server->cross aplication basic setting -> extension field control
if you are UNIT field is in header level choose configure control fields on header level
or choose the item level . there you can create a dynamic class for the UNIT field .
set break point and check the break point is stoping there . if it stops you can write you logic there .
Regards
Chinnaiya Pandian
Hi Anuradha,
The problem in your code is that you are importing lv_text and after that you are using the if condition and assigning the value to lv_text.
What you can do is that you can assign value for lv_text before calling method context_node->get_attribute. I don't think it matters if you check if lv_text = space or not.
The corrected code:
DATA: context_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
lv_text TYPE char2.
context_node = wd_context->get_child_node( name = 'GENERAL_DATA' ).
lv_text = 'EA'.
lr_element = context_node->get_element( ).
context_node->get_attribute( EXPORTING name = 'UNIT'
IMPORTING value = lv_text ).
* Set single attribute
lr_element->set_attribute(
name = `UNIT`
value = 'EA ' ).
Thanks and Regards,
Yaseen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Yaseen.
Thanks for the response. I made the exact changes as you suggested and it stil doesnt show any results in therre.
the code now reads as follows:
DATA: context_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
lv_text TYPE char2.
context_node = wd_context->get_child_node( name = 'GENERAL_DATA' ).
lv_text = 'EA'.
*
lr_element = context_node->get_element( ).
context_node->get_attribute( EXPORTING name = 'UNIT'
IMPORTING value = lv_text ).
* Set single attribute
lr_element->set_attribute(
name = `UNIT`
value = 'EA ' ).
pleae note that I am using POSTEXIT of the WDINIT method to make these changes.
Can you please advice what I am missing here?
Thanks.
Anuradha.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
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.