Skip to Content
0
Former Member
Jul 04, 2007 at 05:50 AM

Join Tables

15 Views

Hi,

I want to join two tables KNA1 and VBAK With common field as KUNNR. I want the following fields in the join table kunnr, land1, vbelnaudat,auart,netwr.

This is the program i wrote. plz let me know the errors.

TYPES:

BEGIN OF TY_OUTPUT,

KUNNR TYPE KNA1.KUNNR,

LAND1 TYPE KNA1.LAND1,

VBELN TYPE VBAK.VBELN,

AUDAT TYPE VBAK.AUDAT,

AUART TYPE VBAK.AUART,

NETWR TYPE VBAK.NETWR,

END OF TY_OUTPUT.

DATA:

ST_OUTPUT TYPE TY_OUTPUT,

IT_OUTPUT TYPE TABLE OF TY_OUTPUT.

SELECT OPTIONS.

SKUNNR FOR ST_OUTPUT.KUNNR.

SELECT KNA1KUNNR EQ VBAKKUNNR

WHERE KNA1~KUNNR IN SKUNNR.

IF SY-SUBRC EQ 0

LOOP AT IT_OUTPUT INTO ST_OUTPUT

WRITE:/ ST_OUTPUT.KUNNR, ST_OUTPUT.LAND1,

ST_OUTPUT_NAME1, ST_OUTPUT.VBELN,ST_OUTPUT.AUDAT,AT_OUTPUT.AUART,ST_OUTPUT.NETWR.

ENDLOOP.