在ON子句中使用子字符串的OpenSQL SELECT

onl*_*lyf 1 sap abap select substring where

我在ABAP中有以下select语句:

SELECT munic~mandt VREFER BIS AB ZZELECDATE ZZCERTDATE CONSYEAR ZDIMO ZZONE_M ZZONE_T USAGE_M USAGE_T M2MC M2MT M2RET EXEMPTMCMT EXEMPRET CHARGEMCMT
INTO corresponding fields of table GT_INSTMUNIC_F
FROM ZCI00_INSTMUNIC AS MUNIC
INNER JOIN EVER AS EV on
  MUNIC~POD = EV~VREFER(9).
"where EV~BSTATUS = '14' or EV~BSTATUS = '32'.
Run Code Online (Sandbox Code Playgroud)

我对上述语句的问题是无法识别'ON'子句上的子串/偏移操作.如果我删除'(9)然后它识别该字段,否则它给出错误:

Field ev~refer未知.它既不在指定的表中,也不由"DATA"语句定义.我也尝试在'Where'子句中做类似的事情,收到类似的错误:

LOOP AT gt_instmunic.

 clear wa_gt_instmunic_f.

 wa_gt_instmunic_f-mandt = gt_instmunic-mandt.
 wa_gt_instmunic_f-bis = gt_instmunic-bis.
 wa_gt_instmunic_f-ab = gt_instmunic-ab.
 wa_gt_instmunic_f-zzelecdate = gt_instmunic-zzelecdate.
 wa_gt_instmunic_f-ZZCERTDATE = gt_instmunic-ZZCERTDATE.
 wa_gt_instmunic_f-CONSYEAR = gt_instmunic-CONSYEAR.
 wa_gt_instmunic_f-ZDIMO = gt_instmunic-ZDIMO.
 wa_gt_instmunic_f-ZZONE_M = gt_instmunic-ZZONE_M.
 wa_gt_instmunic_f-ZZONE_T = gt_instmunic-ZZONE_T.
 wa_gt_instmunic_f-USAGE_M = gt_instmunic-USAGE_M.
 wa_gt_instmunic_f-USAGE_T = gt_instmunic-USAGE_T.

 temp_pod = gt_instmunic-pod.

  SELECT vrefer
  FROM ever
    INTO wa_gt_instmunic_f-vrefer
    WHERE ( vrefer(9) LIKE temp_pod  ).            " PROBLEM WITH SUBSTRING
    "AND ( BSTATUS = '14' OR BSTATUS = '32' ).
  ENDSELECT.

  WRITE: / sy-dbcnt.
  WRITE: / 'wa is: ', wa_gt_instmunic_f.
  WRITE: / 'wa-ever is: ', wa_gt_instmunic_f-vrefer.
  APPEND wa_gt_instmunic_f TO gt_instmunic_f.
  WRITE: / wa_gt_instmunic_f-vrefer.
ENDLOOP.

itab_size = lines( gt_instmunic_f ).
WRITE: / 'Internal table populated with', itab_size, ' lines'.
Run Code Online (Sandbox Code Playgroud)

我想要实现的基本任务是修改一个表上的特定字段,从另一个表中提取值.他们有一个共同的领域(pod = vrefer(9)).在此先感谢您的时间.

Ger*_*ema 8

如果你的NetWeaver版本足够晚,它适用于7.51,你可以使用OpenSQL函数LEFTSUBSTRING.您的查询看起来像:

SELECT munic~mandt VREFER BIS AB ZZELECDATE ZZCERTDATE CONSYEAR ZDIMO ZZONE_M ZZONE_T USAGE_M USAGE_T M2MC M2MT M2RET EXEMPTMCMT EXEMPRET CHARGEMCMT
  FROM ZCI00_INSTMUNIC AS MUNIC
  INNER JOIN ever AS ev 
          ON MUNIC~POD EQ LEFT( EV~VREFER, 9 )
  INTO corresponding fields of table GT_INSTMUNIC_F.
Run Code Online (Sandbox Code Playgroud)

请注意,该INTO子句也需要移动到命令的末尾.


vwe*_*ert 5

field(9)是一个由 ABAP 环境处理的子集操作,不能转换为数据库级 SQL 语句(至少目前不能,但如果将来能转换成数据库级 SQL 语句,我会感到惊讶)。最好的选择是单独选择数据集并手动合并它们(如果两者大致相等)或预先选择一个数据集并使用 FAE/IN 子句。