简体   繁体   English

当 SAP Infoset 中的字段不匹配时如何返回值

[英]How to return a value when the fields don't match in SAP Infoset

I have the main table EKPO joined to tables MLGN and MLGT as outer joins.我将主表 EKPO 作为外连接连接到表 MLGN 和 MLGT。

I have created an extra field BINALOC in the infoset and want it to return a value from table MLGT under certain conditions:我在信息BINALOC创建了一个额外的字段BINALOC并希望它在某些条件下从表 MLGT 返回一个值:

  1. If the fields MLGN-LTKZE and MLGT-LGTYP match then return the associated MLGT-LGPLA field.如果字段 MLGN-LTKZE 和 MLGT-LGTYP 匹配,则返回关联的 MLGT-LGPLA 字段。
  2. If MLGN-LTKZE = 'R1', then only return relevant MLGT-LGPLA where MLGT-LGTYP = '006'.如果 MLGN-LTKZE = 'R1',则只返回相关的 MLGT-LGPLA,其中 MLGT-LGTYP = '006'。
  3. If MLGN-LTKZE <> MLGT-LGTYP return blank.如果 MLGN-LTKZE <> MLGT-LGTYP 返回空白。

Currently I can do the first 2 conditions but unable to fit in the 3rd as it conflicts with the number 2.目前我可以做前两个条件,但无法适应第三个条件,因为它与数字 2 冲突。

I have tried a variety of IF statements and various orders for the IF conditions, and different join types.我已经尝试了各种 IF 语句和 IF 条件的各种命令,以及不同的连接类型。

This the current code I have in the extra field BINALOC coding section:这是我在额外字段BINALOC编码部分的当前代码:

IF MLGN-LTKZE = 'R1'.
  select LGPLA as LGPLA
   from *MLGT into BINALOC
   where *MLGT~LGTYP eq '006'.
  ENDSELECT.    
else.
  select LGPLA as LGPLA
    from *MLGT into BINALOC
    where *MLGT~LGTYP eq MLGN-LTKZE.
  endselect.
endif.

I want the field to return blank when the fields I mentioned before do not match.当我之前提到的字段不匹配时,我希望该字段返回空白。

Currently it returns a copy of the field above it.目前它返回其上方字段的副本。

this?这个?

IF MLGN-LTKZE = 'R1'.
  select LGPLA as LGPLA
    from *MLGT into BINALOC
    where *MLGT~LGTYP eq '006'.
  ENDSELECT.
else.
  select LGPLA as LGPLA
    from *MLGT into BINALOC
    where *MLGT~LGTYP eq MLGN-LTKZE.
  endselect.
  if sy-subrc ne 0.
    select LGPLA as LGPLA
      from *MLGT into BINALOC
      where *MLGT~LGTYP ne MLGN-LTKZE.
    endselect.
  endif.
endif.

First of all, it's difficult to answer because the 3 functional rules are subject to interpretation because they have overlapping conditions.首先,很难回答,因为这 3 条功能规则因具有重叠条件而受到解释。

If they correspond to this truth table:如果它们对应于这个真值表:

MLGN-LTKZE  Exists MLGN-LTKZE/MLGT-LGTYP  BINALOC
----------  ----------------------------  -------------------------------
=R1         true or false                 MLGT-LGPLA for LGTYP='006'
<>R1        true                          MLGT-LGPLA for LGTYP=MLGN-LTKZE
<>R1        false                         blank

Then the program should be like this:那么程序应该是这样的:

if MLGN-LTKZE = 'R1'.
  select LGPLA as LGPLA
    from *MLGT into BINALOC
    where *MLGT~LGTYP eq '006'.
  endselect.
else.
  select LGPLA as LGPLA
    from *MLGT into BINALOC
    where *MLGT~LGTYP eq MLGN-LTKZE.
  endselect.
  if sy-subrc ne 0.
    clear BINALOC.
  endif.
endif.

The issue you had is probably that if one line matched the 3rd condition, then BINALOC was not cleared, and so kept the value calculated during the processing of the previous line.您遇到的问题可能是,如果一行与第三个条件匹配,则 BINALOC 未清除,因此保留在处理前一行期间计算的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM