‎2009 Oct 21 8:55 AM
Hello,
Sorry if this is an "easy" to answer question for you guys but I'm kinda new to SAP and I can't figure out how to solve this.
I'm trying to get the PO to change with the values from my input fields, the input values in poitem are correct (checked in debugger). Problem is everytime I test it it gives me the error "Unable to interpret X as a number "
Code:
wa_poitem-po_item = lv_item_selected.
wa_poitem-ematerial = ls_input_level_1_1-pur_mat.
wa_poitem-quantity = ls_input_level_1_1-disp_quan.
wa_poitem-po_unit = ls_input_level_1_1-unit.
wa_poitem-net_price = ls_input_level_1_1-net_price.
wa_poitem-matl_group = ls_input_level_1_1-mat_grp.
wa_poitem-vend_mat = ls_input_level_1_1-vend_mat.
wa_poitem-short_text = ls_input_level_1_1-short_text.
APPEND wa_poitem TO poitem.
wa_poitemx-po_item = lv_item_selected.
wa_poitemx-ematerial = 'X'.
wa_poitemx-quantity = 'X'.
wa_poitemx-po_unit = 'X'.
wa_poitemx-net_price = 'X'.
wa_poitemx-matl_group = 'X'.
wa_poitemx-vend_mat = 'X'.
wa_poitemx-short_text = 'X'.
append wa_poitemx to poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = '3000000007'
TESTRUN = space
TABLES
POITEM = poitem
POITEMX = poitemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space.
‎2009 Oct 21 9:04 AM
Hi,
If you are sure that the poitem values are correct and if you are getting a dump, it would also indicate at which line you are getting this error. Check that and let us know.
Vikranth
‎2009 Oct 21 9:04 AM
Hi,
If you are sure that the poitem values are correct and if you are getting a dump, it would also indicate at which line you are getting this error. Check that and let us know.
Vikranth
‎2009 Oct 21 9:29 AM
2073 | wa_poitemx-po_item = lv_item_selected. |
2074 | wa_poitemx-ematerial = 'X'. |
>>>>> | wa_poitemx-quantity = 'X'. |
2076 | wa_poitemx-po_unit = 'X'. |
2077 | wa_poitemx-net_price = 'X'. |
2078 | wa_poitemx-matl_group = 'X'. |
2079 | wa_poitemx-vend_mat = 'X'. |
2080 | wa_poitemx-short_text = 'X'. |
| 2081| APPEND wa_poitemx TO poitemx.
So it's when I try to put 'X' in the quantity field from wa_poitemx...
‎2009 Oct 21 9:35 AM
I've solved the problem, it was a wrong declaration from that work area...
Still doesn't make my program work though:
Get selected item PO-number
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_item_selected LIKE ls_context-item_selected.
get element via lead selection
lo_el_context = wd_context->get_element( ).
get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `ITEM_SELECTED`
IMPORTING
value = lv_item_selected ).
DATA lo_nd_input_level_1_1 TYPE REF TO if_wd_context_node.
DATA lo_el_input_level_1_1 TYPE REF TO if_wd_context_element.
DATA ls_input_level_1_1 TYPE wd_this->element_input_level_1_1.
navigate from <CONTEXT> to <INPUT_LEVEL_1_1> via lead selection
lo_nd_input_level_1_1 = wd_context->get_child_node( name = wd_this->wdctx_input_level_1_1 ).
get element via lead selection
lo_el_input_level_1_1 = lo_nd_input_level_1_1->get_element( ).
get all declared attributes
lo_el_input_level_1_1->get_static_attributes(
IMPORTING
static_attributes = ls_input_level_1_1 ).
DATA: poitem TYPE STANDARD TABLE OF bapimepoitem,
wa_poitem TYPE bapimepoitem,
poitemx TYPE STANDARD TABLE OF bapimepoitemx,
wa_poitemx TYPE bapimepoitemx.
*DATA : t_bapireturn type bapiret2.
wa_poitem-po_item = lv_item_selected.
wa_poitem-ematerial = ls_input_level_1_1-pur_mat.
wa_poitem-quantity = ls_input_level_1_1-disp_quan.
wa_poitem-po_unit = ls_input_level_1_1-unit.
wa_poitem-net_price = ls_input_level_1_1-net_price.
wa_poitem-matl_group = ls_input_level_1_1-mat_grp.
wa_poitem-vend_mat = ls_input_level_1_1-vend_mat.
wa_poitem-short_text = ls_input_level_1_1-short_text.
APPEND wa_poitem TO poitem.
wa_poitemx-po_item = lv_item_selected.
wa_poitemx-ematerial = 'X'.
wa_poitemx-quantity = 'X'.
wa_poitemx-po_unit = 'X'.
wa_poitemx-net_price = 'X'.
wa_poitemx-matl_group = 'X'.
wa_poitemx-vend_mat = 'X'.
wa_poitemx-short_text = 'X'.
APPEND wa_poitemx TO poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = '3000000007'
TABLES
poitem = poitem
poitemx = poitemx
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space.
‎2009 Oct 21 9:36 AM
Hi
How have u defined wa_poitemx?
It has to be like BAPIMEPOITEMX, here the field QUANTITY,just like the all others fields of that structure, is a flag, so that error should be erased there.
Max
‎2009 Oct 21 9:37 AM
wa_poitemx-po_item = lv_item_selected.
wa_poitemx-po_itemx = 'X'. "----> Add this and check
wa_poitemx-ematerial = 'X'.
wa_poitemx-quantity = 'X'.
wa_poitemx-po_unit = 'X'.
wa_poitemx-net_price = 'X'.
wa_poitemx-matl_group = 'X'.
wa_poitemx-vend_mat = 'X'.
wa_poitemx-short_text = 'X'.
APPEND wa_poitemx TO poitemx.
‎2009 Oct 21 9:58 AM