12-19-2007 8:23 AM
Hi,
1.I have a table KNA1
2.I want to write a select statement which extracts all the fields into the internal table it_kan1.
3.I want to maintain a structure t_kan1 of KNA1 table which has all the fields .
data: it_kna1 type standard table of t_kna1,
wt_kna1 type t_kna1.
the option I have
1. should I have to copy all the fields in the table and paste there in the structure.
or do you have any other option
12-19-2007 8:57 AM
hi Shilpa,
structure for kna1 (all fields):
DATA : gw_kna1 TYPE kna1.
internal table for kna1 (all fields):
DATA : gt_kna1 TYPE TABLE OF kna1.
hope this helps
ec
12-19-2007 8:33 AM
hi
just do this
data: it_kna1 type standard table of t_kna1,
wt_kna1 type kna1.
here it_kna1 will be an interal table of type kna1 and wt_kna1 will be structure or work area of type kna1 having all the fields as in kna1.
regards
vijay
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Dec 19, 2007 8:22 AM
12-19-2007 8:36 AM
Hi shilpa,
in order to create a structure, go to transaction SE11 and create your own structure. There, in the field list, just type ".INCLUDE" at the first Component, and "KNA1" as the component type. This should make reference to the standard structure of table KNA1.
I hope this helps. Best regards,
Alvaro
12-19-2007 8:38 AM
data: begin of t_kna1,
<define your fields whatever you want>
end of t_kna1.
data: it_kna1 like table of t_kna1.
12-19-2007 8:57 AM
hi Shilpa,
structure for kna1 (all fields):
DATA : gw_kna1 TYPE kna1.
internal table for kna1 (all fields):
DATA : gt_kna1 TYPE TABLE OF kna1.
hope this helps
ec
12-19-2007 9:24 AM
Hi Cartman,
What my doubt is,
firstly I have to create structure t_kna1 which have all the fields of kna1 in se38.
secondly
data: it_kna1 type standard table of t_kna1,
wa_kna1 type t_kna1.
here t_kan1 = structure of kna1 which has all the fields of kan1
it_kna1 = internal table of structure t_kna1
wa_kna1 = work area of structure t_kna1
my doubt is how can I write t_kna1 structure which has all fields of table kna1.
12-19-2007 9:43 AM
Hi,
Please check the below code.
REPORT zstemp_qty2_ .
TABLES:kna1.
TYPES:t_kna1 TYPE kna1.
DATA:it_kna1 TYPE STANDARD TABLE OF t_kna1.
DATA:wa_kna1 TYPE t_kna1.
SELECT * FROM kna1 INTO TABLE it_kna1 UP TO 10 ROWS.
LOOP AT it_kna1 INTO wa_kna1.
WRITE:/ wa_kna1-kunnr.
ENDLOOP.
Regds
Sivaparvathi
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Dec 19, 2007 8:27 AM
12-19-2007 10:23 AM
Hi,
say I have some 100 fields in my internal table i_kna1,
so write the write statement I have to write as
write:/ i_kna1-field1,i_kna1-field2,i_kna1-field3,--
i_kna1-field100.
is there any way to over come this problem.
12-19-2007 11:01 AM
hi shilpa,
if u want to use write stmt u have to hard code it.
like write:\ i_kna1-field
instead that use reuse_alv_grid_display funtion module
simple pass the internal table.
DATA :l_i_fieldcatalog TYPE slis_t_fieldcat_alv,"Field Catalog
l_i_events TYPE slis_t_event, "Events
l_wa_layout TYPE slis_layout_alv. "layout
*FM to create strucure
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = 'kna1structure'
i_inclname = sy-repid
CHANGING
ct_fieldcat = i_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*--Function Module to display Data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'top_of_page'
I_GRID_TITLE =
is_layout = l_wa_layout
it_fieldcat = l_i_fieldcatalog
it_events = l_i_events
TABLES
t_outtab = i_kna1.
EXCEPTIONS
program_error = 1
OTHERS = 2.
create database stucture with similar to kna1,
pass this to alv_merge mentioned above.
after that pass that internal table i_kna1 as mentioned above.
Regards
suneetha
12-19-2007 9:00 AM
In SE38
in ur program, click on pattern button just besides pretty printer.
in dat, structure radio button mention the table name KNA1, it will show all its fields, select which evr u want.
the entire strycture will be built in the program, without u having to copy manully any fields..
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Dec 19, 2007 8:23 AM
12-19-2007 9:18 AM
Hi Shilpa,
You can create a structure that holds all the fields of table KNA1 or any table with different options such as
1.You can declare a internal table that reference to the table.
data: it_kna1 type standard table of t_kna1,
wt_kna1 type kna1.
here it_kna1 will be an interal table of type kna1 and wt_kna1 will be structure or work area of type kna1 having all the fields as in kna1.
2.
in order to create a structure, go to transaction SE11 and create your own structure. There, in the field list, just type ".INCLUDE" at the first Component, and "KNA1" as the component type. This should make reference to the standard structure of table KNA1.
3.
In SE38
in ur program, click on pattern button just besides pretty printer.
in dat, structure radio button mention the table name KNA1, it will show all its fields, select which evr u want.
the entire strycture will be built in the program, without u having to copy manully any fields..
I hope this helps.
<REMOVED BY MODERATOR>
Regards
Manoj Kumar
Edited by: Alvaro Tejada Galindo on Dec 19, 2007 8:24 AM
12-19-2007 10:22 AM
hi shilpa,
i understood u r question.
here no need to create structure with similar fields of KNA1 table.
u can directly refer to the table kna1.
follow this syntax.
TYPES: ty_t_kna1 TYPE STANDARD TABLE OF kan1.
DATA : i_kna1 TYPE ty_t_kna1, (internal table).
wa_kna1 TYPE kna1.(work area )
now use this in select stmt
select *
from kna1
into table i_kna1
where..........
here no need of declaring stmt tables:kna1.
it works,try it.
regards
suneetha.