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

INTERNAL TABLE

Former Member
0 Likes
524

I WANT TO COPY THE DATA FROM DATABASE TO THREE INTERNAL TABLE

AND THEN CONVERT INTO ONE INTERNAL TABLE?TELL ME PLZZ HOW IT IS POSSIBLE PLZZZZZ

5 REPLIES 5
Read only

Former Member
0 Likes
461

hi,

not quite understand your question but to access database, use select to read to internal table. from internal table, you can use loop and read the other 2 internal table and modify it.

Read only

Former Member
0 Likes
461

I WANT TO COPY THE DATA FROM DATABASE TO THREE INTERNAL TABLE

AND THEN CONVERT INTO ONE INTERNAL TABLE?TELL ME PLZZ HOW IT IS POSSIBLE PLZZZZZ

hi.

if u want to copy data from 3 different tables in data base u need not to u need not to drag them into 3 internal tabels. u can define one internal table. table fields from differnt tables.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

werks LIKE mard-werks,

pstat LIKE mard-pstat,

ekgrp LIKE marc-ekgrp,

ausme LIKE marc-ausme,

END OF itab.

SELECT : mara~matnr

mara~ersda

mard~werks

mard~pstat

marc~ekgrp

marc~ausme

INTO TABLE itab UP TO 20 ROWS

FROM mara

INNER JOIN mard

ON maramatnr = mardmatnr

INNER JOIN marc

ON maramatnr = marcmatnr.

IF sy-subrc = 0.

LOOP AT itab.

WRITE :/1 itab-matnr,

20 itab-ersda,

40 itab-werks,

60 itab-pstat,

80 itab-ekgrp,

100 itab-ausme.

ENDLOOP.

ENDIF.

copy and past this program u can see the data from all the 3 data base tables.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
461

You should write something like

TABLES: table1, table2, table3.

DATA: t_table1 type sorted table of table1 with key key1.

DATA: t_table2 type sorted table of table2 with key key1 key2.

DATA: t_table3 type sorted table of table3 with key key1 key2 key3.

Select * into table t_table1 from table1 <where your select-options>.

Select * into table t_table2 from table2 for all entries in t_table1 where key1 = t_table1-key1 <and where your select-options>.

Select * into table t_table3 from table3 for all entries in t_table2 where key1 = t_table2-key1 and key2 = t_table2-key2 <and where your select-options>.

loop at t_table1 into table1.

move-corresponding table1 to outtab.

loop At t-table2 into table2 where k1 = table1-key1.

move-corresponding table2 to outtab.

loop At t-table2 into table2 where k1 = table2-key1 and key2 = table2-key2.

move-corresponding table3 to outtab.

append outtab.

endloop.

endloop.

endloop.

Regards

Read only

Former Member
0 Likes
461

Hi,

Create a main internal table1.filter data into this according to functional requirement.Then use this internal table1 & use join for all entries into internal table 2.similarly use internal table 3 & use join for all entries into internal table 3.

I have worked on something similar.U can have a look at the code.

SELECT ENSTEHDAT WERK PRUEFLOS LIFNR HERSTELLER FROM QALS INTO TABLE LIT_QALS

WHERE LIFNR IN S_LIFNR

AND HERSTELLER IN S_HERST.

SELECT VDATUM VCODE PRUEFLOS FROM QAVE INTO TABLE LIT_QAVE

FOR ALL ENTRIES IN LIT_QALS

WHERE PRUEFLOS = LIT_QALS-PRUEFLOS.

SELECT LIFNR NAME1 FROM LFA1 INTO TABLE LIT_LFA1

FOR ALL ENTRIES IN LIT_QALS

WHERE LIFNR = LIT_QALS-LIFNR.

Read only

Former Member
0 Likes
461

Hi,

Code as follows.I did it in my program:

SELECT QMNUM

IWERK

EQUNR

BTPLN

AUSWK

INGRP

QMDAB

BEZDT

TPLNR

SWERK

MSGRP

FROM VIQMEL INTO TABLE ITABMEL

WHERE IWERK = 'M011' and

AUSWK = 'A' and

INGRP = 'SLM' and

QMDAB NE '00000000' and

BEZDT GE SDATE-LOW and BEZDT LE SDATE-HIGH and

SWERK IN S_WERK.

IF SY-SUBRC = 0.

SELECT QMNUM MNGRP MNCOD FROM QMMA

INTO CORRESPONDING FIELDS OF TABLE ITABMA

FOR ALL ENTRIES IN ITABMEL

WHERE QMNUM = ITABMEL-QMNUM and

MNGRP = 'RESTLT01' and

MNCOD = '0350' OR MNCOD ='0270'.

SORT ITABMA BY QMNUM.

LOOP AT ITABMEL.

READ TABLE ITABMA WITH KEY QMNUM = ITABMEL-QMNUM BINARY

SEARCH.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING ITABMA TO ITABMEL.

MODIFY ITABMEL TRANSPORTING QMNUM.

ENDIF.

ENDLOOP.

SELECT TPLNR PLTXT FROM IFLO

INTO CORRESPONDING FIELDS OF TABLE ITABLO

FOR ALL ENTRIES IN ITABMEL

WHERE TPLNR = ITABMEL-TPLNR.

SORT ITABLO BY TPLNR.

LOOP AT ITABMEL.

READ TABLE ITABLO WITH KEY TPLNR = ITABMEL-TPLNR BINARY

SEARCH.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING ITABLO TO ITABMEL.

MODIFY ITABMEL TRANSPORTING PLTXT.

ENDIF.

ENDLOOP.

SELECT QMNUM

URKAT

URGRP

URCOD FROM QMUR

INTO CORRESPONDING FIELDS OF TABLE ITABMUR

FOR ALL ENTRIES IN ITABMEL

WHERE QMNUM = ITABMEL-QMNUM.

SORT ITABMUR BY QMNUM.

LOOP AT ITABMEL.

READ TABLE ITABMUR WITH KEY QMNUM = ITABMEL-QMNUM

BINARY SEARCH.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING ITABMUR TO ITABMEL.

MODIFY ITABMEL TRANSPORTING URKAT URGRP URCOD.

ENDIF.

ENDLOOP.

Hope this helps.

Reward if helpful.

regards,

Sipra