2012 Nov 14 4:54 AM
Hi experts,
I am new to SAP R/3. I know basics of abap reports. So i am trying to write a RFC program in se37 to insert the data from external application. I have written the code as below,
DATA: wa TYPE ytable2,
wa_str TYPE ystr_emp_details.
LOOP AT table INTO wa_str.
wa_str-emp_name = wa-ename.
wa_str-emp_mail = wa-emial.
wa_str-emp_addr = wa-eaddr.
INSERT ytable2 FROM wa_str.
CLEAR: wa, wa_str.
ENDLOOP.
There is no error. But the data was not populating in the table. Please help to resolve.
Thanks & Regards
Amarnath M
2012 Nov 14 6:48 AM
Hello
Amarnath M,
How about commiting the changes to the table by writing a 'Commit work.' Statement at the end of the Remote Function Module .
Hope this helps.
Anup Deshmukh
2012 Nov 14 6:51 AM
Hi,
Your structure 'wa' is always empty. You don't fill it anywhere.
2012 Nov 14 7:31 AM
Hi,
LOOP AT table INTO wa_str.
wa-ename = wa_str-emp_name.
wa-emial.= wa_str-emp_mail .
wa-eaddr = wa_str-emp_addr .
INSERT ytable2 FROM wa.
CLEAR: wa, wa_str.
ENDLOOP.
try this code...
and explain which is your table and from which wa you are getting the external information.
2012 Nov 14 8:33 AM
Hi,
I have changed according to you. But still i am facing the issue. My table contains only 3 fields namely name, email, address. External application like SAP PI sending data and i wrote a rfc to update those datas in the table. My internal table was 'table' which i have defined in tables tab of rfc and corresponding wa in data. wa_str is a structure of same type as db.
Thanks & Regards
Amarnath M
2012 Nov 14 8:39 AM
Hello Amarnath,
Just to have a SY-SUBRC check after your insert statement .
Try setting up a external break point ( Check the user for the break point .) so that you can debug the RFC when ever it is called from the external system so you that you can check what is going wrong in the function .
Hope this helps
2012 Nov 14 8:40 AM
What the primary key of your table ytable2? You also need to check SY-SUBRC after "INSERT ...". You just need to write the program carefully. Nobody can write the report instead of you.
2012 Nov 14 8:48 AM
Hi,
you may record what is really imported in 'table'. Use statement LOG-POINT and transaction SAAB.
Regards,
Clemens
2012 Nov 14 8:53 AM
hi,
see accoring to you db table is ytable2 and the internal table is
ystr_emp_details.
if so try this in insert.
Hi,
LOOP AT table INTO wa_str.
wa-ename = wa_str-emp_name.
wa-emial.= wa_str-emp_mail .
wa-eaddr = wa_str-emp_addr .
INSERT into ytable2 values wa.
CLEAR: wa, wa_str.
ENDLOOP.
2012 Nov 14 8:47 AM
Hi,
I have set break point and debugged. It is not entering into to the loop. thats the problem. I had set the sy-subrc after loop statement also. But no use. Primary key was ename. I checked sy-subrc after insert statement also. but no use. please help me.
Thanks & Regards
Amarnath M
2012 Nov 14 8:54 AM
Amarnath M wrote:
It is not entering into to the loop.
So you have empty 'table' .
2012 Nov 14 9:03 AM
Hi
My 'table' has 2 entries. I am trying to enter 3rd entry but i am failed.
Thanks & Regards
Amarnath M
2012 Nov 14 9:12 AM
2012 Nov 15 5:10 AM
Hi,
I have checked all the feasibility. But i couldn't find the solution. Please help me.
Thanks & Regards
Amarnath M
2012 Nov 15 5:18 AM
hi ,
let me know your import parameters and export and table parameters in your function module.
Regards,
Vinoth Aruldass.
2012 Nov 15 5:25 AM
Hi
Please find my import, table parameter.. I am not using any export parameter. Here ytable2 was my db table.
*"*"Local Interface:
*" IMPORTING
*" VALUE(EMP_NAME) TYPE YEMP_NAME
*" VALUE(EMP_MAIL) TYPE YEMP_MAIL
*" VALUE(EMP_ADDR) TYPE YEMP_ADDR
*" TABLES
*" TABLE STRUCTURE YTABLE2
Please help me if i am wrong.
Thanks & Regards
Amarnath M
2012 Nov 15 5:37 AM
hi,
in tables
declare
Tables :
table like ytable2.
Then.
confirm me you are putting all your external values which are going to inserted into table right
Your code must me
2012 Nov 15 5:38 AM
2012 Nov 15 5:41 AM
if you are giving your input in the table
your code must be
data :wa type ytable2.
loop at table into wa.
INSERT into ytable2 values wa.
clear wa.
endloop.
hope my answer will be helpful.
2012 Nov 15 5:54 AM
Hi,
I have tried ur coding but still data doesn't get populated. When i debug the program, it is not going inside the loop. I think that may be the problem.
Regards
Amarnath
2012 Nov 15 6:01 AM
first change the table key word to some table_str and try the same code.
2012 Nov 15 6:45 AM
Amarnath,
How you are passing on the data from the Source System to Target System.
What is the strucutre of table which is carrying the data from Source to Target System.
Mostly it is due to the inconsistency in the way that you are passing the data from Source to Target System.Check this part in Debugging.Put indefinite loop in the target system code and run the program from the Source system.Now go to the target system and use T Code SM50,select the program and choose PROGRAM/SESSION>>PROGRAM>>DEBUGGING.This will trigger the break-point in the target system.Now in debugging exit the indefinite loop and check the flow of the program
{code}
data:c_x type c.
Do
if c_x = 'X'. ( in the debugging pass 'X' to c_x field so that you can exit the indefinite loop)
exit.
enddo
{code}
K.Kiran.
2012 Nov 15 6:58 AM
Hi,
I have changed coding as you said but no use. I think i am wrong somewhere. But i dunno where it was.
My source system was SAP PI and target system was SAP R/3. From PI i am sending the data and it needs to get update in the table. For this i wrote an RFC. This is the table DB table structure,
When i debug my RFC code which i mention above, the debugging doesn't goes into loop. I think there may not be any indefinite loop because i am having only one loop.
Regards,
Amarnath
2012 Nov 15 7:18 AM
I think you misunderstood the meaning of TABLE
*"*"Local Interface:
*" IMPORTING
*" VALUE(EMP_NAME) TYPE YEMP_NAME <== individual record values
*" VALUE(EMP_MAIL) TYPE YEMP_MAIL
*" VALUE(EMP_ADDR) TYPE YEMP_ADDR
*" TABLES
*" TABLE STRUCTURE YTABLE2 <===== internal table (list of records)
- You have a database table YTABLE2
- You added a TABLE type parameter to the RFC
You pass the individual new record field values AND an internal table in the FM, and i suppose there is NOTHING in your exported internal table, so change your FM interface and code to look like :
FUNCTION z_rfc_ytable2 .
*"----------------------------------------------------------------------
*"*"Local Interface :
*" IMPORTING
*" VALUE(EMP_NAME) TYPE X
*" VALUE(EMP_MAIL) TYPE X
*" VALUE(EMP_ADDR) TYPE X
*" EXCEPTIONS
*" INSERT_FAILED
*"----------------------------------------------------------------------
DATA: wa TYPE ytable2.
CLEAR wa.
wa-emp_name = i_emp_name.
wa-emp_name = i_emp_name.
wa-emp_name = i_emp_name.
INSERT ytable2 FROM wa.
IF SY-SUBRC NE 0.
RAISE INSERT_FAILED.
ENDIF.
ENDFUNCTION.
Or use only an internal table parameter in source system, if you use the database structure, then code an INSERT FROM TABLE, else LOOP, map and INSERT each record, or build another internal table with same structure than database and code an INSERT FROM TABLE.
Regards,
Raymond
2012 Nov 15 1:07 PM
Hi amarnath m,
as you already observed: No data are passed to parameter TABLE. It does not matter but you should always use meaningful names.
Anyway, the call of your rfc function is not correct. Can you please explain how TABLE is filled with data and how the the call is implemented.
Regards,
Clemens
2012 Nov 16 4:33 AM
Hi,
My coding is correct but data doesn't get updated in table. My kind request is, i having 3 fields namely emp_name, emp_mail, emp_addr in table including mandt field. I am pushing data from SAP PI. The data should get update in the table. Can you please give me the RFC coding for this?
Regards
Amarnath M
2012 Nov 16 4:56 AM
amarnath try this,
in your source code declare a wa.
data wa_ytable2 like ytable2.
* feed wa with input data
wa_ytable2-ename = emp_name.
wa_ytable2-emial = emp_mail.
wa_ytable2-eaddr = emp_adr.
insert ytable2 fro wa_ytable2.
and commit.
this should give positive result.
regards
Satish Chandra
2012 Nov 16 12:17 PM
Hi amarnath,
again: The interface seems to be the problem. If the "LOOP AT table INTO wa_str." is not entered, the internal table with the informative and speaking name "TABLE" is empty. If it is empty, it has not been passed correctly. If you keep secret how you all the RFC function, it is not easy to solve this.
Regards
Clemens