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

Tramsactional RFC

Former Member
0 Likes
815

Dear experts,

I created a RFC that creates Sale orders.

Sale order is entered by excel as

S001 Lininof<1>

S001 LineInfo<2>

S001 LineInfo<3>

S002 Lineinfo <1>

Example in this two sale orders will be created .First one with 3 lineitems and another one will be having a single line item.

When i execute i have maintained internal tables which return errors/messages against individual sale order like

t_error

S001 Error 1

S001 Error2

I get the content of this table if i do not use TRfc.But with TRfc i couldnot.

I created TRfc as follows


FUNCTION ZWRAPPERFMSO.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      T_SOINPUT STRUCTURE  ZINPUTSO
*"      T_MESSAGES STRUCTURE  ZMESSQUOTATION
*"      T_SHMESS STRUCTURE  ZOUTPMESS
*"----------------------------------------------------------------------
data: tid type arfctid.
DATA: ETAB TYPE STANDARD TABLE OF ARFCERRORS.
DATA: WA_ETAB LIKE LINE OF ETAB.

CALL FUNCTION 'ZFMSO' IN BACKGROUND TASK
  TABLES
    t_soinput        = t_soinput
    t_messages       = t_messages
    t_shmess         = t_shmess.

          .
CALL FUNCTION 'ID_OF_BACKGROUNDTASK'
* EXPORTING
*   DEST          = ' '
 IMPORTING
    TID           = tid.
*   FNUM          =



COMMIT WORK.

if sy-subrc eq 0.
          .
CALL FUNCTION 'STATUS_OF_BACKGROUNDTASK'
  EXPORTING
    tid                 = tid
  tables
    errortab            = etab
 EXCEPTIONS
   COMMUNICATION       = 1
   RECORDED            = 2
   ROLLBACK            = 3
   OTHERS              = 4.
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.

       loop at etab into wa_etab.
       endloop.

ENDFUNCTION.

I am also not familiar where to put exactly FM 'STATUS_OF_BACKGROUNDTASK'

Edited by: aditya sharma on Sep 27, 2010 12:02 PM

Dear experts,

I created a RFC that creates Sale orders.

Sale order is entered by excel as

S001 Lininof<1>

S001 LineInfo<2>

S001 LineInfo<3>

S002 Lineinfo <1>

Example in this two sale orders will be created .First one with 3 lineitems and another one will be having a single line item.

When i execute i have maintained internal tables which return errors/messages against individual sale order like

t_error

S001 Error 1

S001 Error2

I get the content of this table if i do not use TRfc.But with TRfc i couldnot.

I created TRfc as follows


FUNCTION ZWRAPPERFMSO.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      T_SOINPUT STRUCTURE  ZINPUTSO
*"      T_MESSAGES STRUCTURE  ZMESSQUOTATION
*"      T_SHMESS STRUCTURE  ZOUTPMESS
*"----------------------------------------------------------------------
data: tid type arfctid.
DATA: ETAB TYPE STANDARD TABLE OF ARFCERRORS.
DATA: WA_ETAB LIKE LINE OF ETAB.

CALL FUNCTION 'ZFMSO' IN BACKGROUND TASK
  TABLES
    t_soinput        = t_soinput
    t_messages       = t_messages
    t_shmess         = t_shmess.

          .
CALL FUNCTION 'ID_OF_BACKGROUNDTASK'
* EXPORTING
*   DEST          = ' '
 IMPORTING
    TID           = tid.
*   FNUM          =



COMMIT WORK.

if sy-subrc eq 0.
          .
CALL FUNCTION 'STATUS_OF_BACKGROUNDTASK'
  EXPORTING
    tid                 = tid
  tables
    errortab            = etab
 EXCEPTIONS
   COMMUNICATION       = 1
   RECORDED            = 2
   ROLLBACK            = 3
   OTHERS              = 4.
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.

       loop at etab into wa_etab.
       endloop.

ENDFUNCTION.

I am also not familiar where to put exactly FM 'STATUS_OF_BACKGROUNDTASK'

Edited by: aditya sharma on Sep 27, 2010 12:02 PM

6 REPLIES 6
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
768

