cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong CFOP determination via BAPI BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hello Gurus,

I need some help on the following:

When I create a Sales document manually (tcode VA01), CFOP code is determined correctly. But when I try to do the same process, using BAPI BAPI_SALESORDER_CREATEFROMDAT2, with same data ( Sold-To Party and Ship-To Party, material code...), CFOP code is determined wrong.

The SD consultant already checked the configuration in SPRO and everything looks fine.

I went thru debug and found that the FM SD_PARTNER_DATA_GET is called for both process, but internal table GVT_LOCAL_MEMORY is NOT filled when running BAPI and it IS filled when running VA01 (this internal table has VBPA - Partners - data).

This causes a NO_OBJECT_FOUND exception, which makes the program to read the address data from KNA1 (FM J_1B_SD_ADDRESS_READ), with the wrong address number, instead the address form Sales Order, since it's an On Time Customer - WE.

The weirdest thing is that it was working perfectly 3 days ago. We first noticed the problem in QAS environment, but in DEV Sandbox the error is the same now.

The scenario is an Interstate Sales Order. We are about 30 days from Go-Live and now this came thru.

Thanks in advance!

Accepted Solutions (0)

Answers (2)

Answers (2)

BTP_Architect
Participant
0 Kudos

Hello Thiago,

I'm facing the same issue, did you found a solution for that?

SD_SALES_DOCUMENT_INIT is also not working for me...

The CFOP is not updated.

Best Regards,

Moez.

Former Member
0 Kudos

Hi Moez.

Functional Team opened a ticket at SAP and we surprisingly got back from them saying that BAPI - BAPI_SALESORDER_CREATEFROMDAT2 doesn't work properly with On Time Customer, having to develop a Z solution by my own.

So I had to re-determinate CFOP in form userexit_move_field_to_vbap, calling FM  J_1B_NF_CFOP_2_DETERMINATION and passing all the fields that I need.

That was the only way I could bypass this problem.

Hope could be helpful.

BTP_Architect
Participant
0 Kudos

Hi Thiago,

I succeeded to let it work even without SD_SALES_DOCUMENT_INIT.

You have two tables used by BAPI_SALESORDER_CREATEFROMDAT2 order_items_in and order_items_inx


Field cfop_long in all order_items_in lines and in all order_items_inx should be empty


Don't forget the BAPI_TRANSACTION_COMMIT after the  BAPI_SALESORDER_CREATEFROMDAT2


Tell me if it's not working for you ...


Moez.

Former Member
0 Kudos

Thanks Moez.

Tell me, are you using On Time Customer for field ship-to? Or a regular customer?

BAPI_TRANSACTION_COMMIT is there!


Regards.

BTP_Architect
Participant
0 Kudos

Hello Thiago,

I'm using regular customers

May be this is the reason which make it working for me and not for you...

BR

Moez.

Former Member
0 Kudos

Hello Moez.

Correct, that's why I had to re-determinate CFOP. As SAP Support said, this BAPI doesn't work properly if you are working with On Time Customer.

Thanks for your help.

Former Member
0 Kudos

Hi Thiago,

Could you share the solution for fix this issue. Like how you were able to redetermine the CFOP.

Thanks,

Sreekanth

Shiva_Ram
Active Contributor
0 Kudos

The weirdest thing is that it was working perfectly 3 days ago. We first noticed the problem in QAS environment, but in DEV Sandbox the error is the same now.

Can you also whether the corresponding programs/master data (like material master/customer master) has been changed in between?

If nothing changed, then can you check OSS   1487132 - Message VP 700 (Address category does not exist) during sales order creation with an SD B...

is of any help.

Regards,

Former Member
0 Kudos

Shiva,

No master data has been changed...

I've tried runnig FM SD_SALES_DOCUMENT_INIT before running BAPI, but the error persists.

Don't know where else to look...

Thanks anyway for you answer!

Regards.