Deep Insert on Business Partner via SAP Cloud SDK VDM doesn't work on to_Customer - sap-cloud-sdk

I'm trying to create a business partner including a customer, a customer sales area and a customer company with the SAP Cloud SDK.
This is how I create my business partner vdm:
final CustomerSalesArea customerSalesArea = CustomerSalesArea.builder()
.salesOrganization("YOD1")
.distributionChannel("Y2")
.division("Z1")
.currency("EUR")
.customerAccountAssignmentGroup("01")
.customerPaymentTerms("0001")
.customerPricingProcedure("Y1")
.incotermsClassification("FH")
.itemOrderProbabilityInPercent("100")
.orderCombinationIsAllowed(true)
.customerAccountGroup("CUST")
.build();
final CustomerCompany company = CustomerCompany.builder()
.companyCode("YOD1")
.reconciliationAccount("0012100000")
.customerAccountGroup("CUST")
.build();
final Customer customer = Customer.builder()
.customerSalesArea(customerSalesArea)
.customerCompany(company)
.build();
final BusinessPartner businessPartner = BusinessPartner.builder()
.firstName(oxidBusinessPartner.getFirstName())
.middleName(oxidBusinessPartner.getMiddleName())
.lastName(oxidBusinessPartner.getLastName())
.businessPartnerCategory("1")
.correspondenceLanguage("DE")
.businessPartnerIDByExtSystem(oxidBusinessPartner.getCustomerId())
.customer(customer)
.build();
final BusinessPartnerRole businessPartnerRole1 = BusinessPartnerRole.builder()
.businessPartnerRole("FLCU00")
.build();
final BusinessPartnerRole businessPartnerRole2 = BusinessPartnerRole.builder()
.businessPartnerRole("FLCU01")
.build();
businessPartner.addBusinessPartnerRole(businessPartnerRole1);
businessPartner.addBusinessPartnerRole(businessPartnerRole2);
final AddressEmailAddress emailAddress = AddressEmailAddress.builder()
.emailAddress(oxidBusinessPartner.getEmail())
.build();
for (PostalAddress address : oxidBusinessPartner.getPostalAddresses()) {
final BusinessPartnerAddress businessPartnerAddress = BusinessPartnerAddress.builder()
.country(address.getCountry())
.cityName(address.getCity())
.postalCode(address.getZipCode())
.county(address.getRegion())
.emailAddress(emailAddress)
.build();
businessPartner.addBusinessPartnerAddress(businessPartnerAddress);
}
Now, I am able to successfully create this business partner with the DefaultBusinessPartnerService. However the actual deep insert doesn't seem to work properly as the Customer is not created.
I can confirm this by querying the A_BusinessPartner API with an expand to to_Customer, which returns null. The deep insert on the BusinessPartnerRole however worked as expected.
So, what am I missing here? Is there some sort of dependency, such as that I first need to create a BusinessPartner and then a Customer (I am by no means an expert in S4/HANA)? But then again, the SAP Cloud SDK doesn't provide a method to create a Customer and neither does api.sap.com.

Unfortunately it's not possible to create instances of Customer entity when using the Business Partner API. In the official documentation you will find only support for "Reading" and "Updating" Customers. I looked for an alternative Rest service in the SAP API Business Hub and found the Customer Master service, with limited functionality though. Maybe it allows the creation of Customers.

If I leave the customer "empty", so if I just do
Customer customer = Customer.builder().build(); and attach it to the Business Partner, the Customer entity is somehow created. I then use the OData Servives /A_CustomerCompany and /A_CustomerSalesArea to create those entities respectively and everything works as expected.

Related

Check ACH credit transfer for customer in stripe using java

Is there any way to check whether ACH credit transfer added to customer or not in stripe using java with using only customerid.
ACH Credit Transfer is still only available on Stripe's legacy API called the Source API as documented here. Since it is not yet compatible with the PaymentMethod API you have to use one of the old calls in Java called getSources() which can be a bit hard to discover.
Your code would look something like this:
// Retrieve the customer with its legacy payment sources included
CustomerRetrieveParams retrieveParams =
CustomerRetrieveParams.builder()
.addExpand("sources")
.build();
Customer customer = Customer.retrieve("cus_1234", retrieveParams, null);
// Filter payment sources down to just Sources
PaymentSourceCollectionListParams sourcesParams =
PaymentSourceCollectionListParams.builder()
.setObject("source")
.build();
PaymentSourceCollection sources = customer.getSources().list(sourcesParams);
// Iterate over the Sources to find what you need
Iterable<PaymentSource> itSources = sources.autoPagingIterable();
for (PaymentSource paymentSource : itSources) {
Source source = (Source) paymentSource;
System.out.println(source.getId());
System.out.println(source.getType());
}
System.out.println("done");

