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

RFC Program, data not populating in the table

Former Member
0 Likes
4,558

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,

   DATAwa     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

27 REPLIES 27
Read only

anup_deshmukh4
Active Contributor
0 Likes
3,921

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

Read only

Former Member
0 Likes
3,921

Hi,

Your structure 'wa' is always empty. You don't fill it anywhere.

Read only

vinoth_aruldass
Contributor
0 Likes
3,921

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.

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

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.

Read only

0 Likes
3,921

Hi,

you may record what is really imported in 'table'. Use statement LOG-POINT and transaction SAAB.

Regards,

Clemens

Read only

0 Likes
3,921

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.

Read only

Former Member
0 Likes
3,921

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

Read only

0 Likes
3,921

Amarnath M wrote:

It is not entering into to the loop.

So you have empty 'table' .

Read only

0 Likes
3,921

Hi

My 'table' has 2 entries. I am trying to enter 3rd entry but i am failed.

Thanks & Regards

Amarnath M

Read only

0 Likes
3,921

check your primary key and don repeat that

Read only

0 Likes
3,921

Hi,

I have checked all the feasibility. But i couldn't find the solution. Please help me.

Thanks & Regards

Amarnath M

Read only

0 Likes
3,921

hi ,

          let me know your import parameters and export and table parameters in your function module.

Regards,

Vinoth  Aruldass.

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

conform me the input you will give in table.

Read only

0 Likes
3,921

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.

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

first change the table key word to some table_str and try the same code.

Read only

0 Likes
3,921

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.

Read only

0 Likes
3,921

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,921

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

Read only

0 Likes
3,921

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

Read only

Former Member
0 Likes
3,921

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

Read only

0 Likes
3,921

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

Read only

0 Likes
3,921

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