Application Development 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: 

SELECT QUERY-URGENT!!!

Former Member
0 Kudos

Hi,

Please respond on this ASAP.

SELECT SINGLE PRODH FROM MVKE INTO MVKE-PRODH WHERE

MATNR = VBDPR-MATNR.

IF SY-SUBRC EQ 0.

IF MVKE-PRODH NE SPACE.

IF MVKE-PRODH(5) EQ '00003'.

V_WINDSHIELDS = V_WINDSHIELDS + V_INV_QTY.

V_WINDSHIELDS_TOTAL = V_WINDSHIELDS_TOTAL + V_INV_QTY.

ELSEIF MVKE-PRODH(5) EQ '00004'.

V_TEMPERED = V_TEMPERED + V_INV_QTY.

V_TEMPERED_TOTAL = V_TEMPERED_TOTAL + V_INV_QTY.

ELSEIF MVKE-PRODH(5) EQ '00005'.

V_MOLDINGS = V_MOLDINGS + V_INV_QTY.

V_MOLDINGS_TOTAL = V_MOLDINGS_TOTAL + V_INV_QTY.

ENDIF.

ENDIF.

ENDIF.

this is the logic

i want to know if we are using sel single and

if there are more entries in MVKE

then too it will pick 1st always

then what is the alternate,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

use the following code.

DATA: BEGIN OF itab_mvke OCCURS 0,
          matnr TYPE mara-matnr,
          prodh TYPE mvke-prodh,
      END OF itab_mvke.

SELECT  prodh FROM mvke INTO CORRESPONDING FIELDS OF itab_mvke WHERE
matnr = vbdpr-matnr.
  IF sy-subrc EQ 0.
  LOOP AT ITAB_MVKE.
    IF ITAB_MVKE-prodh NE space.
      IF ITAB_MVKE-prodh(5) EQ '00003'.
        v_windshields = v_windshields + v_inv_qty.
        v_windshields_total = v_windshields_total + v_inv_qty.
      ELSEIF ITAB_MVKE-prodh(5) EQ '00004'.
        v_tempered = v_tempered + v_inv_qty.
        v_tempered_total = v_tempered_total + v_inv_qty.
      ELSEIF ITAB_MVKE-prodh(5) EQ '00005'.
        v_moldings = v_moldings + v_inv_qty.
        v_moldings_total = v_moldings_total + v_inv_qty.
      ENDIF.
    ENDIF.
  ENDIF.
ENDLOOP.

<i><b>regards

Debjani

Reward points for all helpful answer</b></i>

4 REPLIES 4

Former Member
0 Kudos

Hi,

use the following code.

DATA: BEGIN OF itab_mvke OCCURS 0,
          matnr TYPE mara-matnr,
          prodh TYPE mvke-prodh,
      END OF itab_mvke.

SELECT  prodh FROM mvke INTO CORRESPONDING FIELDS OF itab_mvke WHERE
matnr = vbdpr-matnr.
  IF sy-subrc EQ 0.
  LOOP AT ITAB_MVKE.
    IF ITAB_MVKE-prodh NE space.
      IF ITAB_MVKE-prodh(5) EQ '00003'.
        v_windshields = v_windshields + v_inv_qty.
        v_windshields_total = v_windshields_total + v_inv_qty.
      ELSEIF ITAB_MVKE-prodh(5) EQ '00004'.
        v_tempered = v_tempered + v_inv_qty.
        v_tempered_total = v_tempered_total + v_inv_qty.
      ELSEIF ITAB_MVKE-prodh(5) EQ '00005'.
        v_moldings = v_moldings + v_inv_qty.
        v_moldings_total = v_moldings_total + v_inv_qty.
      ENDIF.
    ENDIF.
  ENDIF.
ENDLOOP.

<i><b>regards

Debjani

Reward points for all helpful answer</b></i>

Former Member
0 Kudos

Hi

When you use select single ,it's always will bring only one result (first that corresponds to selection criteria (in this case MATNR number).

you can make it for example (make performance modifiation later):

data:itab type mvke.

SELECT SINGLE *

FROM MVKE

INTO table ITAB

where MATNR = VBDPR-MATNR.

IF SY-SUBRC EQ 0

loop at itab. (instead of MVKE put ITAB)

IF MVKE-PRODH NE SPACE.

IF MVKE-PRODH(5) EQ '00003'.

V_WINDSHIELDS = V_WINDSHIELDS + V_INV_QTY.

V_WINDSHIELDS_TOTAL = V_WINDSHIELDS_TOTAL + V_INV_QTY.

ELSEIF MVKE-PRODH(5) EQ '00004'.

V_TEMPERED = V_TEMPERED + V_INV_QTY.

V_TEMPERED_TOTAL = V_TEMPERED_TOTAL + V_INV_QTY.

ELSEIF MVKE-PRODH(5) EQ '00005'.

V_MOLDINGS = V_MOLDINGS + V_INV_QTY.

V_MOLDINGS_TOTAL = V_MOLDINGS_TOTAL + V_INV_QTY.

ENDIF.

ENDIF.

endloop.

so you will get all occurrences which corresponds for the matnr number

Regards

Yossi

Pawan_Kesari
Active Contributor
0 Kudos

if you want to process all the records with matching criteria then select all records in internal table and then process each one of them using LOOP statement.

Former Member
0 Kudos

hi

this select single is mainly used for valiation

it will get all the records

but under loop it will work

reward if usefull