@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
//@EndUserText.label: 'Customer GST India Health Check'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #XL,
dataClass: #MIXED
}
@VDM.viewType: #COMPOSITE
@VDM.private:true
define view entity P_IN_CUSTOMERGSTHEALTHCHECK
as select from I_CustomerCompany
inner join I_Customer on I_Customer.Customer = I_CustomerCompany.Customer
and I_Customer.DeletionIndicator = abap.char''
and I_Customer.Country = abap.char'IN'
left outer to one join I_IN_GSTStateCodeMap on I_IN_GSTStateCodeMap.Country = I_Customer.Country
and I_IN_GSTStateCodeMap.Region = I_Customer.Region
left outer to one join I_CustSalesAreaTax as IN_UndefinedCustomerSalesTax on I_Customer.Customer = IN_UndefinedCustomerSalesTax.Customer
and IN_UndefinedCustomerSalesTax.DepartureCountry = abap.char'IN'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory = abap.char'JOIG'
and ( IN_UndefinedCustomerSalesTax.CustomerTaxClassification = abap.char'' or IN_UndefinedCustomerSalesTax.CustomerTaxClassification = abap.char'1' )
//left outer to one join I_CustSlsAreaAddrDepdntTaxInfo as IN_UndefinedCustAddrSalesTax on I_Customer.Customer = IN_UndefinedCustAddrSalesTax.Customer
// and IN_UndefinedCustAddrSalesTax.DepartureCountry = abap.char'IN'
// and IN_UndefinedCustAddrSalesTax.CustomerTaxCategory = abap.char'JOIG'
// and IN_UndefinedCustAddrSalesTax.CustomerTaxClassification = abap.char''
cross join I_IN_CustomerGSTHlthChkList as CustMasterCheckList
{
key I_CustomerCompany.CompanyCode as CompanyCode,
key I_CustomerCompany.Customer as Customer,
key CustMasterCheckList.IN_GSTHlthChkCategory,
key CustMasterCheckList.IN_GSTHealthCheck,
I_CustomerCompany._CompanyCode.CompanyCodeName as CompanyCodeName,
I_Customer.CustomerFullName,
I_Customer._CustomerToBusinessPartner._BusinessPartner.BusinessPartner as BusinessPartner,
CustMasterCheckList.IN_GSTHlthChkCatFldName,
CustMasterCheckList.IN_GSTHealthCheckCatDesc,
replace_regexpr( pcre => abap.sstring'[A-Za-z0-9]', value => I_Customer.TaxNumber3, with => abap.char'Z', result_length => abap.int1'15' ) as TaxNumber3,
//GSTIN Number Initial Check
case when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is null
and I_Customer.TaxNumber3 is initial then abap.char'X'
//GSTIN Number Start With State Code Check
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00002'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is null
and I_Customer.TaxNumber3 is not initial
and I_IN_GSTStateCodeMap.IN_GSTLegalStateCode is not initial
and substring(I_Customer.TaxNumber3, 1, 2 ) <> I_IN_GSTStateCodeMap.IN_GSTLegalStateCode then abap.char'X'
//GSTIN Number Length Check
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00003'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is null
and I_Customer.TaxNumber3 is not initial
and length(I_Customer.TaxNumber3) <> abap.int1'15' then abap.char'X'
//GSTIN Number Special Charcter Check
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00004'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is null
and I_Customer.TaxNumber3 is not initial
and length(I_Customer.TaxNumber3) = abap.int1'15'
and $projection.TaxNumber3 <> abap.char'ZZZZZZZZZZZZZZZ' then 'X'
//State Code Initial Check
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'002'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
and I_IN_GSTStateCodeMap.IN_GSTLegalStateCode is null then abap.char'X'
//Customer Name1 Check
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'003'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
and I_Customer.OrganizationBPName1 is initial then abap.char'X'
//Customer Sales Tax Classification
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'004'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is not initial
and IN_UndefinedCustomerSalesTax.CustomerTaxClassification is initial then abap.char'X'
// //Customer Address Sales Tax Classification
// when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'005'
// and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
// and IN_UndefinedCustomerSalesTax.CustomerTaxCategory is not initial
// and IN_UndefinedCustomerSalesTax.CustomerTaxClassification = abap.char'' then abap.char'X'
end as IN_CustHasGSTHlthChkErr,
case when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
then cast( I_Customer.TaxNumber3 as abap.char (100) )
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'002'
then cast( I_IN_GSTStateCodeMap.IN_GSTLegalStateCode as abap.char (100) )
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'003'
then cast( I_Customer.OrganizationBPName1 as abap.char (100) )
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'004'
then cast( IN_UndefinedCustomerSalesTax.CustomerTaxClassification as abap.char (100) )
// when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'005'
// then cast( IN_UndefinedCustAddrSalesTax.CustomerTaxClassification as abap.char (100) )
end as IN_GSTHlthChkCatFldVal,
case when ( CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
or CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'002'
or CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'003'
or CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'004' )
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00001'
then replace( CustMasterCheckList.IN_GSTHealthCheckErrDesc, abap.char'&1', CustMasterCheckList.IN_GSTHealthCheckCatDesc )
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00002'
then replace( CustMasterCheckList.IN_GSTHealthCheckErrDesc, abap.char'&1', I_IN_GSTStateCodeMap.IN_GSTLegalStateCode )
when CustMasterCheckList.IN_GSTHlthChkCategory = abap.char'001'
and CustMasterCheckList.IN_GSTHealthCheck = abap.char'00003'
then replace( CustMasterCheckList.IN_GSTHealthCheckErrDesc, abap.char'&1', abap.char'15' )
else CustMasterCheckList.IN_GSTHealthCheckErrDesc
end as IN_GSTHealthCheckErrDesc,
CustMasterCheckList.IN_GSTHlthChkCrrtnStp
}
where I_CustomerCompany.IsBusinessPurposeCompleted = abap.char''
and I_CustomerCompany._CompanyCode.Country = abap.char'IN';
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BUSINESSPARTNER",
"I_COMPANYCODE",
"I_CUSTOMER",
"I_CUSTOMERCOMPANY",
"I_CUSTOMERTOBUSINESSPARTNER",
"I_CUSTSALESAREATAX",
"I_IN_CUSTOMERGSTHLTHCHKLIST",
"I_IN_GSTSTATECODEMAP"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/