How is SCM product maintenance tcode redirecting access to MARA

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://jerry.blog.csdn.net/article/details/101197207

Created by Wang, Jerry, last modified on Jan 06, 2017

You can use tcode /SAPAPO/MAT1 to maintain SCM specific attribute of a given material in S4 system.

The material is queried from SCM specific “database table”: /SAPAPO/MATKEY

This table is redirected to CDS view: P_PRDSCM_MATKEY

This CDS view is reading data from MARA:

Source code of this CDS view:

@AbapCatalog.sqlViewName: 'PrdscmMatkey'  @AbapCatalog.compiler.compareFilter: true  @AccessControl.authorizationCheck: #NOT_REQUIRED  @EndUserText.label: 'Redirect for /SAPAPO/MATKEY'  @ObjectModel.usageType.serviceQuality: #C  @ObjectModel.usageType.sizeCategory : #L  @ObjectModel.usageType.dataClass: #MASTER  @ClientHandling.type: #INHERITED  @ClientHandling.algorithm: #AUTOMATED  ////////////////////////////////////////////////////////////////////////////  define view P_Prdscm_Matkey  as  select from mara as mara  // left outer join /sapapo/tclsys _tclsys on mara.mandt = _tclsys.mandt  left outer join marm on marm.matnr = mara.matnr  and marm.meinh = mara.meins  left outer join mara as ref_mara_rmatp on mara.rmatp = ref_mara_rmatp.matnr  left outer join mara as ref_mara_satnr on mara.satnr = ref_mara_satnr.matnr  left outer join  inob  as inob on mara.scm_matid_guid22 = inob.objek  association [0..1] to E_Product as _ActiveProductExt on $projection.MATNR = _ActiveProductExt.Product  {  cast( mara.scm_matid_guid22  as /sapapo/matid preserving type) as MATID,  mara.matnr as MATNR,  cast(' ' as /sapapo/product_type preserving type) as PRODUCT_TYPE,  mara.lvorm as LVORM,  case  // when _tclsys.master_switch = 'C' then 'X'  // when _tclsys.master_switch = 'I' then '1'  when inob.klart = '300' or inob.klart = '400' or inob.klart = '230' then 'X'  end as FLAGCLASS,  cast(case  when mara.vhart is not null and mara.vhart <> '' then cast('X' as /sapapo/flgpack)  else ''  end as /sapapo/flgpack) as FLAGPACK,  mara.disst as DISST,  mara.meins as MEINS,  //map only, if MARA-ATTYP has one of the values: '00' (Single Produc), '01' (Generic Article), '02' (Variant of a Generic Article), '10' (Sales Set), '11' (Prepack), '12' (Display)  cast(case mara.attyp  when '00' then mara.attyp  when '01' then mara.attyp  when '02' then mara.attyp  when '10' then mara.attyp  when '11' then mara.attyp  when '12' then mara.attyp  else ''  end as /sapapo/attyp preserving type) as ATTYP,  mara.logunit as LOGUNIT,  mara.cwqrel as CWREL,  // map TY2TQ against MARM-TY2TQ  marm.ty2tq as TY2TQ,  mara.brgew as BRGEW,  mara.ntgew as NTGEW,  mara.gewei as GEWEI,  mara.volum as VOLUM,  mara.voleh as VOLEH,  // Calculated: True, if Shelf life duration not initial  case  when (mara.iprkz = ' ' or mara.iprkz = '1' or mara.iprkz = '2' or mara.iprkz = '3') and mara.mhdhb > 0 then 'X'  else ''  end as SHELF_LIFE_FLAG,  //Calculated: mhdhb * 240000 & IPRKZ (can be set to day, week(*7), month(*30) or year(*365))  //if result > 2399760000 then result = 2399760000  //  // -> for day: case ( mhdhb * 240000 ) > 2399760000 then SHELF_LIFE_DUR = 2399760000  // else SHELF_LIFE_DUR = mhdhb * 240000  // -> ( mhdhb * 240000 ) > 2399760000 -> case condition: mhdhb > 2399760000 / 240000 ( = 9999 )  // -> case condition iprkz ' ': mhdhb > 9999  // -> case condition iprkz '1': mhdhb > 1428,4286 -> DEC(4,0): 1428  // -> case condition iprkz '2': mhdhb > 333,3333 -> DEC(4,0): 333  // -> case condition iprkz '3': mhdhb > 27,3945 -> DEC(4,0): 27  cast(case  when mara.iprkz = ' ' and mara.mhdhb <= 9999 then mara.mhdhb * 240000  when mara.iprkz = ' ' and mara.mhdhb > 9999 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '1' and mara.mhdhb <= 1428 then mara.mhdhb * 240000 * 7  when mara.iprkz = '1' and mara.mhdhb > 1428 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '2' and mara.mhdhb <= 333 then mara.mhdhb * 240000 * 30  when mara.iprkz = '2' and mara.mhdhb > 333 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '3' and mara.mhdhb <= 27 then mara.mhdhb * 240000 * 365  when mara.iprkz = '3' and mara.mhdhb > 27 then cast( 2399760000 as abap.dec(19) )  else 0  end as /sapapo/shelf_life_dur) as SHELF_LIFE_DUR,  mara.scm_maturity_dur as MATURITY_DUR,  cast(case  when mara.iprkz = ' ' and mara.mhdrz <= 9999 then mara.mhdrz * 240000  when mara.iprkz = ' ' and mara.mhdrz > 9999 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '1' and mara.mhdrz <= 1428 then mara.mhdrz * 240000 * 7  when mara.iprkz = '1' and mara.mhdrz > 1428 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '2' and mara.mhdrz <= 333 then mara.mhdrz * 240000 * 30  when mara.iprkz = '2' and mara.mhdrz > 333 then cast( 2399760000 as abap.dec(19) )  when mara.iprkz = '3' and mara.mhdrz <= 27 then mara.mhdrz * 240000 * 365  when mara.iprkz = '3' and mara.mhdrz > 27 then cast( 2399760000 as abap.dec(19) )  else 0  end as /sapapo/shelf_life_req_min) as SHLF_LFE_REQ_MIN,  mara.scm_shlf_lfe_req_max as SHLF_LFE_REQ_MAX,  mara.mhdlp as MHDLP,  mara.iprkz as IPRKZ,  // SLED_BBD: Map 'E' to SPACE and 'B' to 'X'  case mara.sled_bbd  when 'E' then ' '  when 'B' then 'X'  else ''  end as SLED_BBD,  // Rounding Rule for Calculation of Shelf Life Expiration Date  cast(case  when mara.iprkz = ' ' or mara.rdmhd = ' ' then ' ' // no rounding  when mara.iprkz = '1' and mara.rdmhd = '-' then '1' // beginning of the week  when mara.iprkz = '1' and mara.rdmhd = '+' then '2' // end of the week  when mara.iprkz = '1' and mara.rdmhd = 'F' then '3' // beginning of the next week  when mara.iprkz = '2' and mara.rdmhd = '-' then '4' // beginning of the month  when mara.iprkz = '2' and mara.rdmhd = '+' then '5' // end of the month  when mara.iprkz = '2' and mara.rdmhd = 'F' then '6' // beginning of the next month  when mara.iprkz = '3' and mara.rdmhd = '-' then '7' // beginning of the year  when mara.iprkz = '3' and mara.rdmhd = '+' then '8' // end of the year  when mara.iprkz = '3' and mara.rdmhd = 'F' then '9' // beginning of the next year  else ' ' // no rounding  end as /scmb/mdl_sldrnd) as SLDRND,  cast('' as /sapapo/mat_char40) as ATT01,  cast('' as /sapapo/mat_char30) as ATT02,  cast('' as /sapapo/mat_char20) as ATT03,  cast('' as /sapapo/mat_char10) as ATT04,  cast('' as /sapapo/mat_char10) as ATT05,  '' as BOD_DEPLVL,  '' as EXCL_EXPEDITE,  '' as PROD_PAOOPT,  '' as RESTRICT_INVBAL,  '' as DRP_GL_STOCK,  mara.matkl as MATKL,  mara.compl as COMPL,  // STFAC cannot be set by R/3  cast('' as /sapapo/stfac) as STFAC,  mara.tragr as TRAGR,  '' as TS_SDP_USE,  mara.prdha as PRDHA,  '' as GTIN_IND,  '' as DISPLAY,  mara.herkl as HERKL,  mara.xchpf as BATCH_REQ,  '' as KITCOMP,  '' as PRDSET_IND,  mara.serial as SERIAL,  cast('' as /scmb/mdl_data_checked_by) as DATA_CHECK_BY,  cast(0 as /scmb/mdl_data_checked_at) as DATA_CHECK_AT,  mara.kosch as KOSCH,  cast('' as /sapapo/kosch_grp) as KOSCH_GRP,  cast('' as /sapapo/vmikosch) as VMIKOSCH,  cast('' as /sapapo/vmikosch_grp) as VMIKOSCH_GRP,  mara.magrv as PACKGR,  //  //cast(rmatp as /SAPAPO/RMATID) as RMATP,  //rmatp as RMATP,  cast(ref_mara_rmatp.scm_matid_guid22 as /sapapo/rmatid) as RMATP,  mara.hutyp_dflt as HUTYP_DFLT,  mara.cuobf as CUOBJ,  cast(ref_mara_satnr.scm_matid_guid22 as /sapapo/satid) as SATID,  mara.kzkfg as KZKFG,  cast('' as /sapapo/matvers_head) as MATVERS_HEAD,  // remover by I321042  '' as MATVERS_TYPE,  cast( '' as /sapapo/aennr ) as MATVERS_CHNR,  cast('' as /sapapo/temprpblock) as TEMPRPBLOCK,  cast(0 as /sapapo/temprpfrom) as TEMPRPFROM,  cast(0 as /sapapo/temprpto) as TEMPRPTO,  mara.dummy_prd_incl_eew_ps,  cast('' as /sapapo/likeid) as LIKEID,  cast('' as abap.dats) as PHIN_FROM,  cast('' as abap.dats) as PHIN_TO,  cast('' as abap.char(22)) as PHIN_TSID,  cast('' as abap.dats) as PHOUT_FROM,  cast('' as abap.dats) as PHOUT_TO,  cast('' as abap.char(22)) as PHOUT_TSID,  cast('' as abap.char(22)) as LIFE_CYCLE_LOCID,  mara.ernam as CREATEUSER,  // siehe https://ldcialx.wdf.sap.corp:44318/sap/public/bc/abap/docu?format=standard&object=abencds_f1_cast_expression&sap-language=DE&sap-client=000  // direct cast from DATS to DEC not possible, but cast from DATS to CHAR, from CHAR to NUMC and from NUMC to DEC is possible (concat makes cast from DATS to CHAR)  cast( cast( concat( mara.ersda, '000000') as abap.numc(15) ) as /sapapo/tsucr) as CREATEUTC,  mara.aenam as CHANGEUSER,  cast( cast( concat( mara.laeda, '000000') as abap.numc(15) ) as /sapapo/tsuup) as CHANGEUTC  }  where  mara.scm_matid_guid22 <> '0'  and mara.scm_matid_guid22 <> ''