08-06-2013 12:21 PM
Hi everyone,
I am working in a program where I have to create a function module which selects data from another system, and compares it to the actual one.
In this case, a list of customers is in the two tables, but these customers may have different KUNNR's in the two different tables. So, I have to compare the KUNNR in the actual system with the KUNNR in the other system. Then, I have to show a list with the customers which have different KUNNR's in the two systems. Can somebody give me an idea of how can this be done?
Thanks in advance
08-06-2013 12:53 PM
Hi Shkelqim,
Create a FM (e.x. 'ZTEST_CHECK_CUSTOMER') of type RFC(Remote Function Call). And then in order to send data you have to configure RFC connection (e.x 'ZTEST_RFC') in SM59 of type ABAP connection.
Take importing parameter as Customer Number(KUNNR) and tables as Customer details. Write a select query
Select * into table IT_KNA1 from KNA1 where KUNNR in S_KUNNR.
Call that created FM in destination system where you want to check the values. As
Call Function 'ZTEST_CHECK_CUSTOMER' Destination 'ZTEST_RFC'.
Then in Destination system you can select KNA1 data in different table and compare it with source table.
Thanks,
Govind
08-06-2013 12:53 PM
Hi Shkelqim,
Create a FM (e.x. 'ZTEST_CHECK_CUSTOMER') of type RFC(Remote Function Call). And then in order to send data you have to configure RFC connection (e.x 'ZTEST_RFC') in SM59 of type ABAP connection.
Take importing parameter as Customer Number(KUNNR) and tables as Customer details. Write a select query
Select * into table IT_KNA1 from KNA1 where KUNNR in S_KUNNR.
Call that created FM in destination system where you want to check the values. As
Call Function 'ZTEST_CHECK_CUSTOMER' Destination 'ZTEST_RFC'.
Then in Destination system you can select KNA1 data in different table and compare it with source table.
Thanks,
Govind
08-06-2013 12:56 PM
Dear ,
Try to use Submit and Return Statement .
Thanks and Regards,
Ramkumar R .
08-06-2013 12:56 PM
Hi,
As per my understanding of your requirement,
you need to have a Z mapping table in either system that maps the KUNNRs between the systems. For example, the table caan have fields like
KUNNR system A KUNNR system B
1111 AAAA
2222 BBBB
3333 3333
etc.
Using this you can produce the list with different KUNNRs, in this case first 2 records of the table.
I hope I have understood your requirement correctly.
BR,
Shankar.
08-06-2013 12:57 PM
HI Shkelqim,
You can Use the Fm RFC_READ_TABLE.
You can populate the Option table with the Selection Criteria(similar to how you wirte a dynamic where clause) and access the External System.
Based on certain criteria you should be able to find a field which maps the customers in you original system to the external system so that you may identify the customers .
There is a limitation on the length of the data that you can import(512). so only fetch the fields that you require from the External system.
Please revert if you require any further Information
08-06-2013 1:15 PM
Create two internal tables in your program.
The first will be filled through a SELECT.
For the second one, look for a function module called RFC_READ_TABLE (I think it's called that way). Then learn how to call a function module from an external SAP system (check the help of CALL FUNCTION: you will find a clause called DESTINATION, read it)
Once you have both your tables full, create an algorithm to compare both tables. Hints: LOOP INTO and READ TABLE
And take into consideration Jürgen's advice in your other thread.
08-06-2013 1:19 PM
Hi,
You can compare data between different systems through multiple ways -
1) There is a function called “RFC_READ_TABLE” , through which we can read the other system tables entries . If we have RFC connection and a valid user and password to access the data on the receiving system.
2) with maint.-view
use: sm30 - maintain - utilities - adjust - enter rfc connection - mark - adjust
other tables: compare internal tables with your fm or
fm TABLE_ENTRIES_GET_VIA_RFC and modify your db-table
· 3) Use the Transaction code <b>SCMP</b> to compare the tables. you need RFC conection for the camparison server client ...
Prameters for thsi T.code is:
<b>View/Table:</b> Please give the Table name which you want to compare
<b>R/3 Conection:</b>: Give the RFC conection name (Use F4)
then there is some option, select the options to meet your requirment.
Thanks
Mansi
08-06-2013 1:45 PM
Hi Shkelqim,
In order to retrieve data from another system, use RFC enabled function module.
The RFC connection must be created in SM59 and the function module must be present in the destination system.
The parameters should use pass by value.
Get all the customer numbers from the destination system from table KNA1.
CALL FUNCTION <Function_module_name> DESTINATION <Destination_System>
Importing
gt_kna1 = <All customer numbers from KNA1 of the destination system>.
sort gt_kna1 by kunnr.
In the actual system, retrieve all the values of new customer numbers and old customer numbers using SELECT statement based on the old customers.
if gt_kna1 is not initial.
select kunnr altkn from knb1 into table lt_knb1
for all entries in gt_kna1
WHERE altkn = gt_kna1-kunnr.
if sy-subrc = 0.
sort lt_knb1 by altkn.
endif.
endif.
loop at gt_kna1 into gs_kna1.
read table lt_knb1 into ls_knb1 with key altkn = gs_kna1-kunnr binary search.
if sy-subrc = 0.
"Both old and new customer numbers are the same, proceed to the next record
if gs_kna1-kunnr = ls_knb1-kunnr.
continue.
"Both old and new customer numbers are different, store it into another internal table
else.
ls_final-new = ls_knb1-kunnr. "New Customer Number
ls_final-old = gs_kna1-kunnr. "Old Customer Number
append ls_final to lt_final.
clear: ls_final.
endif.
endif.
clear: ls_knb1, gs_kna1.
endloop.
Thanks & Regards,
T. Prasanna Kumar
08-06-2013 1:50 PM
Hi,
First fetch the respective values from table A from system 1 through a common SELECT statement with the appropriate WHERE conditions,
Then use the Remote enabled function module 'RFC_READ_TABLE' where u mention the destination ( system 2 ), table name (eg. table A) and the respective WHERE conditions in the OPTION parameter and execute. This fetches the appropriate values into the DATA parameter ( name it table 2 ) of the FM.
Now loop table 1 and read table 2 for the corresponding values of table 1. If sy-subrc = 0 delete those values from both the tables A and B. Thus only the values which have mismatch are left out in both the tables which u can read and append to a final table.