Application Development 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: 

Syntax problem

Former Member
0 Kudos
191

Hi Gurus!

Could anyone please let me know what exactly is the problem with my this part of code , its giving me syntax errors saying tables with header lines not supported with OO concept.

The parameters used here are:

IV_KNUMV Importing Type KNUMV

IV_KPOSN Importing Type KPOSN

RV_IS_LIST Returning Type ZPRICE_TYPE


data: lv_kotabnr type c length 15.
data:     begin of it_konv occurs 0,
        KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
      end of it_konv         ,

      begin of it_t685 occurs 0,
        kozgf type t685-kozgf,
      end of it_t685         ,
 
      begin of it_t682i occurs 0,
        kotabnr type t682i-kotabnr,
        kolnr   type t682i-kolnr,
        kozgf type t682i-kozgf  ,
      end of it_t682i         ,

      begin of it_price occurs 0,
        ZPRICE_TYPE type zsd_price_type-ZPRICE_TYPE,
      end of it_price         .


*************************************************************************************
* In all select Queries, fields sequence in WHERE clause should match with that in
* database table. This will improve the performance
*************************************************************************************

refresh it_konv.
select KINAK
       KSCHL
       KOLNR
  from konv
  into table it_konv
 where kinak = ' '
   and knumv eq iv_knumv
   and kposn eq iv_kposn .

check not it_konv[] is initial.

refresh it_t685.
select kozgf
  into table it_t685
  from T685
   for all entries in it_konv
 where kappl = 'V'
   and kschl = it_konv-kschl.

if sy-subrc eq 0.
  refresh it_t682i.
  Loop at it_konv.
    Loop at it_t685 where kschl = it_konv-kschl.
      move : it_konv-kolnr to it_t682i-kolnr,
             it_t685-kozgf to it_t682i-kozgf.
      append it_t682i.
    endloop.
  endloop.


  select kotabnr
         kolnr
         kozgf
    into table it_t682i
    from T682I
     for all entries in it_t682i
   where kappl = 'V'
     and kolnr eq it_t682i-kolnr
     and kozgf eq it_t682i-kozgf.


  if sy-subrc eq 0.

    select ZPRICE_TYPE
      into table it_price
      from zsd_price_type
       for all entries in it_t682i
     where kotabnr = it_t682i-kotabnr .

***************** Set IS_LIST based on your condition *****************
    Loop at it_price where ZPRICE_TYPE is initial .
      exit.
    endloop.
  endif.
endif.

 endmethod.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
133

Hi,

In ABAP OO you can't define internal tables with header line so:

data:     begin of it_konv occurs 0,
        KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
      end of it_konv         ,
 
      begin of it_t685 occurs 0,
        kozgf type t685-kozgf,
      end of it_t685         ,
 
      begin of it_t682i occurs 0,
        kotabnr type t682i-kotabnr,
        kolnr   type t682i-kolnr,
        kozgf type t682i-kozgf  ,
      end of it_t682i         ,
 
      begin of it_price occurs 0,
        ZPRICE_TYPE type zsd_price_type-ZPRICE_TYPE,
      end of it_price

These definitions are wrong because they are defining internal tables with a header line.

You should define them like:

Types: BEGIN OF t_konv,
           KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
END OF t_konv.

DATA: it_konv type table of t_konv, "Internal table
           wa_konv type t_konv. "Work Area

LOOP AT it_konv INTO wa_konv.
wa_konv-kinak = ....
....
ENDLOOP.

Hope it helps.

Regards,

Gilberto Li

12 REPLIES 12

Former Member
0 Kudos
133

Hi,

You cannot declare internal tables with header lines...remove the occurs 0...and create a work area for the internal tables to access the internal table values.

Ex..

types: begin of type_t685,
                  kozgf type t685-kozgf,
                end of type_t685         .
 
      data: it_t685 TYPE STANDARD TABLE OF type_t685,    " Internal table
              wa_t685 TYPE type_t685.                                     " Work area.

