数据源

SAP与XQL

如果不是通过网关,而是通过“直接RFC”建立SAP访问,则SAP访问将通过XQL进行定义。XQL是一种简单的描述语言。下文将解释如何在SAP中使用XQL来访问RFC功能模块、报告、表格、多维数据集和查询。为尽量使解释通俗易懂,本页将使用尽可能多的示例,而尽量少用XQL的正式描述。

表格访问

XtractQL
   := (SelectCommand | ExecuteCommand | DescribeCommand) 
  
SelectCommand
   := "SELECT" [SelectResult] SelectFieldList "FROM" (SelectQuery | SelectQueryBW 
        | SelectTable)
  
SelectResult      
   := "TOP" Integer ["SKIP" Integer]
  
SelectFieldList
   := "*" | (SelectField {"," SelectField})
  
SelectField
   := (Identifier | String | StringPassThrough) ["AS" (Identifier | String |
        StringPassThrough)]
  
SelectQuery
   := "QUERY" String [Into] ["WHERE" SelectQueryCriteria {"," 
        SelectQueryCriteria}] ["USING" String]
  
SelectQueryBW
   := "BWQUERY" String [Into] ["WHERE" SelectQueryCriteria {"," SelectQueryCriteria}]
  
SelectQueryCriteria
   := Identifier (("EQ" | "NE" | GT" | "LT" | "GE" | "LE" | "MP") (String | Variable) | ("IN" "(" SelectQueryCriteriaRange {[","] SelectQueryCriteriaRange} ")") | ("BT" (String | Variable) "AND" (String | Variable)))
  
SelectQueryCriteriaRange
   := "(" (("I" | "INCLUDE") | ("E" | "EXCLUDE")) "," (("EQ" | "NE" | GT" | "LT" | "GE" | "LE") | "LIKE") "," (String | Variable) ["," (String | Variable)] ")"
  
SelectTable
   := ["TABLE"] (String | Identifier) [Into] ["WHERE" SelectTableWhereExpression]) [WithOptions{CUSTOMFUNCTIONNAME}]
  
SelectTableWhereExpression
   := SelectTableWhereTerm {("AND" | "OR") SelectTableWhereTerm}
     
SelectTableWhereTerm
   := SelectTableWhereFactor | ("(" SelectTableWhereExpression ")")
  
SelectTableWhereFactor
   := Identifier (SelectTableWhereFactorOperator | SelectTableWhereFactorNull | (["NOT"] (SelectTableWhereFactorLike | SelectTableWhereFactorBetween | SelectTableWhereFactorIn)))
  
SelectTableWhereFactorOperator
   := ("EQ" | "NE" | "LT" | "GT" | "LE" | "GE") SelectTableWhereFactorValue
     
SelectTableWhereFactorNull  
   := "IS" ["NOT"] "NULL"
  
SelectTableWhereFactorLike
   := "LIKE" (String  | Variable)
  
SelectTableWhereFactorBetween
   := "BETWEEN" SelectTableWhereFactorValue "AND" SelectTableWhereFactorValue
  
SelectTableWhereFactorIn
   := "IN" "(" String {"," String} ")"
  
SelectTableWhereFactorValue
   := String | Integer | Number | Variable | Identifier
  
ExecuteCommand
   := "EXECUTE" (ExecuteMDX | ExecuteFunction)
  
ExecuteMDX
   := "MDX" StringPassThrough [Into]
  
ExecuteFunction
   := "FUNCTION" String [(Imports | Exports | Tables) {(Imports | Exports | Tables)}]
  
Imports
   := ("IMPORTS" | "IMPORTING") ImportsParameter {"," ImportsParameter}
     
ImportsParameter
   := Variable "=" Identifier
  
Exports
   := ("EXPORTS" | "EXPORTING") ExportsParameter {"," ExportsParameter}
     
ExportsParameter
   := Identifier "=" (String | Integer | Number | Variable)
  
Tables
   := "TABLES" TablesParameter {"," TablesParameter}
  
TablesParameter
   := Identifier ["=" (Variable | Table)] [Into]
  
Table
   := "(" TableMaps [","] TableValues {[","] TableValues} ")"
  
TableMaps
   := "(" Identifier {"," Identifier} ")"
     
TableValues
   := "(" String {"," String} ")"
  
DescribeCommand
   := "DESCRIBE" (DescribeTable | DescribeQuery | DescribeQueryBW | DescribeFunction | DescribeStructure) [Into]
  
DescribeTable
   := "TABLE" ((String ["GET" "FIELDS"]) | DescribeTableCatalog)
  
DescribeTableCatalog
   := "CATALOG" "WHERE" "TABLENAME" ("EQ" | "LIKE") String
  
DescribeQuery
   := "QUERY" (DescribeQueryGet | DescribeQueryCatalog | DescribeQueryUserGroup) 
  
DescribeQueryGet
   := String "GET" ("FIELDS" | "VARIANTS" | "SELECTION-PARAMETERS")
     
DescribeQueryCatalog
   := "CATALOG" "WHERE" DescribeQueryCatalogParameter {","  DescribeQueryCatalogParameter}
  
DescribeQueryCatalogParameter
   := DescribeQueryWorkspace | ("USERGROUP" ("EQ" | "LIKE") String) | ("QUERYNAME" ("EQ" | "LIKE") String)
  
DescribeQueryUserGroup
   := "USERGROUP" "WHERE" DescribeQueryWorkspace
  
DescribeQueryWorkspace
   := "WORKSPACE" "EQ" String{G,S,GLOBAL,STANDARD}
  
DescribeQueryBW
   := "BWQUERY" (DescribeQueryBWGet | DescribeQueryBWCatalog) 
  
DescribeQueryBWCatalog
   := "CATALOG" "WHERE" "CUBENAME" ("EQ" | "LIKE") String
     
DescribeQueryBWGet
   := String "GET" ("MEASURES" | "VARIABLES" | "DIMENSIONS" | ("DIMENSIONS-PROPERTIES" ["OF"] String))
  
DescribeFunction
   := "FUNCTION" (DescribeFunctionCatalog | (String "GET" ("EXPORTS" | "IMPORTS" | DescribeFunctionTables)))
  
DescribeFunctionCatalog
   := "CATALOG" "WHERE" "FUNCTIONNAME" ("EQ" | "LIKE") String
  
DescribeFunctionTables
   := "TABLES" | (("TABLES-STRUCTURE" | "TABLES-DATATABLE") ["OF"] String)
  
DescribeStructure
   := "STRUCTURE" String
  
Into
   := "INTO" Variable
  
WithOptions
   := ("WITH" | "WITH-OPTIONS") "(" Settings ")"
        
Settings
   :=  Identifier "=" String {"," Identifier "=" String}
  
Tokens
------
  
Variable
   := "@" , Identifier
  
Identifier
    := (Letter | "_") , {Letter | Digit | "_" | "-" | "$"}
      
String
    := ("'" , {ANY-CHARACTER-EXCEPT-QUOTE | "''"} , "'") | (""" , {ANY-CHARACTER-EXCEPT-QUOTE | """"} , """)
     
StringPassThrough
    := ("[" , {ANY-CHARACTER-EXCEPT-QUOTE | "]]"} , "]") | ("|" , {ANY-CHARACTER-EXCEPT-QUOTE | "||"} , "|")
Number
   := ["-" | "+"] , DigitSequence , ["." , DigitSequence]
Integer
   := DigitSequence
DigitSequence
    := Digit , {Digit}
Digit               
    := "0-9"
Letter
    := "A-Za-z"

示例

检索MAKT表格的所有列,但不超过10行:

SELECT TOP 10 * FROM MAKT;

仅检索MAKT表格的某些列(最多10行) :

SELECT TOP 10 MATNR, MAKTX FROM MAKT

var example = true

其他资源

需要更多支持?

Peakboard Youtube icon 访问腾讯视频

海量视频为您讲解如何设计看板,新手和高级用户同样适宜。

Peakboard Templates icon 查看免费模板

免费下载适用于各种使用场景的模板。

Peakboard icon 浏览www.peakboard.cn

深入了解Peakboard,浏览产品不同的使用场景和客户成功案例。