Skip to Content

How do create a new Contact (Business Patner) in SAP ByDesign?

Hi Experts,

I have a business scenario to create new contacts from Custom Screen. I have tried a piece of ABSL code from custom Business object's Before save event. But I am getting an error "Last Name Missing".

Is there any specific code to create a contact?

//Create a new contact
var createContact : elementsof BusinessPartner;
createContact.CategoryCode = "1";
var resultContact = BusinessPartner.Create(createContact);
var currentCommon : elementsof BusinessPartner.Common;
currentCommon.Person.Name.GivenName = "SDK";
currentCommon.Person.Name.FamilyName = "SDK";
resultContact.CurrentCommon.Create(currentCommon);
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 12 at 02:43 AM

    Hi Sankaran,

    I don't know the reason, but we can use the script, as:

    //Create a new contact
    var createContact : elementsof BusinessPartner;
    createContact.CategoryCode = "1";
    var resultContact = BusinessPartner.Create(createContact);
    
    var currentCommon = resultContact.CurrentCommon.Create();
    if (currentCommon.IsSet())
    {
       currentCommon.Person.Name.GivenName = "SDK22";
       currentCommon.Person.Name.FamilyName = "SDK22";
    }
    
    if (resultContact.Common.GetFirst().IsSet())
    {
       foreach(var ins_com in resultContact.Common)
       {
         ins_com.Person.Name.GivenName = "SDK22";
         ins_com.Person.Name.FamilyName = "SDK22";
       }
    }
    
    resultContact.Activate();

    Best Regards,

    Benny Huang

    Add comment
    10|10000 characters needed characters exceeded

  • May 25 at 05:18 AM

    Hi Sankaran,

    You can use below code to create contact from ABSL:

    var contact : elementsof BusinessPartner;
    contact.CategoryCode = "1";
    var reslt = BusinessPartner.Create(contact);
    if(reslt.IsSet())
    {
    if(reslt.CurrentBusinessCharacters.IsSet())
    {
    reslt.CurrentBusinessCharacters.ContactPersonIndicator = true;
    }
    
    if(reslt.CurrentCommon.IsSet())
    {
    reslt.CurrentCommon.Person.Name.FamilyName = "SDK Contact";
    }
    } 
    

    Regards,

    Sujata

    Add comment
    10|10000 characters needed characters exceeded