Thanks

Naren

Former Member
0 Kudos
134

Hi,

In ABAP OO you can't define internal tables with header line so:

data:     begin of it_konv occurs 0,
        KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
      end of it_konv         ,
 
      begin of it_t685 occurs 0,
        kozgf type t685-kozgf,
      end of it_t685         ,
 
      begin of it_t682i occurs 0,
        kotabnr type t682i-kotabnr,
        kolnr   type t682i-kolnr,
        kozgf type t682i-kozgf  ,
      end of it_t682i         ,
 
      begin of it_price occurs 0,
        ZPRICE_TYPE type zsd_price_type-ZPRICE_TYPE,
      end of it_price

These definitions are wrong because they are defining internal tables with a header line.

You should define them like:

Types: BEGIN OF t_konv,
           KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
END OF t_konv.

DATA: it_konv type table of t_konv, "Internal table
           wa_konv type t_konv. "Work Area

LOOP AT it_konv INTO wa_konv.
wa_konv-kinak = ....
....
ENDLOOP.

Hope it helps.

Regards,

Gilberto Li

0 Kudos
133

Thats right , I changed it to types now but still it gives me an error.

Field "IT_KONV" is unknown. It is neither in one of the specified

tables nor defined by a "DATA" statement . . . . . . . . . ..

I am using this in my methods.

Thanks

0 Kudos
133

Hi,

After the types you need this:

DATA: it_konv type table of t_konv, "Internal table
           wa_konv type t_konv. "Work Area

Regards,

Gilberto Li

0 Kudos
133

Yes that helped a lot but I still get another error msg if can help with.\

if sy-subrc eq 0.
  refresh t_t682i.
  Loop at t_konv.
    Loop at it_t685 where kschl = it_konv-kschl.
      move : it_konv-kolnr to it_t682i-kolnr,
             it_t685-kozgf to it_t682i-kozgf.
      append it_t682i.
    endloop.
  endloop.

At "LOOP AT itab" one of the additions "INTO", "ASSIGNING" or

"TRANSPORTING NO FIELDS" is required in the OO context . .

Thanks

0 Kudos
133

Hi,

Please check if T_konv is declared as an internal table or not...

if its declared as an internal table then what is the correspoding work area of that....

data :
wa like line of t_konv.

this line will create a line type of t_konv table...

then use

loop at t_konv into wa.
" processing steps
endloop.

Regards,

Siddarth

0 Kudos
133

Hi,

Check my entire example:

Types: BEGIN OF t_konv,
           KINAK type konv-kinak,
        KSCHL type konv-kschl,
        KOLNR type konv-kolnr,
END OF t_konv.
 
DATA: it_konv type table of t_konv, "Internal table
           wa_konv type t_konv. "Work Area
 
LOOP AT it_konv INTO wa_konv.
LOOP AT it_t685 where kschl = wa_konv-kschl.
      move : wa_konv-kolnr to wa_t682i-kolnr,
             wa_t685-kozgf to wa_t682i-kozgf.
      append wa_t685 to it_t682i.
    endloop.
  endloop.

Regards,

Gilberto Li

Edited by: Gilberto Li on Feb 26, 2009 7:03 PM

Edited by: Gilberto Li on Feb 26, 2009 7:05 PM

0 Kudos
133

Yes I have done that but the errro is at teh second loop and move statement .

At "LOOP AT itab" one of the additions "INTO", "ASSIGNING" or

"TRANSPORTING NO FIELDS" is required in the OO context . .

at this loop at t_t685....

and

loop at t_price at the end ...


Loop at t_konv into wa_konv.
    Loop at t_t685 where kschl = t_konv-kschl.
      move : it_konv-kolnr to wa_t682i-kolnr,
             it_t685-kozgf to wa_t682i-kozgf.
      append it_t682i.
    endloop.
  endloop.
