简体   繁体   English

如何从表中获取值

[英]how can I get values from the table

I concatenated values of select-options and a parameter.我将选择选项的值和一个参数连接起来。 The condition of that query is based on the concatenated data.该查询的条件基于连接的数据。 I can get all the data i need.我可以获得我需要的所有数据。

here's my code:这是我的代码:

TABLES: bkpf.

SELECT-OPTIONS: s_belnr FOR bkpf-belnr NO-EXTENSION OBLIGATORY .
PARAMETERS: p_ghjahr LIKE bkpf-gjahr DEFAULT sy-datum(4) OBLIGATORY. "Fiscal

DATA: it_con TYPE TABLE OF BKPF,
      ls_con TYPE bkpf-AWKEY,
      lv_belnr   LIKE bkpf-belnr,
      IT TYPE STANDARD TABLE OF BKPF,
      WA TYPE BKPF.

IF s_belnr-high IS INITIAL.
  CONCATENATE s_belnr-low p_ghjahr INTO ls_con.
  APPEND ls_con TO it_con.
ELSE.  
  lv_belnr = s_belnr-low.
  WHILE lv_belnr LE s_belnr-high.
    CONCATENATE lv_belnr p_ghjahr INTO ls_con.
    APPEND ls_con TO it_con.
    ADD 1 TO lv_belnr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = lv_belnr
      IMPORTING
        output = lv_belnr.
  ENDWHILE.
ENDIF.
LOOP AT it_concats INTO ls_concats.
  SELECT BELNR
    FROM BKPF 
    INTO CORRESPONDING FIELDS OF TABLE IT 
    FOR ALL ENTRIES IN IT_CONCATS 
    WHERE AWKEY EQ IT_CONCATS-AWKEY.
ENDLOOP.

LOOP AT IT INTO WA.
  WRITE: / WA-BELNR.
ENDLOOP.

Ignoring (because your question is too vague), the type of document you are looking for, I'll suggest something like (WARNING, I do NOT provide full answers, just code snipets who you must tune to make it work; if someone wants to improve my answer, feel free to do it, and I'll gladly will vote the new one as the good one... if it is)忽略(因为你的问题太模糊),你正在寻找的文档类型,我会建议类似(警告,我不提供完整的答案,只是你必须调整才能使其工作的代码片段;如果有人想要为了改进我的答案,请随意去做,我很乐意将新答案选为好答案……如果是的话)

data: awkey_range type range of bkpf-awkey,
      awkey_line like  line of awkey_range.

* Fill the awkey_range with something like
awkey_line-sign = 'I'.
awkey_line-option = 'EQ'.
* loop at bkpf_table into bkpf_line.
*   concatenate bkpf_line-belnr bkpf_line-ghjahr into awkey_line-low.
*   append awkey_line to awkey_range.
* endloop.

* And then a single SQL
select *
  from bkpf
  into table IT "Ouch, what a name
  where awkey in awkey_range.

And it should work, if I'm not missing something.如果我没有遗漏一些东西,它应该可以工作。

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

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