‎2006 Sep 04 4:51 PM
There is a custom structure in se11, in which one of the fields say f3 is of the type standard transparent table. Now how do I refernce the fiels of this table through an internal table.
An internal table declared of this custom structure type has a structure like f1, f2, f3-fa, f3-fb, f3-fc.... where fa, fb, fc are fields of the standard transparent table.
Thanks.
‎2006 Sep 04 5:04 PM
Here is a better example of how to get the values of your deep structure.
report zrich_0001.
data: begin of ispfli occurs 0,
carrid type spfli-carrid,
connid type spfli-connid,
<b> ibookings type standard table of sbook,</b>
end of ispfli.
data: xspfli like line of ispfli.
data: xbookings type sbook.
loop at ispfli.
read table <b>ispfli-ibookings into xbookings</b> index 1.
if sy-subrc = 0.
write:/ <b>xbookings-customid</b>.
endif.
endloop.
Regards,
Rich Heilman
‎2006 Sep 04 4:52 PM
‎2006 Sep 04 4:56 PM
hi try the below code....
data: begin of itab occurs 0,
fld type f3-fa,
end of itab.
Cheers,
Abdul Hakim
‎2006 Sep 04 5:19 PM
I think I see what you are talking about now. It is a little tricky. Here ZSPFLI is my structure, it contains CARRID CONNID and a table type of SBOOK.
report zrich_0001.
<b>data: ispfli type table of ZSPFLI with header line.
data: xspfli like line of ispfli.
data: xbookings like line of ispfli-ibookings.</b>
data: begin of itest occurs 0,
<b> fld like xbookings-customid,</b>
end of itest.
loop at ispfli.
read table ispfli-ibookings into xbookings index 1.
if sy-subrc = 0.
write:/ xbookings-customid.
endif.
endloop
REgards,
Rich Heilman
‎2006 Sep 04 4:54 PM
Thanks for replying Rich....but I get an error for this saying that 'the stru is a flat type...'
‎2006 Sep 04 4:55 PM
If you mean how to get the value of these fields in your internal table, then just remember that it is another internal table and must be read. For example.
itab is structure like your custom structure, one field, F3 is a table itself, so you will need to read this.
loop itab into wa.
read table wa-f3 index 1. " Or however you need to read it.
if sy-subrc = 0.
write:/ wa-f3-fa.
endif.
endloop.Regards,
Rich HEilman
‎2006 Sep 04 5:04 PM
Here is a better example of how to get the values of your deep structure.
report zrich_0001.
data: begin of ispfli occurs 0,
carrid type spfli-carrid,
connid type spfli-connid,
<b> ibookings type standard table of sbook,</b>
end of ispfli.
data: xspfli like line of ispfli.
data: xbookings type sbook.
loop at ispfli.
read table <b>ispfli-ibookings into xbookings</b> index 1.
if sy-subrc = 0.
write:/ <b>xbookings-customid</b>.
endif.
endloop.
Regards,
Rich Heilman
‎2006 Sep 04 5:22 PM
Hi
data: begin of ispfli occurs 0,
carrid type spfli-carrid,
connid type spfli-connid,
ibookings type standard table of sbook,
end of ispfli.
how to insert the values into above internal table ispfli
‎2006 Sep 04 5:29 PM
Very good question. It can be done simply like this.
report zrich_0001.
data: begin of ispfli occurs 0,
carrid type spfli-carrid,
connid type spfli-connid,
ibookings type standard table of sbook,
end of ispfli.
data: xspfli like line of ispfli.
data: xbookings like line of ispfli-ibookings.
select carrid connid into corresponding fields of table
ispfli from spfli.
<b>loop at ispfli.
select * from sbook into table ispfli-ibookings
where carrid = ispfli-carrid
and connid = ispfli-connid.
modify ispfli.
endloop.</b>
loop at ispfli.
write:/ ispfli-carrid, ispfli-connid.
read table ispfli-ibookings into xbookings index 1.
if sy-subrc = 0.
write:/ 'THe first customer to book is:', xbookings-customid.
endif.
endloop.
Regards,
Rich Heilman
‎2006 Sep 04 5:44 PM
‎2006 Sep 04 5:52 PM
Hi rich
loop at ispfli.
write:/ ispfli-carrid, ispfli-connid.
read table ispfli-ibookings into xbookings index 1.
if sy-subrc = 0.
write:/ 'THe first customer to book is:', xbookings-customid.
endif.
endloop.
rich, in the above code what is the use of index , here u r looping ispfli suppose if i write like this then what happens
loop at ispfli.
write:/ ispfli-carrid, ispfli-connid.
xbookings = ispfli-ibbokings.
write:/ 'THe first customer to book is:', xbookings-customid.
endloop.
‎2006 Sep 04 5:57 PM
ispfli-ibookings is a internal table within the internal table ispfli. The read statement here is simply just reading the first record in that table(ibookings)
Doing this statement will not work.
xbookings = ispfli-ibbokings.Here you see that you are trying to move the internal table into the workarea called xbookings. ISPFLI-IBOOKINGS has no header line, so this does not help. You will get a syntax error.
Regards,
Rich Heilman
‎2006 Sep 04 7:11 PM