Example to Extract Data from SAP: Difference between revisions
m (Ollvihe moved page Extract Data from SAP to Example Script to Extract Data from SAP without leaving a redirect) |
No edit summary |
||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This page | This page contains an example script to extract data from SAP and load into QPR ProcessAnalyzer. This example uses the [[SQL_Scripting_for_ETL|SQL scripting]] and thus the script runs as the QPR ProcessAnalyzer script (not in the Snowflake). As a result, the extracted data is stored into QPR ProcessAnalyzer to tables that can be called ''staging tables''. The data for the staging tables can be located in the Snowflake. After this script is completed, the next step is to [[Example_to_Transform_SAP_Data_into_Eventlog_in_Snowflake|transform the staged data into the eventlogs]] used by the QPR ProcessAnalyzer models. | ||
Sometimes, when using the RFC interface, it's not possible to get all required data in | Sometimes, when using the RFC interface, it's not possible to get all the required data in a single query due to the limitations of the RCF interface. As a workaround, several queries need to be made where each query has a different filter to get a slice of the entire data. For example, date ranges can be used limit how much data one query returns. | ||
< | The example script defines a temporary table ''#SAP_Parameters'' that contains the common SAP query related parameters used in all the queries, to avoid repeating the common values. In addition, each query adds its own query specific parameters to the common parameters. There is also a temporary table ''#SapWhereClauseTable'' containing parameters for the SAP query where clause. | ||
The actual extractions from SAP are performed by the[[SQL_Scripting_Commands#--.23ImportSapQuery|--#ImportSapQuery]] command. | |||
<syntaxhighlight lang="typescript" line> | |||
----------------------------------- | ----------------------------------- | ||
-- Adjust SAP extraction parameters | -- Adjust SAP extraction parameters | ||
----------------------------------- | ----------------------------------- | ||
IF OBJECT_ID ('tempdb..#SAP_Parameters') IS NULL | IF OBJECT_ID ('tempdb..#SAP_Parameters') IS NULL | ||
BEGIN | BEGIN | ||
Line 13: | Line 15: | ||
END | END | ||
TRUNCATE TABLE #SAP_Parameters; | TRUNCATE TABLE #SAP_Parameters; | ||
INSERT INTO #SAP_Parameters | INSERT INTO #SAP_Parameters | ||
SELECT 'SapSystemID', 'PR1' UNION ALL | SELECT 'SapSystemID', 'PR1' UNION ALL | ||
SELECT 'SapMessageServerHost', '<hostname>' UNION ALL | SELECT 'SapMessageServerHost', '<hostname>' UNION ALL | ||
Line 40: | Line 39: | ||
--T001: keeping this here as a first small test, even if it has been already extracted | --T001: keeping this here as a first small test, even if it has been already extracted | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T001' UNION ALL | SELECT 'SapQueryTable', 'T001' UNION ALL | ||
Line 48: | Line 47: | ||
SELECT 'SapRowcount', '0' | SELECT 'SapRowcount', '0' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
----------- | ----------- | ||
--T163F | --T163F | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T163F' UNION ALL | SELECT 'SapQueryTable', 'T163F' UNION ALL | ||
SELECT 'DataTableName', 'T163F' UNION ALL | SELECT 'DataTableName', 'T163F' UNION ALL | ||
SELECT 'SapFieldNames', 'EBTYP,EBTXT,SPRAS' UNION ALL | SELECT 'SapFieldNames', 'EBTYP,EBTXT,SPRAS' UNION ALL | ||
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' | SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL | ||
SELECT 'SapRowskips', '0' UNION ALL | SELECT 'SapRowskips', '0' UNION ALL | ||
SELECT 'SapRowcount', '0' | SELECT 'SapRowcount', '0' | ||
Line 67: | Line 64: | ||
--T008T | --T008T | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T008T' UNION ALL | SELECT 'SapQueryTable', 'T008T' UNION ALL | ||
SELECT 'DataTableName', 'T008T' UNION ALL | SELECT 'DataTableName', 'T008T' UNION ALL | ||
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' | SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL | ||
SELECT 'SapFieldNames', 'SPRAS,ZAHLS,TEXTL' | SELECT 'SapFieldNames', 'SPRAS,ZAHLS,TEXTL' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 78: | Line 75: | ||
--T077Y | --T077Y | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T077Y' UNION ALL | SELECT 'SapQueryTable', 'T077Y' UNION ALL | ||
SELECT 'DataTableName', 'T077Y' UNION ALL | SELECT 'DataTableName', 'T077Y' UNION ALL | ||
SELECT 'SapFieldNames', 'SPRAS,KTOKK,TXT30' UNION ALL | SELECT 'SapFieldNames', 'SPRAS,KTOKK,TXT30' UNION ALL | ||
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' | SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL | ||
SELECT 'SapRowskips', '0' UNION ALL | SELECT 'SapRowskips', '0' UNION ALL | ||
SELECT 'SapRowcount', '0' | SELECT 'SapRowcount', '0' | ||
Line 91: | Line 88: | ||
--T024E | --T024E | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T024E' UNION ALL | SELECT 'SapQueryTable', 'T024E' UNION ALL | ||
Line 103: | Line 100: | ||
--T161T | --T161T | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T161T' UNION ALL | SELECT 'SapQueryTable', 'T161T' UNION ALL | ||
SELECT 'DataTableName', 'T161T' UNION ALL | SELECT 'DataTableName', 'T161T' UNION ALL | ||
SELECT 'SapFieldNames', 'BSART,BSTYP,BATXT,SPRAS' UNION ALL | SELECT 'SapFieldNames', 'BSART,BSTYP,BATXT,SPRAS' UNION ALL | ||
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' | SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL | ||
SELECT 'SapRowskips', '0' UNION ALL | SELECT 'SapRowskips', '0' UNION ALL | ||
SELECT 'SapRowcount', '0' | SELECT 'SapRowcount', '0' | ||
Line 116: | Line 113: | ||
--T052 | --T052 | ||
--------------- | --------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T052' UNION ALL | SELECT 'SapQueryTable', 'T052' UNION ALL | ||
Line 126: | Line 123: | ||
--T052U | --T052U | ||
--------------- | --------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T052U' UNION ALL | SELECT 'SapQueryTable', 'T052U' UNION ALL | ||
Line 137: | Line 134: | ||
--T003T | --T003T | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T003T' UNION ALL | SELECT 'SapQueryTable', 'T003T' UNION ALL | ||
Line 150: | Line 147: | ||
--T005T | --T005T | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T005T' UNION ALL | SELECT 'SapQueryTable', 'T005T' UNION ALL | ||
Line 163: | Line 160: | ||
--T024 | --T024 | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'T024' UNION ALL | SELECT 'SapQueryTable', 'T024' UNION ALL | ||
Line 175: | Line 172: | ||
--USR02 | --USR02 | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'USR02' UNION ALL | SELECT 'SapQueryTable', 'USR02' UNION ALL | ||
Line 187: | Line 184: | ||
--V_USR_NAME | --V_USR_NAME | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'V_USR_NAME' UNION ALL | SELECT 'SapQueryTable', 'V_USR_NAME' UNION ALL | ||
Line 199: | Line 196: | ||
--LFA1 | --LFA1 | ||
----------- | ----------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'LFA1' UNION ALL | SELECT 'SapQueryTable', 'LFA1' UNION ALL | ||
Line 211: | Line 208: | ||
--DD04T | --DD04T | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'DD04T' UNION ALL | SELECT 'SapQueryTable', 'DD04T' UNION ALL | ||
Line 222: | Line 219: | ||
-- Main tables | -- Main tables | ||
------------------------------- | ------------------------------- | ||
----------------------------- | ----------------------------- | ||
-- PO Tables | -- PO Tables | ||
Line 233: | Line 226: | ||
--EKKO | --EKKO | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'EKKO' UNION ALL | SELECT 'SapQueryTable', 'EKKO' UNION ALL | ||
Line 239: | Line 232: | ||
SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL | SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL | ||
SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`' | SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKKO' UNION ALL | SELECT 'SapQueryTable', 'EKKO' UNION ALL | ||
Line 246: | Line 240: | ||
SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL | SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL | ||
SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`' | SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKKO' UNION ALL | SELECT 'SapQueryTable', 'EKKO' UNION ALL | ||
Line 254: | Line 249: | ||
SELECT 'SapWhereClause', 'AEDAT GE `20230101`' | SELECT 'SapWhereClause', 'AEDAT GE `20230101`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
-------------------------- | -------------------------- | ||
--EKPO | --EKPO | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'EKPO' UNION ALL | SELECT 'SapQueryTable', 'EKPO' UNION ALL | ||
Line 263: | Line 259: | ||
SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL | SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL | ||
SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`' | SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKPO' UNION ALL | SELECT 'SapQueryTable', 'EKPO' UNION ALL | ||
Line 270: | Line 267: | ||
SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL | SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL | ||
SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`' | SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKPO' UNION ALL | SELECT 'SapQueryTable', 'EKPO' UNION ALL | ||
Line 278: | Line 276: | ||
SELECT 'SapWhereClause', 'AEDAT GE `20230101`' | SELECT 'SapWhereClause', 'AEDAT GE `20230101`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
-------------------------- | -------------------------- | ||
--EBAN | --EBAN | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'EBAN' UNION ALL | SELECT 'SapQueryTable', 'EBAN' UNION ALL | ||
Line 287: | Line 286: | ||
SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL | SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL | ||
SELECT 'SapWhereClause', 'BADAT GE `20210101` AND BADAT LE `20211231`' | SELECT 'SapWhereClause', 'BADAT GE `20210101` AND BADAT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EBAN' UNION ALL | SELECT 'SapQueryTable', 'EBAN' UNION ALL | ||
Line 294: | Line 294: | ||
SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL | SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL | ||
SELECT 'SapWhereClause', 'BADAT GE `20220101` AND BADAT LE `20221231`' | SELECT 'SapWhereClause', 'BADAT GE `20220101` AND BADAT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EBAN' UNION ALL | SELECT 'SapQueryTable', 'EBAN' UNION ALL | ||
Line 302: | Line 303: | ||
SELECT 'SapWhereClause', 'BADAT GE `20230101`' | SELECT 'SapWhereClause', 'BADAT GE `20230101`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
-------------------------- | -------------------------- | ||
--EKES | --EKES | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'EKES' UNION ALL | SELECT 'SapQueryTable', 'EKES' UNION ALL | ||
Line 312: | Line 314: | ||
SELECT 'SapWhereClause', 'ERDAT GE `20210101` AND ERDAT LE `20211231`' | SELECT 'SapWhereClause', 'ERDAT GE `20210101` AND ERDAT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKES' UNION ALL | SELECT 'SapQueryTable', 'EKES' UNION ALL | ||
Line 319: | Line 322: | ||
SELECT 'SapWhereClause', 'ERDAT GE `20220101` AND ERDAT LE `20221231`' | SELECT 'SapWhereClause', 'ERDAT GE `20220101` AND ERDAT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKES' UNION ALL | SELECT 'SapQueryTable', 'EKES' UNION ALL | ||
Line 326: | Line 330: | ||
SELECT 'SapWhereClause', 'ERDAT GE `20220101`' | SELECT 'SapWhereClause', 'ERDAT GE `20220101`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
-------------------------- | -------------------------- | ||
--EKBE == PO HISTORY | --EKBE == PO HISTORY | ||
-------------------------- | -------------------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'EKBE' UNION ALL | SELECT 'SapQueryTable', 'EKBE' UNION ALL | ||
Line 336: | Line 341: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20210601`' | SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20210601`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKBE' UNION ALL | SELECT 'SapQueryTable', 'EKBE' UNION ALL | ||
Line 343: | Line 349: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20210601` and CPUDT LE `20211231`' | SELECT 'SapWhereClause', 'CPUDT GE `20210601` and CPUDT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKBE' UNION ALL | SELECT 'SapQueryTable', 'EKBE' UNION ALL | ||
Line 350: | Line 357: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20220601`' | SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20220601`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKBE' UNION ALL | SELECT 'SapQueryTable', 'EKBE' UNION ALL | ||
Line 357: | Line 365: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20220601` and CPUDT LE `20221231`' | SELECT 'SapWhereClause', 'CPUDT GE `20220601` and CPUDT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'EKBE' UNION ALL | SELECT 'SapQueryTable', 'EKBE' UNION ALL | ||
Line 368: | Line 377: | ||
-- Billing docs | -- Billing docs | ||
--------------------- | --------------------- | ||
--------------- | --------------- | ||
--RBKP | --RBKP | ||
--------------- | --------------- | ||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT * | |||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'RBKP' UNION ALL | SELECT 'SapQueryTable', 'RBKP' UNION ALL | ||
Line 381: | Line 387: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20211231`' | SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20211231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'RBKP' UNION ALL | SELECT 'SapQueryTable', 'RBKP' UNION ALL | ||
Line 388: | Line 395: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20221231`' | SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20221231`' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'RBKP' UNION ALL | SELECT 'SapQueryTable', 'RBKP' UNION ALL | ||
Line 395: | Line 403: | ||
SELECT 'SapWhereClause', 'CPUDT GE `20230101` ' | SELECT 'SapWhereClause', 'CPUDT GE `20230101` ' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
--------------- | --------------- | ||
--RSEG | --RSEG | ||
--------------- | --------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'RSEG' UNION ALL | SELECT 'SapQueryTable', 'RSEG' UNION ALL | ||
Line 405: | Line 414: | ||
SELECT 'SapWhereClause', '(GJAHR EQ `2021`)' | SELECT 'SapWhereClause', '(GJAHR EQ `2021`)' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'RSEG' UNION ALL | SELECT 'SapQueryTable', 'RSEG' UNION ALL | ||
Line 412: | Line 422: | ||
SELECT 'SapWhereClause', '(GJAHR EQ `2022`)' | SELECT 'SapWhereClause', '(GJAHR EQ `2022`)' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
SELECT * | |||
SELECT * FROM #SAP_parameters UNION ALL | |||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'RSEG' UNION ALL | SELECT 'SapQueryTable', 'RSEG' UNION ALL | ||
Line 429: | Line 440: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'BKPF' UNION ALL | SELECT 'SapQueryTable', 'BKPF' UNION ALL | ||
SELECT 'DataTableName', 'BKPF' UNION ALL | SELECT 'DataTableName', 'BKPF' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 442: | Line 453: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'BKPF' UNION ALL | SELECT 'SapQueryTable', 'BKPF' UNION ALL | ||
SELECT 'DataTableName', 'BKPF' UNION ALL | SELECT 'DataTableName', 'BKPF' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 455: | Line 466: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'BKPF' UNION ALL | SELECT 'SapQueryTable', 'BKPF' UNION ALL | ||
SELECT 'DataTableName', 'BKPF' UNION ALL | SELECT 'DataTableName', 'BKPF' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
--------------- | --------------- | ||
Line 472: | Line 482: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', 'FALSE' UNION ALL | SELECT 'Append', 'FALSE' UNION ALL | ||
SELECT 'SapQueryTable', 'BSAK' UNION ALL | SELECT 'SapQueryTable', 'BSAK' UNION ALL | ||
SELECT 'DataTableName', 'BSAK' UNION ALL | SELECT 'DataTableName', 'BSAK' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 485: | Line 495: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', 'TRUE' UNION ALL | SELECT 'Append', 'TRUE' UNION ALL | ||
SELECT 'SapQueryTable', 'BSAK' UNION ALL | SELECT 'SapQueryTable', 'BSAK' UNION ALL | ||
SELECT 'DataTableName', 'BSAK' UNION ALL | SELECT 'DataTableName', 'BSAK' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 498: | Line 508: | ||
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2 | ||
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3 ; | INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3; | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', 'TRUE' UNION ALL | SELECT 'Append', 'TRUE' UNION ALL | ||
SELECT 'SapQueryTable', 'BSAK' UNION ALL | SELECT 'SapQueryTable', 'BSAK' UNION ALL | ||
SELECT 'DataTableName', 'BSAK' UNION ALL | SELECT 'DataTableName', 'BSAK' UNION ALL | ||
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 521: | Line 531: | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 635: | Line 644: | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 713: | Line 722: | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 751: | Line 760: | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 763: | Line 772: | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 864: | Line 873: | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2 ; | INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2; | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'Append', '1' UNION ALL | SELECT 'Append', '1' UNION ALL | ||
SELECT 'SapQueryTable', 'CDHDR' UNION ALL | SELECT 'SapQueryTable', 'CDHDR' UNION ALL | ||
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL | ||
SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 978: | Line 988: | ||
---------------- | ---------------- | ||
(SELECT 'AnalysisType', '18') UNION ALL | (SELECT 'AnalysisType', '18') UNION ALL | ||
(SELECT 'ProjectId', ( | (SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL | ||
(SELECT 'MaximumCount', '0') UNION ALL | (SELECT 'MaximumCount', '0') UNION ALL | ||
(SELECT 'DataTableName', 'CDHDR_EINKBELEG') UNION ALL | (SELECT 'DataTableName', 'CDHDR_EINKBELEG') UNION ALL | ||
(SELECT 'TargetTable', '#CDHDR') | (SELECT 'TargetTable', '#CDHDR') | ||
--#GetAnalysis | --#GetAnalysis | ||
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | ||
INSERT INTO #CDPOS_Parameters | INSERT INTO #CDPOS_Parameters | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'SapQueryTable', 'CDPOS' UNION ALL | SELECT 'SapQueryTable', 'CDPOS' UNION ALL | ||
SELECT 'SapRowcount', '0' UNION ALL | SELECT 'SapRowcount', '0' UNION ALL | ||
Line 994: | Line 1,002: | ||
SELECT 'DataTableName', 'CDPOS_EINKBELEG' UNION ALL | SELECT 'DataTableName', 'CDPOS_EINKBELEG' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + | INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR | ||
SELECT * | SELECT * FROM #CDPOS_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DROP TABLE #SapWhereClauseTable; | |||
DROP TABLE #CDPOS_Parameters; | |||
DROP TABLE #CDHDR; | |||
---------------- | ---------------- | ||
Line 1,012: | Line 1,018: | ||
---------------- | ---------------- | ||
(SELECT 'AnalysisType', '18') UNION ALL | (SELECT 'AnalysisType', '18') UNION ALL | ||
(SELECT 'ProjectId', ( | (SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL | ||
(SELECT 'MaximumCount', '0') UNION ALL | (SELECT 'MaximumCount', '0') UNION ALL | ||
(SELECT 'DataTableName', 'CDHDR_BANF') UNION ALL | (SELECT 'DataTableName', 'CDHDR_BANF') UNION ALL | ||
Line 1,018: | Line 1,024: | ||
--#GetAnalysis | --#GetAnalysis | ||
CREATE TABLE #SapWhereClauseTable (sap_select_string varchar(255),order_number int) | CREATE TABLE #SapWhereClauseTable (sap_select_string varchar(255), order_number int) | ||
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | ||
INSERT INTO #CDPOS_Parameters | INSERT INTO #CDPOS_Parameters | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'SapQueryTable', 'CDPOS' UNION ALL | SELECT 'SapQueryTable', 'CDPOS' UNION ALL | ||
SELECT 'SapRowcount', '0' UNION ALL | SELECT 'SapRowcount', '0' UNION ALL | ||
Line 1,028: | Line 1,034: | ||
SELECT 'DataTableName', 'CDPOS_BANF' UNION ALL | SELECT 'DataTableName', 'CDPOS_BANF' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + | INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR | ||
SELECT * | SELECT * FROM #CDPOS_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DROP TABLE #SapWhereClauseTable; | |||
DROP TABLE #CDPOS_Parameters; | |||
DROP TABLE #CDHDR; | |||
---------------- | ---------------- | ||
Line 1,045: | Line 1,050: | ||
---------------- | ---------------- | ||
(SELECT 'AnalysisType', '18') UNION ALL | (SELECT 'AnalysisType', '18') UNION ALL | ||
(SELECT 'ProjectId', ( | (SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL | ||
(SELECT 'MaximumCount', '0') UNION ALL | (SELECT 'MaximumCount', '0') UNION ALL | ||
(SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE') UNION ALL | (SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE') UNION ALL | ||
Line 1,055: | Line 1,060: | ||
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | ||
INSERT INTO #CDPOS_Parameters | INSERT INTO #CDPOS_Parameters | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'SapQueryTable', 'CDPOS' UNION ALL | SELECT 'SapQueryTable', 'CDPOS' UNION ALL | ||
SELECT 'SapRowcount', '0' UNION ALL | SELECT 'SapRowcount', '0' UNION ALL | ||
Line 1,064: | Line 1,069: | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + | INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR | ||
SELECT * | SELECT * FROM #CDPOS_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
DROP TABLE #SapWhereClauseTable; | |||
DROP TABLE #CDPOS_Parameters; | |||
DROP TABLE #CDHDR; | |||
---------------- | ---------------- | ||
Line 1,077: | Line 1,082: | ||
---------------- | ---------------- | ||
(SELECT 'AnalysisType', '18') UNION ALL | (SELECT 'AnalysisType', '18') UNION ALL | ||
(SELECT 'ProjectId', ( | (SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL | ||
(SELECT 'MaximumCount', '0') UNION ALL | (SELECT 'MaximumCount', '0') UNION ALL | ||
(SELECT 'DataTableName', 'CDHDR_BELEG') UNION ALL | (SELECT 'DataTableName', 'CDHDR_BELEG') UNION ALL | ||
Line 1,085: | Line 1,090: | ||
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255)) | ||
INSERT INTO #CDPOS_Parameters | INSERT INTO #CDPOS_Parameters | ||
SELECT * | SELECT * FROM #SAP_Parameters UNION ALL | ||
SELECT 'SapQueryTable', 'CDPOS' UNION ALL | SELECT 'SapQueryTable', 'CDPOS' UNION ALL | ||
SELECT 'SapRowcount', '0' UNION ALL | SELECT 'SapRowcount', '0' UNION ALL | ||
Line 1,091: | Line 1,096: | ||
SELECT 'DataTableName', 'CDPOS_BELEG_ALL' UNION ALL | SELECT 'DataTableName', 'CDPOS_BELEG_ALL' UNION ALL | ||
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW' | ||
DELETE FROM #SapWhereClauseTable | DELETE FROM #SapWhereClauseTable | ||
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1 | ||
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + | INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR | ||
--INSERT INTO #SapWhereClauseTable SELECT 'AND FNAME EQ `ZLSPR`', 1 | --INSERT INTO #SapWhereClauseTable SELECT 'AND FNAME EQ `ZLSPR`', 1 | ||
SELECT * | SELECT * FROM #CDPOS_Parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * | SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number' | ||
--#ImportSapQuery | --#ImportSapQuery | ||
Line 1,107: | Line 1,111: | ||
--#Exit | --#Exit | ||
</ | </syntaxhighlight> |
Latest revision as of 18:16, 2 September 2023
This page contains an example script to extract data from SAP and load into QPR ProcessAnalyzer. This example uses the SQL scripting and thus the script runs as the QPR ProcessAnalyzer script (not in the Snowflake). As a result, the extracted data is stored into QPR ProcessAnalyzer to tables that can be called staging tables. The data for the staging tables can be located in the Snowflake. After this script is completed, the next step is to transform the staged data into the eventlogs used by the QPR ProcessAnalyzer models.
Sometimes, when using the RFC interface, it's not possible to get all the required data in a single query due to the limitations of the RCF interface. As a workaround, several queries need to be made where each query has a different filter to get a slice of the entire data. For example, date ranges can be used limit how much data one query returns.
The example script defines a temporary table #SAP_Parameters that contains the common SAP query related parameters used in all the queries, to avoid repeating the common values. In addition, each query adds its own query specific parameters to the common parameters. There is also a temporary table #SapWhereClauseTable containing parameters for the SAP query where clause.
The actual extractions from SAP are performed by the--#ImportSapQuery command.
-----------------------------------
-- Adjust SAP extraction parameters
-----------------------------------
IF OBJECT_ID ('tempdb..#SAP_Parameters') IS NULL
BEGIN
CREATE TABLE #SAP_Parameters (par_name varchar(255), par_value varchar(255))
END
TRUNCATE TABLE #SAP_Parameters;
INSERT INTO #SAP_Parameters
SELECT 'SapSystemID', 'PR1' UNION ALL
SELECT 'SapMessageServerHost', '<hostname>' UNION ALL
SELECT 'SapLogonGroup', '<logongroup>' UNION ALL
SELECT 'SapAppServerHost', '<hostname>' UNION ALL
SELECT 'SapSystemNumber', '02' UNION ALL
SELECT 'SapClient', '100' UNION ALL
SELECT 'SapRouter', '' UNION ALL
SELECT 'SapFunction', 'RFC_READ_TABLE' UNION ALL
SELECT 'SapUser', '<username>' UNION ALL
SELECT 'SapPW', '<password>' UNION ALL
SELECT 'SapLanguage', 'EN' UNION ALL
SELECT 'Start', '20210901' UNION ALL
SELECT 'End', '20230501' UNION ALL
SELECT 'SapPoolSize', '5' UNION ALL
SELECT 'SapIdleTimeout', '600' UNION ALL
SELECT 'ProjectId', '1' UNION ALL
SELECT 'ExecuteInClientSide', '1'
SELECT 'CatchOperationExceptions', '1' -- do not stop for errors, so that we can get all the tables
CREATE TABLE #SapWhereClauseTable (sap_select_string varchar(255),order_number int);
-----------
--T001: keeping this here as a first small test, even if it has been already extracted
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T001' UNION ALL
SELECT 'DataTableName', 'T001' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,BUTXT,LAND1' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T163F
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T163F' UNION ALL
SELECT 'DataTableName', 'T163F' UNION ALL
SELECT 'SapFieldNames', 'EBTYP,EBTXT,SPRAS' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T008T
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T008T' UNION ALL
SELECT 'DataTableName', 'T008T' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapFieldNames', 'SPRAS,ZAHLS,TEXTL'
--#ImportSapQuery
-----------
--T077Y
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T077Y' UNION ALL
SELECT 'DataTableName', 'T077Y' UNION ALL
SELECT 'SapFieldNames', 'SPRAS,KTOKK,TXT30' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T024E
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T024E' UNION ALL
SELECT 'DataTableName', 'T024E' UNION ALL
SELECT 'SapFieldNames', 'EKORG,EKOTX' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T161T
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T161T' UNION ALL
SELECT 'DataTableName', 'T161T' UNION ALL
SELECT 'SapFieldNames', 'BSART,BSTYP,BATXT,SPRAS' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
---------------
--T052
---------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T052' UNION ALL
SELECT 'DataTableName', 'T052' UNION ALL
SELECT 'SapFieldNames', 'ZTERM,ZTAGG,ZTAG1,ZPRZ1,ZTAG2,ZPRZ2,ZTAG3,ZSTG1,ZSMN1'
--#ImportSapQuery
---------------
--T052U
---------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T052U' UNION ALL
SELECT 'DataTableName', 'T052U' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapFieldNames', 'SPRAS,ZTERM,ZTAGG,TEXT1'
--#ImportSapQuery
-----------
--T003T
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T003T' UNION ALL
SELECT 'DataTableName', 'T003T' UNION ALL
SELECT 'SapFieldNames', 'BLART,LTEXT,SPRAS' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T005T
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T005T' UNION ALL
SELECT 'DataTableName', 'T005T' UNION ALL
SELECT 'SapFieldNames', 'SPRAS,LAND1,LANDX' UNION ALL
SELECT 'SapWhereClause', 'SPRAS EQ `EN`' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--T024
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'T024' UNION ALL
SELECT 'DataTableName', 'T024' UNION ALL
SELECT 'SapFieldNames', 'EKGRP,EKNAM' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--USR02
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'USR02' UNION ALL
SELECT 'DataTableName', 'USR02' UNION ALL
SELECT 'SapFieldNames', 'BNAME,USTYP' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--V_USR_NAME
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'V_USR_NAME' UNION ALL
SELECT 'DataTableName', 'V_USR_NAME' UNION ALL
SELECT 'SapFieldNames', 'BNAME,NAME_FIRST,NAME_LAST,NAME_TEXT' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
-----------
--LFA1
-----------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'LFA1' UNION ALL
SELECT 'DataTableName', 'LFA1' UNION ALL
SELECT 'SapFieldNames', 'LIFNR,NAME1,SPRAS,LAND1,ORT01,BRSCH,KTOKK' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'SapRowcount', '0'
--#ImportSapQuery
--------------------------
--DD04T
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'DD04T' UNION ALL
SELECT 'DataTableName', 'DD04T' UNION ALL
SELECT 'SapFieldNames', 'ROLLNAME,SCRTEXT_L' UNION ALL
SELECT 'SapWhereClause', '(DDLANGUAGE EQ `EN`) AND (AS4LOCAL EQ `A`)'
--#ImportSapQuery
-------------------------------
-- Main tables
-------------------------------
-----------------------------
-- PO Tables
------------------------------
--------------------------
--EKKO
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'EKKO' UNION ALL
SELECT 'DataTableName', 'EKKO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKKO' UNION ALL
SELECT 'DataTableName', 'EKKO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKKO' UNION ALL
SELECT 'DataTableName', 'EKKO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,BUKRS,BSTYP,BSART,STATU,LOEKZ,AEDAT,ERNAM,LIFNR,EKORG,EKGRP,WAERS,KUNNR,RESWK,LIFRE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,INCO1,INCO2,FRGZU,FRGKE,FRGGR,FRGSX,IHREZ,UNSEZ' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20230101`'
--#ImportSapQuery
--------------------------
--EKPO
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'EKPO' UNION ALL
SELECT 'DataTableName', 'EKPO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20210101` AND AEDAT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKPO' UNION ALL
SELECT 'DataTableName', 'EKPO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20220101` AND AEDAT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKPO' UNION ALL
SELECT 'DataTableName', 'EKPO' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,LOEKZ,TXZ01,AEDAT,MATNR,BUKRS,WERKS,LGORT,MATKL,MENGE,MEINS,NETPR,NETWR,PSTYP,KNTTP,BANFN,BNFPO,MTART,BSTYP,ELIKZ,EREKZ,BSTAE,BEDNR' UNION ALL
SELECT 'SapWhereClause', 'AEDAT GE `20230101`'
--#ImportSapQuery
--------------------------
--EBAN
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'EBAN' UNION ALL
SELECT 'DataTableName', 'EBAN' UNION ALL
SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL
SELECT 'SapWhereClause', 'BADAT GE `20210101` AND BADAT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EBAN' UNION ALL
SELECT 'DataTableName', 'EBAN' UNION ALL
SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL
SELECT 'SapWhereClause', 'BADAT GE `20220101` AND BADAT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EBAN' UNION ALL
SELECT 'DataTableName', 'EBAN' UNION ALL
SELECT 'SapFieldNames', 'BANFN,BNFPO,BSART,LOEKZ,STATU,ESTKZ,ERNAM,ERDAT,BADAT,EBELN,EBELP,AFNAM,FRGKZ' UNION ALL
SELECT 'SapWhereClause', 'BADAT GE `20230101`'
--#ImportSapQuery
--------------------------
--EKES
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'EKES' UNION ALL
SELECT 'DataTableName', 'EKES' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,ETENS,EBTYP,EINDT,LPEIN,UZEIT,ERDAT,EZEIT,MENGE,ESTKZ,LOEKZ,XBLNR,VBELN,VBELP' UNION ALL
SELECT 'SapWhereClause', 'ERDAT GE `20210101` AND ERDAT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKES' UNION ALL
SELECT 'DataTableName', 'EKES' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,ETENS,EBTYP,EINDT,LPEIN,UZEIT,ERDAT,EZEIT,MENGE,ESTKZ,LOEKZ,XBLNR,VBELN,VBELP' UNION ALL
SELECT 'SapWhereClause', 'ERDAT GE `20220101` AND ERDAT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKES' UNION ALL
SELECT 'DataTableName', 'EKES' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,ETENS,EBTYP,EINDT,LPEIN,UZEIT,ERDAT,EZEIT,MENGE,ESTKZ,LOEKZ,XBLNR,VBELN,VBELP' UNION ALL
SELECT 'SapWhereClause', 'ERDAT GE `20220101`'
--#ImportSapQuery
--------------------------
--EKBE == PO HISTORY
--------------------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'EKBE' UNION ALL
SELECT 'DataTableName', 'EKBE' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,VGABE,GJAHR,BELNR,CPUDT,CPUTM,ERNAM,BUDAT,SHKZG,WRBTR,WAERS,MENGE,BWART,BEWTP,XBLNR' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20210601`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKBE' UNION ALL
SELECT 'DataTableName', 'EKBE' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,VGABE,GJAHR,BELNR,CPUDT,CPUTM,ERNAM,BUDAT,SHKZG,WRBTR,WAERS,MENGE,BWART,BEWTP,XBLNR' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20210601` and CPUDT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKBE' UNION ALL
SELECT 'DataTableName', 'EKBE' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,VGABE,GJAHR,BELNR,CPUDT,CPUTM,ERNAM,BUDAT,SHKZG,WRBTR,WAERS,MENGE,BWART,BEWTP,XBLNR' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20220601`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKBE' UNION ALL
SELECT 'DataTableName', 'EKBE' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,VGABE,GJAHR,BELNR,CPUDT,CPUTM,ERNAM,BUDAT,SHKZG,WRBTR,WAERS,MENGE,BWART,BEWTP,XBLNR' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20220601` and CPUDT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'EKBE' UNION ALL
SELECT 'DataTableName', 'EKBE' UNION ALL
SELECT 'SapFieldNames', 'EBELN,EBELP,VGABE,GJAHR,BELNR,CPUDT,CPUTM,ERNAM,BUDAT,SHKZG,WRBTR,WAERS,MENGE,BWART,BEWTP,XBLNR' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20230101`'
--#ImportSapQuery
-----------------------
-- Billing docs
---------------------
---------------
--RBKP
---------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'RBKP' UNION ALL
SELECT 'DataTableName', 'RBKP' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,BUKRS,USNAM,TCODE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,ZBD3T,ZFBDT,WSKTO,XBLNR,RBSTAT' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20210101` and CPUDT LE `20211231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'RBKP' UNION ALL
SELECT 'DataTableName', 'RBKP' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,BUKRS,USNAM,TCODE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,ZBD3T,ZFBDT,WSKTO,XBLNR,RBSTAT' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20220101` and CPUDT LE `20221231`'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'RBKP' UNION ALL
SELECT 'DataTableName', 'RBKP' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,BUKRS,USNAM,TCODE,ZTERM,ZBD1T,ZBD1P,ZBD2T,ZBD2P,ZBD3T,ZFBDT,WSKTO,XBLNR,RBSTAT' UNION ALL
SELECT 'SapWhereClause', 'CPUDT GE `20230101` '
--#ImportSapQuery
---------------
--RSEG
---------------
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'RSEG' UNION ALL
SELECT 'DataTableName', 'RSEG' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BUKRS,EBELN,EBELP,XBLNR,WRBTR' UNION ALL
SELECT 'SapWhereClause', '(GJAHR EQ `2021`)'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'RSEG' UNION ALL
SELECT 'DataTableName', 'RSEG' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BUKRS,EBELN,EBELP,XBLNR,WRBTR' UNION ALL
SELECT 'SapWhereClause', '(GJAHR EQ `2022`)'
--#ImportSapQuery
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'RSEG' UNION ALL
SELECT 'DataTableName', 'RSEG' UNION ALL
SELECT 'SapFieldNames', 'BELNR,GJAHR,BUKRS,EBELN,EBELP,XBLNR,WRBTR' UNION ALL
SELECT 'SapWhereClause', '(GJAHR EQ `2023`)'
--#ImportSapQuery
-------------------------
-- Accounting docs
-------------------------
---------------
--BKPF
---------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'BKPF' UNION ALL
SELECT 'DataTableName', 'BKPF' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'BKPF' UNION ALL
SELECT 'DataTableName', 'BKPF' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'BKPF' UNION ALL
SELECT 'DataTableName', 'BKPF' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,BELNR,GJAHR,BLART,BLDAT,BUDAT,CPUDT,CPUTM,XBLNR,BKTXT,TCODE,BSTAT,AWTYP,AWKEY,PENRC,USNAM,WAERS,GLVOR,FIKRS,STGRD' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
---------------
--BSAK
---------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2021`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', 'FALSE' UNION ALL
SELECT 'SapQueryTable', 'BSAK' UNION ALL
SELECT 'DataTableName', 'BSAK' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2022`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', 'TRUE' UNION ALL
SELECT 'SapQueryTable', 'BSAK' UNION ALL
SELECT 'DataTableName', 'BSAK' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'GJAHR EQ `2023`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND BUKRS IN (`CZ10`,`DK10`,`FI00`,`FI10`,`FI11`,`FI12`,`FI17`,',2
INSERT INTO #SapWhereClauseTable SELECT '`PL10`,`PL71`,`SE10`,`SE75`,`SE77`,`SE78`,`SE79`,`SK30`,`TR20`)', 3;
SELECT * FROM #SAP_parameters UNION ALL
SELECT 'Append', 'TRUE' UNION ALL
SELECT 'SapQueryTable', 'BSAK' UNION ALL
SELECT 'DataTableName', 'BSAK' UNION ALL
SELECT 'SapFieldNames', 'BUKRS,AUGDT,AUGBL,GJAHR,BELNR,BUZEI,BUDAT,BLART,UMSKZ,XBLNR,KIDNO,BSTAT,WRBTR,ZTERM,ZLSCH,ZLSPR,ZBD1P,ZBD1T,ZFBDT,ZBD2P,ZBD2T,ZBD3T,SKNTO,SKFBT,WAERS,LIFNR,GSBER,EBELN,EBELP,BSCHL,KOSTL,SAKNR,AUGGJ,SHKZG' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
----------------------------------------
-- Change Docs
----------------------------------------
-- Get headers
----------------------------------------
-- Change Docs
----------------------------------------
---------------
--CDHDR_EINKBELEG
---------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
---------------
--CDHDR_BANF
---------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
-- Get headers
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
----------------
--CDHDR_INCOMINGINVOICE
----------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
---------------
--CDHDR_BELEG
---------------
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210101` AND UDATE LE `20210331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210401` AND UDATE LE `20210630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20210701` AND UDATE LE `20210930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20211001` AND UDATE LE `20211231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220101` AND UDATE LE `20220331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20220701` AND UDATE LE `20220930`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20221001` AND UDATE LE `20221231`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230101` AND UDATE LE `20230331`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND UDATE GE `20230401` AND UDATE LE `20220630`', 2;
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'Append', '1' UNION ALL
SELECT 'SapQueryTable', 'CDHDR' UNION ALL
SELECT 'DataTableName', 'CDHDR_BELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTCLAS,OBJECTID,CHANGENR,USERNAME,UDATE,UTIME,TCODE,CHANGE_IND' UNION ALL
SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
---------------------------
--Get Line items
--------------------
----------------
--CDPOS_EINKBELEG
----------------
(SELECT 'AnalysisType', '18') UNION ALL
(SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL
(SELECT 'MaximumCount', '0') UNION ALL
(SELECT 'DataTableName', 'CDHDR_EINKBELEG') UNION ALL
(SELECT 'TargetTable', '#CDHDR')
--#GetAnalysis
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255))
INSERT INTO #CDPOS_Parameters
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'SapQueryTable', 'CDPOS' UNION ALL
SELECT 'SapRowcount', '0' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'DataTableName', 'CDPOS_EINKBELEG' UNION ALL
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW'
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `EINKBELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR
SELECT * FROM #CDPOS_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DROP TABLE #SapWhereClauseTable;
DROP TABLE #CDPOS_Parameters;
DROP TABLE #CDHDR;
----------------
--CDPOS_BANF
----------------
(SELECT 'AnalysisType', '18') UNION ALL
(SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL
(SELECT 'MaximumCount', '0') UNION ALL
(SELECT 'DataTableName', 'CDHDR_BANF') UNION ALL
(SELECT 'TargetTable', '#CDHDR')
--#GetAnalysis
CREATE TABLE #SapWhereClauseTable (sap_select_string varchar(255), order_number int)
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255))
INSERT INTO #CDPOS_Parameters
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'SapQueryTable', 'CDPOS' UNION ALL
SELECT 'SapRowcount', '0' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'DataTableName', 'CDPOS_BANF' UNION ALL
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW'
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BANF`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR
SELECT * FROM #CDPOS_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DROP TABLE #SapWhereClauseTable;
DROP TABLE #CDPOS_Parameters;
DROP TABLE #CDHDR;
----------------
--CDPOS_INCOMINGINVOICE
----------------
(SELECT 'AnalysisType', '18') UNION ALL
(SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL
(SELECT 'MaximumCount', '0') UNION ALL
(SELECT 'DataTableName', 'CDHDR_INCOMINGINVOICE') UNION ALL
(SELECT 'TargetTable', '#CDHDR')
--#GetAnalysis
CREATE TABLE #SapWhereClauseTable (sap_select_string varchar(255),order_number int)
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255))
INSERT INTO #CDPOS_Parameters
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'SapQueryTable', 'CDPOS' UNION ALL
SELECT 'SapRowcount', '0' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'DataTableName', 'CDPOS_INCOMINGINVOICE' UNION ALL
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW'
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `INCOMINGINVOICE`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR
SELECT * FROM #CDPOS_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DROP TABLE #SapWhereClauseTable;
DROP TABLE #CDPOS_Parameters;
DROP TABLE #CDHDR;
----------------
--CDPOS_BELEG
----------------
(SELECT 'AnalysisType', '18') UNION ALL
(SELECT 'ProjectId', (SELECT par_value FROM #SAP_Parameters WHERE par_name = 'ProjectId')) UNION ALL
(SELECT 'MaximumCount', '0') UNION ALL
(SELECT 'DataTableName', 'CDHDR_BELEG') UNION ALL
(SELECT 'TargetTable', '#CDHDR')
--#GetAnalysis
CREATE TABLE #CDPOS_Parameters (par_name varchar(255), par_value varchar(255))
INSERT INTO #CDPOS_Parameters
SELECT * FROM #SAP_Parameters UNION ALL
SELECT 'SapQueryTable', 'CDPOS' UNION ALL
SELECT 'SapRowcount', '0' UNION ALL
SELECT 'SapRowskips', '0' UNION ALL
SELECT 'DataTableName', 'CDPOS_BELEG_ALL' UNION ALL
SELECT 'SapFieldNames', 'OBJECTID,CHANGENR,TABNAME,TABKEY,FNAME,CHNGIND,VALUE_NEW'
DELETE FROM #SapWhereClauseTable
INSERT INTO #SapWhereClauseTable SELECT 'OBJECTCLAS EQ `BELEG`', 1
INSERT INTO #SapWhereClauseTable SELECT 'AND CHANGENR GE `' + CONVERT(nvarchar,min(changenr)) + '`', 2 FROM #CDHDR
--INSERT INTO #SapWhereClauseTable SELECT 'AND FNAME EQ `ZLSPR`', 1
SELECT * FROM #CDPOS_Parameters UNION ALL
SELECT 'Append', '0' UNION ALL SELECT 'SapWhereClauseSelect', 'SELECT * FROM #SapWhereClauseTable ORDER BY order_number'
--#ImportSapQuery
DROP TABLE #SapWhereClauseTable;
DROP TABLE #CDPOS_Parameters;
DROP TABLE #CDHDR;
--#Exit