Application Development and Automation 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: 
Read only

Issue with BAPI parameters

Former Member
0 Likes
359

Hi,

I am trying to use BAPI_SALESORDER_CHANGE to modify the contents of the sales order item quantity. but the below code was not working, can any one correct the below program.

I have seen the same type of post few months back but no one provided the solution till now. I hope experts can correct my program. Surely i will reward.

regards

jaya

-


REPORT y_bapi1 .

TABLES: vbap.

DATA:

bapichdr LIKE bapisdh1,

bapichdrx LIKE bapisdh1x,

bapirtn LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

bapiitm LIKE bapisditm OCCURS 0 WITH HEADER LINE,

bapiitmx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.

DATA: s_vbap LIKE vbap.

PARAMETERS: p_vbeln LIKE vbap-vbeln DEFAULT '40486',

p_posnr LIKE vbap-posnr DEFAULT '20'.

  • start-of-selection.

START-OF-SELECTION.

PERFORM get_data_4m_vbap.

PERFORM fill_header_in.

PERFORM fill_header_inx.

PERFORM fill_item_in.

PERFORM fill_item_inx.

PERFORM call_bapi_so_change.

PERFORM call_bapi_commit.

&----


*& Form get_data_4m_vbap

&----


  • text

----


FORM get_data_4m_vbap.

SELECT SINGLE * FROM

vbap

INTO s_vbap

WHERE vbeln = p_vbeln

AND posnr = p_posnr.

ENDFORM. " get_data_4m_vbap

&----


*& Form fill_header_in

&----


  • text

----


FORM fill_header_in.

*bapichdr

ENDFORM. " fill_header_in

&----


*& Form fill_header_inx

&----


  • text

----


FORM fill_header_inx.

bapichdrx-updateflag = 'U'.

ENDFORM. " fill_header_inx

&----


*& Form fill_item_in

&----


  • text

----


FORM fill_item_in.

bapiitm-itm_number = p_posnr.

bapiitm-target_qty = s_vbap-kwmeng + 5.

APPEND bapiitm.

CLEAR bapiitm.

ENDFORM. " fill_item_in

&----


*& Form fill_item_inx

&----


  • text

----


FORM fill_item_inx.

bapiitmx-itm_number = p_posnr.

bapiitmx-updateflag = 'U'. " I for insert & D for Delete

bapiitmx-TARGET_QTY = 'X'.

APPEND bapiitmx.

CLEAR bapiitmx.

bapiitmx-itm_number = p_posnr.

bapiitmx-updateflag = 'I'. " I for insert & D for Delete

bapiitmx-target_qty = 'X'.

APPEND bapiitmx.

CLEAR bapiitmx.

ENDFORM. " fill_item_inx

&----


*& Form call_bapi_SO_change

&----


  • text

----


FORM call_bapi_so_change.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = p_vbeln

order_header_in = bapichdr

order_header_inx = bapichdrx

  • SIMULATION =

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

  • NO_STATUS_BUF_INIT = ' '

TABLES

return = bapirtn

order_item_in = bapiitm

order_item_inx = bapiitmx

  • 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 =

  • SCHEDULE_LINESX =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

READ TABLE bapirtn WITH KEY id = 'V1' number = '311'.

IF sy-subrc <> 0.

PERFORM bapi_errorlist.

ENDIF.

ENDFORM. " call_bapi_SO_change

&----


*& Form call_bapi_commit

&----


  • text

----


FORM call_bapi_commit.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

  • IMPORTING

  • RETURN =

.

ENDFORM. " call_bapi_commit

&----


*& Form bapi_errorlist

&----


  • text

----


FORM bapi_errorlist.

DATA: bapierr TYPE c,

string TYPE string,

i TYPE i.

bapierr = 'X'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

LEAVE TO LIST-PROCESSING.

SET PF-STATUS 'LIST'.

FORMAT INTENSIFIED ON.

WRITE: / 'BAPI ERROR OCCURED' COLOR COL_NEGATIVE INVERSE ON.

SKIP 1.

LOOP AT bapirtn.

CONCATENATE bapirtn-type bapirtn-number '(' bapirtn-id ')'

INTO string.

WRITE: / string.

i = strlen( bapirtn-message ).

WRITE bapirtn-message(i).

ENDLOOP.

LEAVE TO SCREEN 0100.

ENDFORM. " bapi_errorlist

-


1 REPLY 1
Read only

Former Member
0 Likes
324

What errors are you getting in the RETURN parameter?