P_IN_IncgInvcAcctgDocHlthChk

DDL: P_IN_INCGINVCACCTGDOCHLTHCHK Type: view_entity COMPOSITE

P_IN_IncgInvcAcctgDocHlthChk is a Composite CDS View in SAP S/4HANA. It reads from 6 data sources and exposes 39 fields with key fields CompanyCode, AccountingDocument, FiscalYear, AccountingDocumentItem, IN_GSTHlthChkCategory.

Data Sources (6)

SourceAliasJoin Type
I_OperationalAcctgDocItem IncgInvcAccDocTaxItem union
I_IN_IncgInvcAPItmHlthChklst IncgInvcAPHlthChk cross
I_IN_IncgInvcAcctPyblItem IncgInvcAPItem from
I_IN_IncgInvcRevnItmHlthChklst IncgInvcRevnHlthChk cross
I_OperationalAcctgDocItem IncgInvcRevnItem union
I_IN_IncgInvcTxItmHlthChklst IncgInvcTaxHlthChk cross

Annotations (7)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #COMPOSITE view
VDM.private true view

Fields (39)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_IN_IncgInvcAcctPyblItem CompanyCode
KEY AccountingDocument I_IN_IncgInvcAcctPyblItem AccountingDocument
KEY FiscalYear I_IN_IncgInvcAcctPyblItem FiscalYear
KEY AccountingDocumentItem
KEY IN_GSTHlthChkCategory I_IN_IncgInvcAPItmHlthChklst IN_GSTHlthChkCategory
KEY IN_GSTHealthCheck I_IN_IncgInvcAPItmHlthChklst IN_GSTHealthCheck
IN_GSTHlthChkCatFldName I_IN_IncgInvcAPItmHlthChklst IN_GSTHlthChkCatFldName
IN_GSTHealthCheckCatDesc I_IN_IncgInvcAPItmHlthChklst IN_GSTHealthCheckCatDesc
DocumentDate I_IN_IncgInvcAcctPyblItem DocumentDate
PostingDate I_IN_IncgInvcAcctPyblItem PostingDate
IN_HSNOrSACCode I_IN_IncgInvcAcctPyblItem IN_HSNOrSACCode
charXendasIN_AcctgDocHasGSTHlthChkErr
char100endasIN_GSTHlthChkCatFldVal
CompanyCode
KEY AccountingDocument I_OperationalAcctgDocItem AccountingDocument
KEY FiscalYear I_OperationalAcctgDocItem FiscalYear
KEY AccountingDocumentItem I_OperationalAcctgDocItem AccountingDocumentItem
KEY IN_GSTHlthChkCategory I_IN_IncgInvcRevnItmHlthChklst IN_GSTHlthChkCategory
KEY IN_GSTHealthCheck I_IN_IncgInvcRevnItmHlthChklst IN_GSTHealthCheck
IN_GSTHlthChkCatFldName I_IN_IncgInvcRevnItmHlthChklst IN_GSTHlthChkCatFldName
IN_GSTHealthCheckCatDesc I_IN_IncgInvcRevnItmHlthChklst IN_GSTHealthCheckCatDesc
DocumentDate I_OperationalAcctgDocItem DocumentDate
PostingDate I_OperationalAcctgDocItem PostingDate
IN_HSNOrSACCode
charXendasIN_AcctgDocHasGSTHlthChkErr
BaseUnitendasIN_GSTHlthChkCatFldVal
CompanyCode
KEY AccountingDocument I_OperationalAcctgDocItem AccountingDocument
KEY FiscalYear I_OperationalAcctgDocItem FiscalYear
KEY AccountingDocumentItem I_OperationalAcctgDocItem AccountingDocumentItem
KEY IN_GSTHlthChkCategory I_IN_IncgInvcTxItmHlthChklst IN_GSTHlthChkCategory
KEY IN_GSTHealthCheck I_IN_IncgInvcTxItmHlthChklst IN_GSTHealthCheck
IN_GSTHlthChkCatFldName I_IN_IncgInvcTxItmHlthChklst IN_GSTHlthChkCatFldName
IN_GSTHealthCheckCatDesc I_IN_IncgInvcTxItmHlthChklst IN_GSTHealthCheckCatDesc
DocumentDate I_OperationalAcctgDocItem DocumentDate
PostingDate I_OperationalAcctgDocItem PostingDate
IN_HSNOrSACCode I_OperationalAcctgDocItem IN_HSNOrSACCode
charXendasIN_AcctgDocHasGSTHlthChkErr
char100endasIN_GSTHlthChkCatFldVal
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
//@EndUserText.label: 'Incoming Invoice GST India health check'