Has azure user ids changed their format?

Good evening ppl at Microsoft!
I have an Mobile App Service at Microsoft Azure Located at South Central US named CeneamApp.
My backend is configured in a way so that my user can access only the data they capture, by making use of stable user ids.
so I had followed Adrian Hall book to create an a user id (https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/authorization/)with the following format sid:{identifier}as described here: (https://github.com/Azure/azure-mobile-apps-net-server/wiki/Understanding-User-Ids).
now all my userid had been changed and my user cant access their previous data capture by them, because somehow the provider or issuer or whatever is going on, doesnt let me retrieve a user id as described by the github project team wiki (in the previous link). so instead i receive a new userid but seem to be a random number:
I'm adding screenshot of the essential part of my code at my backend project which i debugged so i could understand whats going on and my dummy database where you can see an stable_id save on it and the new suppose stable_ids the next two rows.
Debugged code retrieving apparently a new userid from FACEBOOK could you confirm about this change? because I havent been able to understand this change.
Dummy Database with the lost userid and the new ones from other accounts database screenshot
if anyone has information about this odd behavior i would appreciate to enlight me, because this line of code:
principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;
used to give me a user id with this format: "sid:{identifier}", now the format is a the screenshot shows.
Same situation here. About to go live and suddenly this. Interesting that only one Mobile App based in the UK datacenter is affected. Other 2 apps which are in production and plus another Web App are still fine.
The full solution can only be provided by Azure team. But I have a workaround and and idea:
1. Workaround.
In the base controller I read and parse the token from the header. The sid is in the subject of the token. The code is simple:
string _userSid;
public string UserSid
{
get
{
if (_userSid == null)
{
KeyValuePair<string, IEnumerable<string>> auth_header = Request.Headers.FirstOrDefault(h => h.Key.Equals("x-zumo-auth", StringComparison.InvariantCultureIgnoreCase));
string token = auth_header.Value.FirstOrDefault();
if (!string.IsNullOrEmpty(token))
{
var jwtToken = new JwtSecurityToken(token);
if (jwtToken != null)
{
_userSid = jwtToken.Subject;
}
}
}
return _userSid;
}
}
I use it instead of getting this from ClaimPrinciple as per manual. I checked the Mobile App Server code does a very similar thing.
2. Idea.
Azure Mobile Apps have this parameter:
MobileAppsManagement_EXTENSION_VERSION it is recommended to set to latest. I think if we downgraded it to previous version it would work until Microsoft finds and solves the problem. The only issue is that I do not know and could not find the version number. May be someone knows and can post here?

Good way to send 200k mails per day with c#

I work at Across an Human Resource company and we are building a new system for our young professionals department. That application needs to send a lot of mail in different cenarious (update resume, lost password, events, tests, etc.) for all registered users and I have a architecture issue/question.
That system will send several groups of e-mail in a day, each group probably will have around 30k and we believe that the system will send more than 10 groups per day.
My first idea was to create a Windows Service to process all email groups in my e-mail table (SQL), but I will have problems with availability and one single point of failure.
I'm just concerning about that because my queue will take hours to send all groups (each mail individually in a row).
Anybody knows how big systems like twitter / facebook /instragram and so on sends that amount of mail? I'm concerned about infrastructure and development.
Btw, i'm using smtpClient.Send() and I'm not into using smtpClient.SendAsync() because I have trouble to maintaing and control it.
I'm open to any sugestions from the Infrastructure to the dev side. All the infrastructure will relies on AWS Datacenter (SES) or Microsoft Azure, our infra team is testing both of them.
This works for us to send out our batch email:
public void sendEmail(String email, PdfDocument attachFile)
{
attachFile.Save("attachment.pdf");
attachFile.Close();
SmtpClient mSmtpClient = new SmtpClient("smtp.domain.com", 25);
mSmtpClient.EnableSsl = true;
mSmtpClient.Credentials = new System.Net.NetworkCredential("user", "pass");
MailAddress from = new MailAddress("address#domain.com", String.Empty, System.Text.Encoding.UTF8);
MailAddress to = new MailAddress(email.ToString());
MailMessage mMailMessage = new MailMessage(from, to);
System.Net.Mail.Attachment at = new System.Net.Mail.Attachment("Payroll Direct Deposit Notification.pdf");
mMailMessage.Body = "Please see attached for your pay summary.";
mMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mMailMessage.Subject = "subject";
mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mMailMessage.Attachments.Add(at);
try
{
mSmtpClient.Send(mMailMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
at.Dispose();
attachFile.Dispose();
}
You may want to adjust the mSmtpClient.Timeout from the default depending on what the hardware you are relaying off of is capable of, you can use separate threads that call this function or send asynchronously depending on how you build the rest of your applications, or you can just jack up the timeout to smooth it out if that's your preference.

Create association between marketing list and contact entity

I am using php to interact with Microsoft Dynamics CRM 2011 using library located here.
Can anyone tell me how to add contact to marketing list for a given list.
static::$contact = new \DynamicsCRM2011_Contact(static::get_connector());
static::$contact->contactid = trim($contact_id);
static::$list = new \DynamicsCRM2011_List(static::get_connector());
static::$list->__set('listname', 'testlist');
static::$list->__set('listcontact_association', static::$contact);
$list_info = static::get_connector()->create(static::$list);
To make your code work you should build correct Soap Request. You can take all needed information from following article - http://mileyja.blogspot.com/2011/11/add-entity-member-to-marketing-list-in.html

How do I "Follow Site" in Sharepoint 2013 with SSOM?

I haven't found that much information online about how to utilize the Social Part of SharePoint 2013 by Server Object Model. To understand and follow my question better i recommend you going to this site.
Lets say I have a Feature Receiver that is fired when i certain site is created and I would like to take advantage of the Follow Content Feature but instead of every time a site is created i would like to make the person that created the site automatically follow that site.
Does anyone got experience with working with the Social functionallity in SharePoint 2013? If so would be awesome with a summary how to use the different Social methods.
Social Actor
From what I've understood from reading about this you need to create a "Actor" to represent the item or in my case the site. SocialActorInfo which takes to properties ContentUri and ActorType.
SocialActorInfo actorInfo = new SocialActorInfo();
actorInfo.ContentUri = contentUrl;
actorInfo.ActorType = contentType;
Find and Check if that Actor is followed by the current user
Then you have to check if that SocialActor is Followed by the current user.
ClientResult<bool> isFollowed = followingManager.IsFollowed(actorInfo);
Follow/Unfollow the Site/Item
ClientResult<SocialFollowResult> result = followingManager.Follow(actorInfo);
clientContext.ExecuteQuery();
"followingManager.UnFollow(actorInfo);"
Questions,
If I want to follow a site, what kind of ActorTypes are there?
How do i do this with server-side code?
Additional Information
Microsoft says: When users follow documents, sites, or tags, status updates from documents, conversations on sites, and notifications of tag use show up in their newsfeed. The features related to following content can be seen on the Newsfeed and the Following content pages.
SharePoint Server 2013 provides the following APIs that you can use to programmatically follow content:
Client object models for managed code
NET client object model
Silverlight client object model
Mobile client object model
JavaScript object model
Representational State Transfer (REST) service
Server object model
Link to Follow Content in SharePoint 2013, I can just find how to do it with REST or CSOM.
Just wanted to Share, this Solved the task.
Just a Follow Method that takes a SPWeb object and a SPUser object.
SPServiceContext serverContext = SPServiceContext.GetContext(web.Site);
UserProfileManager profileManager = new UserProfileManager(serverContext);
string userString = user.LoginName.ToString();
UserProfile userProfile = profileManager.GetUserProfile(userString);
if (userProfile != null)
{
SPSocialFollowingManager manager = new
SPSocialFollowingManager(userProfile);
SPSocialActorInfo actorInfo = new SPSocialActorInfo();
actorInfo.ContentUri = new Uri(web.Url);
actorInfo.AccountName = user.LoginName;
actorInfo.ActorType = SPSocialActorType.Site;
manager.Follow(actorInfo);
}

Resources