Hi,
I was extracting data from SAP table VBAK with same data period at different time in one day.
However, I found that the number of records is reducing.
For example,
the number of records is 6108 at 1st extraction at 7:30 am, then
the number of records is 6088 at 2nd extraction around 9:40 am, then
the number of records is 6055 at 5th extraction around 11:05 am.
Wondering if there's someone facing the same issue like me?
Here's my script:
SET vSavePath ='lib://Daily Sales (win-ro2ovhfhs0q_senseadmin)/';
SET vInitialStartDate = '20180701';
SET vThisExectDate = '20180730';
LET vCurrentMondifiedDate = Today();
SET vExtractStatus = 'Y'; // Inital Load or Incremental Reload
If vExtractStatus = 'Y' Then
[Initial Load]:
LOAD
VBELN,
ERDAT,
AEDAT,
$(vThisExectDate) as [Current Extracting Date]
;
Select VBELN ERDAT AEDAT
FROM VBAK WHERE
(ERDAT>='$(vInitialStartDate)' and ERDAT<='$(vThisExectDate)') and
(AEDAT <= '$(vThisExectDate)');
Store * from [Initial Load] into [$(vSavePath)VBAK_Initial Load.csv](txt, delimiter is '|');
Drop Table [Initial Load];
Else
[Incremental Load]:
Load
VBELN,
ERDAT,
AEDAT,
$(vLastExectDate) as [Last Extracting Date],
$(vThisExectDate) as [Current Extracting Date],
if(Date#(ERDAT)>'$(vLastExectDate)','Add',
if(Date#(ERDAT)<'$(vLastExectDate)' and AEDAT >= '$(vLastExectDate)','Modified','Others')) as [Extract Type]
;
Select VBELN ERDAT AEDAT
FROM VBAK WHERE
(ERDAT > '$(vLastExectDate)' and ERDAT <= '$(vThisExectDate)') or
(AEDAT > '$(vLastExectDate)' and AEDAT <= '$(vThisExectDate)');
Store * from [Incremental Load] into [$(vSavePath)VBAK_Incremental_$(vThisExectDate).csv](txt, delimiter is '|');
Drop Table [Incremental Load];
End If
LET vLastExectDate = vThisExectDate;