09-11-2008 2:31 PM
Hi Experts,
I have simple problem,
I want to retrieve plnnr number from mapl table like this
SELECT SINGLE plnnr
matnr
FROM mapl
INTO CORRESPONDING FIELDS OF wa_mapl
WHERE matnr = wa_qals-selmatnr AND
plnty = '2'.
By using this 'plnnr' number, i want to retrieve data from another table using for all entries. like
SELECT verwmerkm
plnnr
plnkn
merknr
FROM plmk
INTO CORRESPONDING FIELDS OF TABLE it_plmk
FOR ALL ENTRIES IN it_qasr
WHERE plnkn = it_qasr-vorglfnr AND
merknr = it_qasr-merknr AND
plnnr = wa_mapl-plnnr.
My question is, Can i use this where condition (plnnr = wa_mapl-plnnr) in this statement. If i used like this, Is it retrieve data or not?
Otherwise, please give me suggession in this regard and give some coding also......
Advance thanks to all.........
Regards
Ravindra
09-11-2008 2:33 PM
Yes you can. When you use for all entries you don't have to be restricted on itab fields. Also, don't forget to check if it_qasr has entries before select.
Regards,
Valter Oliveira.
09-11-2008 2:37 PM
If iam using like this, it doest retrieve the date. Just jump from the select statement. I think, because of that wa_mapl-plnnr field.
Please help me.............
Any Experts.......................
Edited by: Sai Babu on Sep 11, 2008 3:40 PM
09-11-2008 2:44 PM
Hello Sai,
Sure you can do this, in the debugging mode before select statement check whether you are getting data into work area.
Regards,
Naresh
09-11-2008 2:41 PM
Sure you can use the field PLNNR as a condition and indeed you should do that since it is a key field.
My question is where do you get the value of wa_mapl-plnnr because I don't see it in the coding you posted here?
09-11-2008 2:43 PM
Hi Sai,
If you are using the SELECT statement within the LOOP of
T_MAPL then it is ok.
Regards,
Rajitha.
09-11-2008 2:47 PM
In debug, verify two thing: the number of record you have in your itab, and then the value of that field wa_mapl-plnnr. For your info, this coding works (take your conclusions).
TYPES: BEGIN OF ty_vbrk,
vbeln TYPE vbeln,
END OF ty_vbrk,
BEGIN OF ty_vbrp,
vbeln TYPE vbeln,
posnr TYPE posnr,
END OF ty_vbrp.
DATA: ti_vbrk TYPE STANDARD TABLE OF ty_vbrk,
wa_vbrk TYPE ty_vbrk,
ti_vbrp TYPE STANDARD TABLE OF ty_vbrp,
wa_vbrp TYPE ty_vbrp,
wa_posnr TYPE posnr.
SELECT vbeln FROM vbrk INTO TABLE ti_vbrk WHERE fkart = 'ZZOT'.
CHECK sy-subrc EQ 0.
wa_posnr = '000020'.
SELECT vbeln posnr FROM vbrp
INTO TABLE ti_vbrp
FOR ALL ENTRIES IN ti_vbrk
WHERE vbeln = ti_vbrk-vbeln
AND posnr = wa_posnr.
Regards.
Valter Oliveira.
09-11-2008 2:45 PM
Hi Sai,
There wont be any difference between the two Select Statements.
You will get the same output for the two as the Primary key will be compared, any how, in the Statements For All Entries.
You can execute the below code and check.
REPORT ZAMIT101754.
data: wa_mapl type mapl,
wa_qals type qals,
it_plmk type plmk occurs 0 with header line,
it_qasr type qasr occurs 0 with header line .
SELECT SINGLE plnnr
matnr
FROM mapl
INTO CORRESPONDING FIELDS OF wa_mapl
WHERE matnr = wa_qals-selmatnr AND
plnty = '2'.
SELECT verwmerkm
plnnr
plnkn
merknr
FROM plmk
INTO CORRESPONDING FIELDS OF TABLE it_plmk
FOR ALL ENTRIES IN it_qasr
WHERE plnkn = it_qasr-vorglfnr AND
merknr = it_qasr-merknr.
AND
plnnr = wa_mapl-plnnr.
loop at it_plmk.
write it_plmk-plnnr.
endloop.
09-11-2008 2:49 PM
Hi Sai,
Yes you can use plnnr = wa_mapl-plnnr in where condition.
Regards,
Rajitha.
09-11-2008 2:57 PM
09-11-2008 2:58 PM
Hi,
As per the query you can follow in the below way.
-
REPORT ysdn_sp .
DATA:wa_mapl LIKE mapl.
DATA:wa_qals LIKE qals.
DATA:it_plmk LIKE plmk OCCURS 0 WITH HEADER LINE.
DATA:it_qasr LIKE qasr OCCURS 0 WITH HEADER LINE.
SELECT SINGLE selmatnr
FROM qals
INTO CORRESPONDING FIELDS OF wa_qals.
*WHERE matnr =
SELECT SINGLE plnnr matnr
FROM mapl
INTO CORRESPONDING FIELDS OF wa_mapl
WHERE matnr = wa_qals-selmatnr AND
plnty = '2'.
SELECT vorglfnr merknr
FROM qasr
INTO CORRESPONDING FIELDS OF TABLE it_qasr
UP TO 500 ROWS.
IF NOT it_qasr[] IS INITIAL.
SELECT verwmerkm plnnr plnkn merknr
FROM plmk
INTO CORRESPONDING FIELDS OF TABLE it_plmk
FOR ALL ENTRIES IN it_qasr
WHERE plnkn = it_qasr-vorglfnr AND
merknr = it_qasr-merknr AND
plnnr = wa_mapl-plnnr.
ENDIF.
-
Regds
Parvathi
09-11-2008 3:07 PM