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

Sysntax error

Former Member
0 Likes
2,290

Hi experts:

This code is giving error:

Select * from t001 into corresponding fields of table it_t001.

Select * from T009 into corresponding fields of table it_t009.

Loop at it_t001 into it_t001_line.

read table it_t009 with key periv = it_t001-periv.

If sy-subrc ne 0.

move-corresponding it_t001-periv to it_t001_inconsistent-periv.

append it_t001_inconsistent.

endif.

endloop.

The internal table "IT_T009" has no header line - explicit specification of an output area with "INTO wa" or "ASSIGNING <fs>" is required."

"IT_T001" is a table without a header line and therefore has no component called "PERIV".

The internal table "IT_T001_INCONSISTENT" has no header line - instead of "APPEND IT_T001_INCONSISTENT", only "APPEND wa TO IT_T001_INCONSISTENT" is possible"

How do i correct this.

Thanks,

Ajay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,225

Hello,

Thanks to you all. Now I am able to get entries in the table it_t001_inconsistent. Now how do I print the result of this table?

Thanks,

Ajay.

22 REPLIES 22
Read only

Sm1tje
Active Contributor
0 Likes
2,225

read table .... INTO workarea. No header line defined, so use the workarea for reading data from itab.

Read only

Former Member
0 Likes
2,225

Check ur Internal tables declaration. Declare the internal tables as follows.

data: it_t001 type standard table of x_t001 with header line.

Read only

Former Member
0 Likes
2,225

hi,

Check the Read statement and replace it with below and declare it_t009_line .

read table it_t009 into it_t009_line with key periv = it_t001-periv.

Read only

Former Member
0 Likes
2,225

hi,

you are doing this ...

Select * from t001 into corresponding fields of table it_t001.

Select * from T009 into corresponding fields of table it_t009.

Loop at it_t001 into it_t001_line.

read table it_t009 with key periv = it_t001-periv.

If sy-subrc ne 0.

move-corresponding it_t001-periv to it_t001_inconsistent-periv.

append it_t001_inconsistent.

endif.

endloop.

try this...

Select * from t001 into corresponding fields of table it_t001.

Select * from T009 into corresponding fields of table it_t009.

Loop at it_t001 .

read table it_t009 into it_t001_line with key periv = it_t001-periv.

If sy-subrc ne 0.

move-corresponding it_t001-periv to it_t001_inconsistent-periv.

append it_t001_inconsistent.

endif.

endloop.

hope this help you

Regards

Ritesh J

Read only

Former Member
0 Likes
2,225

Hi...

here is d correct code.

data:it_t001 TYPE STANDARD TABLE OF t001,

wa_t001 TYPE t001,

it_t001_inconsistent TYPE STANDARD TABLE OF t001,

wa_t001_inconsistent TYPE t001,

it_t009 TYPE STANDARD TABLE OF t009,

wa_t009 TYPE t009,

Select * from t001 into table it_t001.

IF it_t001[] is not initial.

Select * from T009

into table it_t009

for all entries in it_t001

where periv = it_t001-periv.

Loop at it_t001 into wa_t001.

read table it_t009 with key periv = it_t001-periv transporting no fileds.

If sy-subrc ne 0.

move wa_t001-periv to wa_t001_inconsistent-periv.

append wa_t001_inconsistent TO it_t001_inconsistent.

endif.

endloop.

endif.

Read only

Former Member
0 Likes
2,225

Hi,

Define a work are of type T009


data gwa_t009 like t009.

then change this line


read table it_t009 with key periv = it_t001-periv.

to this


read table it_t009 into gwa_t009 with key periv = it_t001_line-periv.
" When comparing the periv field of the t001 table, you have to compare it 
"with the contents of the field periv in the work area it_t001_line.

Also change the lines of code where you are moving the data.


move-corresponding it_t001-periv to it_t001_inconsistent_wa-periv. " Define the work area as well
append it_t001_inconsistent_wa to it_t001_inconsistent.

Alternatively you can declare all the tables with the addition with header line, but that is not recommended.

regards,

Advait

Edited by: Advait Gode on Jan 13, 2009 8:48 AM

Read only

Former Member
0 Likes
2,225

Try it this way:

Select * from t001 into corresponding fields of table it_t001.
Select * from T009 into corresponding fields of table it_t009.

Loop at it_t001." into it_t001_line.

read table it_t009 with key periv = it_t001-periv.

If sy-subrc ne 0.

move-corresponding it_t001-periv to wa_t001_inconsistent-periv. "if you want to move only content of periv

" or else for entire record use 

move-corresponding it_t001 to wa_t001_inconsistent.
  
