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

insert into internal table

Former Member
0 Likes
1,001

Hi Experts,

I am new comer to ABAP, have some very important task to be done, need help from all of you. I have a program which displays the results(inform about the infocubes). I want to insert the output of this prgm into an internal table, I am looking lot into the documentation, but so far not much help and i am not able to execute it. And one more task, I want to join this internal table and one database table and get the result, my question is , Is it possible to join this internal table and database table based on some common field.

Any help will be of grt help

Thanks,

Hem.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
748

Hi prabhakaran,

First in the REPORT_X which gives the data from infocubes export the required internal table i_tab in to a memory ID.

Now in your required application call the REPORT_X using submit statement with return addition.

now import the internal table i_tab from the memory id as specified in the REPORT_X.

to join the internal table with the database table use the following query:

select val3

val4

.

.

into table i_tab_new

from <database table>

for all entries in i_tab

where i_tab-val1 = <database table>-val1

and <additional condition>.

most important thing to be noted while using this select is that the internal table must not contain duplicate entries for the val1 which is mapped with the database table.

4 REPLIES 4
Read only

Former Member
0 Likes
748

Hi Prabhakaran,

You can use the sentence SUBMIT from one program, to call the program that create the report. Use adition LISTO TO MEMORY.

This Adition does not display the output list of the called report, but saves it in ABAP memory and leaves the called report immediately. Since the calling program can read the list from memory and process it further, you need to use the addition ... AND RETURN . Also, since the called report cannot be requested for printing, the addition ... TO SAP-SPOOL is not allowed here. You can read the saved list from SAP memory with the function module 'LIST_FROM_MEMORY' and then (for example) store it in the database with EXPORT. You can process this list further with the function modules 'WRITE_LIST', 'DISPLAY_LIST' ... of the function group "SLST".

Other way is to take the spool order created by the report, and store it in an internal table.

To join the internal table with a database, you have to code the logic to do it.

Regards

PabloX.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
748

Hi,

For joining internal table with database table,you need to write the logic as below.

This is the pseudo code.

select * from database into table itab2 where condition.

loop at itab1 into wa1.

move-corresponding wa1 to wa3.

.....

loop at itab2 into wa2 where field = wa1-field.

move-corresponding wa2 to wa3.

endloop.

append wa3 to itab3.

...

endloop.

1. select the required data from database table into internal table.

2. loop the first internal table which you already have.

3. Based on the key fields in these two internal tables[database],place the condition in READ or LOOP statement for the second internal table inside the loop of the first internal table.

4. If there are more records in second internal table for a single record in first internal table,then use LOOP the second internal table within the first internal table.Otherwise, read the second internal table within the first internal table.

5.Then move the corresponding fields from both the internal tables inside the loop to third internal table.Append the record to the third internal table.

Hope it helps.

Regards,

J.Jayanthi

Read only

Former Member
0 Likes
749

Hi prabhakaran,

First in the REPORT_X which gives the data from infocubes export the required internal table i_tab in to a memory ID.

Now in your required application call the REPORT_X using submit statement with return addition.

now import the internal table i_tab from the memory id as specified in the REPORT_X.

to join the internal table with the database table use the following query:

select val3

val4

.

.

into table i_tab_new

from <database table>

for all entries in i_tab

where i_tab-val1 = <database table>-val1

and <additional condition>.

most important thing to be noted while using this select is that the internal table must not contain duplicate entries for the val1 which is mapped with the database table.

Read only

0 Likes
748

Hi Everyone,

Thanks for all your replies, it helped me lot.

Regards,

Hem