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

BAPI_SALESORDER_CHANGE

Former Member
0 Likes
2,322

Dear Friends,

My requirement is for sales order i am updating two conditon types for each material item and passing some amount in

the field your reference(ihrez).

i am using bapi-salesorder_change for this.

As, this is the first time i am moulding from bdc to bapi i don't have exact idea how to write code.

by watching some examples i try to do my best to changing sales order data.

but it throughs an error that 'Field header_inx-updateflagX is not an input field'.

please analyse the below code and give me your guidance.

TABLES : vbak,

vbap.

TABLES : BAPISDH1X,

BAPISDITM,

BAPISDH1,

BAPICOND,

BAPICONDX.

  • Structure Decleration

TYPES : BEGIN OF ty_vbak,

vbeln LIKE vbak-vbeln,

amount(12) TYPE c,

END OF ty_vbak.

*Internal table decleration

DATA: it_vbak TYPE TABLE OF ty_vbak,

wa_vbak LIKE LINE OF it_vbak,

it_vbap TYPE TABLE OF vbap,

wa_vbap TYPE vbap.

DATA : IT_COND TYPE TABLE OF BAPICOND,

WA_COND LIKE LINE OF IT_COND,

IT_CONDX TYPE TABLE OF BAPICONDX,

WA_CONDX LIKE LINE OF IT_CONDX.

LOOP AT it_vbak INTO wa_vbak.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_vbak-vbeln

IMPORTING

output = wa_vbak-vbeln.

SELECT * FROM vbap INTO TABLE it_vbap

WHERE vbeln = wa_vbak-vbeln.

CLEAR : bapisdh1, bapisdh1x.

*Header

BAPISDH1-name = wa_vbak-amount.

*Headerx

BAPISDH1X-name = 'X'.

BAPISDH1X-UPDATEFLAG = 'X'.

LOOP AT IT_VBAP INTO WA_VBAP WHERE VBELN = WA_VBAK-VBELN.

*Item level

BAPISDITM-material = wa_vbap-matnr.

*Condtion types

WA_COND-COND_TYPE = 'ZSTC'.

WA_COND-COND_VALUE = '25'.

WA_COND-COND_TYPE = 'ZSVT'.

WA_COND-COND_VALUE = '10.3'.

APPEND WA_COND TO IT_COND.

clear wa_cond.

*Condition types x

WA_CONDX-COND_TYPE = 'ZSTC'.

WA_CONDX-COND_VALUE = 'X'.

APPEND WA_CONDX TO IT_CONDX.

clear wa_condx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = WA_VBAK-VBELN

ORDER_HEADER_IN = BAPISDH1

order_header_inx = bapisdh1x

tables

return = it_return

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

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

CONDITIONS_INX = IT_CONDX

  • EXTENSIONIN =

  • NFMETALLITMS =

.

*if sy-subrc ne 0.

perform process_data.

*endif.

clear : wa_vbak, wa_vbap.

refresh : it_cond, it_condx.

ENDLOOP.

ENDLOOP.

&----


*& Form process_data

&----


FORM process_data .

LOOP AT it_return INTO wa_return WHERE type = 'E'.

ENDLOOP.

IF sy-subrc IS NOT INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X' .

  • IMPORTING

  • RETURN =

WRITE : / 'PR SUCCESSFULLY Changerd check the DB .'.

ELSE.

LOOP AT it_return INTO wa_return.

WRITE : / wa_return-type, wa_return-message .

ENDLOOP.

ENDIF.

ENDFORM. " process_data

Dear Friends,

My requirement is for sales order i am updating two conditon types for each material item and passing some amount in

the field your reference(ihrez).

i am using bapi-salesorder_change for this.

As, this is the first time i am moulding from bdc to bapi i don't have exact idea how to write code.

by watching some examples i try to do my best to changing sales order data.

but it throughs an error that 'Field header_inx-updateflagX is not an input field'.

please analyse the below code and give me your guidance.

TABLES : vbak,

