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

Combining 2 internal tables

Former Member
0 Likes
317

Hi,

The following is my current source code:

TABLES: ZCUSTOMER,

ZCUSTFIN.

DATA IT_1 LIKE ZCUSTOMER OCCURS 0 WITH HEADER LINE.

DATA IT_RES LIKE ZCUSTFIN OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZCUSTOMER INTO TABLE IT_1.

SELECT * FROM ZCUSTFIN INTO TABLE IT_RES.

LOOP AT IT_RES.

WRITE / IT_1.

ENDLOOP.

-


I'd like to output all of the records and fields from table IT_1 onto the screen, as well as one field and it's entries from table IT_RES (both tables have a key field as their first, so I'd like to sort the new table afterwards.)

How do i combine them and enter the data onto the screen?

Thanks in advance.

-John

Message was edited by:

John Damion

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
286

HI JOhn,

TABLES: ZCUSTOMER,

ZCUSTFIN.

DATA IT_1 LIKE ZCUSTOMER OCCURS 0 WITH HEADER LINE.

DATA IT_RES LIKE ZCUSTFIN OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZCUSTOMER INTO TABLE IT_1.

SELECT * FROM ZCUSTFIN INTO TABLE IT_RES.

LOOP AT IT_1.

READ TABLE IT_RES WITH KEY KEY_FIELD = IT_1-KEY_FIELD.

WRITE / IT_1-FIELD1, IT_1-FIELD2, IT_1-FIELD3, IT_RES-FIELD1, IT_RES-FIELD2.

CLEAR IT_RES.

ENDLOOP.

*********************************************************

assume the key_fields in both ztables are primary keys.

or may be u can use join...

for ex:

SELECT * INTO TABLE IT_FINAL FROM ZCUSTOMER INNER JOIN ZCUSTFIN ON ZCUSTOMERKEY_FIELD = ZCUSTFINKEY_FIELD.

LOOP AT IT_FINAL.

WRITE: / IT_FINAL-FIELD1,.................. .

ENDLOOP.

Regards

SAB

1 REPLY 1
Read only

Former Member
0 Likes
287

HI JOhn,

TABLES: ZCUSTOMER,

ZCUSTFIN.

DATA IT_1 LIKE ZCUSTOMER OCCURS 0 WITH HEADER LINE.

DATA IT_RES LIKE ZCUSTFIN OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZCUSTOMER INTO TABLE IT_1.

SELECT * FROM ZCUSTFIN INTO TABLE IT_RES.

LOOP AT IT_1.

READ TABLE IT_RES WITH KEY KEY_FIELD = IT_1-KEY_FIELD.

WRITE / IT_1-FIELD1, IT_1-FIELD2, IT_1-FIELD3, IT_RES-FIELD1, IT_RES-FIELD2.

CLEAR IT_RES.

ENDLOOP.

*********************************************************

assume the key_fields in both ztables are primary keys.

or may be u can use join...

for ex:

SELECT * INTO TABLE IT_FINAL FROM ZCUSTOMER INNER JOIN ZCUSTFIN ON ZCUSTOMERKEY_FIELD = ZCUSTFINKEY_FIELD.

LOOP AT IT_FINAL.

WRITE: / IT_FINAL-FIELD1,.................. .

ENDLOOP.

Regards

SAB