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: 

simple structure

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

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

11 REPLIES 11

Vijay
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

data: begin of t_kna1,

<define your fields whatever you want>

end of t_kna1.

data: it_kna1 like table of t_kna1.

JozsefSzikszai
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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-field40--


i_kna1-field100.

is there any way to over come this problem.

0 Kudos

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

Former Member
0 Kudos

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

former_member402443
Contributor
0 Kudos

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

Former Member
0 Kudos

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.