Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

code

Former Member
0 Likes
890

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
804

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.

6 REPLIES 6
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
804

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

Read only

Former Member
0 Likes
804

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

Read only

Former Member
0 Likes
804

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.

Read only

dev_parbutteea
Active Contributor
0 Likes
804

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

Read only

Former Member
0 Likes
805

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.

Read only

Former Member
0 Likes
804

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