我在使用 FM 时遇到问题BAPI_SALESORDER_CHANGE
。
一旦我执行我的报告,FM 就会抛出异常。以下是异常的转储。
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
not caught and
therefore caused a runtime error.
The reason for the exception is:
The call to the function module "BAPI_SALESORDER_CHANGE" is incorrect:
In the function module interface, you can specify only
fields of a specific type and length under "ORDER_HEADER_IN".
Although the currently specified field
"LS_ORDER_HEADER_IN" is the correct type, its length is incorrect.
现在,我知道LS_ORDER_HEADER_IN
' 的长度不正确。但我不明白为什么它是不正确的。
以下是我的报告代码:
REPORT ztesting.
DATA:
lv_sales_document TYPE bapivbeln-vbeln,
ls_order_header_in TYPE bapisdhd1,
lt_order_header_in TYPE TABLE OF bapisdhd1,
ls_order_header_inx TYPE bapisdhd1x,
lt_order_header_inx TYPE TABLE OF bapisdh1x,
lt_return TYPE TABLE OF bapiret2,
ls_order_item_in TYPE bapisditm,
lt_order_item_in TYPE bapisditm OCCURS 0 WITH HEADER LINE,
ls_order_item_inx TYPE bapisditmx,
lt_order_item_inx TYPE bapisditmx OCCURS 0 WITH HEADER LINE,
ls_schedule_lines TYPE bapischdl,
lt_schedule_lines TYPE STANDARD TABLE OF bapischdl WITH HEADER LINE,
ls_schedule_linesx TYPE bapischdlx,
lt_schedule_linesx TYPE STANDARD TABLE OF bapischdlx WITH HEADER LINE,
ls_return TYPE bapiret2.
lv_sales_document = '5999999'.
ls_order_header_inx-updateflag = 'U'.
ls_order_item_in-itm_number = '10'.
ls_order_item_inx-itm_number = 'X'.
ls_order_item_in-material = '16'.
ls_order_item_inx-material = 'X'.
ls_order_item_inx-updateflag = 'U'.
ls_schedule_lines-itm_number = '10'.
ls_schedule_linesx-itm_number = 'X'.
ls_schedule_lines-req_qty = '1000'.
ls_schedule_linesx-req_qty = 'X'.
ls_schedule_linesx-req_qty = 'X'.
APPEND:
ls_order_header_inx TO lt_order_header_inx,
ls_order_header_in TO lt_order_header_in,
ls_order_item_in TO lt_order_item_in,
ls_order_item_inx TO lt_order_item_inx,
ls_schedule_lines TO lt_schedule_lines,
ls_schedule_linesx TO lt_schedule_linesx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_sales_document
order_header_in = ls_order_header_in
order_header_inx = ls_order_header_inx
TABLES
return = lt_return
order_item_in = lt_order_item_in
order_item_inx = lt_order_item_inx
schedule_lines = lt_schedule_lines
schedule_linesx = lt_schedule_linesx.
DATA: lt_return2 TYPE TABLE OF bapiret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
LOOP AT lt_return INTO ls_return.
WRITE: / sy-subrc, ls_return-type, ls_return-number, ls_return-id, ls_return-message.
ENDLOOP.
另外,你能发现我犯的任何其他错误吗?这是我第一次使用这个功能。注意:我从 SAP 论坛复制了代码。我只是修改了值和变量名。
提前致谢。
问候,迭戈。