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

Table control doubt

0 Likes
1,151

Hi,

Please explain me the below code snippet.

LOOP AT itab with CONTROL TC CURSOR TC-top_line.

MODULE FETCHDATA. *** Why FETCHDATA should be called inside the Loop? Will this code hit the database again and again while looping? I tried FETCHDATA before the loop but did not work. why??? ***

ENDLOOP.

MODULE FETCHDATA OUTPUT.

SELECT * FROM SFLIGHT INTO TABLE itab.

SFLIGHT = itab. *** What is the significance? Why it is required ??? ***

ENDMODULE.

Thanks

Anand D

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,129

hi anand,

Fetching the data is always written in a loop because u fetch data into an internal table or from an internal table.so if u want to access all the fields of an internal table u have to put it in a loop.

if you want to retrieve the data from internal table then also fetching should be done ina loop.

SFLIGHT = itab

this is also used to move the contents of sfilght to itab,but i think it will give an error,because sflight and itab are not compatible.

reward if helpful.

regards,

sravanthi.

6 REPLIES 6
Read only

Former Member
0 Likes
1,129

Anand,

1.Every time you are deleting or adding in table control LOOP will get triggered and updated data will display on table control.

LOOP will be there in

PBO and PAI. to pass the data to and fro.to the table control.

Only few key words only will work in flow logic editor

like LOOP ,FIELDS ,CHAIN and end chain,Module etc.

I think max. 7 or 8 key fields will work

2.SFLIGHT = itab. *** What is the significance? Why it is required ??? ***

That is what i mensioned in above answer. To move the deleted or added data(changes) passing to screen to display

Pls. reward if useful.

Read only

0 Likes
1,129

Murali krishna,

Thanks for the reply.

Ok, one more question, so each and every time while modifying the Table Control the data gets updated to the database. What if I use my Table Control only for displaying the records; is it possible to put my FETCHDATA module outside the LOOP (Single time data fetch), since no updates possible???

If we are hitting the database inside the loop, will this decrease the performance???

Thanks

Anand D

Read only

Former Member
0 Likes
1,129

Hi Anand,

The module FETCHDATA has to be in the loop only because the fetching of data is being done into the table control using an internal table associated with it.

If the FETCHDATA module is out of the loop,then the data will no longer be fetched as the module is not being references to the table control(i.e., it is not being looped with the table control's internal table)

Without the loop,the table control cannot recieve the data.

SFLIGHT = itab.

This statement is generally used to move the contents of one internal table into the other.But here,it is not possible as SFLIGHT is a transparent table and itab is an internal table.

So you will get an error message saying

'The type of SFILGHT cannot be converted to the type of ITAB'.

Please check with the code once again.

Reward if usefull.

Thanks,

Kashyap Ivaturi

Read only

0 Likes
1,129

Hi Kashyap,

No error, the code works fine.

(Sorry the SFLIGHT here is Table Control field structure name... That is the reason its working)

Thanks for the reply.

Anand D

Edited by: Anand Deenadayalu on Jan 10, 2008 12:03 PM

Read only

Former Member
0 Likes
1,130

hi anand,

Fetching the data is always written in a loop because u fetch data into an internal table or from an internal table.so if u want to access all the fields of an internal table u have to put it in a loop.

if you want to retrieve the data from internal table then also fetching should be done ina loop.

SFLIGHT = itab

this is also used to move the contents of sfilght to itab,but i think it will give an error,because sflight and itab are not compatible.

reward if helpful.

regards,

sravanthi.

Read only

0 Likes
1,129

Hi Sravanthi,

Thanks,

I got a better solution from my friend to this...

This works fine and the select query is outside the loop.

MODULE FETCHDATA.

LOOP AT itab with CONTROL TCFLIGHT CURSOR TCFLIGHT-top_line.

module move_data_to_tablecontrol.

ENDLOOP.

-


MODULE move_data_to_tablecontrol OUTPUT.

move-corresponding itab to sflight.

ENDMODULE.

MODULE FETCHDATA OUTPUT.

SELECT * FROM SFLIGHT INTO TABLE itab.

ENDMODULE.

Thanks

Anand D