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

Fill Internal table

Former Member
0 Likes
1,795

Hello,

in my program i can't fill and send contents of my internal table. my code looks like this:

...

TABLES:

MKPF,

MSEG.

TYPES: BEGIN OF ST_2,

F_1 LIKE MKPF-MANDT, " For MKPF~MANDT,

F_2 LIKE MKPF-MBLNR, " For MKPF~MBLNR,

  • etc

F_18 LIKE MSEG-ZEILE, " For MSEG~ZEILE,

F_19 LIKE MSEG-LINE_ID, " For MSEG~LINE_ID,

  • etc

END OF ST_2.

DATA: it_1 TYPE TABLE OF ST_2,

wa_it LIKE LINE OF it_1.

FORM get_data.

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

INTO wa_it

FROM

MKPF AS MKPF

INNER JOIN

MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

ENDSELECT.

so, where should i put:

INSERT wa_it INTO TABLE it_1.

CLEAR wa_it.

to append my internal table with data?

please help me!!!!

14 REPLIES 14
Read only

Former Member
0 Likes
1,653

only help to put that data to my internal table, later i'll figure how to send data...

pls!

hlp!

Read only

Former Member
0 Likes
1,653
SELECT
MKPF~MANDT
MKPF~MBLNR
*etc
MSEG~ZEILE
MSEG~LINE_ID
<b>INTO corresponding fields of table itaB</b>
FROM
MKPF AS MKPF
INNER JOIN
MSEG AS MSEG
ON MKPF~MANDT = MSEG~MANDT AND
MKPF~MBLNR = MSEG~MBLNR AND
MKPF~MJAHR = MSEG~MJAHR
WHERE
MKPF~CPUDT >= '20060301' AND
MSEG~BUKRS = 'M' AND
MSEG~BWART IN ('601', '602').

so ITAB contains all the which meets the requiment.

regards

prabhu

Read only

naimesh_patel
Active Contributor
0 Likes
1,653

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

INTO<b> table it_1</b>

FROM

MKPF AS MKPF

INNER JOIN

MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

Regards,

Naimesh

Read only

Former Member
0 Likes
1,653

Hi,

i`ve made the necessary changes to your code :

SELECT MKPFMANDT MKPFMBLNR MSEGZEILE MSEGLINE_ID

INTO wa_it FROM MKPF AS MKPF INNER JOIN MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

<b>

append wa_it to it_it.
clear wa_it.

</b>

ENDSELECT.

reward points if helpful.

Regards

Read only

Former Member
0 Likes
1,653

Hi Maja,

Just put append itab from wa inbetween Select and Endselect statement.

No need of of Insert statement.

This would work.

Regards,

Prashanth

Read only

0 Likes
1,653

o.k.

1. try - when i put append between select and endselect nothing happens when i go to debugg mode...

my Table it_1 is Table[Initial]

2. try - when i put my it_table after INTO statement i get this error:

it_1 cannot be a table, a reference, a string, or contain any of these objects...

please help!

Read only

Former Member
0 Likes
1,653

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

INTO wa_it

FROM MKPF INNER JOIN MSEG

<b>into table it_1</b>

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

Read only

Former Member
0 Likes
1,653

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

<b>*INTO wa_it <--not required

into TABLE <ITAB_NAME> <-This will be added</b>

FROM

MKPF AS MKPF

INNER JOIN

MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

<b>* ENDSELECT. <-- NOT REQURIED if you use INTO TABLE.</b>

Read only

Former Member
0 Likes
1,653

Hi

Do it like this way

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

INTO table IT1

FROM

MKPF AS MKPF

INNER JOIN

MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

Read only

Former Member
0 Likes
1,653

SELECT

MKPF~MANDT

MKPF~MBLNR

*etc

MSEG~ZEILE

MSEG~LINE_ID

*etc

<b>*INTO wa_it <--THIS IS NOT REQUIRED

INTO TABLE <ITAB_NAME> <--ADD THIS</b>FROM

MKPF AS MKPF

INNER JOIN

MSEG AS MSEG

ON MKPFMANDT = MSEGMANDT AND

MKPFMBLNR = MSEGMBLNR AND

MKPFMJAHR = MSEGMJAHR

WHERE

MKPF~CPUDT >= '20060301' AND

MSEG~BUKRS = 'M' AND

MSEG~BWART IN ('601', '602').

<b>*ENDSELECT. <--this is not required if you use INTO TABLE</b>

Read only

0 Likes
1,653

o.k. i've done it like this:

INTO wa_it

*etc

*ENDSELECT

but in debugging, my table is first Initial and then it accepts good fields but still no data...

when i previously putted it into wa_it that one was filled with some acctual data..

pls help

Read only

0 Likes
1,653

hi,

i have my perform statement, code is too big to post it all... so.

Read only

0 Likes
1,653

hey,

if you use JUST WA_IT , then you should use ENDSELECT & BEFORE THAT USE append WA_IT into ITAB.

select...

into WA_IT

...

WHERE ....

APPEND WA_IT INTO ITAB.

ENDSELECT.

Regards

srikanth

Read only

Former Member
0 Likes
1,653

hi,

i found two points in your code,

1. where is the perform statement, without perform statement the form..will not work,use perform get_data.

2. check the data in the table,using sy-dbcnt,

if sy-dbcnt is initial.

message i121(zxxx).

endif.

regards,

kcc