Skip to Content
-5
Apr 30, 2018 at 06:32 AM

HOW CAN I SELECT A VALUE FROM THE TABLE?

1111 Views Last edit Apr 30, 2018 at 06:43 AM 2 rev

So i concatenated the select option value and a parameter. and i want that to be the condition in my select query but i can't achieve it.

heres 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.