English 中文(简体)
选定一个选定的领域
原标题:select more fields within one select

我可以选择更多的选择和选择。 4个表格(最后一个表格只是收集所有数据)

但现在认为,要选择所有领域的方法,只需要一份选择说明。 这里是巨大的选择:

  SELECT vbak~vbeln vbak~audat
         tvakt~bezei
         vbap~posnr vbap~matnr vbap~kwmeng vbap~vrkme
         lips~vbeln lips~posnr lips~werks lips~lfimg
         vbfa~vbtyp_n
    FROM vbak JOIN vbap ON vbak~vbeln = vbap~vbeln
              JOIN tvakt ON vbak~auart = tvakt~auart
              LEFT JOIN vbfa ON vbfa~vbelv = vbak~vbeln AND vbfa~posnv = vbap~posnr
              JOIN lips ON vbfa~vbeln = lips~vbeln AND vbfa~posnn = lips~posnr
    INTO TABLE gt_salord
    WHERE tvakt~spras =  EN  AND
          vbak~vbeln IN s_vbeln AND
          vbak~audat IN s_audat.

The problem is this doesn t work. When i try to activate it throws this error: " Unable to compare with "VBAP~POSNR". A table can be joined with a maximum of one other table using LEFT OUTER JOIN " If i don t use LEFT JOIN and only JOIN it works but i don t get all what i want. I need to get all the SALES ORDERS even if they don t have a DELIVERY ORDER assigned. Is there a way to do that, or do i really have to split my select?

最佳回答

我在SAP中注意到,简化选择说明和着手处理不参与数据选择的表格的LOOP和SlectT SINGLE的工作效率更高。

在您的案例中,表VBFA的数据在数据选择之后可以检索(这并不限制与非行的数据数量)。

当然,这取决于指数、应用服务器缓冲...,但即使它可能是对专家的反攻,在SAP中保留某些并非过于复杂的声明也是最好的。

问题回答

您可以尝试以下选择:

SELECT vbak~vbeln vbak~audat
       tvakt~bezei
       vbap~posnr vbap~matnr vbap~kwmeng vbap~vrkme
       lips~vbeln lips~posnr lips~werks lips~lfimg
       vbfa~vbtyp_n
  FROM vbak JOIN vbap ON vbak~vbeln = vbap~vbeln
            JOIN tvakt ON vbak~auart = tvakt~auart
            LEFT JOIN vbfa ON vbfa~vbelv = vbap~vbeln AND vbfa~posnv = vbap~posnr
            JOIN lips ON vbfa~vbeln = lips~vbeln AND vbfa~posnn = lips~posnr
  INTO TABLE gt_salord
  WHERE tvakt~spras =  EN  AND
        vbak~vbeln IN s_vbeln AND
        vbak~audat IN s_audat.

I can t test the result, but the syntax check say: ok.

只有一个小差:

                                                  x---- difference
                                                  v
                LEFT JOIN vbfa ON vbfa~vbelv = vbap~vbeln AND vbfa~posnv = vbap~posnr 
                LEFT JOIN vbfa ON vbfa~vbelv = vbak~vbeln AND vbfa~posnv = vbap~posnr

http://code>vbfa~vbelv with vbak~vbeln, I do it with vbap~vbeln. 两者都具有同样的价值,但在<代码>on-clause,你再次使用vbap

我非常了解SAP Abap。 但从观点看,如果在SAP中支持,你可以使用衍生的查询。

下面是一些做法:

select * from
(
select * from
table1 inner join table2 on table1.key=table2.key
inner join table3 on table1.key=table3.key
) a left outer join table4 b 
on a.key=b.key

由于问题被拖到Kingk。 希望能发挥作用

要求修改左边条款中的表格田顺序。 Put vbap~vbeln = vbfa~vbelv





相关问题
using the where clause + new constraint with args?

I have a piece of code that looks like this: public static T CreateSomething<T>(SomeType a) where T : SomeMicrosoftBaseClass, new() { var newElement = new T { SomeProperty = a}; ...

Strange .Where() behaviour. Somebody has an explanation?

Original I don t get why the Where() clause doesn t give me the right results in the last example. It isn t any different is it? Why does C# behaves differently? transactions = IEnumerable<...

Linq To Sql Where Or operator

I need to create a query which checks if a field (string) contains one or more words supplied at run time. Basically I need to be able to ask a WhereOr question. This seems like it should be a ...

C# Beginner: Where has my IList.Where() method gone?

I ve got another simple one (I think) that s stumping me. I have written a method in one of my controls that gets the latest version of a file in a CMS given it s filename (i.e. regardless of what ...

sql simple query

Yesterday my friend asked me a question about this query: select * from user where 1=1 I said that the query is incorrect, but he said it s correct. I don t understand how this query can be correct....

Codeigniter WHERE on "AS" field

I have a query where I need to modify the selected data and I want to limit my results of that data. For instance: SELECT table_id, radians( 25 ) AS rad FROM test_table WHERE rad < 5 ORDER BY rad ...

SEARCH several Tables IN SQL

I m trying to search several tables at once for a search term. My query is: SELECT item.ItemID FROM Inventory.Item item JOIN Inventory.Category catR // each item can be in several ...

热门标签