cancel
Showing results for 
Search instead for 
Did you mean: 

How to declare itab inside Smartform

Former Member
0 Kudos

hi guys,

my requirement is this. I am passing a value(p_empno) to SF from SE38 pgm through function. i want to fetch the records from 2 tbls based on this value. In global definition, under initialisation tab, i wrote the code:

data : itab type table of str,

wa_itab type str.

select aempno aname a~dob

bdept bloc b~sal into table itab

from zempmaster as a

inner join zempdetails as b on bempno = aempno

where a~empno = p_empno.

the error is : itab is neither specified under "TABLES" nor is it defined as an internal table.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

*Global Data*

itab type str. -


> itab type table of str [Try this]

wa_itab type str.

Types

types:begin of str,

empno like zempmaster-empno,

name like zempmaster-name,

dob like zempmaster-dob,

dept like zempdetails-dept,

loc like zempdetails-loc,

sal like zempdetails-sal,

end of str.

Initialization

code for fetching data from DB into itab.

The ERROR is:

Field itab is unknown

Former Member
0 Kudos

thanks to all.

now it is working fine. I changed the code under GLOBAL DATA to "itab type str", previously it was "itab type str".

thanks a lot.

Former Member
0 Kudos

thanks to all.

now it is working fine. I changed the code under GLOBAL DATA to "itab type str", previously it was "itab type table of str".

thanks a lot.

raymond_giuseppi
Active Contributor
0 Kudos

Did you define the internal table in "Initialization" tab or "Global data" tab.

If in "Initialization" tab, that should work.

If in "Global data" tab, don't forget to fill the "Output parameters" with itab and the "Input parameter" with p_empno.

Also str is only a data element of length 12. is it long enough ?

Regards

Former Member
0 Kudos

hi

previously the str (str is a structure has 6 fields and defined using begin...end....) is defined under TYPES tab. now i declared in the initialization. still the error ' Filed ITAB is unknown'

Former Member
0 Kudos

Hi

When you declare in initialization area the type used in global definition will show an error message

so if you have declared a TYPE then declare it in TYPES area

If you declare it in INITIALIZATION area then you can use within that only but not for interface and for TYPE

in TYPES

types: begin of t_vbak,

vbeln type vbak-vbeln,

end of t_vbak.

in Global definition

i_VBAK type t_vbak

no error here

Declare the same in TYPES and use the same

Regards

Shiva

Former Member
0 Kudos

I'll brief u abt what I' ve done:

Global Data

-


itab type str.

wa_itab type str.

Types

-


types:begin of str,

empno like zempmaster-empno,

name like zempmaster-name,

dob like zempmaster-dob,

dept like zempdetails-dept,

loc like zempdetails-loc,

sal like zempdetails-sal,

end of str.

Initialization

-


code for fetching data from DB into itab.

The ERROR is:

-


Field itab is unknown

Former Member
0 Kudos

HI

You need to ITAB either in Input Parameters if it is not being used if ITAB is used to display final value then pass the same in OUTPUT PARAMETERS

try this and let me know

Regards

Shiva

Former Member
0 Kudos

Hi Shiv,

I filled the "Output parameters" with itab and the "Input parameter" with p_empno. am looping this itab to display the data in SF.

ERROR:

-


ITAB is not an internal table "OCCURS n" specification is missing.

Former Member
0 Kudos

Hi

You need to declare one work area for this

wa_str type str

or wa_str like line of itab

Regards

Shiva

Former Member
0 Kudos

Hi

STR is not table it is a data element check it

and use the table name for it or use begin of

Regards

Shiva