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 Starting New Task

former_member188001
Active Participant
0 Likes
1,117

All,

I have a function which is being called in RFC. I am not able to write the code successfully as i am getting stuck on the subroutine.

Please review the following code and let me know what wrong i am done and how to correct.

FUNCTION zmam_bcc_pubdate_getlist_wrap.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PUB_START_DATE) LIKE  ZMAM_BCC_LIST-S_TERMIN OPTIONAL
*"     VALUE(PUB_END_DATE) LIKE  ZMAM_BCC_LIST-E_TERMIN OPTIONAL
*"     VALUE(CHANGE_FROM_DATE) LIKE  JHAE-AENDATE OPTIONAL
*"     VALUE(CHANGE_FROM_TIME) LIKE  JHAE-AENTIME OPTIONAL
*"     VALUE(CHANGE_TO_DATE) LIKE  JHAE-AENDATE OPTIONAL
*"     VALUE(CHANGE_TO_TIME) LIKE  JHAE-AENTIME OPTIONAL
*"     VALUE(SALES_ORDER_NO) LIKE  JHAK-AVM_NR OPTIONAL
*"     VALUE(GET_PUBD_LINES) TYPE  CHAR1 OPTIONAL
*"  TABLES
*"      ZMAM_BCC_LIST STRUCTURE  ZMAM_BCC_LIST OPTIONAL
*"      ZMAM_INHK_KFM STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      ZMAM_INHK_KFM_WEBFLAG STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      ZMAM_BOOKING_UNIT STRUCTURE  ZMAM_BOOKING_UNIT OPTIONAL
*"      ZMAM_PSTYV STRUCTURE  ZMAM_PSTYV OPTIONAL
*"      ZMAM_INHK_KFM_NOWEBFLAG STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      IGNORE_CHANGES_BY STRUCTURE  ZMAM_IGRNOREID OPTIONAL
*"----------------------------------------------------------------------
* This is a wrapper to the function  ZMAM_BCC_PUBDATE_GETLIST.
* Since that function is timing out, this wrapper will call that
* function in background mode
  DATA :lt_zmam_bcc_list            TYPE STANDARD TABLE OF  zmam_bcc_list,
        lt_zmam_inhk_kfm            TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_zmam_inhk_kfm_webflag    TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_zmam_booking_unit        TYPE STANDARD TABLE OF  zmam_booking_unit,
        lt_zmam_pstyv               TYPE STANDARD TABLE OF  zmam_pstyv,
        lt_zmam_inhk_kfm_nowebflag  TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_ignore_changes_by        TYPE STANDARD TABLE OF  zmam_igrnoreid.

  lt_zmam_bcc_list[]            =  zmam_bcc_list[].
  lt_zmam_inhk_kfm[]            =  zmam_inhk_kfm[].
  lt_zmam_inhk_kfm_webflag[]    =  zmam_inhk_kfm[].
  lt_zmam_booking_unit[]        =  zmam_booking_unit[].
  lt_zmam_pstyv[]               =  zmam_pstyv[].
  lt_zmam_inhk_kfm_nowebflag[]  =  zmam_inhk_kfm[].
  lt_ignore_changes_by[]        =  ignore_changes_by[].


  CALL FUNCTION 'ZMAM_BCC_PUBDATE_GETLIST' STARTING NEW TASK
    'mytask' PERFORMING output ON END OF TASK
    EXPORTING
      pub_start_date          = pub_start_date
      pub_end_date            = pub_end_date
      change_from_date        = change_from_date
      change_from_time        = change_from_time
      change_to_date          = change_to_date
      change_to_time          = change_to_time
      sales_order_no          = sales_order_no
      get_pubd_lines          = get_pubd_lines
    TABLES
      zmam_bcc_list           = lt_zmam_bcc_list
      zmam_inhk_kfm           = lt_zmam_inhk_kfm
      zmam_inhk_kfm_webflag   = lt_zmam_inhk_kfm_webflag
      zmam_booking_unit       = lt_zmam_booking_unit
      zmam_pstyv              = lt_zmam_pstyv
      zmam_inhk_kfm_nowebflag = lt_zmam_inhk_kfm_nowebflag
      ignore_changes_by       = lt_ignore_changes_by.

ENDFUNCTION.

Subroutine as follow