append wa_t001_inconsistent to it_t001_inconsistent. " using a explicit work area
endif.
endloop.

With luck,

Pritam.

Read only

faisalatsap
Active Contributor
0 Likes
2,225

Hi,

Please use the following statement to define you Internal table or work area

DATA: it_t001 LIKE STANDARD TABLE OF t001 WITH HEADER LINE,
      wa_it_t001 LIKE t001,
      it_t009 LIKE STANDARD TABLE OF t009 WITH HEADER LINE,
      wa_it_t009 LIKE t009.

Kind Regards,

Faisal

Read only

Former Member
0 Likes
2,225

1) First declare a work area for it_tT009 internal tables.

data : wa_t009 like line of it_tT009.

2) Then write the below code

Select * from t001 into corresponding fields of table it_t001.

Select * from T009 into corresponding fields of table it_t009.

clear it_t001_line.

Loop at it_t001 into it_t001_line.

clear wa_t009.

read table it_t009 into wa_t009 with key periv = it_t001-periv.

If sy-subrc ne 0.

move-corresponding it_t001-periv to it_t001_inconsistent-periv.

append it_t001_inconsistent.

clear it_t001_line.

endif.

endloop.

Read only

Former Member
0 Likes
2,225

Hello,

One of you has given me this code:

data:it_t001 TYPE STANDARD TABLE OF t001,

wa_t001 TYPE t001,

it_t001_inconsistent TYPE STANDARD TABLE OF t001,

wa_t001_inconsistent TYPE t001,

it_t009 TYPE STANDARD TABLE OF t009,

wa_t009 TYPE t009,

Select * from t001 into table it_t001.

IF it_t001[] is not initial.

Select * from T009

into table it_t009

for all entries in it_t001

where periv = it_t001-periv.

Loop at it_t001 into wa_t001.

read table it_t009 with key periv = it_t001-periv transporting no fileds.

If sy-subrc ne 0.

move wa_t001-periv to wa_t001_inconsistent-periv.

append wa_t001_inconsistent TO it_t001_inconsistent.

endif.

endloop.

endif.

Its giving a syntax error:

The internal table "IT_T009" has no header line - explicit specification of an output area with "INTO wa" or "ASSIGNING <fs>" is required.

Could you please help me out with this?

Thanks,

Ajay.

Read only

0 Likes
2,225

yeah...there was small type errors...here it is...

data:it_t001 TYPE STANDARD TABLE OF t001,

wa_t001 TYPE t001,

it_t001_inconsistent TYPE STANDARD TABLE OF t001,

wa_t001_inconsistent TYPE t001,

it_t009 TYPE STANDARD TABLE OF t009,

wa_t009 TYPE t009.

Select * from t001 into table it_t001.

IF it_t001[] is not initial.

Select * from T009

into table it_t009

for all entries in it_t001

where periv = it_t001-periv.

Loop at it_t001 into wa_t001.

read table it_t009 with key periv = wa_t001-periv transporting no fields.

If sy-subrc ne 0.

move wa_t001-periv to wa_t001_inconsistent-periv.

append wa_t001_inconsistent TO it_t001_inconsistent.

endif.

endloop.

endif.

Read only

0 Likes
2,225

If you want to use explicit work area for all the tables than do it this way: Modify the code given above:

Select * from t001 into table it_t001.

IF it_t001 is not initial.

Select * from T009 
into table it_t009
for all entries in it_t001
where periv = it_t001-periv.

Loop at it_t001 into wa_t001.
read table it_t009 into wa_t009 with key periv = wa_t001-periv.
If sy-subrc ne 0.
move wa_t001-periv to wa_t001_inconsistent-periv.
append wa_t001_inconsistent TO it_t001_inconsistent.
endif.
endloop.
endif.

With luck,

Pritam.

Read only

Former Member
0 Likes
2,225

Hi,

Use workarea for ur internal tables or use with headerline statement in ur internal table declaration.

Hope this will help u.

Thanks.

Read only

Former Member
0 Likes
2,225

Hi,

I am using this code:

data:it_t001 like STANDARD TABLE OF t001 with header line,

wa_t001 TYPE t001,

it_t001_inconsistent TYPE STANDARD TABLE OF t001,

wa_t001_inconsistent TYPE t001,

it_t009 like STANDARD TABLE OF t009 with header line,

wa_t009 TYPE t009.

Select * from t001 into table it_t001.

IF it_t001[] is not initial.

Select * from T009

into table it_t009

for all entries in it_t001

where periv = it_t001-periv.

Loop at it_t001 into wa_t001.

read table it_t009 with key periv = it_t001-periv." TRANSPORTING NO FIELDS.

