Skip to Content
0
Former Member
Apr 09, 2008 at 06:53 AM

Select Statement

13 Views

Hi,

This is my program.

Here in the select statement(In Bold letters) I had selected KNa1KUNNR two times. If I keep the KNA1KUNNR for only one time iam getting the runtime error.

In the select options I had this statement. SKUNNR FOR ST_OUTPUT-KUNNR.(Instead of st_output-kunnr can i select from TY_OUTPUT-KUNNR).

This is the program.

TYPES:

BEGIN OF TY_OUTPUT,

KUNNR TYPE KNA1-KUNNR,

NAME1 TYPE KNA1-NAME1,

VBELN TYPE VBAK-VBELN,

POSEX TYPE VBAP-POSEX,

ZMENG TYPE VBAP-ZMENG,

NETPR TYPE VBAP-NETPR,

NETWR TYPE VBAP-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 KNA1KUNNR VBAKVBELN VBAPPOSEX VBAPZMENG VBAPNETPR VBAP~NETWR INTO TABLE IT_OUTPUT

FROM VBAK INNER JOIN KNA1 ON KNA1KUNNR EQ VBAKKUNNR INNER JOIN VBAP ON VBAKVBELN EQ VBAPVBELN

WHERE KNA1~KUNNR IN SKUNNR.

IF SY-SUBRC EQ 0.

LOOP AT IT_OUTPUT INTO ST_OUTPUT.

WRITE:/ ST_OUTPUT-KUNNR, ST_OUTPUT-NAME1,ST_OUTPUT-VBELN,

ST_OUTPUT-POSEX, ST_OUTPUT-ZMENG,ST_OUTPUT-NETPR,ST_OUTPUT-NETWR.

ENDLOOP.

ENDIF.

Thanks.