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 Sales Order change.

Former Member
0 Likes
746

Hi ALL,

Need help in BAPI sales order change.

I unable to change the Quantity field of the line item in sales order. Even if I try to insert a new line item the quantity field is not updating. It is blank.

Below I have pasted the code: Please check and correct it.

REPORT ZTEST1.

DATA ord_headerx TYPE bapisdh1x.

DATA: it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: itm_tab LIKE bapisditm OCCURS 0 WITH HEADER LINE,

itm_chk LIKE bapisditmx OCCURS 0 WITH HEADER LINE.

data: hdr_in type BAPISDH1.

PARAMETERS: posnr TYPE posnr_va OBLIGATORY, "item number

vbeln TYPE vbeln_va OBLIGATORY, "SO number

uom type VRKME OBLIGATORY, "Unit o fmeasure

tqty type DZMENG, "Quantity

matnr type matnr. "Material number

hdr_in-SD_DOC_CAT = 'C'.

ord_headerx-updateflag = 'U'. "'U'.

itm_tab-itm_number = posnr.

itm_tab-SALES_UNIT = uom. "'H'. " target_qu = 'EA'.

itm_tab-target_qty = tqty.

itm_tab-MATERIAL = matnr.

itm_chk-itm_number = posnr.

itm_chk-updateflag = 'I'. "'U'.

itm_chk-SALES_UNIT = 'X'.

itm_chk-target_qty = 'X'.

itm_chk-material = 'X'.

APPEND itm_tab.

APPEND itm_chk.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = vbeln

order_header_inx = ord_headerx

TABLES

return = it_return

order_item_in = itm_tab

order_item_inx = itm_chk.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '.

LOOP AT it_return.

WRITE:/ it_return-type, it_return-message.

ENDLOOP.

Hi ALL,

Need help in BAPI sales order change.

I unable to change the Quantity field of the line item in sales order. Even if I try to insert a new line item the quantity field is not updating. It is blank.

Below I have pasted the code: Please check and correct it.

REPORT ZTEST1.

DATA ord_headerx TYPE bapisdh1x.

DATA: it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: itm_tab LIKE bapisditm OCCURS 0 WITH HEADER LINE,

itm_chk LIKE bapisditmx OCCURS 0 WITH HEADER LINE.

data: hdr_in type BAPISDH1.

PARAMETERS: posnr TYPE posnr_va OBLIGATORY, "item number

vbeln TYPE vbeln_va OBLIGATORY, "SO number

uom type VRKME OBLIGATORY, "Unit o fmeasure

tqty type DZMENG, "Quantity

matnr type matnr. "Material number

hdr_in-SD_DOC_CAT = 'C'.

ord_headerx-updateflag = 'U'. "'U'.

itm_tab-itm_number = posnr.

itm_tab-SALES_UNIT = uom. "'H'. " target_qu = 'EA'.

itm_tab-target_qty = tqty.

itm_tab-MATERIAL = matnr.

itm_chk-itm_number = posnr.

itm_chk-updateflag = 'I'. "'U'.

itm_chk-SALES_UNIT = 'X'.

itm_chk-target_qty = 'X'.

itm_chk-material = 'X'.

APPEND itm_tab.

APPEND itm_chk.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = vbeln

order_header_inx = ord_headerx

TABLES

return = it_return

order_item_in = itm_tab

order_item_inx = itm_chk.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '.

LOOP AT it_return.

WRITE:/ it_return-type, it_return-message.

ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
709

hELLO,

Try calling FM BAPI_SALESORDER_GETLIST, to see if you are missing any parameter in order to change what you need.

Also check if the X structures are filled correcly, I would recommend to learn how to use the FM on se37 before programming anything.

Bye

Gabriel P.-

Read only

0 Likes
709

Hello... Gabriel P.

If some one ask a question in this form. Try to answer or else sit quite.

Don't advise me and don't think that you are too smart how to check the FM in SE37. (Don't try to teach me)

Regards,

Rajesh.

Read only

0 Likes
709

Hello Rajesh...

My friend please dont take my advice on the wrong hand. I only wanted to explain you the procedure I follow when I find a FM that could work depending on my needs, that is what I meant when I said "learn how to use SE37 for that FM" nothing else.

I just want to help, and share some of my experience, please dont think Im too smart for this forum... as I said I only wanted to help you...I dont understand why you answer that, the idea if this forum is to help eachother, no to get offended when getting help from people all around the world.

Cheers men...

Bye

Gabriel P-

Read only

Former Member
0 Likes
709

Hi,

I see in the code that u r not filling the Schedule lines structure in BAPI. Quantity will be changed only if u fill the schedule lines in BAPI.

U can find the schedule lines in TABLES of BAPI 'BAPI_SALESORDER_CHANGE' .

SCHEDULE_LINES LIKE BAPISCHDL

SCHEDULE_LINESX LIKE BAPISCHDLX

Try to fill the above structures and update the data.

I hope it wll get updated.

Regards,

Asif Ali Khan

Read only

Former Member
0 Likes
709

Hi.....