If sy-subrc ne 0.

move wa_t001-periv to wa_t001_inconsistent-periv.

append wa_t001_inconsistent TO it_t001_inconsistent.

endif.

endloop.

endif.

But the internal table it_t001_inconsistent gets all the entries which are there in it_t001... i.e. the basic logic of the program is failing, which is that only those entries should come in it_t001_inconsistent that are there is T001-PERIV but not in T009-PERIV.

Can you please help me out with this?

Thanks,

Ajay.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,225

Hello Ajay,

You wrote:

" .... those entries should come in it_t001_inconsistent that are there is T001-PERIV but not in T009-PERIV."

Just to let you know this is NEVER possible because against T001-PERIV you have T009 maintained as check table. This situation will never happen.


Select * from t001 into table it_t001.
IF it_t001[] is not initial.
Select * from T009
into table it_t009
for all entries in it_t001
where periv = it_t001-periv.

Loop at it_t001 into wa_t001.
read table it_t009 with key periv = it_t001-periv." TRANSPORTING NO FIELDS.
If sy-subrc ne 0.
move wa_t001-periv to wa_t001_inconsistent-periv.
append wa_t001_inconsistent TO it_t001_inconsistent.
endif.
endloop.
endif.

Change the stmt:

 read table it_t009 with key periv = it_t001-periv." TRANSPORTING NO FIELDS. 

to

read table it_t009 with key periv = wa_t001-periv. 

You will find it_t001_inconsistent will have no values !!!

BR,

Suhas

I hope i am clear on this.

BR,

Suhas

Edited by: Suhas Saha on Jan 13, 2009 10:51 AM

Read only

0 Likes
2,225

Hi,

You are reading the data in a work area wa_t001, but while comparing the key preiv, you are using the itab. this is wrong.


Loop at it_t001 into wa_t001.
read table it_t009 with key periv = it_t001-periv." TRANSPORTING NO FIELDS.

to


Loop at it_t001 into wa_t001.
read table it_t009 with key periv = wa_t001-periv.  "use the work are here

regards,

Advait

Read only

0 Likes
2,225

Hello Suhas,

I have this situation where there are some blank values in T001-PERIV, which are not present in T009-PERIV.

Thanks,

Ajay.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,225

Hi Ajay,

Blank values in T001-PERIV means that Fiscal Year Variant is not maintained for that Company Code. What i meant is that you cannot give wrong / incorrect values to this field. You can always leave it as blank )

Then your code will work, with the modifications mentioned in my post.

BR,

Suhas

Edited by: Suhas Saha on Jan 13, 2009 10:57 AM

Read only

0 Likes
2,225

if you are using this code.

data:it_t001 like STANDARD TABLE OF t001 with header line,
wa_t001 TYPE t001,
it_t001_inconsistent TYPE STANDARD TABLE OF t001,
wa_t001_inconsistent TYPE t001,
it_t009 like STANDARD TABLE OF t009 with header line,
wa_t009 TYPE t009.

Select * from t001 into table it_t001.
IF it_t001[] is not initial.
Select * from T009
into table it_t009
for all entries in it_t001
where periv = it_t001-periv.

Loop at it_t001 into wa_t001.
read table it_t009 with key periv = wa_t001-periv. " change is done here, instead of it_t001-periv compare wa_t001-periv
If sy-subrc ne 0.
*move wa_t001-periv to wa_t001_inconsistent-periv.
move wa_t001 to wa_t001_inconsistent.  " change to this for display otherwise all will be blank
append wa_t001_inconsistent TO it_t001_inconsistent.
endif.
endloop.
endif.
* now loop the internal table it_t001_inconsistent and display the fields you want to show

Read only

Former Member
0 Likes
2,226

Hello,

Thanks to you all. Now I am able to get entries in the table it_t001_inconsistent. Now how do I print the result of this table?

Thanks,

Ajay.

Read only

0 Likes
2,225

Now how do I print the result of this table?

Please open a new thread for new question.

regards,

Advait

Edited by: Advait Gode on Jan 13, 2009 11:03 AM

Read only

Former Member
0 Likes
2,225

Select * from t001 into corresponding fields of table it_t001.

Select * from T009 into corresponding fields of table it_t009.

data : wa_t009 like line of it_t009,

wa_t001_inconsistent like line of it_t001_inconsistent.

Loop at it_t001 into it_t001_line.

read table it_t009 with key periv = it_t001_line-periv

into wa_t009.

If sy-subrc ne 0.

move-corresponding it_t001_line to wa_t001_inconsistent.

append wa_t001_inconsistent to it_t001_inconsistent.

endif.

endloop.

try this

Naresh