‎2010 May 27 10:46 AM
Hello all ,
Please see the below code . Here i got the shipment number in internal table IT_VTTK . So For this shipment number i want to get the details from Vekp table in to internal table IT_VEKP . There is no need for me to use For all entries . I have passed the value of it_vekp into work area wa_vekp and getting the details in to IT_vekp using loop.
But since we should not use the select statement inside the loop , Can anybody please tell me how to achieve this functionality .
Instead of passing into work area wa_vttk if i directly use the internal table I'm getting the following error .
"IT_VTTK" is a table without a header line and therefore has no component called "TKNUM".
Hence i have used select statement inside a loop . Please tell me is there any other way to avoid this ?
types:begin of ty_likp,
vbeln type likp-vbeln,
end of ty_likp,
begin of ty_vttk,
tknum type vttk-tknum,
end of ty_vttk.
DATA: IT_VEKP TYPE STANDARD TABLE OF TY_VEKP,
WA_VEKP TYPE TY_VEKP.
data:it_likp type standard table of ty_likp,
wa_likp type ty_likp,
it_likp1 type standard table of ty_likp,
it_vttk type standard table of ty_vttk,
wa_vttk type ty_vttk.
data:w_tknum type vttk-tknum.
if not it_likp is initial .
select vbeln
from
vbfa
into table it_vttk
for all entries in it_likp where vbelv = it_likp-vbeln and vbtyp_n = '8'.
endif .
IF IT_VTTK[] IS NOT INiTIAL.
loop at it_vttk into wa_vttk.
SELECT venum
EXIDV
EXIDV2
BRGEW
NTGEW
GEWEI
TARAG
GEWEI
VHART
INHALT
FROM VEKP INTO TABLE IT_VEKP where VPOBJKEY = wa_vttk-tknum and vpobj = '4'.
endloop.
endif.
‎2010 May 27 10:49 AM
Hello,
Why would you not like to use FOR ALL ENTRIES in the second select? Is it becasue of the length or type mismatch error between the fields VPOBJKEY and wa_vttk-tknum ?
Vikranth
‎2010 May 27 11:01 AM
yes.I'm getting Lenght mismatch with VPOBJKY when i use for all entries . using for all entries is not required here right ? Please suggest me
‎2010 May 27 11:04 AM
Hii
I have used for all entries and by rectifying the vpobjky mismatch error . But still i want to know how to avoid select inside a loop if we come across any scenario like this
‎2010 May 27 11:09 AM
‎2016 Mar 14 1:32 PM
Hi Pavan,
I am facing same issue.
Kindly guide me how you resolved the mismatch error.
Thanks in advance.
Regards,
Aman Garg
‎2016 Mar 14 3:21 PM
You have a similar problem when trying to read NAST with VBELN as OBJKY, so it's worth understanding the issue and doing it right.
The best way to use FOR ALL ENTRIES in case of a type mismatch is to build a separate internal key table. Since the type mismatch does not occur in internal table reads, you just need that table for the selection.
Ddefine an internal table with the target field types of the selection keys of your dependent table (here VPOBJKY) and fill it. LOOP at VTTK and put TKNUM into VPOBJKY of the internal table. Then use FOR ALL ENTRIES against that internal table. Don't forget to check that it's not empty. It works with multiple fields (compound keys), too, which you may need for example for getting item output NAST records.
Wolfgang