‎2008 Dec 02 10:19 AM
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
‎2008 Dec 02 10:25 AM
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
‎2008 Dec 02 10:21 AM
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.
‎2008 Dec 02 10:25 AM
hello
thats is not working
it says tht zmara should be flat structure
‎2008 Dec 02 10:21 AM
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.
‎2008 Dec 02 10:23 AM
declare an internal table and use this internal table ...
data : it_zmara like zmara occurs 0 with header line.
‎2008 Dec 02 10:25 AM
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
‎2008 Dec 02 10:25 AM
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.
‎2008 Dec 02 10:25 AM
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
‎2008 Dec 02 10:28 AM
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
‎2008 Dec 02 10:25 AM
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
‎2008 Dec 02 10:30 AM
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
‎2008 Dec 02 11:30 AM
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