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

append internal table.

Former Member
0 Likes
1,882

Hi all ..

I have 2 internal tables and i want to append both in 3rd table..

data of 1st internal table : itab : like.

A

81000

81001

81002

81003

81004

data of 2nd internal table : itab1 is like :

A B

81000 23232323

81001 34343433

81001 45454545

81003 56565655

in output i want data like :

A B

81000 23232323

81001 34343434

81001 45454545

81002

81003 56565656

81004

Plz help me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,859

Hi Ankitha.

Fst loop the internal table in which u have max records and read snd table.

fst declare final internal table the fields u want to append

Loop AT fst_tab into fst_wa.

move fst internal table fileds into final_wa

READ table snd_tab into snd_wa with key snd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 2nd internal table fields to final_wa

endif

READ table trd_tab into trd_wa with key trd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 3rdinternal table fields to final_wa

endif

append final_wa to final_it

clear final_wa.

ENDLOOP

Edited by: Rasheed salman on Nov 29, 2008 5:53 AM

19 REPLIES 19
Read only

Former Member
0 Likes
1,860

Hi Ankitha.

Fst loop the internal table in which u have max records and read snd table.

fst declare final internal table the fields u want to append

Loop AT fst_tab into fst_wa.

move fst internal table fileds into final_wa

READ table snd_tab into snd_wa with key snd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 2nd internal table fields to final_wa

endif

READ table trd_tab into trd_wa with key trd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 3rdinternal table fields to final_wa

endif

append final_wa to final_it

clear final_wa.

ENDLOOP

Edited by: Rasheed salman on Nov 29, 2008 5:53 AM

Read only

0 Likes
1,859

SORRY

but it is not working..

it shows only last line for multiple times..

Plz help me..

Read only

0 Likes
1,859

Hi Ankita

Loop at itab1 into wa_itab1.

Read table itab with Key A = wa_itab1-A into wa_itab.

If sy-subrc ne 0.

clear wa_itab1.

move wa_itab-A to wa_itab1-A.

Append wa_itab1 to itab1.

endif.

Endloop.

Regards

Neha

Read only

0 Likes
1,859

Hi

It should work.Please check the code in Degugging mode and sort out the issue.

In the read table statement try to hit the primary key

Loop AT fst_tab into fst_wa.

move fst internal table fileds into final_wa

READ table snd_tab into snd_wa with key snd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 2nd internal table fields to final_wa

endif

READ table trd_tab into trd_wa with key trd_wa_feild = fst_wa_field

if sy-subrc eq 0

move 3rdinternal table fields to final_wa

endif

append final_wa to final_it

clear :final_wa,fst_wa.

ENDLOOP

Regards

Edited by: Rasheed salman on Nov 29, 2008 6:13 AM

Edited by: Rasheed salman on Nov 29, 2008 6:13 AM

Read only

0 Likes
1,859

Hi Rasheed...

I have 2 internal tables and i want to append it in 3rd internal table...

plz help me.

Read only

0 Likes
1,859

Hi,

Do like this.

Loop at itab.
Move-corresponding itab to it_final.
Append it_final.
Endloop.

Loop at itab1.
Move-corresponding itab1 to it_final.
Append it_final.
Endloop.
Sort it_final by A.

Read only

0 Likes
1,859

Hi Rasheed...

My code is like :

Loop AT itab into fst_wa.

move itab-banfn to final_wa-banfn.

*move fst internal table fileds into final_wa

*READ table snd_tab into snd_wa with key snd_wa_feild = fst_wa_field

read table itab1 into snd_wa with key banfn = fst_wa-banfn.

if sy-subrc eq 0.

*move 2nd internal table fields to final_wa

move itab1-banfn to final_wa-banfn.

endif.

*READ table trd_tab into trd_wa with key trd_wa_feild = fst_wa_field

*if sy-subrc eq 0

*move 3rdinternal table fields to final_wa

*endif

append final_wa to final_it.

clear :final_wa,fst_wa.

ENDLOOP.

LOOP AT final_it.

WRITE : / final_it-BANFN,final_it-ebeln.

ENDLOOP.

Plz help me Rasheed.......

Read only

0 Likes
1,859

your statistics says:


Registered:  Jul 4, 2007   
Total Posts:  147   
Total Questions:  74 (51 unresolved)"Means you did't setisfied at all in 51 Qns?!

You register yourself one and half year Ago and still you need logic to append in 3rd itab from two itab?!!!

Read only

0 Likes
1,859

Hi Ankit,

You are just moving the data to final internal table work area. But, You are not appending this data to final internal table.

Read only

0 Likes
1,859

hi amit..

If u want to help me than its oki...

there is no need of any king of suggestion like this...

Thanks a lot

Read only

0 Likes
1,859

