Skip to Content
author's profile photo Former Member
Former Member

Select Statement

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 09, 2008 at 06:59 AM

    Hi Keyur

    instead of second kna1~kunnr

    write kna1~name1

    like below

    SELECT KNA1KUNNR *KNA1NAME1* 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.

    Reward if useful

    Regards,

    Talwinder

    Edited by: Talwinder Singh on Apr 9, 2008 12:29 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 09, 2008 at 07:02 AM

    Hi,

    use

    SELECT KNA1KUNNR *KNA1NAME1* 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.

    or

    SELECT KNA1KUNNR VBAKVBELN VBAPPOSEX VBAPZMENG VBAPNETPR VBAPNETWR INTO CORRESPONDING FIELDS OF TABLE IT_OUTPUT

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

    WHERE KNA1~KUNNR IN SKUNNR.

    rgds,

    bharat.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.