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] RFC function module works 1 time only thru a loop.

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

Posted by Ben Meijs Ctac(Product Manager SAP Developments)
on 07/19/2009 11:15:00 AM

yes. I wrote a book together with 3 of my colleagues. It was published by SAPpress in 2004 but still on sale ;-)

I hope that their will be an opportunity for us to publish an updated version.
________________________________
Van: soldner via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Verzonden: vr 17-7-2009 16:25
Aan: Ben Meijs
Onderwerp: RE: [sap-abap] RFC function module works 1 time only thru a loop.


Thanks for the follow up. I am calling the standard BAPI_COMMIT so your analyses is 100% and I have learned something else.
You have a SAP book out?
From: Ben Meijs Ctac via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Sent: Friday, July 17, 2009 9:00 AM
To: Steve Oldner
Subject: RE: [sap-abap] RFC function module works 1 time only thru a loop.
[cid:image001.jpg@01CA06C0.9077D3A0]
Glad that I could help you.
I think the issue in the RFC itself is this: you are probably calling
some standard SAP function/BAPI to achieve the updates in CRM. These
function modules are part of a function group as you are probably aware.
And the global data of this function group remains intact.
Now when calling a function with the same destination, the session
remains active in your CRM system, which means the global data remains
available in this session. And I think this global data is what is
bothering you in CRM.
By closing the RFC-connection, the session on CRM is also closed, so
now, every time you call the function, you start with empty global data.
Alternatives are often found in extra parameters of BAPI's or functions
to overrule buffers, or calling specific functions to refresh these
buffers.
Vriendelijke Groet,
Ben Meijs
________________________________
From: soldner via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Sent: vrijdag 17 juli 2009 15:43
To: Ben Meijs
Subject: RE: [sap-abap] RFC function module works 1 time only thru a
loop.
Ben - You are the Man!
I added RFC_CONNECTION_CLOSE right after the RFC call it works. Now
whether this is a good design, I don't know.
Neal, I would have to have BASIS change the user back to me so I can
debug in CRM.
For consideration for the readers and anyone who would like to comment,
here is the code:
LOOP AT gt_0001 INTO gs_0001.
CLEAR gs_0006.
READ TABLE gt_0006
INTO gs_0006
WITH KEY pernr = gs_0001-pernr
BINARY SEARCH.
CLEAR alv_rec.
MOVE: gs_0001-werks TO alv_rec-werks,
gs_0001-pernr TO alv_rec-pernr,
gs_0001-nachn TO alv_rec-nachn,
gs_0001-vorna TO alv_rec-vorna,
gs_0006-wrknr TO alv_rec-phone.
READ TABLE lt_0105
WITH KEY pernr = alv_rec-pernr
subty = '0001'
INTO ls_0105
BINARY SEARCH.
IF sy-subrc = 0.
MOVE ls_0105-usrid TO alv_rec-userid.
ENDIF.
READ TABLE lt_0105
WITH KEY pernr = alv_rec-pernr
subty = 'MAIL'
INTO ls_0105
BINARY SEARCH.
IF sy-subrc = 0.
MOVE ls_0105-usrid TO alv_rec-email.
ENDIF.
IF p_update = 'X'.
CLEAR: ls_out_rec, ls_return.
MOVE alv_rec TO ls_out_rec.
CALL FUNCTION 'Z_BUS_PART_CNTRLUSER_CREATE'
DESTINATION p_dest
EXPORTING
i_struc = ls_out_rec
IMPORTING
o_return = ls_return
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc = 0.
IF ls_return-type = 'S'.
MOVE text-m01 TO alv_rec-comment. "successful
ELSE.
MOVE ls_return-message TO alv_rec-comment.
ENDIF.
ELSE.
MESSAGE i000 WITH 'Connection failure to CRM'.
STOP.
ENDIF.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = p_dest
* TASKNAME = TASKNAME
EXCEPTIONS
destination_not_open = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'RFC close connection error'.
ENDIF.
ENDIF.
APPEND alv_rec TO alv_itab.
ENDLOOP.
Thanks to all,
Steven Oldner
DOA/OIS Payroll & Interfaces Team
State of Louisiana
225.219.6935
From: Ben Meijs Ctac via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Sent: Friday, July 17, 2009 8:19 AM
To: Steve Oldner
Subject: RE: [sap-abap] RFC function module works 1 time only thru a
loop.
[cid:image001.jpg@01CA06BA.58D6DB40]
Some thoughts:
-> can there be relation with COMMIT/ROLLBACK? Is there a commit work or
bapi_transaction_commit in the RFC function?
-> what happens if you close the RFC every time you have called it
(function rfc_connection_close). Just as a test to check if this helps
Vriendelijke Groet,
Ben Meijs
________________________________
From: soldner via sap-abap [mailto:sap-abap@Groups.ITtoolbox.com]
Sent: vrijdag 17 juli 2009 15:08
To: Ben Meijs
Subject: [sap-abap] RFC function module works 1 time only thru a loop.
I created a RFC 'z' function module in CRM to create an EE business
partner and central user from ECC from a data structure. In ECC, I have
a report that pulls EE data and loops thru an itab and calls the RFC.
RFC works the first record (updates CRM) but doesn't create the
following records. After I exit the ECC program and re-run, same thing
happens - works first time and no others. I'm using a special batch user
and BASIS set up the SM59.
What am I doing wrong?
__.____._

Copyright © 2009 CEB Toolbox, Inc. and message author.

Toolbox.com
4343 N. Scottsdale Road
Suite 280
Scottsdale, AZ 85251

0 comments:

Post a Comment

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