Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am Extracting SAP ERP Tables but some of the Tables are taking 15-20 hours like SAP BSEG Table , But i need to reduce it to
less than 10 Hrs, Since my user is Accessing Application on Daily wise. We have connected to SAP ERP system through Connectors
and we are creating QVD's using QVD Generator.Please let me know how to achieve it
Tables such as BSEG need incremental loads using the BKPF table.
You can also reduce the amount of fields you are loading by commenting out fields you don't require.
Here is an example of the incremental I am using, it loads only new data from SAP, loads the existing data from QVD, concatenates it together and saves it all back to QVD;
//Load BSEG qvd Date and Time
BSEG_Incremental:
Load
CPUDT,
CPUTM
FROM
[..\04_QVD\01_Extract\BKPF.qvd]
(qvd);
///Find Max BKPT Date from the existing QVD
BKPT_DateLookup:
LOAD
Date(Max(CPUDT), 'YYYYMMDD') as CPUDT
Resident BSEG_Incremental;
//
//Save to Variable
Let vBSEGIncrementalDate = Date(Peek('CPUDT',0,'BKPT_DateLookup'), 'YYYYMMDD');
Let vReloadTime = Date(Today(), 'DD/MM/YYYY');
Drop Table BSEG_Incremental;
Drop Table BKPT_DateLookup;
[BKPF]:
Load *, BUKRS &'_'& BELNR &'_'& GJAHR as BKPFKey;
SELECT MANDT, // Client
BUKRS, // CoCode
BELNR, // DocumentNo
GJAHR, // Fiscal Yr
BLART, // Type
BLDAT, // Doc. Date
BUDAT, // Pstng Date
MONAT, // Period
CPUDT, // Entered
CPUTM, // Time
AEDAT, // Changed
UPDDT, // Last updte
WWERT, // TranslDate
USNAM, // User
TCODE, // TCode
XBLNR, // Reference
BKTXT, // HeaderText
WAERS, // Currency
GLVOR, // Transactn
AWTYP,
AWKEY,
HWAER,
STGRD,
PPNAM,
BRNCH
FROM BKPF
WHERE CPUDT >= '$(vBSEGIncrementalDate)'
or AEDAT >= '$(vBSEGIncrementalDate)';
Concatenate
LOAD
MANDT, // Client
BUKRS, // CoCode
BELNR, // DocumentNo
GJAHR, // Fiscal Yr
BLART, // Type
BLDAT, // Doc. Date
BUDAT, // Pstng Date
MONAT, // Period
CPUDT, // Entered
CPUTM, // Time
AEDAT, // Changed
UPDDT, // Last updte
WWERT, // TranslDate
USNAM, // User
TCODE, // TCode
XBLNR, // Reference
BKTXT, // HeaderText
WAERS, // Currency
GLVOR, // Transactn
AWTYP,
AWKEY,
HWAER,
STGRD,
PPNAM,
BRNCH
FROM
[..\04_QVD\01_Extract\BKPF.qvd]
(qvd)
Where not Exists(BKPFKey, BKPFKey);
STORE * FROM [BKPF] INTO [..\04_QVD\01_Extract\BKPF.qvd];
DROP TABLE [BKPF];
Trace;
Trace '***************BSEG***************';
Trace;
//Load BSEG using the date and time from the QVD
[BSEG]:
Load *, BUKRS &'_'& BELNR &'_'& GJAHR &'_'& BUZEI as BSEGKey;
SQL
SUBSELECT MANDT, // Client
BUKRS, // CoCode
BELNR, // DocumentNo
GJAHR, // Fiscal Yr
BUZEI, // Item
BUZID, // Item ID
AUGDT, // Clearing
AUGCP, // ClgEntDate
AUGBL, // Clrng Doc
// BSCHL, // PostKey
KOART, // Acct Type
// UMSKZ, // SGL Ind.
// UMSKS, // SpG/L
// ZUMSK, // Trg.sp.G/L
SHKZG, // D/C indic.
// GSBER, // Bus. Area
// PARGB, // Tr.Part.BA
MWSKZ, // Tax code
// QSSKZ, // W.Tax Code
DMBTR, // Amount LC
// WRBTR, // Amount
// KZBTR, // Org.rdctn
// PSWBT, // G/L amount
// PSWSL, // Currency
// TXBHW, // Original Tax Base Am
// TXBFW, // Original Tax Base Am
// MWSTS, // LC tax
// WMWST, // Tax
// HWBAS, // LC bas.amt
// FWBAS, // Base amnt
// HWZUZ, // LC prov.
// FWZUZ, // Addit.tax
// SHZUZ, // Debit/Credit Additio
// STEKZ, // Version Number Compo
// MWART, // Tax type
// TXGRP, // Group
// KTOSL, // Trans.
// QSSHB, // W.tax base
// KURSR, // Hedged ex.rt
// GBETR, // Hedged
// BDIFF, // Val.diff.
// BDIF2, // Val.diff.2
VALUT, // Value Date
ZUONR, // Assign.
SGTXT, // Text
// ZINKZ, // Int.Block
// VBUND, // Tradg Part
// BEWAR, // Trans.Type
// ALTKT, // Group Acct
// VORGN, // Trans.type
// FDLEV, // Plan. Lvl
// FDGRP, // Plan. grp
// FDWBT, // Amount
// FDTAG, // Plan. Date
// FKONT, // Fin.bud.im
KOKRS, // CO Area
KOSTL, // Cost Ctr
PROJN, // not in use
AUFNR, // Order
VBELN, // Bill.Doc.
VBEL2, // Sales Doc.
POSN2, // Item
// ETEN2, // Schd. Line
// ANLN1, // Asset
// ANLN2, // Subnumber
// ANBWA, // Trans.type
// BZDAT, // AsstValDat
// PERNR, // Pers.No.
// XUMSW, // Sales-Related
// XHRES, // Indicator: Resident
// XKRES, // Line items
// XOPVW, // OI Mgmt
// XCPDD, // Individ. Set
// XSKST, // CCtr Stat.
// XSAUF, // OrderStat.
// XSPRO, // ProjStat
// XSERG, // PA Stat
// XFAKT, // Indicator: Billing D
// XUMAN, // Indicator: Transfer
// XANET, // Indicator: Down Paym
// XSKRL, // WD
// XINVE, // Invest.ID
// XPANZ, // Disp. Item
// XAUTO, // Auto.Creat
// XNCOP, // Indicator: Items Can
// XZAHL, // Tr
// SAKNR, // G/L acct
HKONT, // G/L Acc
KUNNR, // Customer
LIFNR, // Vendor
FILKD, // Branch
XBILK, // B/S Acct
GVTYP, // P&L Acct
// HZUON, // Sp.G/L ass
ZFBDT, // Bline Date
ZTERM, // Payt Terms
// ZBD1T, // Day 1
// ZBD2T, // Day 2
// ZBD3T, // Days net
// ZBD1P, // Discount %
// ZBD2P, // Discount 2
// SKFBT, // Disc.base
// SKNTO, // Disc. Amnt
// WSKTO, // CashDiscnt
// ZLSCH, // Pmt Method
// ZLSPR, // Pmnt Block
// ZBFIX, // Fixed
// HBKID, // House Bank
// BVTYP, // Part. Bank
// NEBTR, // Payment Amnt
// MWSK1, // Tax code
// DMBT1, // Amount
// WRBT1, // Amount
// MWSK2, // Tax code
// DMBT2, // Amount
// WRBT2, // Amount
// MWSK3, // Tax code
// DMBT3, // Amount
// WRBT3, // Amount
// REBZG, // Inv.ref.
// REBZJ, // Year
// REBZZ, // Item
// REBZT, // Type
// ZOLLT, // Cust.tariff no.
// ZOLLD, // Customs date
// LZBKZ, // SCB Ind.
// LANDL, // Suppl.Ctry
// DIEKZ, // Serv. Ind.
// SAMNR, // Collct.inv
// ABPER, // Settl.Per.
// VRSKZ, // Insur.Ind.
// VRSDT, // Insur.Date
// DISBN, // Usage
// DISBJ, // Year
// DISBZ, // Line item
// WVERW, // Usage
// ANFBN, // B/e pmt rq
// ANFBJ, // Fiscal yr
// ANFBU, // Company code
// ANFAE, // Return bef.
// BLNBT, // Pref.amnt
// BLNKZ, // Subs.ind.
// BLNPZ, // Pref.%rate
// MSCHL, // Dunn. Key
// MANSP, // Dunn.Block
// MADAT, // DunnDate
// MANST, // Dunn.Level
// MABER, // Dunn.area
// ESRNR, // ISR No.
// ESRRE, // ISR Ref.
// ESRPZ, // ChkDg
// KLIBT, // Cred. ctrl amnt
// QSZNR, // Exempt.no.
// QBSHB, // Wi.tax amt
// QSFBT, // W.tax expt
// NAVHW, // Nondeduct.
// NAVFW, // Nondeductible
MATNR, // Material
WERKS, // Plant
MENGE, // Quantity
MEINS, // Unit
// ERFMG, // Qty in UnE
// ERFME, // Entry Unit
// BPMNG, // Qty OPUn
// BPRME, // OPUn
EBELN, // Purch.Doc.
EBELP, // Item
// ZEKKN, // SqNoAccAss
// ELIKZ, // Del. Cmpl.
// VPRSV, // Price Ctrl
// PEINH, // Price Unit
// BWKEY, // Val. Area
// BWTAR, // Val. Type
// BUSTW, // Value Str.
// REWRT, // Inv. Value
// REWWR, // Inv. Value
// BONFB, // Amount Qualifying fo
// BUALT, // Amount
// PSALT, // Alt. price
// NPREI, // New Price
// TBTKZ, // Sub. Dr/Cr
// SPGRP, // BlockR Pr.
// SPGRM, // BlockR:Qty
// SPGRT, // BlockR Dte
// SPGRG, // Block: OPQ
// SPGRV, // BlockRProj
// SPGRQ, // Man.Block.
// STCEG, // VAT Reg.No
// EGBLD, // Dest.cntry
// EGLLD, // Suppl.cnty
// RSTGR, // Reason cde
// RYACQ, // Yr of acq.
// RPACQ, // Per.of Acq
// RDIFF, // Diff.real.
// RDIF2, // RealDiff2
PRCTR, // Profit Ctr
// XHKOM, // Manual G/L Acct
// VNAME, // Venture
// RECID, // Rec.Indic.
// EGRUP, // Equity Grp
// VPTNR, // Partner
// VERTT, // Cont.Type
// VERTN, // Contract
// VBEWA, // Flow Type
// DEPOT, // Sec. Acct
// TXJCD, // Tax Jur.
// IMKEY, // RE Key
// DABRZ, // Ref. Date
// POPTS, // Option Rte
// FIPOS, // Cmmt Item
// KSTRG, // CostObject
// NPLNR, // Network
// AUFPL, // TaskListNo
// APLZL, // Counter
PROJK, // WBS Elem.
PAOBJNR, // Prof.Segmt
// PASUBNR, // Subnumber
// SPGRS, // BR Amount
// SPGRC, // Block:Qlty
// BTYPE, // BillngInd.
// ETYPE, // Equity Ty.
// XEGDR, // Tri.deal
// LNRAN, // Seq.Number
// HRKFT, // Orig.group
// DMBE2, // LC2 amount
// DMBE3, // LC3 amount
// DMB21, // Amount
// DMB22, // Amount
// DMB23, // Amount
// DMB31, // Amount
// DMB32, // Amount
// DMB33, // Amount
// MWST2, // LC2 tax
// MWST3, // LC3 tax
// NAVH2, // Nondeduct.
// NAVH3, // Nondeduct.
// SKNT2, // LC2 disc.
// SKNT3, // LC3 disc.
// BDIF3, // Val.diff.
// RDIF3, // Diff.real.
// HWMET, // Method with Which th
// GLUPM, // Update
// XRAGL, // Indicator: Clearing
// UZAWE, // PmtMthSupl
// LOKKT, // Alt. Acct
// FISTL, // Funds Ctr
// GEBER, // Fund
// STBUK, // CoCde
// TXBH2, // Tax Base/Original Ta
// TXBH3, // Tax Base/Original Ta
// PPRCT, // Partner PC
// XREF1, // Ref. Key 1
// XREF2, // Ref. Key 2
// KBLNR, // Earmd Fnds
// KBLPOS, // Doc. item
// STTAX, // Stat. Tax
// FKBER, // Func. Area
// OBZEI, // Orig.item
// XNEGP, // Neg.postng
// RFZEI, // PmtCrdItem
// CCBTC, // Settlement
// KKBER, // CreditArea
// EMPFB, // Payer
// XREF3, // Ref. Key 3
// DTWS1, // Inst.Key 1
// DTWS2, // IK2
// DTWS3, // IK3
// DTWS4, // IK4
// GRICD, // Activity
// GRIRG, // Region
// GITYP, // Distribut.
// XPYPR, // Pymnt.sent
// KIDNO, // Paymt ref.
// ABSBT, // HedgedAmnt
// IDXSP, // Index
// LINFV, // Last Adj.
// KONTT, // AcctAssCat
// KONTL, // Acct Asst
// TXDAT, // Tax Date
// AGZEI, // ClrngItm
// PYCUR, // PmntCurrcy
// PYAMT, // Pmnt/c amt
// BUPLA, // Bus. Pl.
// SECCO, // Sect. Code
// LSTAR, // Acty Type
// CESSION_KZ, // AR pledg.
// PRZNR, // BusProcess
// PPDIFF, // Diff.real.
// PPDIF2, // Diff.real.
// PPDIF3, // Diff.real.
// PENLC1, // Pen.Charge
// PENLC2, // Pen.Charge
// PENLC3, // Pen.Charge
// PENFC, // Pen.Charge
// PENDAYS, // Days
// PENRC, // Reason
// GRANT_NBR, // Grant
// SCTAX, // TaxPortion
// FKBER_LONG, // Func. Area
// GMVKZ, // Execution
// SRTYPE, // Add.Rcvbls
// INTRENO, // RE code
// MEASURE, // Funded Prg
// AUGGJ, // Fisc. Year
// PPA_EX_IND, // PPA Excl.
// DOCLN, // Line Item
// SEGMENT, // Segment
// PSEGMENT, // Ptnr Segm.
// PFKBER, // Part.FArea
// HKTID, // Account ID
KSTAR, // Cost Elem.
// XLGCLR, // LG-SpecClg
// TAXPS, // Tax item
// PAYS_PROV, // PSP
// PAYS_TRAN, // PSP PayRef
// MNDID, // Mand.Ref.
// XFRGE_BSEG, // Released
// PGEBER, // PartFund
// PGRANT_NBR, // Prtnr Grnt
// BUDGET_PD, // BP
// PBUDGET_PD, // P.BP
// PEROP_BEG, // Start Date
// PEROP_END, // End Date
// FASTPAY, // Fast Pay
// IGNR_IVREF, // Ignore Inv
// FMFGUS_KEY, // US Govt
// FMXDOCNR, // FM Rf. Doc
// FMXYEAR, // FM Rf. Yr.
// FMXDOCLN, // FM Rf. It.
// FMXZEKKN, // FM Rf. AA.
// PRODPER // Prod.Month
FROM BSEG
WHERE BUKRS GJAHR BELNR IN (SELECT BUKRS GJAHR BELNR FROM BKPF WHERE CPUDT >= '$(vBSEGIncrementalDate)'
or AEDAT >= '$(vBSEGIncrementalDate)') ;
Concatenate
LOAD BSEGKey,
MANDT, // Client
BUKRS, // CoCode
BELNR, // DocumentNo
GJAHR, // Fiscal Yr
BUZEI, // Item
BUZID, // Item ID
AUGDT, // Clearing
AUGCP, // ClgEntDate
AUGBL, // Clrng Doc
KOART, // Acct Type
SHKZG, // D/C indic.
MWSKZ, // Tax code
DMBTR, // Amount LC
VALUT, // Value Date
ZUONR, // Assign.
SGTXT, // Text
KOKRS, // CO Area
KOSTL, // Cost Ctr
PROJN, // not in use
AUFNR, // Order
VBELN, // Bill.Doc.
VBEL2, // Sales Doc.
POSN2, // Item
HKONT, // G/L Acc
KUNNR, // Customer
LIFNR, // Vendor
FILKD, // Branch
XBILK, // B/S Acct
GVTYP, // P&L Acct
ZFBDT, // Bline Date
ZTERM, // Payt Terms
MATNR, // Material
WERKS, // Plant
MENGE, // Quantity
MEINS, // Unit
EBELN, // Purch.Doc.
EBELP, // Item
PRCTR, // Profit Ctr
PROJK, // WBS Elem.
PAOBJNR, // Prof.Segmt
KSTAR // Cost Elem.
FROM
[..\04_QVD\01_Extract\BSEG.qvd]
(qvd)
Where not Exists(BSEGKey, BSEGKey);
STORE * FROM [BSEG] INTO [..\04_QVD\01_Extract\BSEG.qvd];
DROP TABLE [BSEG];