.........
,,,,,,,,,,,,,,,,,,,,,,

     
***************** Set IS_LIST based on your condition *****************
    Loop at it_price where ZPRICE_TYPE is initial .
      exit.
    endloop.
  endif.
endif.

0 Kudos
133

hi,

data : wa_t685 like line of t_t685,
wa_price like line of it_price.                " additions

Loop at t_konv into wa_konv.
    Loop at t_t685 into wa_t685 where kschl = t_konv-kschl.            " addition of into statement
      move : it_konv-kolnr to wa_t682i-kolnr,
             it_t685-kozgf to wa_t682i-kozgf.
      append wa_t682 to it_t682i.               " change here also
    endloop.
  endloop.
.........
,,,,,,,,,,,,,,,,,,,,,,
 
     
***************** Set IS_LIST based on your condition *****************
    Loop at it_price into wa_price where ZPRICE_TYPE is initial .          " addition of into statement
      exit.
    endloop.
  endif.
endif.

Regards,

Siddarth

0 Kudos
133

Thanks for all the help but I am getting errors still , dont know why but ist error still.


data: lv_kotabnr type c length 15.
types: begin of it_konv ,
         kinak type konv-kinak,
         kschl type konv-kschl,
         kolnr type konv-kolnr,
       end of it_konv,

       begin of it_t685 ,
         kozgf type t685-kozgf,
       end of it_t685,

       begin of it_t682i,
        kotabnr type t682i-kotabnr,
        kolnr   type t682i-kolnr,
        kozgf type t682i-kozgf  ,
      end of it_t682i         ,

      begin of it_price ,
        ZPRICE_TYPE type zsd_price_type-ZPRICE_TYPE,
      end of it_price  .

      DATA: t_konv type table of it_konv, "Internal table
            wa_konv type it_konv, "Work Area
            t_t685 type table of it_t685,
            wa_t685 type it_t685,
            t_t682i type table of it_t682i,
            wa_t682i type it_t682i,
            t_price type table of  it_price,
            wa_price type it_price,

refresh t_konv.
select KINAK
       KSCHL
       KOLNR
  from konv
  into table t_konv
 where kinak = ' '
   and knumv eq iv_knumv
   and kposn eq iv_kposn .

check not t_konv[] is initial.

refresh t_t685.
select kozgf
  into table t_t685
  from T685
   for all entries in t_konv
 where kappl = 'V'
   and kschl = t_konv-kschl.

if sy-subrc eq 0.
  refresh t_t682i.
Loop at t_konv into wa_konv.
    Loop at t_t685 into wa_t685 where kschl = wa_konv-kschl.            
      move : it_konv-kolnr to wa_t682i-kolnr,
             it_t685-kozgf to wa_t682i-kozgf.
      append wa_t682 to it_t682i.               
    endloop.
  endloop.

  select kotabnr
         kolnr
         kozgf
    into table t_t682i
    from T682I
     for all entries in t_t682i
   where kappl = 'V'
     and kolnr eq t_t682i-kolnr
     and kozgf eq t_t682i-kozgf.

  if sy-subrc eq 0.

    select ZPRICE_TYPE
      into table t_price
      from zsd_price_type
       for all entries in t_t682i
     where kotabnr = t_t682i-kotabnr .

    Loop at t_price where ZPRICE_TYPE is initial .
      exit.
    endloop.
  endif.
endif.

 endmethod.

Thanks

Former Member
0 Kudos
133

Hi,

i have made the following changes please check.

