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

Dynamically change the number of batch/dialog workprocesses



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 18, 2007 8:19 pm    Post subject: Dynamically change the number of batch/dialog workprocesses Reply with quote

Dynamically increase/decrease the number of batch/dialog workprocesses from ABAP

Code:

REPORT ZURLS.
************************************************************************
* This program dynamically increases/decreases the number of
* dialog/batch workpocesses by 1,2,3 or 4. Before running the program
* two working test (non-productive) operation mode has to be created
* called flex1 and flex2.
* The program does not switch workprocesses, if the workprocess number
* gets too low (min. dia: 2, min. btc.: 1)
* The instance name is hardcoded in this program version!
************************************************************************
TABLES: TPFID.
PARAMETERS:
      PLUS_4 RADIOBUTTON GROUP AAA,
      PLUS_3 RADIOBUTTON GROUP AAA,
      PLUS_2 RADIOBUTTON GROUP AAA,
      PLUS_1 RADIOBUTTON GROUP AAA,
      MINUS_1 RADIOBUTTON GROUP AAA,
      MINUS_2 RADIOBUTTON GROUP AAA,
      MINUS_3 RADIOBUTTON GROUP AAA,
      MINUS_4 RADIOBUTTON GROUP AAA.
DATA: SWITCH_TO_OPMODE LIKE TPFID-BANAME,
      RECENT_OPMODE LIKE TPFID-BANAME.
DATA: MIN_DIA      TYPE I VALUE '2',
      MIN_BTCH     TYPE I VALUE '1',
      RECENT_DIA   TYPE I,
      RECENT_BTCH  TYPE I,
      TARGET_DIA   TYPE I,
      TARGET_BTCH  TYPE I.
DATA: BEGIN OF REQ_TBL OCCURS 20.
      INCLUDE STRUCTURE STHCMLIST.
DATA: END OF REQ_TBL.
DATA: BEGIN OF RSP_TBL OCCURS 50.
      INCLUDE STRUCTURE STHCMLIST.
DATA: END OF RSP_TBL.
DATA: SUBRC LIKE SY-SUBRC.

* Find out the active operation
CALL FUNCTION 'RZL_MAKE_STRG_READ_REQ'
     EXPORTING
          NAME    = 'RZL_BANAME'
          TYP     = 'C'
     TABLES
          REQ_TBL = REQ_TBL.

CALL FUNCTION 'TH_SEND_ADM_MESS'
     EXPORTING
          LEVEL           = 2
          SERVER_NAME     = 'instance_name' "e.g. hostname_SID_00
          SERVER_TYPES    = 0
          WAIT_FOR_ANSWER = 1
          TRACE           = 1
     IMPORTING
          SUBRC           = SUBRC
     TABLES
          IN_DATA         = REQ_TBL
          OUT_DATA        = RSP_TBL
     EXCEPTIONS
          SEND_ERROR      = 1
          OTHERS          = 2.

READ TABLE RSP_TBL INDEX 1.
RECENT_OPMODE = RSP_TBL-BUFFER+24.

* Determine the switch_to operation mode
IF RECENT_OPMODE = 'flex1'.
  SWITCH_TO_OPMODE = 'flex2'.
ELSE.
  SWITCH_TO_OPMODE = 'flex1'.
ENDIF.

* Determine the current workprocess number.
SELECT * FROM TPFID WHERE BANAME = RECENT_OPMODE.
ENDSELECT.
RECENT_DIA = TPFID-WPNODIA.
RECENT_BTCH = TPFID-WPNOBTC.

* Is the switch is possible? (min. dia=2, min. batch=1)
IF PLUS_4 = 'X'. TARGET_DIA = RECENT_DIA + 4. ENDIF.
IF PLUS_3 = 'X'. TARGET_DIA = RECENT_DIA + 3. ENDIF.
IF PLUS_2 = 'X'. TARGET_DIA = RECENT_DIA + 2. ENDIF.
IF PLUS_1 = 'X'. TARGET_DIA = RECENT_DIA + 1. ENDIF.
IF MINUS_1 = 'X'. TARGET_DIA = RECENT_DIA - 1. ENDIF.
IF MINUS_2 = 'X'. TARGET_DIA = RECENT_DIA - 2. ENDIF.
IF MINUS_3 = 'X'. TARGET_DIA = RECENT_DIA - 3. ENDIF.
IF MINUS_4 = 'X'. TARGET_DIA = RECENT_DIA - 4. ENDIF.

TARGET_BTCH = RECENT_DIA + RECENT_BTCH - TARGET_DIA.

IF TARGET_DIA < MIN_DIA.
  WRITE: 'ERROR: less then ',MIN_DIA, 'dialog process is not permitted'.
  EXIT.
ENDIF.

IF TARGET_BTCH < MIN_BTCH.
  WRITE: 'ERROR: less then ',MIN_BTCH, 'batch process is not permitted'.
  EXIT.
ENDIF.

* Modify the instance definition
SELECT * FROM TPFID WHERE BANAME = SWITCH_TO_OPMODE.
ENDSELECT.
TPFID-WPNODIA = TARGET_DIA.
TPFID-WPNOBTC = TARGET_BTCH.
MODIFY TPFID.
COMMIT WORK.

* Carry out the actual switch
CALL FUNCTION 'RZL_SWITCH_TO_BA'
     EXPORTING
     BANAME = SWITCH_TO_OPMODE.
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 -> Programming Techniques | Приемы программирования 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.