Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while changing Sales order using 'BAPI_SALESORDER_CHANGE'

0 Kudos
596

Hi all,

Below is my code to update delivery block value:

***********************************************************************

----


FORM call_bapi_salesorder_change .

                                                                                                                                            • *********************************************************************

DATA: iv_bapi_view LIKE order_view.

DATA: gt_sales_doc TYPE STANDARD TABLE OF sales_key, " Document Numbers to Be Selected

gt_items TYPE STANDARD TABLE OF bapisdit. " Order Item Data for Document Numbers

*************************************************************8

DATA:order_headers_out LIKE bapisdhd OCCURS 0 WITH HEADER LINE.

DATA:order_header_inx LIKE bapisdh1x.

DATA: lv_salesdocument LIKE bapivbeln-vbeln.

data: lv_matnr(10) type c.

DATA:

gt_schdule TYPE STANDARD TABLE OF bapischdl, " for gl date & load date

gt_schdulex TYPE STANDARD TABLE OF bapischdlx, " for partner role and partner function.

gt_return TYPE STANDARD TABLE OF bapiret2,

gt_itemin TYPE STANDARD TABLE OF bapisditm,

gt_iteminx TYPE STANDARD TABLE OF bapisditmx ,

gt_bapisdh1 TYPE STANDARD TABLE OF bapisdh1.

DATA:gs_head_bapi TYPE bapisdh1x,

gs_schdule TYPE bapischdl,

gs_schdulex TYPE bapischdlx,

gs_return TYPE bapiret2,

gs_itemin TYPE bapisditm,

gs_iteminx TYPE bapisditmx,

gs_bapisdh1 TYPE bapisdh1.

CLEAR : gt_schdule,gt_schdulex,gs_return.

REFRESH gt_return.

gs_head_bapi-updateflag = 'U'.

  • SORT gt_final BY vbeln.

  • CLEAR gs_vbep.

  • REFRESH gt_vbep[].

CLEAR gs_final.

LOOP AT gt_final1 INTO gs_final.

gs_itemin-itm_number = gs_final-posnr.

*move gs_final-matnr to lv_matnr."qx94162

  • gs_itemin-material = gs_final-matnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = gs_final-matnr

IMPORTING

output = gs_final-matnr.

*

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • input = lv_matnr

  • IMPORTING

  • output = lv_matnr.

*

  • gs_itemin-material = lv_matnr.

gs_itemin-material = gs_final-matnr.

gs_iteminx-itm_number = gs_final-posnr.

gs_iteminx-updateflag = 'U'.""changed to I

gs_iteminx-material = 'X'.

" gs_schdule-req_dlv_bl = gs_final-lifsp. " Delivery block

gs_schdule-itm_number = gs_final-posnr.

gs_schdulex-itm_number = gs_final-posnr.

gs_schdule-sched_line = '0001'.

gs_schdulex-sched_line = '0001'.

  • MOVE gs_final-lifsp to gs_schdule-req_dlv_bl.

gs_schdule-req_dlv_bl = gs_final-lifsp.

gs_schdulex-req_dlv_bl = 'X'. " Delivery block

gs_schdulex-updateflag = 'U'.

gs_bapisdh1-sales_org = gs_final-vkorg.

APPEND gs_schdule TO gt_schdule.

APPEND gs_schdulex TO gt_schdulex.

APPEND gs_itemin TO gt_itemin.

APPEND gs_iteminx TO gt_iteminx.

  • Append gs_BAPISDH1 to gt_BAPISDH1.

lv_salesdocument = gs_final-vbeln.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = lv_salesdocument

  • ORDER_HEADER_IN = gs_BAPISDH1

order_header_inx = gs_head_bapi

  • SIMULATION =

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

  • NO_STATUS_BUF_INIT = ' '

TABLES

return = gt_return

order_item_in = gt_itemin

order_item_inx = gt_iteminx

  • PARTNERS =

  • PARTNERCHANGES =

  • PARTNERADDRESSES =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

schedule_lines = gt_schdule

schedule_linesx = gt_schdulex

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

  • NFMETALLITMS =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

REFRESH: gt_schdule, gt_schdulex, gt_itemin , gt_iteminx.

LOOP AT gt_return INTO gs_return.

WRITE / gs_return-message .

ENDLOOP .

ENDLOOP.

ENDFORM. " CALL_BAPI_SALESORDER_CHANGE

***************************************************************************************************

When I am using material value as 18342 using CONVERSION_EXIT_ALPHA_OUTPUT:

ORDER_HEADER_IN has been processed successfully

Material is not defined for sales org.A101, distr.chan.00, language DE

Error in ITEM_IN 000030

SCHEDULE_IN has been processed successfully

The sales document is not yet complete: Edit data

Sales document 5010000715 was not changed

******************************************************************************************************

and when I am using CONVERSION_EXIT_ALPHA_INPUT (000000000000018342)or while debuging when I am changing value to 0018342 :

I am getting below dump:

Runtime Errors DATA_LENGTH_0

Exception CX_SY_RANGE_OUT_OF_BOUNDS

Date and Time 21.10.2010 07:22:17

Information on where terminated

Termination occurred in the ABAP program "SAPLVBAK" - in

"MAP_VBAP_TO_BAPISDIT".

The main program was "RS_TESTFRAME_CALL ".

In the source code you have the termination point in line 168

of the (Include) program "LVBAK001".

The termination is caused because exception "CX_SY_RANGE_OUT_OF_BOUNDS"

occurred in

procedure "MAP_VBAP_TO_BAPISDIT" "(FORM)", but it was neither handled local

nor declared

in the RAISING clause of its signature.

The procedure is in program "SAPLVBAK "; its source code begins in line

99 of the (Include program "LVBAK001 ".

************************************************************************************************************

The same dump I am getting while executing this above BAPI from SE37 tcode with the same test data.

but I am able to change it though Va02 tcode.

Edited by: Arora26 on Oct 21, 2010 7:58 AM

1 REPLY 1

mvoros
Active Contributor
0 Kudos
150

Hi,

have you searched for OSS notes? The note 1137897 looks like related to your problem. It mentions different BAPI but I assume that both BAPI reuse same routines and therefore it might solve your problem as well.

Cheers