data: lv_kotabnr type c length 15.
types: begin of it_konv ,
         kinak type konv-kinak,
         kschl type konv-kschl,
         kolnr type konv-kolnr,
       end of it_konv,
 
       begin of it_t685 ,
         kozgf type t685-kozgf,
       end of it_t685,
 
       begin of it_t682i,
        kotabnr type t682i-kotabnr,
        kolnr   type t682i-kolnr,
        kozgf type t682i-kozgf  ,
      end of it_t682i         ,

      begin of it_price ,
        ZPRICE_TYPE type zsd_price_type-ZPRICE_TYPE,
      end of it_price  .
 
      DATA: t_konv type table of it_konv, "Internal table
            wa_konv type it_konv, "Work Area
            t_t685 type table of it_t685,
            wa_t685 type it_t685,
            t_t682i type table of it_t682i,
            wa_t682i type it_t682i,
            t_price type table of  it_price,
            wa_price type it_price.        " replace ',' with '.'
 
refresh t_konv.
select KINAK
       KSCHL
       KOLNR
  from konv
  into table t_konv
 where kinak = ' '
   and knumv eq iv_knumv
   and kposn eq iv_kposn .
 
check not t_konv is initial.
 
refresh t_t685.
select kozgf
  into table t_t685
  from T685
   for all entries in t_konv
 where kappl = 'V'
   and kschl = t_konv-kschl.
 
if sy-subrc eq 0.
  refresh t_t682i.
Loop at t_konv into wa_konv.
    Loop at t_t685 into wa_t685. " where kschl = wa_konv-kschl.      " there is no component declared as KSCHL in t_t685
"  here is the declaration which you have made...
"begin of it_t685 ,
"         kozgf type t685-kozgf,
"       end of it_t685,  
" only one component so in this case if you try to use loop at t_t685 into wa_t685 where kschl = ...
" it does not recognize....
      move : wa_konv-kolnr to wa_t682i-kolnr,        " changed from it_konv to wa_konv
             wa_t685-kozgf to wa_t682i-kozgf.        " changed from it_t685 to wa_t685 as it_ are types as you have decleared they are not data variables
      append wa_t682i to t_t682i.               " changed from it_t682i to t_t682i and wa_t682 to wa_t682i
    endloop.
  endloop.
 
  select kotabnr
         kolnr
         kozgf
    into table t_t682i
    from T682I
     for all entries in t_t682i
   where kappl = 'V'
     and kolnr eq t_t682i-kolnr
     and kozgf eq t_t682i-kozgf.
 
  if sy-subrc eq 0.
 
    select ZPRICE_TYPE
      into table t_price
      from zsd_price_type
       for all entries in t_t682i
     where kotabnr = t_t682i-kotabnr .
 
    Loop at t_price into wa_price where ZPRICE_TYPE is initial .  " included into wa_price
      exit.
    endloop.
  endif.
endif.

regards,

Siddarth

deepak_dhamat
Active Contributor
0 Kudos
133

Dear Arav ,

You have defined structure of table in wrong way pls use this format to define work area and then internal table for that work area .

such as

DATA: lv_kotabnr TYPE c LENGTH 15.

TYPES: BEGIN OF wa_konv , " This is work area for internal table it_konv .

kinak TYPE konv-kinak,

kschl TYPE konv-kschl,

kolnr TYPE konv-kolnr,

END OF it_konv.

TYPES : BEGIN OF wa_t685 , " This is work area for internal table it_t685 .

kozgf TYPE t685-kozgf,

kschl TYPE konv-kschl,

END OF it_t685.

TYPES : BEGIN OF wa_t682i, " This is work area for internal table it_t682i .

kotabnr TYPE t682i-kotabnr,

kolnr TYPE t682i-kolnr,

kozgf TYPE t682i-kozgf ,

END OF it_t682i .

*TYPES: BEGIN OF wa_price , " This is work area for internal table it_price .

  • zprice_type TYPE zsd_price_type-zprice_type,

  • END OF it_price .

*

data : it_konv type standard table of wa_konv with header line , " This is internal table for all workarea .

it_t685 type standard table of wa_t685 with header line ,

it_t682i type standard table of wa_t682i with header line ,

it_price type standard table of wa_price with header line .

now you can use this as internal table for further calculation .