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

TWO Internal Tables Access

Former Member
0 Likes
1,299

Hi,

I have 2 internal tables with different struc:

1 itab1 2. itab2

CID, CID

CEID, CEID

Month From

Year TO

for the second itab at run time i want to provide the values from(concatination of month and year) and TO.

1. i want to extract the data from the DB tables and add to the itab1

2. same data is copied to itab2 but at run time i wnat to concatenate the month and year in FROm and TO values will pass.

3. itab2 two is compare with another DB tables ...

Please help me with the code by taking any example..

can anyone will help me in this as iam unable to copy the data friol itab1 to itab2 because of diff strucure...

ur help is appreciable....

anjali

Hi,

I have 2 internal tables with different struc:

1 itab1 2. itab2

CID, CID

CEID, CEID

Month From

Year TO

for the second itab at run time i want to provide the values from(concatination of month and year) and TO.

1. i want to extract the data from the DB tables and add to the itab1

2. same data is copied to itab2 but at run time i wnat to concatenate the month and year in FROm and TO values will pass.

3. itab2 two is compare with another DB tables ...

Please help me with the code by taking any example..

can anyone will help me in this as iam unable to copy the data friol itab1 to itab2 because of diff strucure...

ur help is appreciable....

anjali

10 REPLIES 10
Read only

Former Member
0 Likes
1,272
Is this what you are looking for??

loop at itab1.

  move-corresponding itab1 to itab2.

   itab2-month_from = sy-datum+4(2).
   itab2-year_to = sy-datum+0(4).

   append itab2.

endloop.
Read only

0 Likes
1,272

Hi chandersheker,

My concept is diff....

1st iam using select statement

select * from <db1> to itab1.

in itab 1 i have cid,month , year.....

2. i wnat to read one by one record from itab1 and copy into another but i ahve a condition

1 record cid (picup from itab1) FROM (concatenation of month and year) TO i will provide the value).

This step should reapeat for earch and every record and add the changes to itab2.

...................................

after this itab2 is compred with DB2 tables ...

Plz reply its an urgent...

Anjali

Read only

0 Likes
1,272

Anjai, if you post EXACTLY the structure of the two tables people may be able to help you.

Read only

0 Likes
1,272

Hi Neil,

table1 : CID , CEId, Month , Year.

Table2 : CID , CEID, FROM, TO.( in this data already present but we need to modify the data for TO)

these are the two database tables....

table 1 data is coming from thirdparty and these is passing to FM...

1. so ... i have created created itab1 and copied the data from table 1 to itab1( here i created itab1 similar structure to table1)

2. i created 2nd internal table with CID,CEID,FROM and TWO ( FRom aand TO i accepted the fields from Table2)

3. know i want to copy the data of first internal table to second internal table....

but condition is CID (copy as it is) CEID (copy as it is) FROm should be concatenation of Month and year of itab1.TO need to be passed from program.

4. know compare the data which is their in itab2 with table2.

how to gohead can atleast some one will help me... plz provide me the code

Anjali

Read only

0 Likes
1,272

loop at itab1.

move-corresponding itab1 to itab2.

concatenate itab1-month itab1-year into itab2-from.

itab2-to = your_parameter_value.

append itab2.

endloop.

Read only

0 Likes
1,272

Hi

For that after the looping of itab1 you can put an if condition...

See the code given below

loop at itab1.

Cocatenate itab1-Month itab1-year into var1.

if ( var1 = itaab1-CID and var1 = itab1-CEID )

move-corresponding itab1 to itab2.

append itab2.

else.

endif.

endloop.

Read only

0 Likes
1,272

Think this is your requirment.....If not explain once more....

Read only

Former Member
0 Likes
1,272

Hi

Consider that itab1 and itab2 as the values . now to update the month and year dynamically to itab2 as follows

loop at itab1 into wa1

concatenate wa1-month wa1-year into lv_from

read itab2 with key cid = wa1-cid ceid = wa1-cied into wa2.

wa2-from = lv-from .

clear lv_from .

modify itab2 from wa2 transporting fields from .

endloop.

Read only

former_member196280
Active Contributor
0 Likes
1,272

EX:

Internal tables:

data : date(8).

itab1

ID Month

01 12

02 03

03 08

Itab2

Id Year

01 2006

02 2007

03 2005

Loop At itab1.

Read table itab2 WITH KEY id = itab1-id.

If sy-subrc = 0.

Concatenate itab1-month itab2-year INTO date.

ENDIF.

ENDLOOP.

2) for copying data use this

MOVE-CORRESPONDING itab1 TO itab2.

I hope it will solve your problem

Reward points to all useful questions.

Read only

Former Member
0 Likes
1,272

Hi

loop at itab1 into wa1.

move-corresponding wa1 to wa2.

wa2-month_from = sy-datum+4(2).

wa2-year_to = sy-datum+0(4).

append wa2 to itab2.

endloop.

Reward all helpfull answers.......