‎2008 May 23 3:15 PM
Hi friends
I want to fetch data from a Z table based on another table using field vbeln. The corresponding field in Z table is having a different character length. how can i do it.
SELECT docno vendrinv cpudt FROM zmdh INTO TABLE gt_zmdh
FOR ALL ENTRIES IN gt_vbrk WHERE vendrinv EQ gt_vbrk-vbeln AND dele_indi NE 'X'.
here vendrinv is having a type C & length 15 where as vbeln has type C and length 10.
I dont want to use loop for doing it.
Regards
Sathar
‎2008 May 23 3:19 PM
It works very well. check this.
data: begin of it_data occurs 0,
vbeln(20),
matnr type matnr,
end of it_data.
select vbeln
matnr
from vbap
into table it_data
up to 3 rows.
break-point.
‎2008 May 23 3:20 PM
you could add a field help_vendrinv to gt_vbrk in length 15 and move the contents of vbeln into that field before you do the "for all entries".
You might even be able to declare gt_vbrk-vbeln in length 15 to start with, no need for a help field then.
Cheers
Thomas
‎2008 May 23 3:25 PM
I have tried moving all contents of gt_vbrk into a new table with similiar fields but changed the type of vbeln to vendrinv. But the problem here is it added 5 zeroes to vbeln in the new table and the where condition will always go false.
Rgds
‎2008 May 23 3:49 PM
both fields are type C as you say, so there should not be an issue with leading zeroes unless you add them yourself somehow. Or is vendrinv actually of type N?
Anyway, if you declare GT_VBRK-VBELN same as ZMDH-VENDRINV, you can still select the values from VBRK into it and then use the field to select ZMDH using "for all entries".
Otherwise I have no further idea.
Cheers
Thomas
‎2008 May 24 9:24 AM
Hi Thomas
Thanks for your reply. I find that when I copy the contents of gt_vbrk to the temporary internal table which has the field vbeln with type same as vendrinv, five characters from next field is getting added to this. ie there is a shift of 5 characters to the left side for all fields after vbeln.
Now I have solved the problem in this way. I dont know whether this is the best method. Anyway it solved my prob for time being.
I have declared a temp int table with single field vbeln having data type & length same as vbeln. Now copied vbeln from gt_vbrk to this table. Again declared another int table with single field vbeln having data type & length same as vendrinv and moved the contents from prev temp table to this table.
Once again thanks to all for spending your precious time in this.
Regards
Sathar