Skip to Content
-5

HOW CAN I SELECT A VALUE FROM THE TABLE?

Apr 30 at 06:32 AM

79

avatar image

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.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

ROBERTO Forti Santos May 07 at 02:07 AM
0

Never consider implementing "Select" inside the "Loop" as well as "into corresponding fields of table...".

SAP has Best practices to help you understanding and recommend using that.

Regards,

Share
10 |10000 characters needed characters left characters exceeded
Guus Werinussa Apr 30 at 08:31 AM
-2
DATA:
  it_con TYPETABLEOF BKPF,
  ls_con TYPE bkpf-AWKEY,

You cannot append ls_con to it_con (1 field vs table structure).

LOOP  AT it_concats INTO ls_concats.
  SELECT BELNR FROM BKPF INTO
     CORRESPONDING FIELDS OF TABLE IT
     FOR ALLENTRIES IN IT_CONCATS
     WHERE AWKEY EQ IT_CONCATS-AWKEY.
ENDLOOP.

Loop at it_concat and then do a FAE using that same it_concat inside the loop? Drop the loop and only do the FAE and make sure it_concat is not empty.

Either you're leaving out a lot of code in your example or i simply don't understand your requirement (and way of thinking).

Share
10 |10000 characters needed characters left characters exceeded