Hello,

Why did you create a tRFC if you don't use DESTINATION? If i understand correctly you should be using Update FMs instead?

Anyway are you clear how calling an RFC with BACKGROUND TASK works?

BR,

Suhas

Read only

Former Member
0 Likes
768

A job will be submitted to background and recorded in RFc system table ARFCSSTATE.

Same is happening Ie Exactly Once concept.But this Exactly once doesnot know what messages are created in T_SHMESS table

after executing target RFC.

When i cannot return succes or failure of my actions.How will i know what is happening ?

Failure what i could conclude means target system is down from trfc perspective.Even if system attempted but failed to create Sale order due to functional error,ie not an error for tRFC.So even in case of any functional error i need back my messages table.

I could not do this with ' BACKGROUND TASK'so whats the fun of parallerl processing. ?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
768

>

> A job will be submitted to background and recorded in RFc system table ARFCSSTATE.

False. In SAP the RFCs are designed to work via dialog work process. I remember participating in a similar discussion in the SDN ABAP forum a few weeks back.

>

> When i cannot return succes or failure of my actions.How will i know what is happening ?

> I could not do this with ' BACKGROUND TASK' so whats the fun of parallerl processing. ?

'BACKGROUND TASK' is used to incorporate the tRFC concept. Did you read this documentation: [http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_BACKGROUND_PARA.htm]

For Parallel processing you do it via 'STARTING NEW TASK' & you can capture the return messages. Read this: [http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_STARTING.htm#&ABAP_ADDITION_2@2@]

BR,

Suhas

Read only

Former Member
0 Likes
768

Major issue ,i find working with rfc ie reason why i shifted from synchronous RFC to asynchronous is folllowing.

RFCs retrieve less number of rows than R/3 in comparison incase called from .NET or java.This applies to those RFCs which are not so good in performance either due to burdened queries or nested structures.

I think ,this approach of using asynchronous RFC may deem fit here.

I do not want to take risk of incomplete transactions postings here.Ex i have excel file with 300 record to post and eventually getting posted only 240 sale orders.

Further i find trFC and asynchronous RFC are quite similar .Plz correct me incase i am wrong and also i am interested to

have everybodys views on RFC handling.

Still i am not very confident if shifting to this approach will work or not because one thing is certain.There is some minimum time till which RFCs run and they suddenly break intermediate.I would say this is really bad/ highly misleading on SAP part that they have not made any acknowledgment for this behaviour on client side and instead giving unpredictable results.I guess increasing some

/ rdisp param limit may help here but still this awkward .Why the context changes and become misleading when we call sap from any other high level language ?.

SAP has done a lot of good work on LUW ie complete or not at all following atomicity.But i am not aware whether they have worked on taking complete transactions and posting all of them ?. I mean 300 should not let me see only 240.

I fear it may happen i n updation as it has already happened with me on selection for sure.

Suhas with STARTING NEW TASK, are you sure i will not be in constriant with this /rdisp parameter

Edited by: aditya sharma on Sep 27, 2010 2:12 PM

Read only

Former Member
0 Likes
768

In your document link i found this line.What does this mean ,should i sit and have a cigar.

The asynchronous RFC does not support communication with external systems or programs in other programming languages.

Means i cannot call asynchronous RFC from .NET

Edited by: aditya sharma on Sep 27, 2010 2:24 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
768

But i am not aware whether they have worked on taking complete transactions and posting all of them ?

Heard about Transaction Integrity via SAP LUW?

Techniques to achieve this are:

1. UPDATE function modules(normal scenario, which i've mentioned in my previous post) &

2. tRFC(for RFC technology) via IN BACKGROUND TASK.

Anyway in case of tRFC you can use the FM 'STATUS_OF_BACKGROUNDTASK' to get the status of the tRFC call. Also i see this statement in the online documentation:

Error messages displayed in SM58 are taken from the target system. To display the text of the message, double-click on the message.

Does this ring a bell?

Edited by: Suhas Saha on Sep 27, 2010 6:00 PM

The asynchronous RFC does not support communication with external systems or programs in other programming languages.

ROFL ... Pretty obvious i must say

BR,

Suhas