SAP Knowledge Base Article - Public

3605284 - "Sales Area not valid based on Organizational Structure, Field value validation failed" Error When Creating Lead using PDI Code

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

  1. Go to the Sales work center.
  2. Go to the Leads view.
  3. Click in the + icon.
  4. Fill in the required fields.
  5. Click in the Save button.
  6. 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

Product

SAP Cloud for Customer core applications 2502