cancel
Showing results for 
Search instead for 
Did you mean: 

Creating/Saving a BO Instance - Sample ABSL

Former Member
0 Kudos

Hi All,

I know there's been a lot of questions about creating a BO instance, so I thought I would provide you with an example from one of my projects. Some code is omitted to protect my Customer.

In this script I am checking if a Customer already exists matching my custom User BO. If not, I create an instance of the the Customer BO filled with elements from my custom BO. Anyway, I hope this helps.

// Get customers in User BO

query_customer = Customer.QueryByIdentification;

query_customer_selparam = query_customer.CreateSelectionParams();

query_customer_selparam.Add(query_customer.InternalID , "I", "EQ", this.UserID);

query_customer_result = query_customer.Execute(query_customer_selparam);

// If Customer does not exist, create Customer

if (query_customer_result.Count() == 0) {

var customerRoot : elementsof Customer;

customerRoot.CategoryCode = "2"; // or 1 or 3

customerRoot.InternalID = this.UserID;

CustomerBO = Customer.Create(customerRoot);

//Customer Indicator

CustomerBO.CurrentBusinessCharacters.CustomerIndicator = true;

CustomerBO.CurrentBusinessCharacters.ProspectIndicator = false;

//Organisation

CustomerBO.CurrentCommon.Organisation.Name.FirstLineName = this.UserName.content;                CustomerBO.CurrentCommon.Organisation.Name.SecondLineName = "";

CustomerBO.Activate();

}

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Judson,

I am using the On Demand System 1302.

And I am able to create Customer Instances : InternalID, CategoryCode, CustomerIndicator, ProspectIndicator, from My BO this is possible.

But if i want to create some instances for the Address like: CityName, CountryCode, HouseID and other fields from address, I canot do this because those  elements or others elements from Adress has NO Public Write Acces.

How can i create instances in the Customer BO for the Address elements  from MY BO ?

Thanks,

Madalin

former_member197479
Active Participant
0 Kudos

Great post Judson.. But I'm having an issue, In order to that script to work, its event handler must have activated the checkbox "SaveAfterExecution" or "SaveBeforeExecution".

But, those options create an empty record, how do i create an instance, without using those checkboxes?

Former Member
0 Kudos

Actually it's in a BeforeSace script

former_member197479
Active Participant
0 Kudos

Doesn't it create you an empty record, below the data that you recorded?

I mean.. if you have any fields in the UI attached to one element declared on the B.O, and you typed on it any text, that action will save an instance with that text.. even if the field is for example a search field..

Former Member
0 Kudos

I don't think so, no.

Former Member
0 Kudos

You're think AfterModify.

BeforeSave only executes when you click the 'Save' button.

former_member47640
Active Contributor
0 Kudos

Judson,

please post these things as blog post or document but not as a question. It's confusing.

Other than that: Keep on going, man!

I even have a use case for a simple add-on like this:
Create a custom BO for a supplier-request. Lots of companies - especially in the US - let their employees request new suppliers including all the necessary information such as 1099, minority-owned, women-owned, etc.

Add a simple approval workflow with the responsible buyer and there you go.

In addition you could add a website that your employees just send the new supplier a link to for them to fill out this information on their own.

Cheers, Christian

Former Member
0 Kudos

I don't know this use case from our german customers but I think it could be realized within one some few days...

Public website could be realized with SAP Netveawer Neo 🙂 ...a little bit to big for this use case but cool 🙂

Andreas

Former Member
0 Kudos

Yeah, my bad posting as a question. I wanted it to be a discussion. Thanks for the good ideas.