@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
  serviceQuality: #X,
  sizeCategory: #XXL,
  dataClass: #MIXED
}
@VDM.viewType: #COMPOSITE
@VDM.private:true
define view entity P_IN_IncgInvcAcctgDocHlthChk
  as select from //I_OperationalAcctgDocItem    as IncgInvcAPItem

      I_IN_IncgInvcAcctPyblItem    as IncgInvcAPItem

    cross join   I_IN_IncgInvcAPItmHlthChklst as IncgInvcAPHlthChk
{
  key IncgInvcAPItem.CompanyCode,
  key IncgInvcAPItem.AccountingDocument,
  key IncgInvcAPItem.FiscalYear,
  key cast ( IncgInvcAPItem.AccountingDocumentItem as buzei preserving type ) as AccountingDocumentItem,
  key IncgInvcAPHlthChk.IN_GSTHlthChkCategory,
  key IncgInvcAPHlthChk.IN_GSTHealthCheck,
      IncgInvcAPHlthChk.IN_GSTHlthChkCatFldName,
      IncgInvcAPHlthChk.IN_GSTHealthCheckCatDesc,
      IncgInvcAPItem.DocumentDate,
      IncgInvcAPItem.PostingDate,
      case when IncgInvcAPItem.ReferenceDocumentType = abap.char'RMRP'
           then cast( concat( substring(IncgInvcAPItem.OriginalReferenceDocument, 1, 10), concat('/', substring(IncgInvcAPItem.OriginalReferenceDocument, 11, 4))) as mmiv_belnr_gjahr_no_conversion  )
           end                                                                as SupplierInvoiceWthnFiscalYear,
      IncgInvcAPItem.IN_HSNOrSACCode,
      //ODN Check #TODO Implement ODN for RCM Scenario

      case 
//          when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'008'

//           and IncgInvcAPHlthChk.IN_GSTHealthCheck = abap.char'00001'

//           and IncgInvcAPItem._JournalEntry.DocumentReferenceID is initial then abap.char'X'


      // GST Partner check

           when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'009'
            and IncgInvcAPHlthChk.IN_GSTHealthCheck = abap.char'00001'
            and IncgInvcAPItem.IN_GSTPartner is initial then abap.char'X'

      // Place of supply check

           when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'010'
            and IncgInvcAPHlthChk.IN_GSTHealthCheck = abap.char'00001'
            and IncgInvcAPItem.IN_GSTPlaceOfSupply is initial then abap.char'X'

      // Business Place initial check

           when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'011'
            and IncgInvcAPHlthChk.IN_GSTHealthCheck = abap.char'00001'
            and IncgInvcAPItem.BusinessPlace is initial then abap.char'X'
        end                                                                   as IN_AcctgDocHasGSTHlthChkErr,

      //Field Value 

      case 
//      when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'008'

//      then cast(IncgInvcAPItem._JournalEntry.DocumentReferenceID  as abap.char( 100 )) //ODN  #TODO Implement ODN for RCM Scenario

      when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'009'
      then cast(IncgInvcAPItem.IN_GSTPartner as abap.char( 100 )) // GST Partner

      when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'010'
      then cast(IncgInvcAPItem.IN_GSTPlaceOfSupply as abap.char(100))  // Place of Supply

      when IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'011'
      then cast(IncgInvcAPItem.BusinessPlace as abap.char( 100 )) // Business Place

      end                                                                     as IN_GSTHlthChkCatFldVal,

      //Error Description 

      case when //IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'008' or   #TODO Implement ODN for RCM Scenario

               IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'009'
            or IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'010'
            or IncgInvcAPHlthChk.IN_GSTHlthChkCategory = abap.char'011'
            and  IncgInvcAPHlthChk.IN_GSTHealthCheck = abap.char'00001'
            then replace( IncgInvcAPHlthChk.IN_GSTHealthCheckErrDesc, abap.char'&1' , IncgInvcAPHlthChk.IN_GSTHealthCheckCatDesc )
            else IncgInvcAPHlthChk.IN_GSTHealthCheckErrDesc
            end                                                               as IN_GSTHealthCheckErrDesc

}
//where

