Module: Host3270::GenericFunctions
- Included in:
- ButlerMainframe::Host
- Defined in:
- lib/mainframe/customization/generic_functions.rb
Instance Method Summary collapse
-
#abend? ⇒ Boolean
Check if there was a malfunction on the mainframe.
-
#catch_abend ⇒ Object
Get the abend message.
-
#catch_message(options = {}) ⇒ Object
Get the message line usually in the bottom of the screen You can define which rows provide the message: :first_row => 22, :last_row => 23.
-
#cics? ⇒ Boolean
Check if we are the first blank cics screen.
-
#cics_selection(ar_cics) ⇒ Object
On this map, we have to select the cics environment param1 cics(array) [text, y, x].
-
#cics_selection? ⇒ Boolean
Check the label to know when we are on the cics selection map.
-
#company_menu(ar_menu) ⇒ Object
On this map, we have to select the cics environment param1 cics usually is a number.
-
#company_menu? ⇒ Boolean
Check the label to know when we are on the cics selection map.
-
#destination_list ⇒ Object
If you add your static screen you must add it in the navigation method to define how to manage it.
- #do_confirm ⇒ Object
- #do_enter ⇒ Object
- #do_erase ⇒ Object
- #do_quit ⇒ Object
- #execute_cics(name) ⇒ Object
- #go_back ⇒ Object
-
#navigate(destination, options = {}) ⇒ Object
Use navigation method to move through the static screens Options: :cics => ButlerMainframe::Settings.cics, :user => ButlerMainframe::Settings.user, :password => ButlerMainframe::Settings.password, :raise_on_abend => false raise an exception if an abend is occured.
-
#screen_title(options = {}) ⇒ Object
Get the title usually the first row You can change default option :rows to get more lines starting from the first.
-
#session_login(ar_user, ar_password) ⇒ Object
Login to mainframe param1 user(array) [text, y, x] param2 password(array) [text, y, x].
-
#session_login? ⇒ Boolean
Check if we are on the login mainframe screen.
Instance Method Details
#abend? ⇒ Boolean
Check if there was a malfunction on the mainframe
222 223 224 |
# File 'lib/mainframe/customization/generic_functions.rb', line 222 def abend? /DFHA/i === catch_abend end |
#catch_abend ⇒ Object
Get the abend message
217 218 219 |
# File 'lib/mainframe/customization/generic_functions.rb', line 217 def catch_abend scan(:y1 => 23, :x1 => 1, :y2 => 23, :x2 => 80) end |
#catch_message(options = {}) ⇒ Object
Get the message line usually in the bottom of the screen You can define which rows provide the message:
:first_row => 22,
:last_row => 23
208 209 210 211 212 213 214 |
# File 'lib/mainframe/customization/generic_functions.rb', line 208 def ={} = { :first_row => 22, :last_row => 23 }.merge() scan(:y1 => [:first_row], :x1 => 1, :y2 => [:last_row], :x2 => 80).gsub(/\s+/, " ").strip end |
#cics? ⇒ Boolean
Check if we are the first blank cics screen
140 141 142 |
# File 'lib/mainframe/customization/generic_functions.rb', line 140 def cics? scan(:y1 => 1, :x1 => 1, :y2 => 22, :x2 => 80).strip.empty? end |
#cics_selection(ar_cics) ⇒ Object
On this map, we have to select the cics environment param1 cics(array) [text, y, x]
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/mainframe/customization/generic_functions.rb', line 174 def cics_selection ar_cics puts "Starting selezione_cics..." if @debug cics, y_cics, x_cics = ar_cics raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics wait_session raise "It was waiting cics selezion map instead of: #{screen_title}, message: #{}" unless cics_selection? write cics, :y => y_cics, :x => x_cics do_enter wait_session 1 end |
#cics_selection? ⇒ Boolean
Check the label to know when we are on the cics selection map
168 169 170 |
# File 'lib/mainframe/customization/generic_functions.rb', line 168 def cics_selection? /#{ButlerMainframe::Settings.cics_selection_tag}/i === screen_title end |
#company_menu(ar_menu) ⇒ Object
On this map, we have to select the cics environment param1 cics usually is a number
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/mainframe/customization/generic_functions.rb', line 193 def puts "Starting company menu..." if @debug , , = raise "Check company menu configuration! #{} #{} #{}" unless && && wait_session raise "It was waiting company menu map instead of: #{screen_title}, message: #{}" unless write , :y => , :x => do_enter end |
#company_menu? ⇒ Boolean
Check the label to know when we are on the cics selection map
187 188 189 |
# File 'lib/mainframe/customization/generic_functions.rb', line 187 def /#{ButlerMainframe::Settings.}/i === screen_title end |
#destination_list ⇒ Object
If you add your static screen you must add it in the navigation method to define how to manage it
16 17 18 19 20 21 22 23 |
# File 'lib/mainframe/customization/generic_functions.rb', line 16 def destination_list [ :company_menu, :cics_selection, :session_login, :next, :back] end |
#do_confirm ⇒ Object
9 |
# File 'lib/mainframe/customization/generic_functions.rb', line 9 def do_confirm; exec_command "PF3" end |
#do_enter ⇒ Object
5 |
# File 'lib/mainframe/customization/generic_functions.rb', line 5 def do_enter; exec_command "ENTER" end |
#do_erase ⇒ Object
13 |
# File 'lib/mainframe/customization/generic_functions.rb', line 13 def do_erase; exec_command "ERASE EOF" end |
#do_quit ⇒ Object
11 |
# File 'lib/mainframe/customization/generic_functions.rb', line 11 def do_quit; exec_command "CLEAR" end |
#execute_cics(name) ⇒ Object
235 236 237 238 |
# File 'lib/mainframe/customization/generic_functions.rb', line 235 def execute_cics name write name, :y => 1, :x => 2 do_enter end |
#go_back ⇒ Object
7 |
# File 'lib/mainframe/customization/generic_functions.rb', line 7 def go_back; exec_command "PA2" end |
#navigate(destination, options = {}) ⇒ Object
Use navigation method to move through the static screens Options: :cics => ButlerMainframe::Settings.cics, :user => ButlerMainframe::Settings.user, :password => ButlerMainframe::Settings.password, :raise_on_abend => false raise an exception if an abend is occured
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/mainframe/customization/generic_functions.rb', line 31 def navigate destination, ={} = { :session_user => ButlerMainframe::Settings.session_user, :session_password => ButlerMainframe::Settings.session_password, :cics => ButlerMainframe::Settings.cics, :company_menu => ButlerMainframe::Settings., :raise_on_abend => false }.merge() max_attempts_number = ButlerMainframe::Settings.max_attempts_number transactions_cics = ButlerMainframe::Settings.transactions_cics raise "Destination #{destination} not valid, please use: #{destination_list.join(', ')}" unless destination_list.include? destination puts "Navigating to #{destination}" if @debug destination_found = nil attempt_number = 0 while !destination_found do attempt_number += 1 if abend? puts "Navigate: abend" if @debug [:raise_on_abend] ? raise(catch_abend) : do_quit elsif puts "Navigating to #{destination} from company menu" if @debug case destination when :cics_selection, :session_login then do_quit when :back then do_quit destination_found = true when :next then [:company_menu] destination_found = true when :company_menu then destination_found = true else # Every other destination is forward [:company_menu] end elsif cics? puts "Navigating to #{destination} from cics" if @debug case destination when :cics_selection, :session_login then execute_cics ButlerMainframe::Settings.logoff_cics when :back then execute_cics ButlerMainframe::Settings.logoff_cics destination_found = true when :next then execute_cics transactions_cics[:main_application] destination_found = true when :company_menu then execute_cics transactions_cics[:company_menu] else #If we are in CICS with blank screen start the first transaction execute_cics transactions_cics[:main_application] end elsif cics_selection? puts "Navigating to #{destination} from cics selection" if @debug case destination when :cics_selection then destination_found = true when :session_login then exec_command("PF3") when :next then cics_selection [:cics] if [:cics] destination_found = true when :back then exec_command("PF3") destination_found = true else cics_selection [:cics] if [:cics] end elsif session_login? puts "Navigating to #{destination} from session login" if @debug case destination when :session_login, :back then destination_found = true when :next then session_login [:session_user], [:session_password] destination_found = true else session_login [:session_user], [:session_password] end else puts "Navigating to #{destination} from unknown screen" if @debug # If we do not know where we are... case destination when :session_login then # ...to come back to the first screen we surely have to go back go_back when :back then # ...we can try to go back (not all the screen may go back in the same way) go_back destination_found = true when :next then # ...but we dont know how to move forward raise "Define how to go forward in the navigation method on generic function module" else # We unlock the position with both commands to be sure that they are managed by all maps cics raise "Destination #{destination} not defined in the current screen" end end break if attempt_number > max_attempts_number wait_session end raise "It was waiting #{destination} map instead of: #{screen_title(:rows => 2).strip}" unless destination_found end |
#screen_title(options = {}) ⇒ Object
Get the title usually the first row You can change default option :rows to get more lines starting from the first
228 229 230 231 232 233 |
# File 'lib/mainframe/customization/generic_functions.rb', line 228 def screen_title ={} = { :rows => 1 }.merge() scan(:y1 => 1, :x1 => 1, :y2 => [:rows], :x2 => 80) end |
#session_login(ar_user, ar_password) ⇒ Object
Login to mainframe param1 user(array) [text, y, x] param2 password(array) [text, y, x]
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/mainframe/customization/generic_functions.rb', line 152 def session_login ar_user, ar_password puts "Starting session login..." if @debug user, y_user, x_user = ar_user raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user password, y_password, x_password = ar_password raise "Check session password configuration! #{password} #{y_password} #{x_password}" unless password && y_password && x_password wait_session #inizializza_sessione raise "It was waiting session login map instead of: #{screen_title}" unless session_login? write user, :y => y_user, :x => x_user write password, :y => y_password, :x => x_password, :sensible_data => true do_enter end |
#session_login? ⇒ Boolean
Check if we are on the login mainframe screen
145 146 147 |
# File 'lib/mainframe/customization/generic_functions.rb', line 145 def session_login? /#{ButlerMainframe::Settings.session_login_tag}/i === screen_title end |