Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

perticular select query is throwing the error..

Former Member
0 Likes
419

Hi all,

i am trying to get the ffew feilds with the count of one specific feild called as bpartner but the cursor doesnot move inside the select and directly going to the message and thowing the message as output..

can u please check it out and let me know where i have to change the query....and if the code whatever is written is right or not....

thanks in advance,,,

REPORT ZDISTRICT_CUST_AUCSALES00.

TABLES: /BIC/AUCSALES00,

/BIC/TCOKEY.

DATA: BEGIN OF ITAB OCCURS 0,

BILL_DATE LIKE /BIC/AUCSALES00-BILL_DATE,

/BIC/COKEY LIKE /BIC/AUCSALES00-/BIC/COKEY,

BPARTNER LIKE /BIC/AUCSALES00-BPARTNER,

TXTSH LIKE /BIC/TCOKEY-TXTSH,

CUSTOMER TYPE I,

END OF ITAB.

DATA: BILDT LIKE /BIC/AUCSALES00-BILL_DATE.

SELECT-OPTIONS: S_BILDT FOR /BIC/AUCSALES00-BILL_DATE.

**AT SELECTION-SCREEN.

    • IF NOT s_bildt IS INITIAL.

    • write:/ 'please enter a value'.

    • SELECT * FROM /BIC/AUCSALES00

    • INTO BILDT

    • WHERE BILL_DATE EQ S_BILDT.

    • ENDIF.

    • IF SY-SUBRC <> 0.

    • WRITE:/ 'please enter a '.

      • MESSAGE E010 WITH 'NOT A VALID DATE'(003) S_BILL_DATE 'Found'(004).

    • ENDIF.

<b>SELECT A~BILL_DATE

A~/BIC/COKEY

A~BPARTNER

COUNT( DISTINCT A~BPARTNER )

B~TXTSH

  • INTO (BILL_DATE, COKEY, BPARTNER, COUNT, TXTSH)

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM /BIC/AUCSALES00 AS A INNER JOIN /BIC/TCOKEY AS B

ON A/BIC/COKEY = B/BIC/COKEY

WHERE BILL_DATE = S_BILDT

  • A/BIC/COKEY = B/BIC/COKEY

GROUP BY ABILL_DATE A/BIC/COKEY ABPARTNER BTXTSH

ORDER BY A~/BIC/COKEY.

  • ENDSELECT.</b>

<i>IF SY-SUBRC NE 0.

WRITE:/ 'doesnot contain any data'.

ENDIF.</i>

LOOP AT ITAB.

WRITE:/ SY-VLINE, ITAB-BILL_DATE,

15 SY-VLINE, ITAB-/BIC/COKEY,

30 SY-VLINE, ITAB-TXTSH,

45 SY-VLINE, ITAB-CUSTOMER,

60 SY-VLINE.

ULINE /(60).

AT END OF BPARTNER.

SUM.

WRITE:/45 'TOTAL NUMBER OF CUSTOMER:',45 ITAB-CUSTOMER.

ENDAT.

Hi all,

i am trying to get the ffew feilds with the count of one specific feild called as bpartner but the cursor doesnot move inside the select and directly going to the message and thowing the message as output..

can u please check it out and let me know where i have to change the query....and if the code whatever is written is right or not....

thanks in advance,,,

REPORT ZDISTRICT_CUST_AUCSALES00.

TABLES: /BIC/AUCSALES00,

/BIC/TCOKEY.

DATA: BEGIN OF ITAB OCCURS 0,

BILL_DATE LIKE /BIC/AUCSALES00-BILL_DATE,

/BIC/COKEY LIKE /BIC/AUCSALES00-/BIC/COKEY,

BPARTNER LIKE /BIC/AUCSALES00-BPARTNER,

TXTSH LIKE /BIC/TCOKEY-TXTSH,

CUSTOMER TYPE I,

END OF ITAB.

DATA: BILDT LIKE /BIC/AUCSALES00-BILL_DATE.

SELECT-OPTIONS: S_BILDT FOR /BIC/AUCSALES00-BILL_DATE.

**AT SELECTION-SCREEN.

    • IF NOT s_bildt IS INITIAL.

    • write:/ 'please enter a value'.

    • SELECT * FROM /BIC/AUCSALES00

    • INTO BILDT

    • WHERE BILL_DATE EQ S_BILDT.

    • ENDIF.

    • IF SY-SUBRC <> 0.

    • WRITE:/ 'please enter a '.

      • MESSAGE E010 WITH 'NOT A VALID DATE'(003) S_BILL_DATE 'Found'(004).

    • ENDIF.

<b>SELECT A~BILL_DATE

A~/BIC/COKEY

A~BPARTNER

COUNT( DISTINCT A~BPARTNER )

B~TXTSH

  • INTO (BILL_DATE, COKEY, BPARTNER, COUNT, TXTSH)

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM /BIC/AUCSALES00 AS A INNER JOIN /BIC/TCOKEY AS B

ON A/BIC/COKEY = B/BIC/COKEY

WHERE BILL_DATE = S_BILDT

  • A/BIC/COKEY = B/BIC/COKEY

GROUP BY ABILL_DATE A/BIC/COKEY ABPARTNER BTXTSH

ORDER BY A~/BIC/COKEY.

  • ENDSELECT.</b>

<i>IF SY-SUBRC NE 0.

WRITE:/ 'doesnot contain any data'.

ENDIF.</i>

LOOP AT ITAB.

WRITE:/ SY-VLINE, ITAB-BILL_DATE,

15 SY-VLINE, ITAB-/BIC/COKEY,

30 SY-VLINE, ITAB-TXTSH,

45 SY-VLINE, ITAB-CUSTOMER,

60 SY-VLINE.

ULINE /(60).

AT END OF BPARTNER.

SUM.

WRITE:/45 'TOTAL NUMBER OF CUSTOMER:',45 ITAB-CUSTOMER.

ENDAT.

1 REPLY 1
Read only

Former Member
0 Likes
390

Hi,

Try like this,

SELECT A~BILL_DATE

A~/BIC/COKEY

A~BPARTNER

COUNT( DISTINCT A~BPARTNER )

B~TXTSH

  • INTO (BILL_DATE, COKEY, BPARTNER, COUNT, TXTSH)

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM /BIC/AUCSALES00 AS A INNER JOIN /BIC/TCOKEY AS B

ON A/BIC/COKEY = B/BIC/COKEY

WHERE BILL_DATE<b> IN</b> S_BILDT

  • A/BIC/COKEY = B/BIC/COKEY

GROUP BY ABILL_DATE A/BIC/COKEY ABPARTNER BTXTSH

ORDER BY A~/BIC/COKEY.

  • ENDSELECT.

<b>

Regards,

Azhar</b>