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: 

BAPI_SALESORDER_CREATEFROMDAT2 Create for success material only

Former Member
0 Kudos

Hi,

In flat file 10 line items are there for a customer to create  sales order. But  5 material are correct but 5 are incorrect. ( may be order quantity problem for incorrect material). Now sales order not creating. showing error like mismatch quantity.

Now my requirement is create order for materials what ever correct material and leave incorrect materials.

Please update how we can do this.

Regards,

Maruthi S

9 REPLIES 9

atul_mohanty
Active Contributor
0 Kudos

check with BAPI_SALESORDER_SIMULATE first.

0 Kudos

Hi Atul,

I used the above FM . But in this call in message tab not getting any error but while calling  BAPI_SALESORDER_CREATEFROMDAT2 it showing error "Miss match in order and confirmed quantity"

   CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'

     EXPORTING

       order_header_in           = lw_bapisdhead

* IMPORTING

*   SALESDOCUMENT               =

     TABLES

       order_items_in            = lt_bapiitemin

       order_partners            = lt_bapipartnr

       order_schedule_in         = lt_bapischdl

       messagetable              = lt_messtab.


Regards,

Maruthi S

christophe_hu2
Participant
0 Kudos

Hello,

Can you launch first the BAPI in test mode, if the return code is not Initial, you can fix the issue and launch again the BAPI.

thank you

best regards,

christophe

0 Kudos

Hi,

I ran it in test mode 'x' but not giving any error in return but in non test mode it is showing error .

Regards,

Maruthi S

raymond_giuseppi
Active Contributor
0 Kudos

You could call the BAPI once for each line, but allways execute a BAPI_TRANSACTION_ROLLBACK. Then call a last time the BAPI will every correct lines and this table execute a BAPI_TRANSACTION_COMMIT if no error raised in RETURN.

Regards,

Raymond

jack_graus2
Active Contributor
0 Kudos

Hi

There is a BAPI input parameter BEHAVE_WHEN_ERROR

With the value 'P' the order will be saved when errors occur and problematic items will not be saved.

The BAPI documentation gives a more detailed description.

Regards Jack

0 Kudos

Hi Jack,

I passed the parameter  behave_when_error       = 'P' but still its giving same error 'Ordered and confirmed quantity mismatch'. sales document not creted.

Regards,

Maruthi S.

0 Kudos

Hi,

Did you check the ORDER_ITEMS_IN-TARGET_QTY and ORDER_SCHEDULES_IN-REQ_QTY values match or not.

Hope this helps.

suresh_kutam
Participant
0 Kudos

Hello Maruthi,

I am not sure - BAPI will ignore your wrong entries.

What SAP expect - give us correct data to post - if not SAP will return Error.

Either you do your validation first and remove Error materials and then go for BAPI call.

That is best way to process records.

Thanks,

SK