‎2014 Nov 20 10:13 AM
Hi there,
I am writing some code which uses the BAPI_CUSTOMER_CREATEFROMDATA1
to create a new customer.
However, when running the code I get the following error:
Internal error: Refe. customer does not exist in master record
Which suggests that the customer no I am passing to the BAPI does not exist.
But the customer number will not exist because I am trying to create it !
I'm obviously missing a step somewhere?
Any ideas anyone
Thanks
Andy
‎2014 Nov 21 8:20 AM
Hi Andy,
As per the SAP Note 390045 - Usage of BAPI_CUSTOMER_* of function group V02D, there is a danger that you will lose data if you use the FM BAPI_CUSTOMER_CREATEFROMDATA1 outside of SAP online store.
Instead of this FM, we have a method called as CMD_EI_API=>MAINTAIN_BAPI to create/ update a customer without any reference.
Using this method, you can create/ update the general data, company code data and Sales area data without any issues.
‎2014 Nov 20 11:02 AM
Hi andy,
Please try to see FM'long text,and you will get more infomations.
Regards.
‎2014 Nov 20 11:08 AM
Thanks for the reply , but the long text is blank when I run the program in debug mode.
Andy
‎2014 Nov 21 1:00 AM
Hi andy,
The long text that i mentioned is import/export parameter's.
The usage of each parameter was introduced in long text.
Regards.
‎2014 Nov 20 11:31 AM
Hi Andy,
Did You try not passing PI_COPYREFERENCE structure ? This , I think , is reference customer to create new customer.
Best regards,
Shanmukh
‎2014 Nov 20 11:35 AM
Hi,
Yep using the copyref :
e.g. copyref-ref_custmr = 'CRM1379345'.
‎2014 Nov 20 11:39 AM
‎2014 Nov 20 11:41 AM
‎2014 Nov 20 11:53 AM
Hi,
It will give error for obvious reasons. You're passing a reference customer to BAPI which is not even created.
BAPI is trying to create new customer by copying the reference customer passed by you. Hence the error.
‎2014 Nov 20 12:12 PM
Pass an existing customer as reference , so that the new customer is created copying appropriate fields from ref. customer.
‎2014 Nov 20 12:14 PM
Also, the new customer number will be generated and returned in exporting parameters of the BAPI.
‎2014 Nov 21 7:17 AM
Hi many thanks for the reply.
The problem I have got is that I need to pass into the BAPI the customer number
I need creating. In my example I need 'CRM1379345' creating.
I know you can do this via transaction XD01. There must be a way of doing the same
with the BAPI??
Thanks
Andy
‎2014 Nov 21 7:39 AM
Hi Andy,
Customer number is internally generated by SAP. Even in XD01, you pass all the required fields , like customer information and after saving SAP generates the Customer number for you. You cannot create a customer with predetermined Customer number.
Best regards,
Shanmukh
‎2014 Nov 21 7:56 AM
Hi,
Isn't this based on a 'customising setting' ?
Isn't it possible to activate 'external numbering' ?
I think you should check with a functional person.
I know this is possible for some objects, but I'm not 100% sure that this is the case for BP's
Regards,
‎2014 Nov 21 8:20 AM
Hi Andy,
As per the SAP Note 390045 - Usage of BAPI_CUSTOMER_* of function group V02D, there is a danger that you will lose data if you use the FM BAPI_CUSTOMER_CREATEFROMDATA1 outside of SAP online store.
Instead of this FM, we have a method called as CMD_EI_API=>MAINTAIN_BAPI to create/ update a customer without any reference.
Using this method, you can create/ update the general data, company code data and Sales area data without any issues.
‎2014 Nov 25 10:25 AM
I'm still a little confused with this.
One of our functional people has just created a customer in XD01 by entering the
the customer 'CRM1379345'. The one I was trying to create.
The transaction worked and the customer was created.
I should be able to replicate this in the BAPI ??
Thanks
Andy
‎2014 Nov 25 10:47 AM
Hi Andy,
Just Ask your functional Consultant weather Customer creation number range is Internal or External. If it is External which i don't think most company prefers , than you have to pass Customer number in Bapi and also you have to pass reference Customer Number in Bapi (Note Reference Customer should be already created and exist in system) . If it is internal number range than no need to pass customer number in Bapi but you can pass reference customer number to create new customer by taking reference another customer.
Pass all mandatory parameters. For this you can use below documentation
Tcode : BAPI-> Tab Alphabetical -> Customer -> CreateFromData1 -> Documentation.
Hope this will help.
Regards,
Sagar
‎2014 Nov 25 11:31 AM
Many thanks for your reply Sagar, much appreciated.
I have just checked and we are using external number range.
So am I correct that I need to pass the ref cust i.e. BAPIKNA102-REF_CUSTMR which
is a customer previously created ?
And also pass the customer number in which I need created?
If this is the case I cant see where to pass the customer number that I need creating.
That make sense?
‎2014 Nov 25 11:56 AM
Hi Andy,
Yes you are right I just go through this bapi. It seems that to create the customer using bapi, you have to use internal number range. Because there is no option to pass external number range.
You can ask your functional consultant to do it ones and you can test it. If it will work then you might go with this approach.
Or if it is strict to use external number range then you can use BDC. It will be only approach.
Regards,
Sagar
‎2014 Nov 25 10:52 AM
Hi Andy,
You can switch on logging for synchronous calls in PI ( I am assuming the QOS is BE in your case) and see if the request payload to the RFC adapter is getting framed correctly.
‎2014 Nov 27 9:51 AM
Many thanks for the replies and suggestions.
I'm going down the route of creating a BDC session with my code. I couldn't find a solution
with the BAPI
Thanks
Andy
‎2014 Nov 27 11:02 AM
Hi Andy,
As is often the case with relatively straight forward questions here on SCN, you have managed to obtain a number of random and to some extent irrelevant answers, suggestions and comments, that have probably confused things a little. Having read through this thread, here are some pertinent points IMHO that you should consider:-
Hope some of this helps,
G.
‎2014 Nov 27 11:22 AM
Hi Gareth,
Many thanks for your reply. I really appreciate your comments.
As usual with SCN like you say there are always some silly suggestions !!
I have used BDC before in the past with uploads of various kinds. I was just trying
out something different for a change but failed miserably.
As this is just a one off upload I couldn't afford to spend any more research on this so
I went with the tried and tested method. I have now got it working.
Thanks again
Andy
‎2014 Nov 27 11:54 AM
Don't forget that with the new SAPgui, BCD is not a 100% fullproof option either.
Some 'features' in the new releases are not supported by BCD.
So it always depends on the situation and requirements.
An addtional advantage of using a BAPI is that fact that, when for example customising is modified later on, the BAPI will remain working, while maybe the BCD needs to be adapted to handle the modified process (dynpro sequence)