Posted: Sat Nov 17, 2007 6:57 pm Post subject: Master client copy trigger
Master client copy trigger - if no user activity or scheduled jobs
Code:
REPORT YMASTCP .
* This program raise an event START_MCP to start an automatic
* master client copy if there are no users in the system and
* there is no sceduled background job for the time when the client
* copy is running. The time period can be changed (syuzeit), and all
* the background jobs starting with @ are avoided. During this time
* the users get a system message in case of login attempt.
* The event should be specified in CCMS and a event driven client
* copy should be scheduled by SCC0.
TABLES: UINFO, TBTCO.
DATA: SYUZEIT TYPE T, SYDATUM TYPE D, LIN TYPE N, OPCODE TYPE X VALUE 2,
FLAG, STCR.
DATA: BEGIN OF ITAB OCCURS 10,
JOBNAME LIKE TBTCO-JOBNAME,
SDLSTRTDT LIKE TBTCO-SDLSTRTDT,
SDLSTRTTM LIKE TBTCO-SDLSTRTTM,
EVENTID LIKE TBTCO-EVENTID,
END OF ITAB.
DATA: BEGIN OF BDC_TAB OCCURS 5.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.
DATA: BEGIN OF DATUM,
1(2),
2 VALUE '.',
3(2),
4 VALUE '.',
5(4),
END OF DATUM.
DATA: BEGIN OF TIME,
1(2),
2 VALUE ':',
3(2),
4 VALUE ':',
5(2),
END OF TIME.
DATA: BEGIN OF USR_TABL OCCURS 10.
INCLUDE STRUCTURE UINFO.
DATA: END OF USR_TABL.
CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE
ID 'TAB' FIELD USR_TABL-*SYS*.
SORT USR_TABL BY BNAME.
DESCRIBE TABLE USR_TABL LINES LIN.
IF LIN > 0.
SKIP.
WRITE: / LIN, 'ACTIVE USER IS IN THE SYSTEM'.
SKIP.
LOOP AT USR_TABL.
WRITE: /2 USR_TABL-MANDT, 15 USR_TABL-BNAME.
ENDLOOP.
SKIP.
WRITE: / 'MASTER CLIENT COPY ABORTED!!!'.
EXIT.
ENDIF.
* Are there scheduled jobs ?
IF SYDATUM = SY-DATUM.
SELECT * FROM TBTCO WHERE STATUS = 'S' AND SDLSTRTTM <> ' '
AND SDLSTRTTM > SY-UZEIT AND SDLSTRTTM < SYUZEIT
AND SDLSTRTDT = SYDATUM.
MOVE-CORRESPONDING TBTCO TO ITAB.
APPEND ITAB.
ENDSELECT.
ELSE.
SELECT * FROM TBTCO WHERE STATUS = 'S' AND SDLSTRTTM <> ' '
AND ( ( ( SDLSTRTDT = SY-DATUM ) AND ( SDLSTRTTM > SYUZEIT ) ) OR
( ( SDLSTRTDT = SYDATUM ) AND ( SDLSTRTTM < SYUZEIT ) ) ).
MOVE-CORRESPONDING TBTCO TO ITAB.
APPEND ITAB.
ENDSELECT.
ENDIF.
DESCRIBE TABLE ITAB LINES LIN.
IF LIN > 0.
LOOP AT ITAB.
STCR = ITAB-JOBNAME.
IF STCR <> '@'.
FLAG = 'R'.
WRITE: / ITAB.
ENDIF.
ENDLOOP.
IF FLAG = 'R'.
SKIP.
WRITE: / 'MASTER CLIENT COPY ABORTED!!!'.
EXIT.
ENDIF.
ENDIF.
* Enter system message: Do not work in client 21!!!
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.