We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

Re: [sap-abap] Replace Or Modify Content of One Internal Table by Content of Another Internal Table

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from milindpendse123 on Feb 8 at 12:22 PM
Dear Kasi & Kilbil,


I have seen your requirement. Giving below the solution for the same.
I have taken dummy table itab1 and itab2 and their fields as
field1. field2, field3 as given by you.
just copy and pas the below code to see the solution.


If you the below solution gives you the solution, kindly give the marks.


Regards,


Milind Pendse
Nagpur




***********************************************************************************
*** define 2 tables ITAB1 and ITAB2


DATA : BEGIN OF ITAB1 OCCURS 0,   FIELD1(3),     FIELD2(15),     FIELD3(1),   END OF ITAB1.


  DATA : BEGIN OF ITAB2 OCCURS 0,  FIELD1(3),  FIELD2(15),  FIELD3(1),  END OF ITAB2.


*** Move the 5 records in 2 tables ITAB1 and ITAB2
  ITAB1-FIELD1 = '1'.  ITAB1-FIELD2 = 'f1100017'.  ITAB1-FIELD3 = 'A'.  APPEND ITAB1.


  ITAB1-FIELD1 = '2'.  ITAB1-FIELD2 = ''.  ITAB1-FIELD3 = 'B'.  APPEND ITAB1.


  ITAB1-FIELD1 = '3'.  ITAB1-FIELD2 = 'f1100016'.  ITAB1-FIELD3 = 'C'.  APPEND ITAB1.


  ITAB1-FIELD1 = '4'.  ITAB1-FIELD2 = ''.  ITAB1-FIELD3 = 'D'.  APPEND ITAB1.


  ITAB1-FIELD1 = '5'.  ITAB1-FIELD2 = 'f1100018'.  ITAB1-FIELD3 = 'B'.  APPEND ITAB1.
** ENTRY FOR TABLE ITAB2 5 records


  ITAB2-FIELD1 = '1'.  ITAB2-FIELD2 = 'f1100011'.  ITAB2-FIELD3 = 'A'.  APPEND ITAB2.


  ITAB2-FIELD1 = '2'.  ITAB2-FIELD2 = 'f1100012'.  ITAB2-FIELD3 = 'B'.  APPEND ITAB2.


  ITAB2-FIELD1 = '3'.  ITAB2-FIELD2 = 'f1100013'.  ITAB2-FIELD3 = 'C'.  APPEND ITAB2.


  ITAB2-FIELD1 = '4'.  ITAB2-FIELD2 = 'f1100014'.  ITAB2-FIELD3 = 'D'.  APPEND ITAB2.


  ITAB2-FIELD1 = '5'.  ITAB2-FIELD2 = 'f1100015'.  ITAB2-FIELD3 = 'B'.  APPEND ITAB2.


****************printing both tables ITAB1 & ITAB2******************************


  LOOP AT ITAB1.    WRITE : / ITAB1-FIELD1, ITAB1-FIELD2, ITAB1-FIELD3.  ENDLOOP.


  SKIP 5.


  LOOP AT ITAB2.  WRITE : / ITAB2-FIELD1, ITAB2-FIELD2, ITAB2-FIELD3.  ENDLOOP.


**********solution*************************8


  LOOP AT ITAB1.     IF ITAB1-FIELD2 IS NOT INITIAL.       READ TABLE ITAB2 WITH KEY FIELD1 = ITAB1-FIELD1.       & #160;  IF SY-SUBRC = 0.             ITAB1-FIELD2 = ITAB2-FIELD2.       & #160;    MODIFY ITAB1.       &# 160; ENDIF.     ENDIF.  ENDLOOP.
SKIP 5.
LOOP AT ITAB1.    WRITE : / ITAB1-FIELD1, ITAB1-FIELD2, ITAB1-FIELD3.ENDLOOP.


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

---------------Original Message---------------
From: prakasareddyk
Sent: Tuesday, February 04, 2014 7:10 AM
Subject: Replace Or Modify Content of One Internal Table by Content of Another Internal Table

Hi Friends,

i have a requirement , where need to modify the content of an internal table by another internal table.

for example:
Itab1 is as follows
Field1 field2 field3
1 f1100017 A
2 f110002 B
3 C
4 f1100015 D
5 f1100010 E
6 F
7 f1100009 G

and itab2 is as follows


Field1 field2 field3
1 f1100001 A
2 f1100002 B
3 f1100003 C
4 f1100004 D
5 f1100005 E
6 f1100006 F
7 f1100007 G
How to replace or modify the field2 values of itab1 with field2 values of itb2, when field2 value is not empty.
I have tried with the field symbol logic but it is not working. Please provide me the source code for the same.

Thank you,
kasi.

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2014 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
milindpendse123  
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Earn Recognition for Your Contributions at Toolbox for IT. Gain Points for Community Achievements

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language