Skip to Content
avatar image
Former Member

Alv report output not show according to selection screen.

In selection screen first two options from KNA1 table and next three options from knvv table. like

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: S_KUNNR FOR KNA1-KUNNR, S_REGIO FOR KNA1-REGIO, S_VTWEG FOR KNVV-VTWEG, S_VKBUR FOR KNVV-VKBUR, S_KDGRP FOR KNVV-KDGRP. SELECTION-SCREEN: END OF BLOCK B1.

When I execute first option like S_KUNNR, its filter is ok no problem. The problem is when I execute knvv filed like S_VTWEG, It does not show as VTWEG, rather it show all.Below is select query.

SELECT KUNNR NAME1 REGIO ADRNR AUFSD ERDAT

FROM KNA1

INTO TABLE GT_KNA1

WHERE KUNNR IN S_KUNNR

AND REGIO IN S_REGIO.

IF SY-SUBRC = 0.

SORT GT_KNA1 BY KUNNR REGIO.

ENDIF.

IF GT_KNA1 IS NOT INITIAL.

SELECT KUNNR VKORG VTWEG KDGRP BZIRK VKGRP VKBUR

FROM KNVV

INTO TABLE GT_KNVV

FOR ALL ENTRIES IN GT_KNA1

WHERE KUNNR = GT_KNA1-KUNNR

AND VTWEG IN S_VTWEG

AND VKBUR IN S_VKBUR

AND KDGRP IN S_KDGRP.

ENDIF.

LOOP AT GT_KNA1 INTO GS_KNA1.

GS_FINAL-KUNNR = GS_KNA1-KUNNR.

GS_FINAL-NAME1 = GS_KNA1-NAME1.

GS_FINAL-REGIO = GS_KNA1-REGIO.

GS_FINAL-AUFSD = GS_KNA1-AUFSD.

GS_FINAL-ERDAT = GS_KNA1-ERDAT.

READ TABLE GT_KNVV INTO GS_KNVV WITH KEY KUNNR = GS_KNA1-KUNNR.

IF SY-SUBRC EQ 0.

GS_FINAL-VTWEG = GS_KNVV-VTWEG.

GS_FINAL-KDGRP = GS_KNVV-KDGRP.

GS_FINAL-BZIRK = GS_KNVV-BZIRK.

GS_FINAL-VKGRP = GS_KNVV-VKGRP.

GS_FINAL-VKBUR = GS_KNVV-VKBUR.

ENDIF. ENDLOOP.

How could it shows output according to input selection screen, please help.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 10 at 11:03 AM

    Did you checked in debug at where the additional entry is added? Either in select statement or in LOOP.

    GS_FINAL-VKGRP = GS_KNVV-VKGRP.
    GS_FINAL-VKBUR = GS_KNVV-VKBUR.
    ENDIF. ENDLOOP.

    Also I didn't found the Final append statement in the above code. where is the actual append is happening?

    Add comment
    10|10000 characters needed characters exceeded

  • May 10 at 11:05 AM

    I would use a join between KNA1 and KNVV to select the data.

    Other than that:

    LOOP AT GT_KNA1 INTO GS_KNA1.
    ...
    ENDLOOP.
    

    You are looping and filling GS_FINAL. But where's the APPEND?

    Add comment
    10|10000 characters needed characters exceeded