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

Using SUBMIT in RFC giving error

Former Member
0 Likes
3,932

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
Read only

Clemenss
Active Contributor
0 Likes
2,818

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

10 REPLIES 10
Read only

0 Likes
2,818

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.

Read only

0 Likes
2,818

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

Read only

0 Likes
2,818

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.

Read only

0 Likes
2,818

Hi Dhruvin

Yes it is in SM37 but it is calcelled.

Read only

0 Likes
2,818

Hi,

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

Thanks,

Sree

Read only

0 Likes
2,818

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

Read only

0 Likes
2,818

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

Read only

0 Likes
2,818

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

Read only

Clemenss
Active Contributor
0 Likes
2,819

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

Read only

0 Likes
2,084

Hi ,

I am currently implementing an rfc i.e inbound I am getting vbeln as input from user in importing parameters and i am exporting other column details from same custom table i use. and all field type in rfc is standard as i use in table also. 

but there is a problem when i trigger the other program it execute the rfc with subrc = 0. and while execution it fills the exporting parameters correctly but when it comes back to main program it don't fill the parameters in main program that are there in response to the exporting parameters of rfc ?

 i have create as rfc as remote inable and also declare both importing and exporting parameters as pass by value.

Still i haven't got those output/exporting in main program have anyone ever face this problem ?

can you guys help me out ?