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

internal table

Former Member
0 Likes
1,143

Hi,

Can anybody tel me what is wrong with following code:

data: itab_tbtco type TBTCO occurs 0.

data: wa type itab_tbtco.

select * into table itab_tbtco from tbtco where jobname = p_jname

and authcknam = p_uname

and strttime in s_time.

loop at itab_tbtco into wa.

write:/ wa-jobname, itab-authcknam, itab-strttime.

endloop.

bcz internal is not get fill by using above query.

if any thing is wrong tel me correct one.

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,094

Hi,

Instead of


data: itab_tbtco type TBTCO occurs 0.

Write-



data:itab_tbtco type table of TBTCO occurs 0.

Regards,

Sujit

14 REPLIES 14
Read only

Former Member
0 Likes
1,095

Hi,

Instead of


data: itab_tbtco type TBTCO occurs 0.

Write-



data:itab_tbtco type table of TBTCO occurs 0.

Regards,

Sujit

Read only

former_member787646
Contributor
0 Likes
1,094

Hi

the problem is here in the loop. As the Internal table doesn't have a header line you have to access the components using a work area. Please try the following code and check.

loop at itab_tbtco into wa.

write:/ wa-jobname, wa-authcknam, wa-strttime.

endloop.

Hope it helps.

Murthy

Read only

Former Member
0 Likes
1,094

hi,

Declare the work area as follows

DATA: WA type TBTCO. Rest of the code is correct.

Thanks!!

rahul

Read only

former_member787646
Contributor
0 Likes
1,094

Hi ,

As Rahul said above,

Declare the WA as follows and do the change in the LOOP.

  • Data: WA like line of itab_tbtco. (or)

Data: WA type tbtco.

*

loop at itab_tbtco into wa.

write:/ wa-jobname, wa-authcknam, wa-strttime.

endloop.

Read only

Former Member
0 Likes
1,094

Priya,

There have been several complaints that you do not follow up on your questions.

Please do that, and indicate which answer you found to be helpfull or correct.

My advice to others is, simply ignore the question.

Cheers,

Julius

PS: If the rules are broken in the question already, the whole thread thread is deleted and points are removed anyway...

Read only

Former Member
0 Likes
1,094

Hi,

I think you dont need to declare a work area here.I hope the below code will help you.

data: itab_tbtco type TBTCO occurs 0.

*data: wa like line of itab_tbtco.

select * into table itab_tbtco from tbtco where jobname = p_jname

and authcknam = p_uname

and strttime in s_time.

loop at itab_tbtco.

write:/ itab_tbtco-jobname, itab_tbtco-authcknam, itab_tbtco-strttime.

endloop.

Thanks,

Khushbu.

Read only

Former Member
0 Likes
1,094

Use following code....

DATA: itab_tbtco TYPE STANDARD TABLE OF tbtco .

DATA: wa TYPE tbtco.

SELECT * INTO TABLE itab_tbtco FROM tbtco WHERE jobname = p_jname
AND authcknam = p_uname
AND strttime IN s_time.


LOOP AT itab_tbtco INTO wa.

  WRITE:/ wa-jobname, WA-authcknam, WA-strttime.

ENDLOOP.

Read only

Former Member
0 Likes
1,094

hi,

DATA: itab_tbtco TYPE STANDARD TABLE OF tbtco ,

wa TYPE tbtco.

SELECT * INTO TABLE itab_tbtco FROM tbtco WHERE jobname = p_jname

AND authcknam = p_uname

AND strttime IN s_time.

LOOP AT itab_tbtco INTO wa.

WRITE:/ wa-jobname, WA-authcknam, WA-strttime.

ENDLOOP.

ur using occurs that is good, but dont use '0' , use any number instead of '0', for performence issue

Read only

Former Member
0 Likes
1,094

hi Priya ,

instead of writing

data: itab_tbtco type TBTCO occurs 0.

u can use

data: itab_tbtco type standard table of TBTCO .

Regards

Amit

Read only

Former Member
0 Likes
1,094

Hi,

You can changed your code like this:


TABLES : tbtco.

"Define internal table itab_tbtco
DATA : itab_tbtco TYPE STANDARD TABLE OF tbtco.

"Define work area wa of internal table itab_tbtco
DATA : wa LIKE LINE OF itab_tbtco.

SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS : p_jname TYPE tbtco-jobname,
             p_uname TYPE tbtco-authcknam.
SELECT-OPTIONS : s_time FOR tbtco-strttime.
SELECTION-SCREEN END OF BLOCK b1.

SELECT *
  INTO TABLE itab_tbtco
  FROM tbtco
  WHERE jobname = p_jname
  AND authcknam = p_uname
  AND strttime IN s_time.

LOOP AT itab_tbtco INTO wa.

  WRITE:/ wa-jobname, wa-authcknam, wa-strttime.

ENDLOOP.

A little suggestion:

The syntax of "DATA-OCCURS" has exactly the same function as the following DATA statement for the declaration of a standard table and is replace by this also:

DATA itab { {TYPE STANDARD TABLE OF [REF TO] type}

| {LIKE STANDARD TABLE OF [REF TO] dobj} }

WITH NON-UNIQUE DEFAULT KEY

INITIAL SIZE n.

[WITH HEADER LINE].

So it is better not to use "OCCURS 0" in the program.

Besides that, "WITH HEADER LINE" is also not recommended, the best way is to define an internal table, and then an extra work area of that internal table.

Hope it will help.

Best Regards,

Stephanie

Read only

Former Member
0 Likes
1,094

Since the select is done as an array fetch ,(as selection is directly been done in the internal table from the database table) so the internal table is being filled in a loop , so end the select statement with endselect.

Thanks and Regards ,

Debojyoti Chanda.

Read only

Former Member
0 Likes
1,094

Since the select is done as an array fetch ,(as selection is directly been done in the internal table from the database table) so the internal table is being filled in a loop , so end the select statement with endselect.

Thanks and Regards ,

Debojyoti Chanda.

Read only

Former Member
0 Likes
1,094

hi

you can rewrite the code like this,

DATA : wa type itab_tbtco.

select *

into WA

from tbtco where jobname = p_jname

and authcknam = p_uname

and strttime in s_time.

write:/ wa-jobname, wa-authcknam, wa-strttime.

ENDSELECT.

and occurs 0 is an obsolete statement.

Regards

Jose

Edited by: Jijo Jose on Jul 29, 2008 7:49 PM

Read only

Former Member
0 Likes
1,094

Hi Priya,

you can do the same thing in the following way:

data: itab_tbtco type table of TBTCO occurs 0.

(above statement will create an internal table of type TBTCO)

data: wa like line of itab_tbtco.

(above statement will create a work area for itab_tbtco)

select * into table itab_tbtco from tbtco where

jobname = p_jname

and authcknam = p_uname

and strttime in s_time.

loop at itab_tbtco into wa.

write:/ wa-jobname, wa-authcknam, wa-strttime.

endloop.

i hope this will help u...

Thanks & Regards

Ashu Singh