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

How a Structure can be used in program

Former Member
0 Likes
2,043

Dear Experts

I have created a structure in SE11.For example assume i have created Structure Zmara and i have three fields matnr,werks,lgort as fields.

how to use this in a program..i mean how to call this in a program with selection screen and to display some list using this...

please help with this

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,757

sorry all, but all the answers are far away from perfectness...

if you have a structure (zmara) in the DB, you have to create internal table the following way:

DATA : itab TYPE TABLE OF zmara.

work area:

DATA : wa TYPE zmara

11 REPLIES 11
Read only

Former Member
0 Likes
1,757

data: begin of itab occurs 0.

include structure zmara.

data: end of itab.

select matnr werks lgort from mara into table itab.

loop at itab.

write: itab.

endloop.

Read only

0 Likes
1,757

hello

thats is not working

it says tht zmara should be flat structure

Read only

Former Member
0 Likes
1,757

hi,

this example will help you:

TYPES: BEGIN OF name,

title(5) TYPE c,

first_name(10) TYPE c,

last_name(10) TYPE c,

END OF name.

TYPES: BEGIN OF mylist,

client TYPE name,

number TYPE i,

END OF mylist.

DATA list TYPE mylist.

list-client-title = 'Lord'.

list-client-first_name = 'Howard'.

list-client-last_name = 'Mac Duff'.

list-number = 1.

WRITE list-client-title.

WRITE list-client-first_name.

WRITE list-client-last_name.

WRITE / 'Number'.

WRITE list-number.

Read only

Former Member
0 Likes
1,757

declare an internal table and use this internal table ...

data : it_zmara like zmara occurs 0 with header line.

Read only

Former Member
0 Likes
1,757

u have to create ITAB using structure STR.

data: ITAB type standard table of STR with header line initial size 0.

so that u can have internal table with same fields like STR.

Regards,

Ajay

Read only

Former Member
0 Likes
1,757

Hi,

As you have created Z Structure, You need not to redeclare it in your program. You can directly create an internal table of type this structure or can use any field of the Structure as matnr-Zmara.

Regards.

Read only

Former Member
0 Likes
1,757

Hi,

you can use Structure in Type Declarations ,like you can define Internal Tables of this structure type,but you cannot Call a structure,and remember structure does not hold any data,its the Transparent tables that hold data.For more info on this you can refer ABAP Documentation.

Regards,

Neha

Read only

0 Likes
1,757

yes neha

i know , structure dont have any values

but in many real time examples , they created many structures and from that structure they are fetching values.structure do have values at runtime right.thats why i'm asking.could you please help

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,758

sorry all, but all the answers are far away from perfectness...

if you have a structure (zmara) in the DB, you have to create internal table the following way:

DATA : itab TYPE TABLE OF zmara.

work area:

DATA : wa TYPE zmara

Read only

Former Member
0 Likes
1,757

You can't get data from Structure because it is a logical table & it willn't store any data. DB Table can store data if u want u can retrieve it. Just u can use structure during Runtime for referring some internal table's which r suppose to using in program thats it.

Regards,

BBR.

Edited by: BBR on Dec 2, 2008 4:01 PM

Read only

Former Member
0 Likes
1,757

Through SE11...the structure which u have declared is global..

you can also declare structure internally also..SE38

Types : begin of str,

matnr type matnr,

werks type werks,

lgort type lgort,

end of str.

Then you need to declare internal tables...as follows...

Data : itab type standard table of str with header line.

or

data : begin of itab occurs 0.

include structure str / Zmara.

data : end of itab.

Then write the select query to retrive data from database table n then write staement..

its an simple ex to use structure in programs..

Regards

Ansumesh