SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Schedules a local ABAP to run in batch on a remote system



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 25, 2007 12:26 pm    Post subject: Schedules a local ABAP to run in batch on a remote system Reply with quote

Code:
REPORT ZREMBTCH.
************************************************
* The program schedules a batch job in a remote
* system. SAP has it's own function module for a
* similar task :RFC_ABAP_INSTALL_AND_RUN (input:
* local program name and RFC destination, output:
* the result of the abap run from the remote
* system), however the program runs in a dialog
* task in the remote system, and when it reaches
* rdisp/max_wprun_time it crashes.
*
* The report has three sections: the main program
* (first section) sends over the second and
* third sections to the remote system, where
* the second section will run in a dialog task
* and schedule the third section to run in
* batch. The result will be placed to the spool
* of the batch job.
************************************************
*Local program
DATA: BEGIN OF PROGRAM OCCURS 100.
        INCLUDE STRUCTURE PROGTAB.
DATA: END OF PROGRAM.
DATA: BEGIN OF WRITES OCCURS 100.
        INCLUDE STRUCTURE LISTZEILE.
DATA: END OF WRITES.

*Move zrsched to an internal table
READ REPORT 'ZREMBTCH' INTO PROGRAM.
LOOP AT PROGRAM.
  IF PROGRAM-LINE+1(1) = 'R'.
    IF PROGRAM-LINE+1(6) = 'RSCHED'.
      SHIFT PROGRAM LEFT BY 8 PLACES.
      MODIFY PROGRAM.
    ENDIF.
  ELSE.
    DELETE PROGRAM.
  ENDIF.
ENDLOOP.

*Call zrsched in the remote system
CALL FUNCTION 'RFC_ABAP_INSTALL_AND_RUN'
DESTINATION 'RFC_LINK'
      TABLES
             PROGRAM = PROGRAM
             WRITES = WRITES.
*End local program

*This portion vill be run in the remote system to
*scedule the batch job
*RSCHED program zrsched.
*RSCHED data: begin of program occurs 100.
*RSCHED         include structure progtab.
*RSCHED data: end of program.
*RSCHED data: pro(8), jobcount(8).
*RSCHED DATA: TIM LIKE SY-UZEIT, N TYPE I VALUE 10.
*RSCHED *Inserting the program
*RSCHED pro = sy-cprog.
*RSCHED READ REPORT pro INTO program.
*RSCHED loop at program.
*RSCHED   if program-line(2) = '*R'.
*RSCHED     shift program left by 8 places.
*RSCHED     modify program.
*RSCHED   else.
*RSCHED     delete program.
*RSCHED   endif.
*RSCHED endloop.
*RSCHED insert report 'ZCLILST' from program.
*RSCHED *Scheduling the remote program to run in background.
*RSCHED CALL FUNCTION 'JOB_OPEN'
*RSCHED   EXPORTING
*RSCHED     JOBNAME = '<>'
*RSCHED   IMPORTING
*RSCHED     JOBCOUNT = JOBCOUNT.
*RSCHED CALL FUNCTION 'JOB_SUBMIT'
*RSCHED   EXPORTING
*RSCHED     JOBNAME = '<>'
*RSCHED     JOBCOUNT = JOBCOUNT
*RSCHED     AUTHCKNAM = sy-uname
*RSCHED     REPORT = 'ZCLILST'.
*RSCHED CALL FUNCTION 'JOB_CLOSE'
*RSCHED   EXPORTING
*RSCHED     JOBNAME = '<>'
*RSCHED     JOBCOUNT = JOBCOUNT
*RSCHED     STRTIMMED = 'X'.
*RSCHED *Delay for 10 seconds
*RSCHED TIM = SY-UZEIT.
*RSCHED TIM = TIM + N.
*RSCHED DO.
*RSCHED   GET TIME.
*RSCHED   IF TIM < SY-UZEIT.
*RSCHED     EXIT.
*RSCHED   ENDIF.
*RSCHED ENDDO.
*RSCHED *Delete the program
*RSCHED delete report 'ZCLILST'.


*This portion will be read and scheduled to run
*in background by rsched
*RBATCH Program zclilst.
*RBATCH write: / sy-sysid.
*RBATCH write: / sy-uzeit.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.