*&---------------------------------------------------------------------* *& Module pool ZMODTRP * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* PROGRAM ZMODTRP. * INCLUDE ZMODIO01. " PBO-Modules * * INCLUDE ZMODII01. " PAI-Modules * * INCLUDE ZMODIF01. " FORM-Routines * *&---------------------------------------------------------------------* *& Module INIT_NUM OUTPUT *&---------------------------------------------------------------------* * text * *----------------------------------------------------------------------* MODULE INIT_NUM OUTPUT. DATA: CRNUM(6). DATA: RBUT1, RBUT2. CLEAR CRNUM. ENDMODULE. " INIT_NUM OUTPUT *&---------------------------------------------------------------------* *& Module PROCESS INPUT *&---------------------------------------------------------------------* * text * *----------------------------------------------------------------------* MODULE PROCESS INPUT. DATA: CRN(50), N TYPE I. CASE SY-UCOMM. WHEN 'OK'. CRN = 'BO4K'. CRN+4(6) = CRNUM. IF RBUT1 = 'X'. CRN+11(3) = 'SRM'. ELSE. CRN+11(3) = 'PTS'. ENDIF. CRN+15(3) = SY-SYSID. CRN+19(3) = SY-MANDT. CRN+23(8) = SY-UNAME. CRN+32(8) = SY-DATUM. CRN+41(6) = SY-UZEIT. IF CRNUM IS INITIAL.EXIT.ENDIF. N = STRLEN( CRNUM ). IF N < 6.EXIT.ENDIF. IF ( CRNUM CN '1234567890' ).EXIT.ENDIF. OPEN DATASET '/usr/sap/trans/autotransport/data/request_list' FOR APPENDING IN TEXT MODE. TRANSFER CRN TO '/usr/sap/trans/autotransport/data/request_list'. CLOSE DATASET '/usr/sap/trans/autotransport/data/request_list'. WHEN 'EXIT'. SET SCREEN 0.LEAVE SCREEN. ENDCASE. ENDMODULE. " PROCESS INPUT UNIX SCRIPT: #!/bin/ksh # # This script transports the change requests listed in # /usr/sap/trans/autotransport/data/request_list. # If the second field is SRM : to BBB client 31,41,51. # If the second field is PTS : to BBB client 31,51. # The script is scheduled in the crontab to run in every 5 minutes. # First it checks whether another instance of it is running. # Then it checks wheter the the request_list exists or not. # Then it moves request_list to ../save/request_list.timestamp # and to ../tmp/request_list. # Afterwards it creates the TP script from ../tmp/request_list # and runs it. The TP script is called ../tmp/tpscrpt. # The TP log is created in ../log/log.timestamp. # The TP script has lines like these: # "tp delfromboffer crnumber" # "tp addtobuffer crnumber" # "tp import crnumber client..." # At the end the script deletes everything under ../tmp # # # timestmp=`date +%y%m%d.%H%M%S` requfile=/usr/sap/trans/autotransport/data/request_list tempfile=/usr/sap/trans/autotransport/temp/request_list log_file=/usr/sap/trans/autotransport/log/log.$timestmp tpscript=/usr/sap/trans/autotransport/temp/tpscrpt savefile=/usr/sap/trans/autotransport/save/request_list.$timestmp # if [[ -a $tempfile ]] then exit fi # if [[ -a $requfile ]] then : else exit fi print CHANGE REQUESTS FOUND at $(date +'%D %T') > $log_file cat $requfile >> $log_file mv $requfile $tempfile wait cp $tempfile $savefile # echo "cd /usr/sap/trans/bin" > $tpscript cat $tempfile|awk '{ if ( $2 == "SRM" ) print "/sapmnt/BBB/exe/tp delfrombuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp addtobuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp import "$1" BBB client031 u1\n" \ "/sapmnt/BBB/exe/tp delfrombuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp addtobuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp import "$1" BBB client041 u1\n" \ "/sapmnt/BBB/exe/tp delfrombuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp addtobuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp import "$1" BBB client051 u1" if ( $2 == "PTS" ) print "/sapmnt/BBB/exe/tp delfrombuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp addtobuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp import "$1" BBB client031 u1\n" \ "/sapmnt/BBB/exe/tp delfrombuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp addtobuffer "$1" BBB\n" \ "/sapmnt/BBB/exe/tp import "$1" BBB client051 u1" \ }' >> $tpscript # chmod 777 $tpscript su - bbbadm -c "/usr/sap/trans/autotransport/temp/tpscrpt" >> $log_file 2>&1 # rm -f $tpscript rm -f $tempfile