Application Development 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: 

Using SUBMIT in RFC giving error

Former Member
0 Kudos

Hi Experts

I have created a RFC and in that i am calling another program to get some data using SUBMIT with a bunch of selection value. New if i run it in SAP through SE37 then it works fine, but if somebody calls this RFC from some third party software like .NET then it gives error on SUBMIT statement saying "NOT_SUPPORTED_BY_GUI".

Kindly help me to resolve it.

Thanks in advance

Regards

Ashutosh 

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi,

does you SUBMItted program try to do any kind of screen interaction? An RFC call is a background task where no GUI or screen or user is avaliable.

If the SUBMItted program runs as background job (try using SA38 and F9) then it will also run when submitted by RFC function.

BTW: What program do you submit, what does the dump tell you about source code where the error occurred?

Regards

Clemens

9 REPLIES 9

0 Kudos

Hello Ashutosh,

   Instead of Submiting the report directly, try to Schedule a Background Job for that report from RFC.

Sample code:

CALL FUNCTION 'JOB_OPEN'

     EXPORTING

       DELANFREP        = 'X'

       JOBNAME          = L_NAME

     IMPORTING

       JOBCOUNT         = L_NUMBER

     EXCEPTIONS

       CANT_CREATE_JOB  = 1

       INVALID_JOB_DATA = 2

       JOBNAME_MISSING  = 3

       OTHERS           = 4.

   IF SY-SUBRC <> 0.

*   Implement suitable error handling here

   ELSE.

*   Schdule Background job for Report 

     SUBMIT ZXXXX TO SAP-SPOOL

*                      WITH S_VBELN = R_VBELN

            SPOOL PARAMETERS PRINT_PARAMS WITHOUT SPOOL DYNPRO

                        USER 'SAPBATCH'  "SY-UNAME

                     VIA JOB L_NAME

                      NUMBER L_NUMBER

                         AND RETURN.

     IF SY-SUBRC = 0.

*     Close Job

       CALL FUNCTION 'JOB_CLOSE'

         EXPORTING

           JOBCOUNT             = L_NUMBER

           JOBNAME              = L_NAME

           STRTIMMED            = 'X'

         EXCEPTIONS

           CANT_START_IMMEDIATE = 1

           INVALID_STARTDATE    = 2

           JOBNAME_MISSING      = 3

           JOB_CLOSE_FAILED     = 4

           JOB_NOSTEPS          = 5

           JOB_NOTEX            = 6

           LOCK_FAILED          = 7

           INVALID_TARGET       = 8

           OTHERS               = 9.

       IF SY-SUBRC <> 0.

*       Implement suitable error handling here

       ENDIF.

       CONCATENATE 'Background Job with Name' L_NAME 'Scheduled Sucessfully'

              INTO RETURN-MESSAGE SEPARATED BY SPACE.

       APPEND RETURN.

     ENDIF.

   ENDIF.

0 Kudos

Hi Uyala

Thanks for your reply but it didn't solved my problem, even by your method background program is not calling in SAP also.

Let me update you something about my issue that is i am getting my output of background report in internal table and using it in RFC FM.

Here is my code which i was trying.

EXPORT rfc_name TO MEMORY ID 'ZRFC'.
   CALL FUNCTION 'JOB_OPEN'
     EXPORTING
      DELANFREP              = 'X'
*     JOBGROUP               = ' '
       jobname                = job_name
    IMPORTING
      JOBCOUNT               = job_num     .
   IF sy-subrc <> 0.
* Implement suitable error handling here
   ENDIF.

  SUBMIT ZREPORT TO SAP-SPOOL WITH SELECTION-TABLE it_sel SPOOL PARAMETERS print_params WITHOUT SPOOL DYNPRO
   USER sy-uname VIA JOB job_name NUMBER job_num AND RETURN.

   CALL FUNCTION 'JOB_CLOSE'
     EXPORTING
       jobcount                          = job_num
       jobname                           = job_name
      STRTIMMED                         = 'X'
    EXCEPTIONS
      CANT_START_IMMEDIATE              = 1
      INVALID_STARTDATE                 = 2
      JOBNAME_MISSING                   = 3
      JOB_CLOSE_FAILED                  = 4
      JOB_NOSTEPS                       = 5
      JOB_NOTEX                         = 6
      LOCK_FAILED                       = 7
      INVALID_TARGET                    = 8
      OTHERS                            = 9
             .
   IF sy-subrc <> 0.
* Implement suitable error handling here
   ENDIF.

   IMPORT FINAL FROM MEMORY ID 'ZRFC'.
   FREE MEMORY ID 'ZRFC'.



Regards

Ashutosh

0 Kudos

What do you mean by background program not getting called.. by submit it gets scheduled in background job check sm37 ur job has to be there.

0 Kudos

Hi Dhruvin

Yes it is in SM37 but it is calcelled.

0 Kudos

Hi,

Please check the log for cancelled job then you will get an idea where it is failed.

Thanks,

Sree

0 Kudos

Then check the error due to what it has been cancelled ur program which got submitted should not have anything which requires GUI.

0 Kudos

Hi Ashutosh,

  It may take some time to complete the Back ground Job. It may causes no data from Memory.. So try to give some time before importing the Data. 

  First Execute it in Foreground in debug mode. Stop after scheduling the Back ground Job for some time and wait untill successful completion of the the Job. then execute remaining and get it from Memory..

  If the memory return values, you can write 'wait untill n sec..' statement before 'Import final..' statement..

  Try to find out the reason for Cancelling the Job & try without selection table in Submit for Testing purpose..

Regards,

Raghu

0 Kudos

Hi Ashutosh,

The background job will work in a separate session, so i doubt whether the data you exported to memory can be used inside the submitted program. Also you will have to add a wait till the background job complete the execution to get the output. imo, here also the import will not work as the batch job runs in a different session).

Regards,

Murali

Clemenss
Active Contributor
0 Kudos

Hi,

does you SUBMItted program try to do any kind of screen interaction? An RFC call is a background task where no GUI or screen or user is avaliable.

If the SUBMItted program runs as background job (try using SA38 and F9) then it will also run when submitted by RFC function.

BTW: What program do you submit, what does the dump tell you about source code where the error occurred?

Regards

Clemens