//       IncgInvcAPItem.FinancialAccountType                 = 'K'

//  and  IncgInvcAPItem.AccountingDocumentItemType           = ''

//  and  IncgInvcAPItem.SpecialGLTransactionType             = ''

//  and  IncgInvcAPItem.SpecialGLCode                        = ''

//  and  IncgInvcAPItem.IsUsedInPaymentTransaction           = ''

//  and(

//       IncgInvcAPItem.AccountingDocumentType               = 'KR'

//    or IncgInvcAPItem.AccountingDocumentType               = 'KG'

//    or IncgInvcAPItem.AccountingDocumentType               = 'RE'

//  )

//  and(

//       IncgInvcAPItem._JournalEntry.AccountingDocumentType = 'KR'

//    or IncgInvcAPItem._JournalEntry.AccountingDocumentType = 'KG'

//    or IncgInvcAPItem._JournalEntry.AccountingDocumentType = 'RE'

//  )

//  and  IncgInvcAPItem._JournalEntry.IsReversal             = ''

//  and  IncgInvcAPItem._CompanyCode.Country                 = 'IN'


union

select from  I_OperationalAcctgDocItem      as IncgInvcRevnItem
  cross join I_IN_IncgInvcRevnItmHlthChklst as IncgInvcRevnHlthChk
{
  key IncgInvcRevnItem.CompanyCode,
  key IncgInvcRevnItem.AccountingDocument,
  key IncgInvcRevnItem.FiscalYear,
  key IncgInvcRevnItem.AccountingDocumentItem,
  key IncgInvcRevnHlthChk.IN_GSTHlthChkCategory,
  key IncgInvcRevnHlthChk.IN_GSTHealthCheck,
      IncgInvcRevnHlthChk.IN_GSTHlthChkCatFldName,
      IncgInvcRevnHlthChk.IN_GSTHealthCheckCatDesc,
      IncgInvcRevnItem.DocumentDate,
      IncgInvcRevnItem.PostingDate,
      case when IncgInvcRevnItem.ReferenceDocumentType = abap.char'RMRP'
           then cast( concat( substring(IncgInvcRevnItem.OriginalReferenceDocument, 1, 10), concat('/', substring(IncgInvcRevnItem.OriginalReferenceDocument, 11, 4))) as mmiv_belnr_gjahr_no_conversion  )
           end                                                                                                                                                                                as SupplierInvoiceWthnFiscalYear,

      replace_regexpr( pcre => abap.sstring'[A-Za-z0-9]', value => rpad(IncgInvcRevnItem.IN_HSNOrSACCode, abap.int1'8', abap.char'Z' ), with => abap.char'Z', result_length => abap.int1'8' ) as IN_HSNOrSACCode,

      // HSN Code initial check

      case when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
      and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00001'
      and IncgInvcRevnItem.IN_HSNOrSACCode is initial then abap.char'X'

      // HSN Code Length check

      when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
      and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00005'
      and IncgInvcRevnItem.IN_HSNOrSACCode is not initial
      and length(IncgInvcRevnItem.IN_HSNOrSACCode) > abap.int1'8'  then abap.char'X'

      // HSN Code special character check

      when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
      and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00004'
      and IncgInvcRevnItem.IN_HSNOrSACCode is not initial
      and length(IncgInvcRevnItem.IN_HSNOrSACCode) <= abap.int1'8'
      and $projection.IN_HSNOrSACCode <> abap.char'ZZZZZZZZ' then abap.char'X'

      // Quantity check

      when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'014'
      and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00001'
      and IncgInvcRevnItem.Quantity is initial then abap.char'X'

      // Base UOM check

      when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'013'
      and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00001'
      and IncgInvcRevnItem.BaseUnit is initial then abap.char'X'
      end                                                                                                                                                                                     as IN_AcctgDocHasGSTHlthChkErr,

      // Field Value

      case when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
      then cast(IncgInvcRevnItem.IN_HSNOrSACCode as abap.char(100)) //HSN

             when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'014'
      then cast(IncgInvcRevnItem.Quantity as abap.char( 100 )) //Quantity

      when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'013'
      then IncgInvcRevnItem.BaseUnit // Base UOM

      end                                                                                                                                                                                     as IN_GSTHlthChkCatFldVal,


      //Error Description

      case when( IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
            or IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'013'
            or IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'014' )
            and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00001'
           then replace( IncgInvcRevnHlthChk.IN_GSTHealthCheckErrDesc, abap.char'&1' , IncgInvcRevnHlthChk.IN_GSTHealthCheckCatDesc)

            when IncgInvcRevnHlthChk.IN_GSTHlthChkCategory = abap.char'007'
            and IncgInvcRevnHlthChk.IN_GSTHealthCheck = abap.char'00005'
            then replace( IncgInvcRevnHlthChk.IN_GSTHealthCheckErrDesc, abap.char'&1' , abap.char'8' )
            else IncgInvcRevnHlthChk.IN_GSTHealthCheckErrDesc
            end                                                                                                                                                                               as IN_GSTHealthCheckErrDesc

}
where
       IncgInvcRevnItem.FinancialAccountType                 =  abap.char'S'
  and  IncgInvcRevnItem.TransactionTypeDetermination         <> abap.char'UPF'
  and  IncgInvcRevnItem.IsAutomaticallyCreated               =  abap.char''
  and  IncgInvcRevnItem.IsUsedInPaymentTransaction           =  abap.char''
  and(
       IncgInvcRevnItem.AccountingDocumentType               =  abap.char'KR'
    or IncgInvcRevnItem.AccountingDocumentType               =  abap.char'KG'
    or IncgInvcRevnItem.AccountingDocumentType               =  abap.char'RE'
  )
  and(
       IncgInvcRevnItem._JournalEntry.AccountingDocumentType =  abap.char'KR'
    or IncgInvcRevnItem._JournalEntry.AccountingDocumentType =  abap.char'KG'
    or IncgInvcRevnItem._JournalEntry.AccountingDocumentType =  abap.char'RE'
  )
  and  IncgInvcRevnItem._JournalEntry.IsReversal             =  abap.char''
  and  IncgInvcRevnItem._CompanyCode.Country                 =  abap.char'IN'

