Search code examples
sqlssisopensqlsap-erp

Select last 30 days rows from MARA using SSIS


I'm trying to select rows for last date change = 30 days.

I tried LAEDA = ( sy-datum -30 ) in where clause, but it always generated error.I connect to sap Abap database.

enter image description here

The message error:

[EIS-Material 1] Error: ERPConnect.ERPException: Error while receiving function return values: SYSTEM_FAILURE An error has occurred while parsing a dynamic entry. at ERPConnect.RFCAPI.ReceiveFunctionResults(UInt32 connectionHandle, RFC_PARAMETER[] importing, RFC_PARAMETER[] changing, RFC_TABLE[] tables, Encoding apiEncoding) at ERPConnect.RFCFunction.ReceiveFunctionArguments(RFC_TABLE[]& apiTables) at ERPConnect.RFCFunction.CallClassicAPI() at ERPConnect.RFCFunction.ExecuteRFC(Byte[] tid) at XtractKernel.Extractors.TableExtractor.GetPackage(RFCFunction& func)
at XtractKernel.Extractors.TableExtractor.Extract() at XtractKernel.Extractors.ExtractorBase`1.Extract(ProcessResultCallback processResult) at XtractIS.XtractSourceTable.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPrimeOutput(IDTSManagedComponentWrapper100 wrapper, Int32 outputs, Int32[] outputIDs, IDTSBuffer100[] buffers, IntPtr ppBufferWirePacket)


Solution

  • So you are using a third party tool to extract data from an SAP system. According to the error message, the toole makes a Remote Function Call (RFC) and handing the SQL to the ABAP backend. Then your where condition must be valid ABAP/Open SQL syntax, regardless of the database behind.

    Your call (simplified) would look like this in ABAP (with new @-syntax):

    DATA(lf_dat) = sy-datum - 30.
    
    SELECT matnr
    FROM mara
    WHERE laeda >= @lf_dat
    INTO TABLE @DATA(lt_matnr)
    .
    

    The problem is, that you are not allowed to make this calculation within the the statement, as far as I know, so you have to use a variable. But since your third party tool only allows you to write a where condition I see no way to handle this, except with a static date in the condition:

    laeda >= '20190106' "YYYYMMDD
    

    You can add the ABAP tag to your question to attract more specialists on this ABAP specific topic.