vbap.

TABLES : BAPISDH1X,

BAPISDITM,

BAPISDH1,

BAPICOND,

BAPICONDX.

  • Structure Decleration

TYPES : BEGIN OF ty_vbak,

vbeln LIKE vbak-vbeln,

amount(12) TYPE c,

END OF ty_vbak.

*Internal table decleration

DATA: it_vbak TYPE TABLE OF ty_vbak,

wa_vbak LIKE LINE OF it_vbak,

it_vbap TYPE TABLE OF vbap,

wa_vbap TYPE vbap.

DATA : IT_COND TYPE TABLE OF BAPICOND,

WA_COND LIKE LINE OF IT_COND,

IT_CONDX TYPE TABLE OF BAPICONDX,

WA_CONDX LIKE LINE OF IT_CONDX.

LOOP AT it_vbak INTO wa_vbak.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_vbak-vbeln

IMPORTING

output = wa_vbak-vbeln.

SELECT * FROM vbap INTO TABLE it_vbap

WHERE vbeln = wa_vbak-vbeln.

CLEAR : bapisdh1, bapisdh1x.

*Header

BAPISDH1-name = wa_vbak-amount.

*Headerx

BAPISDH1X-name = 'X'.

BAPISDH1X-UPDATEFLAG = 'X'.

LOOP AT IT_VBAP INTO WA_VBAP WHERE VBELN = WA_VBAK-VBELN.

*Item level

BAPISDITM-material = wa_vbap-matnr.

*Condtion types

WA_COND-COND_TYPE = 'ZSTC'.

WA_COND-COND_VALUE = '25'.

WA_COND-COND_TYPE = 'ZSVT'.

WA_COND-COND_VALUE = '10.3'.

APPEND WA_COND TO IT_COND.

clear wa_cond.

*Condition types x

WA_CONDX-COND_TYPE = 'ZSTC'.

WA_CONDX-COND_VALUE = 'X'.

APPEND WA_CONDX TO IT_CONDX.

clear wa_condx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = WA_VBAK-VBELN

ORDER_HEADER_IN = BAPISDH1

order_header_inx = bapisdh1x

tables

return = it_return

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

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

CONDITIONS_INX = IT_CONDX

  • EXTENSIONIN =

  • NFMETALLITMS =

.

*if sy-subrc ne 0.

perform process_data.

*endif.

clear : wa_vbak, wa_vbap.

refresh : it_cond, it_condx.

ENDLOOP.

ENDLOOP.

&----


*& Form process_data

&----


FORM process_data .

LOOP AT it_return INTO wa_return WHERE type = 'E'.

ENDLOOP.

IF sy-subrc IS NOT INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X' .

  • IMPORTING

  • RETURN =

WRITE : / 'PR SUCCESSFULLY Changerd check the DB .'.

ELSE.

LOOP AT it_return INTO wa_return.

WRITE : / wa_return-type, wa_return-message .

ENDLOOP.

ENDIF.

ENDFORM. " process_data

3 REPLIES 3
Read only

Former Member
0 Likes
1,789

Hi,

The field BAPISDH1X-UPDATEFLAG is used to store the update indicator. In my opinion you get this error message due to the wrong value passed ('X'). Try passing 'U' for Update or 'D' for Delete.

Kr,

Manu.

Read only

0 Likes
1,789

Hi manu,

i changed updation flag value as 'U' .

but now i am getting the eroor message

'Condition ZSVT is not allowed as header condition'.

Actually i have to update condition types zsvt and zstc for different fixed %'s.

I am not sure, whether i am passing values to the suitable structures/jtables in bapi.

can you please check it and give me your suggestions.

Edited by: anurag.radha on Dec 20, 2011 7:00 AM

Read only

0 Likes
1,789

Hi,

You should check with your functional SD team... You seem to use conditions that are not allowed on both header and item level... This issue can also be due to an unknown material beeing used, check that the material used is corectly formatted.

Kr,

Manu.