I think you already got Well Enough Hint and Code from Neha and Rasheed,Now beyond this can't you put your efforts now?

I just simply said because asking this kind of help doesn't let you Efficient programmer.

As much as sugar you put in milk it will Sweeter more. So put effort in your work will lead you on Top.

Rest up to you,Sorry if my words hurt you at any corent of your heart.

Happy posting.

Read only

0 Likes
1,859

Hi Amit..

Its oki...

I tried a lot and after that i move to this sdn with such questions...

I cant get any output still...

If u can help me...

Read only

0 Likes
1,859

Hi Ankith

Dekho

TYPES: BEGIN OF ty_vbrk,

vbeln TYPE vbrk-vbeln,

fktyp TYPE vbrk-fktyp,

END OF ty_vbrk.

TYPES:BEGIN OF ty_vbrp,

vbeln TYPE vbrp-vbeln,

posnr TYPE vbrp-posnr,

END OF ty_vbrp.

TYPES:BEGIN OF ty_final,

vbeln TYPE vbrp-vbeln,

posnr TYPE vbrp-posnr,

fktyp TYPE vbrk-fktyp,

END OF ty_final.

DATA: it_vbrk TYPE STANDARD TABLE OF ty_vbrk,

it_vbrp TYPE STANDARD TABLE OF ty_vbrp,

it_final TYPE STANDARD TABLE OF ty_final,

wa_vbrk TYPE ty_vbrk,

wa_vbrp TYPE ty_vbrp,

wa_final TYPE ty_final.

SELECT vbeln

fktyp FROM vbrk

INTO TABLE it_vbrk.

IF sy-subrc EQ 0.

SORT it_vbrk BY vbeln.

SELECT vbeln

posnr FROM vbrp

INTO TABLE it_vbrp

FOR ALL ENTRIES IN it_vbrk

WHERE vbeln = it_vbrk-vbeln.

IF sy-subrc EQ 0.

SORT it_vbrp BY vbeln.

ENDIF.

ENDIF.

LOOP AT it_vbrp INTO wa_vbrp.

MOVE: wa_vbrp-vbeln TO wa_final-vbeln,

wa_vbrp-posnr TO wa_final-posnr.

READ TABLE it_vbrk INTO wa_vbrk WITH KEY vbeln = wa_vbrp-vbeln.

IF sy-subrc EQ 0.

MOVE: wa_vbrk-fktyp TO wa_final-fktyp.

ENDIF.

APPEND wa_final TO it_final.

CLEAR:wa_final,wa_vbrp.

ENDLOOP.

Follow this code

Regards

Read only

0 Likes
1,859

Ok np,

Here i assume:

This is Itab1.

Field1

A

81000

81001

81002

81003

81004

and itab2 is like :

Field1 Field2

A B

81000 23232323

81001 34343433

81001 45454545

81003 56565655

Try this code.

sort :itab1 by field1 field2,
itab2 by field1 field2.
Loop at itab1.
Read table itab2 with key field1 = itab1-field1 field2 ne initial binary search.
if sy-subrc = 0.
itab3-field1 = itab2-field1.
itab3-field2 = itab2-field2.
else.
itab3-field1 = itab1-field1.
append itab3.
Endif.
Endloop.

Cheers,

Amit.

Read only

0 Likes
1,859

>

> Hi Ankith

> Dekho

Rasheed,

First he/she is not Ankith he/she is Ankita,sometimes it may hurt anyone.And second Please don't use any Hindi words in posting.

Use Standard language.

Read only

0 Likes
1,859

Thanks Amit...

But there is still problem in output..

from ur logic output shows...

field 1 field2

81000 18000226

81001 18000743

81002

81003 18002681

81004

But l need output like..

field1 field2

81000 18000226

81001 18000743

81001 18000745

81002

81003 18002681

81004

plz u can do something for it .. then try it....

Plz yaar........

Read only

0 Likes
1,859

Hi

You can ask ur seniors in ur team regarding this query.Please add some knowledge sharing when u post a thread.

You got as many answers u want and u r simply asking for a spoon feeding which wehad already given in my code and amits code..

Please dont xpect SDN to understand ur requiremnt and give you solution as you want.

Sorry,if hurts u

Cheers

Read only

0 Likes
1,859

Finally,

Data:check type c.
sort :itab1 by field1 field2,
itab2 by field1 field2.
Loop at itab1.
loop at itab2 where field1 = itab1-field1 and field2 ne initial."replace read from inner loop.
itab3-field1 = itab2-field1.
itab3-field2 = itab2-field2.
append itab3.
check = 'X'.'
endloop.
if check = ' '.
itab3-field1 = itab1-field1.
append itab3.
endif.
clear check..
Endloop.

Read only

0 Likes
1,859

THANKS A LOT AMIT..

iTS WORKING.....

THANK U....