‎2007 May 23 12:34 PM
Hi Experts,
What's wrong in this code?
data: itab like vbak occurs 0 with header line.
data: begin of jtab occurs 0,
matnr like vbap-matnr,
end of jtab.
select * from vbak into table itab up to 10 rows.
if itab is not initial.
select matnr from vbap into table jtab for all entries in itab
where vbeln = itab-vbeln.
if jtab is not initial.
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
it is not priniting values in JTAB
‎2007 May 23 12:40 PM
Hi,
data: itab like vbak occurs 0 with header line.
data: begin of jtab occurs 0,
matnr like vbap-matnr,
end of jtab.
select * from vbak into table itab up to 10 rows.
if <b>itab[]</b> is not initial.
select matnr from vbap into table jtab for all entries in itab
where vbeln = itab-vbeln.
if <b>jtab[]</b> is not initial.
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
Regards,
Padmam.
‎2007 May 23 12:36 PM
Hi,
You have to use the table if you use the name it will treat the table with headerline as a workarea.
if <b>itab[ ]</b> is not initial.
select matnr from vbap into <b>corresponding fields of</b> table jtab for all entries in <b>itab[ ]</b>
where vbeln = itab-vbeln.
if <b>jtab[ ]</b> is not initial.
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
Regards,
Sesh
Message was edited by:
Seshatalpasai Madala
‎2007 May 23 12:38 PM
Hi,
Put [] bracket after internal table name in both the if conditions.
if not itab[] is initial.
select matnr from vbap into table jtab for all entries in itab
where vbeln = itab-vbeln.
if not jtab[] is initial.
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
Thanks
Sandeep
Reward if helpful
‎2007 May 23 12:39 PM
hi ravi,
chk if the itab[] is initial or not...
data: itab like vbak occurs 0 with header line.
data: begin of jtab occurs 0,
matnr like vbap-matnr,
end of jtab.
select * from vbak into table itab up to 10 rows.
<b>if not itab[] is initial.</b>
select matnr from vbap into table jtab for all entries in itab
where vbeln = itab-vbeln.
<b>if jtab[] is not initial.</b>
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
regards,
priya.
‎2007 May 23 12:40 PM
Hi,
loop at jtab.
write:/ <b>jtab-matnr</b>.
endloop.
use loop at jtab <b>into wa_jtab</b> <b>or assigning <fs_jtab></b>
write:/ wa_jtab-matnr or <fs_jtab>-matnr
endloop.
Regards,
Sooness
‎2007 May 23 12:40 PM
Hi,
data: itab like vbak occurs 0 with header line.
data: begin of jtab occurs 0,
matnr like vbap-matnr,
end of jtab.
select * from vbak into table itab up to 10 rows.
if <b>itab[]</b> is not initial.
select matnr from vbap into table jtab for all entries in itab
where vbeln = itab-vbeln.
if <b>jtab[]</b> is not initial.
loop at jtab.
write:/ jtab-matnr.
endloop.
endif.
endif.
Regards,
Padmam.
‎2007 May 23 12:53 PM
hi ravi,
when u say itab is not initial then it will check the header of ur internal table so it is initial so if condition is false.
when u put [] then it will check the body of ur internal table ..
sathish