*----------------------------------------------------------------------*
***INCLUDE ZMAM_BCC_PUBDATE_WRAPPER .
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
*      Form  OUTPUT
*---------------------------------------------------------------------*
* This routine is called within function ZMAM_BCC_PUBDATE_GETLIST_WRAP
*----------------------------------------------------------------------*
FORM output  TABLES   p_zmam_bcc_list           STRUCTURE zmam_bcc_list
                      p_zmam_inhk_kfm           STRUCTURE zmam_inhk_kfm
                      p_zmam_inhk_kfm_webflag   STRUCTURE zmam_inhk_kfm
                      p_zmam_booking_unit       STRUCTURE zmam_booking_unit
                      p_zmam_pstyv              STRUCTURE zmam_pstyv
                      p_zmam_inhk_kfm_nowebflag STRUCTURE zmam_inhk_kfm
                      p_ignore_changes_by       STRUCTURE zmam_igrnoreid.


  zmam_bcc_list[]             = p_zmam_bcc_list[].
  zmam_inhk_kfm[]             = p_zmam_inhk_kfm[].
  zmam_inhk_kfm_webflag[]     = p_zmam_inhk_kfm_webflag[].
  zmam_booking_unit[]         = p_zmam_booking_unit[].
  zmam_pstyv[]                = p_zmam_pstyv[].
  zmam_inhk_kfm_nowebflag[]   = p_zmam_inhk_kfm_nowebflag[].
  ignore_changes_by[]         = p_ignore_changes_by[].


ENDFORM.                    " OUTPUT

Any help is on this is highly appreciated.

All,

I have a function which is being called in RFC. I am not able to write the code successfully as i am getting stuck on the subroutine.

Please review the following code and let me know what wrong i am done and how to correct.

FUNCTION zmam_bcc_pubdate_getlist_wrap.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PUB_START_DATE) LIKE  ZMAM_BCC_LIST-S_TERMIN OPTIONAL
*"     VALUE(PUB_END_DATE) LIKE  ZMAM_BCC_LIST-E_TERMIN OPTIONAL
*"     VALUE(CHANGE_FROM_DATE) LIKE  JHAE-AENDATE OPTIONAL
*"     VALUE(CHANGE_FROM_TIME) LIKE  JHAE-AENTIME OPTIONAL
*"     VALUE(CHANGE_TO_DATE) LIKE  JHAE-AENDATE OPTIONAL
*"     VALUE(CHANGE_TO_TIME) LIKE  JHAE-AENTIME OPTIONAL
*"     VALUE(SALES_ORDER_NO) LIKE  JHAK-AVM_NR OPTIONAL
*"     VALUE(GET_PUBD_LINES) TYPE  CHAR1 OPTIONAL
*"  TABLES
*"      ZMAM_BCC_LIST STRUCTURE  ZMAM_BCC_LIST OPTIONAL
*"      ZMAM_INHK_KFM STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      ZMAM_INHK_KFM_WEBFLAG STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      ZMAM_BOOKING_UNIT STRUCTURE  ZMAM_BOOKING_UNIT OPTIONAL
*"      ZMAM_PSTYV STRUCTURE  ZMAM_PSTYV OPTIONAL
*"      ZMAM_INHK_KFM_NOWEBFLAG STRUCTURE  ZMAM_INHK_KFM OPTIONAL
*"      IGNORE_CHANGES_BY STRUCTURE  ZMAM_IGRNOREID OPTIONAL
*"----------------------------------------------------------------------
* This is a wrapper to the function  ZMAM_BCC_PUBDATE_GETLIST.
* Since that function is timing out, this wrapper will call that
* function in background mode
  DATA :lt_zmam_bcc_list            TYPE STANDARD TABLE OF  zmam_bcc_list,
        lt_zmam_inhk_kfm            TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_zmam_inhk_kfm_webflag    TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_zmam_booking_unit        TYPE STANDARD TABLE OF  zmam_booking_unit,
        lt_zmam_pstyv               TYPE STANDARD TABLE OF  zmam_pstyv,
        lt_zmam_inhk_kfm_nowebflag  TYPE STANDARD TABLE OF  zmam_inhk_kfm,
        lt_ignore_changes_by        TYPE STANDARD TABLE OF  zmam_igrnoreid.

  lt_zmam_bcc_list[]            =  zmam_bcc_list[].
  lt_zmam_inhk_kfm[]            =  zmam_inhk_kfm[].
  lt_zmam_inhk_kfm_webflag[]    =  zmam_inhk_kfm[].
  lt_zmam_booking_unit[]        =  zmam_booking_unit[].
  lt_zmam_pstyv[]               =  zmam_pstyv[].
  lt_zmam_inhk_kfm_nowebflag[]  =  zmam_inhk_kfm[].
  lt_ignore_changes_by[]        =  ignore_changes_by[].


  CALL FUNCTION 'ZMAM_BCC_PUBDATE_GETLIST' STARTING NEW TASK
    'mytask' PERFORMING output ON END OF TASK
    EXPORTING
      pub_start_date          = pub_start_date
      pub_end_date            = pub_end_date
      change_from_date        = change_from_date
      change_from_time        = change_from_time
      change_to_date          = change_to_date
      change_to_time          = change_to_time
      sales_order_no          = sales_order_no
      get_pubd_lines          = get_pubd_lines
    TABLES
      zmam_bcc_list           = lt_zmam_bcc_list
      zmam_inhk_kfm           = lt_zmam_inhk_kfm
      zmam_inhk_kfm_webflag   = lt_zmam_inhk_kfm_webflag
      zmam_booking_unit       = lt_zmam_booking_unit
      zmam_pstyv              = lt_zmam_pstyv
      zmam_inhk_kfm_nowebflag = lt_zmam_inhk_kfm_nowebflag
      ignore_changes_by       = lt_ignore_changes_by.

