Symptom
You are using PDI code to affect lead creation and you face the error "Sales Area not valid based on Organizational Structure, Field value validation failed"; you wonder why.
Environment
SAP Cloud for Customer
Reproducing the Issue
- Go to the Sales work center.
- Go to the Leads view.
- Click in the + icon.
- Fill in the required fields.
- Click in the Save button.
- Message appears.
Cause
Sales arrangement checks in code will see if sales org and distribution channel were provided. There is even a hard coded 'Distribution Channel mandatory' check in:
cl_ap_sales_area=>if_ap_sales_area~check_sales_areas * In single method distribution channel is also considered mandatory
IF <ls_sales_area>-distr_channel IS INITIAL.
APPEND <ls_sales_area> TO et_invalid_sales_area.
CONTINUE.
ENDIF.
Probably your code is:
if (SalesOrg.IsSet())
{
salesArrangmntData.SalesOrganisationUUID = SalesOrg.UUID;
}
As you can see from the PDI Code within the determination only the SalesOrg is set with above value, but the Distribution Channel is not set.
This causes the observed error on save, as Distribution Channel is mandatory for an Sales Arrangement.
Resolution
Provide at least sales org/distribution channel in your PDI code.
See Also
KBA 2893401 - Error 'Sales area not valid based on organizational structure' Occurs when Convert Lead to Opportunity
Keywords
Sales, Arrangement, Lead, PDI, Custom, Code, Sales, Area, not, valid, based, on, Organizational, Structure, Field, value, validation, failed, salesArrangmntData.SalesOrganisationUUID, SalesOrg.IsSet() , KBA , LOD-CRM-LM , Lead Management , Problem
SAP Knowledge Base Article - Public