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

problem codinq extra fields SQ02

0 Likes
857

hi guru

i have a problem, I explain the situation:

I created a query with this additional field (see coding below),  the query is based on customer orders, in this field is calculated, the sum of qty shipped, for each position of sales order (from tables LIPS), for this purpose it's all right.

Now, I would like to add in the code, the ability to select only the qty shipped, For this reason, I would like to include in the filter field LIKP-WADAT_IST, how can I do?

I can not add in the current code, a header field of the table LIKP ... help, thanks in advance

TABLES LIPS.

CLEAR QTASPE.

SELECT * FROM LIPS

  WHERE VGBEL = VBAP-VBELN

  AND   VGPOS = VBAP-POSNR.

  IF ( sy-dbcnt NE '0').

    ADD LIPS-LFIMG TO QTASPE.

  ELSE.

    MOVE '' TO QTASPE.

  ENDIF.

ENDSELECT.

5 REPLIES 5
Read only

former_member188827
Active Contributor
0 Likes
776

Why dont you use join? also instead of selcting all fields,select only required field. Try the following code:

SELECT LIPS~LFIMG FROM LIPS INNER JOIN LIKP

on LIPS~VBELN = LIKP~VBELN

  WHERE VGBEL = VBAP-VBELN

  AND   VGPOS = VBAP-POSNR and  LIKP~WADAT_IST  ne '00000000'..

  IF  sy-subrc = 0.

    ADD LIPS-LFIMG TO QTASPE.

   ENDIF.

ENDSELECT.

Read only

0 Likes
776

hi

I'm sorry, but it gives me this error:

"Field list without INTO clause is not allowed"

Read only

0 Likes
776

Checking sy-subrc within a SELECT... ENDSELECT loop doesn't do anything. If your in the loop, sy-subrc is always zero.

Read only

matt
Active Contributor
0 Likes
776

You are using the TABLES statement to define a work area. You are also using an obsolete form of the SELECT statement. Thirdly, since you check sy-dbcnt within the loop, it will never be zero if the loop executes, so your ELSE clause will never run.

Far better to use:

DATA: s_lips TYPE lips.

SELECT * INTO s_lips FROM lips...

Read only

0 Likes
776

unfortunately I can not solve, please show me the code in detail.

thanks so much