cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with FM BAPI_SALESORDER_CREATEFROMDAT2

0 Kudos

Hi expert,

I'm trying to create a sales order with the function module BAPI_SALESORDER_CREATEFROMDAT2 but it isn't work correctly.

If I only define the header information (exporting data: ORDER_HEADER_IN, ORDER_HEADER_INX and tables: ORDER_PARTNERS) the function module creates the sales order without problems.

However, if I define a position the function returns the following messages:

  • VBAKKOM has been processed successfully (V4233)
  • No article hierarchies found (RTCMMD402)
  • VBAPKOM has been processed successfully (V4233)
  • No article hierarchies found (RTCMMD402)
  • has been saved (V1311)

And the sales is not created.

When I call this function module I use the following data/parameters:

 CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
 EXPORTING
 order_header_in = x_order_header_in
 order_header_inx = x_order_header_inx
 logic_switch = xl_logic_switch
 IMPORTING
 salesdocument = pc_vbeln
 TABLES
 return = t_return
 order_items_in = t_order_items_in
 order_items_inx = t_order_items_inx
 order_partners = t_order_partners
 order_schedules_in = t_order_schedules_in
 order_schedules_inx = t_order_schedules_inx
 order_conditions_in = t_order_conditions_in
 order_conditions_inx = t_order_conditions_inx
 order_text = t_order_text.

Before I call function module 'SD_SALES_DOCUMENT_INIT’ to reset the system with the following parameters:

CALL FUNCTION 'SD_SALES_DOCUMENT_INIT'EXPORTING
 simulation_mode_bapi = 'X'.

Please, can you help me with this issue?

Thanks in advanced!

Accepted Solutions (0)

Answers (2)

Answers (2)

DoanManhQuynh
Active Contributor

Hello.

after that BAPI did you commit yet (you can call BAPI_TRANSACTION_COMMIT)?

pjcools
Active Contributor
0 Kudos

Yes, totally missed that. Definitely need the BAPI_TRANSACTION_COMMIT executed after it. Best to use the Test Sequence option in SE37 to run them one after the other (if you are performing this manually). To be honest I've not used the SD_SALES_DOCUMENT_INIT before, I don't believe this is required here. I would also check what you are passing in the logic switch variable, don't believe this is required to be set either but would be good to see what you are populating it with.

Thanks

Phil Cooley

0 Kudos

Hi Phil,

I'm calling the function BAPI_TRANSACTION_COMMIT after create the sales order, however, this function module is not executing because the sales order is not created.

The call to this function is the following:

 CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = x_order_header_in
order_header_inx = x_order_header_inx
logic_switch = xl_logic_switch
IMPORTING
salesdocument = pc_vbeln
TABLES
return = t_return
order_items_in = t_order_items_in
order_items_inx = t_order_items_inx
order_partners = t_order_partners
order_schedules_in = t_order_schedules_in
order_schedules_inx = t_order_schedules_inx
order_conditions_in = t_order_conditions_in
order_conditions_inx = t_order_conditions_inx
order_text = t_order_text.

The variable XL_LOGIC_SWITCH has the following data:

 xl_logic_switch-cond_handl = abap_true.
xl_logic_switch-PRICING = 'G'.

I don't know if these values are correct.

Thanks!

Best regards,

VeselinaPeykova
Active Contributor
0 Kudos

COND_HANDL = 'X' is related to how your pricing conditions should be treated and pricing = 'G' is simply triggering repricing. I seriously doubt that it has anything to do with the error that you get (No article hierarchies found (RTCMMD402). You can easily verify this by not setting anything in PRICING and in COND_HANDL (despite that your pricing result may not be what you want to achieve).

I think that it makes more sense to double check what you populate in the item data. Did you also try to enter exactly the same data in VA01 at least to eliminate potntial master data and configuration problems?

0 Kudos

Hi,

The problema is not in the popullated data because if I execute the function module from the SE37 with the same data the sales order is created without problems.

The messages that the table RETURN returns are the following:

VBAKKOM has been processed successfully
VBAPKOM has been processed successfully
VBAPKOM has been processed successfully
KONVKOM has been processed successfully
KONVKOM has been processed successfully
has been saved

There is no error but the sales order is not generated.

Thanks!

Best regards,

DoanManhQuynh
Active Contributor
0 Kudos

If you run this BAPI in SE37 without error but SO is not generated is because you didnt call bapi commit. Try to run your bapi and commit bapi in a set: in screen SE37 choose Function Module/ Execute/Test sequences then input those bapi in right order. Read this wiki for more detail:

https://wiki.scn.sap.com/wiki/display/ABAP/BAPI_TRANSACTION_COMMIT+versus+COMMIT+WORK

0 Kudos

Hi,

In the SE37 the sales order is generated without problems. My problem is when I execute the BAPI from my Z program. The function module returns the following messages in the program:

VBAKKOM has been processed successfully
VBAPKOM has been processed successfully
VBAPKOM has been processed successfully
KONVKOM has been processed successfully
KONVKOM has been processed successfully
has been saved

In the last message, you can see that the sales order is not generated.

Thanks!

Best regards,

pjcools
Active Contributor

Hi Lydia

Interesting issue. Have you got more detail around the parameters and table entries you populate to try and create the sales order successfully. Did you follow up on the error that is detailed in the return message

No article hierarchies found (RTCMMD402)

Sounds like missing master data is causing the sales order not to be created.

If you can add some more info will try and assist.

Thanks

Phil Cooley