‎2010 Apr 28 3:14 PM
Hi experts,
I have a req. in which I get data from one DB table into an internal table lt_hrp.
Now based on the data in it1, I need to fetch data in lt_hrt.
Below is the piece of code:
DATA: lt_zhrp TYPE STANDARD TABLE OF zhrp,
lt_zhrt TYPE STANDARD TABLE OF zhrt.
SELECT tabnr
FROM zhrp
INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
WHERE objid = lv_posid.
SELECT low
from zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
where tabnr = lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
This is giving a syntax error at the line: where tabnr = lt_zhrp-tabnr
""LT_HRP1222" is a table without a header line and therefore has no component called "TABNR".
Since I am coding inside a method, I can't use WITH HEADER LINE, as it has become obsolete.
Can you please help me out with this problem?
Thanks,
Ajay.
‎2010 Apr 28 3:18 PM
Hi,
You need to use the FOR ALL ENTRIES in the second query.
SELECT tabnr
FROM zhrp
INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
WHERE objid = lv_posid.
SELECT low
from zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
FOR ALL ENTRIES IN lt_zhrp
where tabnr = lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
Hope this helps
Regards
Shiva
‎2010 Apr 28 3:18 PM
You are missing the "FOR ALL ENTRIES" instruction in the second select.
SELECT low
from zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
FOR ALL ENTRIES IN LT_ZHRP
where tabnr = lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
‎2010 Apr 28 3:18 PM
Hi,
You need to use the FOR ALL ENTRIES in the second query.
SELECT tabnr
FROM zhrp
INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
WHERE objid = lv_posid.
SELECT low
from zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
FOR ALL ENTRIES IN lt_zhrp
where tabnr = lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
Hope this helps
Regards
Shiva
‎2010 Apr 28 3:20 PM
hi,
i think your problem is need of a work area...
Using "FOR ALL ENTRIES IN lt_zhrp" You must use " check lt_zhrp is not initial "
DATA: lt_zhrp TYPE STANDARD TABLE OF zhrp,
lt_zhrt TYPE STANDARD TABLE OF zhrt.
*new
data: wa_zhrp type lt_zhrp.
SELECT tabnr
FROM zhrp
INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
WHERE objid = lv_posid.
LOOP AT lt_zhrp INTO wa_zhrp.
SELECT low
FROM zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
WHERE tabnr = wa_zhrp-tabnr " lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
ENDLOOP.
Edited by: Miguel Antunes on Apr 28, 2010 4:22 PM
‎2010 Apr 28 3:37 PM
‎2010 Apr 28 3:39 PM
Hi experts,
When I user FOR ALL ENTRIES, there is one problem.
The field ATTRIB is from the table zhrt, but in using for all entries, the system treats it as the field of zhrp,
and therefore sy-subrc = 4 i.e. the query fails.
Could you please let me know a possible solution?
Thanks,
Ajay.
‎2010 Apr 28 3:46 PM
‎2010 Apr 29 2:24 AM
Hi Manas,
Below is the piece of code:
DATA: lt_zhrp TYPE STANDARD TABLE OF zhrp,
lt_zhrt TYPE STANDARD TABLE OF zhrt.
SELECT tabnr
FROM zhrp
INTO CORRESPONDING FIELDS OF TABLE lt_zhrp
WHERE objid = lv_posid.
SELECT low
from zhrt
INTO CORRESPONDING FIELDS OF TABLE lt_zhrt
where tabnr = lt_zhrp-tabnr
AND attrib = 'NET_VALUE'.
Thanks,
Ajay.
‎2010 Apr 29 6:10 AM