Example to Extract Data from SAP: Difference between revisions
No edit summary |
No edit summary |
||
(10 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 script defines a temporary table ''#SAP_Parameters'' that contains the common SAP query related parameters used in all the queries. In addition, | 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> | |||
The actual extractions are | |||
< | |||
----------------------------------- | ----------------------------------- | ||
-- Adjust SAP extraction parameters | -- Adjust SAP extraction parameters | ||
Line 41: | 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 53: | Line 51: | ||
--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 | ||
Line 66: | 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 | ||
Line 77: | 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 | ||
Line 90: | 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 102: | 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 | ||
Line 115: | 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 125: | 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 136: | 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 149: | 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 162: | 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 174: | 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 186: | 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 198: | 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 210: | 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 228: | 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 236: | Line 234: | ||
--#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 244: | Line 242: | ||
--#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 255: | Line 253: | ||
--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 261: | ||
--#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 271: | Line 269: | ||
--#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 282: | Line 280: | ||
--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 290: | Line 288: | ||
--#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 298: | Line 296: | ||
--#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 309: | Line 307: | ||
--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 317: | Line 315: | ||
--#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 325: | Line 323: | ||
--#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 336: | Line 334: | ||
--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 344: | Line 342: | ||
--#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 352: | Line 350: | ||
--#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 360: | Line 358: | ||
--#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 366: | ||
--#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 382: | Line 380: | ||
--RBKP | --RBKP | ||
--------------- | --------------- | ||
SELECT * | SELECT * FROM #SAP_parameters UNION ALL | ||
SELECT 'Append', '0' UNION ALL | SELECT 'Append', '0' UNION ALL | ||
SELECT 'SapQueryTable', 'RBKP' UNION ALL | SELECT 'SapQueryTable', 'RBKP' UNION ALL | ||
Line 390: | Line 388: | ||
--#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 398: | Line 396: | ||
--#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 409: | Line 407: | ||
--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 417: | Line 415: | ||
--#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 425: | Line 423: | ||
--#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 442: | 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 455: | 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 468: | 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 484: | 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 497: | 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 510: | 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 533: | 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 646: | 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 724: | 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 762: | 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 774: | 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 875: | 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 989: | 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 | ||
Line 997: | Line 996: | ||
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,006: | Line 1,005: | ||
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 | ||
Line 1,019: | 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,029: | Line 1,028: | ||
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,035: | 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 | ||
Line 1,052: | 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,062: | 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,071: | 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 | ||
Line 1,084: | 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,092: | 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,101: | Line 1,099: | ||
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,113: | 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