ENDFUNCTION.

Subroutine as follow

*----------------------------------------------------------------------*
***INCLUDE ZMAM_BCC_PUBDATE_WRAPPER .
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
*      Form  OUTPUT
*---------------------------------------------------------------------*
* This routine is called within function ZMAM_BCC_PUBDATE_GETLIST_WRAP
*----------------------------------------------------------------------*
FORM output  TABLES   p_zmam_bcc_list           STRUCTURE zmam_bcc_list
                      p_zmam_inhk_kfm           STRUCTURE zmam_inhk_kfm
                      p_zmam_inhk_kfm_webflag   STRUCTURE zmam_inhk_kfm
                      p_zmam_booking_unit       STRUCTURE zmam_booking_unit
                      p_zmam_pstyv              STRUCTURE zmam_pstyv
                      p_zmam_inhk_kfm_nowebflag STRUCTURE zmam_inhk_kfm
                      p_ignore_changes_by       STRUCTURE zmam_igrnoreid.


  zmam_bcc_list[]             = p_zmam_bcc_list[].
  zmam_inhk_kfm[]             = p_zmam_inhk_kfm[].
  zmam_inhk_kfm_webflag[]     = p_zmam_inhk_kfm_webflag[].
  zmam_booking_unit[]         = p_zmam_booking_unit[].
  zmam_pstyv[]                = p_zmam_pstyv[].
  zmam_inhk_kfm_nowebflag[]   = p_zmam_inhk_kfm_nowebflag[].
  ignore_changes_by[]         = p_ignore_changes_by[].


ENDFORM.                    " OUTPUT

Any help is on this is highly appreciated.

5 REPLIES 5
Read only

Former Member
0 Likes
1,026

Salil,

If you press F1 on keyword 'PERFORMING' in your code it will help you a lot.


>> ZMAM_BCC_PUBDATE_GETLIST should be RFC enabled.

>> Form output should have only 1 parameter type C and not all the table names.
SO, use 

FORM output  USING lv_param1 type c.

data: t1 type table of zmam_bcc_list,.....

RECEIVE RESULTS FROM FUNCTION 'ZMAM_BCC_PUBDATE_GETLIST' tables zmam_bcc_list = t1....so on

*t1 is your required table

Endform.

This should solve your problem. If you face any, just get back.

regards,

Diwakar

Read only

yuri_ziryukin
Product and Topic Expert
Product and Topic Expert
0 Likes
1,026

Hi Salil,

When I read your comments, your "solution" is not going to work.

* Since that function is timing out, this wrapper will call that
* function in background mode

RFC call in a new task is again a "dialog" task, so it will timeout in the same way.

As for the subroutine, you already got an answer above, if you want to know more, read here:

http://help.sap.com/saphelp_nw04/helpdata/en/fa/096e92543b11d1898e0000e8322d00/frameset.htm

Regards,

Yuri

Read only

0 Likes
1,026

Thanks Yuri.

The issue I have is, we have RFC which is being called by an external system. The external system passes some parameters to this RFC and RFC in turns returns multiple table out to the external system.

This RFC is failing giving timeout. As a result, I thought of writing a wrapper to this RFC and call this RFC in background so that it will not time out. What is the best way to do it and since I have multiple output parameters, how can I achieve this.

Thanks,

Salil

Read only

yuri_ziryukin
Product and Topic Expert
Product and Topic Expert
0 Likes
1,026

Hello Salil,

if I am not wrong, the process times out if it runs for too long without rolling out.

One solution would be that you try to parallelize and thus speed-up the execution of each dialog task. This of course would work if your task can be parallelized.

If not, I can imagine something like writing a report that can be scheduled as a background job.

Save the parameters that you got from caller into some database transparent or cluster table (like export to database statement). Kick the background job using JOB_SUBMIT. Monitor the job execution periodically (every X seconds) and do WAIT UP TO x SECONDS in between. This should make the work process to roll-out and it should not timeout. When the job finishes, it should write the result again into the database, so the waiting process can read the result from there.

I hope you got my idea.

Regards,

Yuri

Read only

0 Likes
1,026

Hi,

Have you checked the code RFC why it gives Time out error? There must be a database query (probably having multiple inner joins etc) which is failing and giving time out. These kind of query can be splitted in smaller queries which will solve the time out issue.

Thanks,

Murtuza