union

select from              I_OperationalAcctgDocItem    as IncgInvcAccDocTaxItem
  left outer to one join P_Bset                       as IncgInvcTaxItem on  IncgInvcAccDocTaxItem.CompanyCode            = IncgInvcTaxItem.CompanyCode
                                                                         and IncgInvcAccDocTaxItem.AccountingDocument     = IncgInvcTaxItem.AccountingDocument
                                                                         and IncgInvcAccDocTaxItem.FiscalYear             = IncgInvcTaxItem.FiscalYear
                                                                         and IncgInvcAccDocTaxItem.TaxItemGroup           = IncgInvcTaxItem.TaxItemGroup
                                                                         and IncgInvcAccDocTaxItem.TaxItemAcctgDocItemRef = IncgInvcTaxItem.TaxItemAcctgDocItemRef

  cross join             I_IN_IncgInvcTxItmHlthChklst as IncgInvcTaxHlthChk
{
  key IncgInvcAccDocTaxItem.CompanyCode,
  key IncgInvcAccDocTaxItem.AccountingDocument,
  key IncgInvcAccDocTaxItem.FiscalYear,
  key IncgInvcAccDocTaxItem.AccountingDocumentItem,
  key IncgInvcTaxHlthChk.IN_GSTHlthChkCategory,
  key IncgInvcTaxHlthChk.IN_GSTHealthCheck,
      IncgInvcTaxHlthChk.IN_GSTHlthChkCatFldName,
      IncgInvcTaxHlthChk.IN_GSTHealthCheckCatDesc,
      IncgInvcAccDocTaxItem.DocumentDate,
      IncgInvcAccDocTaxItem.PostingDate,
      case when IncgInvcAccDocTaxItem.ReferenceDocumentType = abap.char'RMRP'
           then cast( concat( substring(IncgInvcAccDocTaxItem.OriginalReferenceDocument, 1, 10), concat('/', substring(IncgInvcAccDocTaxItem.OriginalReferenceDocument, 11, 4))) as mmiv_belnr_gjahr_no_conversion  )
           end as SupplierInvoiceWthnFiscalYear,
      IncgInvcAccDocTaxItem.IN_HSNOrSACCode,
      // TAXPS initial check

      case when IncgInvcTaxHlthChk.IN_GSTHlthChkCategory = abap.char'012'
      and IncgInvcTaxHlthChk.IN_GSTHealthCheck = abap.char'00001'
      and IncgInvcAccDocTaxItem.TaxItemAcctgDocItemRef is initial then abap.char'X'

      //TAXPS in BSET initial check

      when IncgInvcTaxHlthChk.IN_GSTHlthChkCategory = abap.char'012'
      and IncgInvcTaxHlthChk.IN_GSTHealthCheck = abap.char'00001'
      and IncgInvcAccDocTaxItem.TaxItemAcctgDocItemRef is not initial
      and  IncgInvcTaxItem .TaxItemAcctgDocItemRef is initial then abap.char'X'
      end      as IN_AcctgDocHasGSTHlthChkErr,

      // Field Value

      case when IncgInvcTaxHlthChk.IN_GSTHlthChkCategory = abap.char'012'
      then cast(IncgInvcAccDocTaxItem.TaxItemAcctgDocItemRef as abap.char(100)) //Taxps

      end      as IN_GSTHlthChkCatFldVal,

      //Error Description

      case when( IncgInvcTaxHlthChk.IN_GSTHlthChkCategory = abap.char'012')
            and IncgInvcTaxHlthChk.IN_GSTHealthCheck = abap.char'00001'
           then replace( IncgInvcTaxHlthChk.IN_GSTHealthCheckErrDesc, abap.char'&1' , IncgInvcTaxHlthChk.IN_GSTHealthCheckCatDesc )
           else IncgInvcTaxHlthChk.IN_GSTHealthCheckErrDesc
           end as IN_GSTHealthCheckErrDesc


}
where
       IncgInvcAccDocTaxItem.FinancialAccountType                 =  abap.char'S'
  and  IncgInvcAccDocTaxItem.AccountingDocumentItemType           =  abap.char'T'
  and  IncgInvcAccDocTaxItem.TransactionTypeDetermination         <> abap.char''
  and  IncgInvcAccDocTaxItem.IsAutomaticallyCreated               =  abap.char'X'
  and  IncgInvcAccDocTaxItem.IsUsedInPaymentTransaction           =  abap.char''
  and(
       IncgInvcAccDocTaxItem.AccountingDocumentType               =  abap.char'KR'
    or IncgInvcAccDocTaxItem.AccountingDocumentType               =  abap.char'KG'
    or IncgInvcAccDocTaxItem.AccountingDocumentType               =  abap.char'RE'
  )
  and(
       IncgInvcAccDocTaxItem._JournalEntry.AccountingDocumentType =  abap.char'KR'
    or IncgInvcAccDocTaxItem._JournalEntry.AccountingDocumentType =  abap.char'KG'
    or IncgInvcAccDocTaxItem._JournalEntry.AccountingDocumentType =  abap.char'RE'
  )
  and  IncgInvcAccDocTaxItem._JournalEntry.IsReversal             =  abap.char''
  and  IncgInvcAccDocTaxItem._CompanyCode.Country                 =  abap.char'IN'