code efficiency
Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: code efficiency
PostPosted: Thu Nov 19, 2009 5:36 am 
Offline
Newbie

Joined: Thu Nov 19, 2009 5:22 am
Posts: 1
Hello I use this for parsing through a phone system and switching the processors.
Eventually i would like to fully automate it though and want to make sure it's code efficient.

ie any suggestions would be appreciated.




  1. ;tt start and connection variables, turn off with ttstart = 0
  2. ttstart = 0
  3.     span1 = '*.*.*.*:23 /nossh'
  4.     span2 = '*.*.*.*:23 /nossh'
  5.     span3 = '*.*.*.*:23 /nossh'
  6.     span1b = '*.*.*.*:23 /nossh'
  7.     span2b = '*.*.*.*:23 /nossh'
  8.     span3b = '*.*.*.*:23 /nossh'
  9.  
  10. ;hdt login info, turn off with hdtlogin = 0
  11. hdtlogin = 0
  12.     hdtun = 'root'
  13.     hdtpw = '*****'
  14.  
  15. ;Timeout controls
  16.     sTime = 10 ;finite
  17.     iTime = 0  ;infinite
  18.  
  19. ;Speed control
  20.     p1 = 2 ;multiple
  21.     p2 = p1 * 3 ;6
  22.     p3 = p1 * 6 ;12
  23. ;muliplier for speed [0 being real time, 10 being ultra slow]
  24.     m1 = 1
  25. ;note: this does not affect "waitrecv" lines
  26. ;default is 1
  27.  
  28.  
  29. ;code begin
  30. timeout = sTime
  31. if hdtlogin = 1 then
  32.         pause p1 * m1
  33.             if ttstart = 1 then
  34.                     connect span1
  35.                     waitrecv 'login:' 6 1
  36.             endif
  37.         sendln hdtun
  38.         sendln hdtpw
  39.         waitrecv 'TERM' 4 1
  40.         sendln #13
  41.         waitrecv 'opc>' 4 1
  42.         pause p1 * m1
  43. endif
  44. crbegin = 1
  45. if crbegin = 1 then
  46.         sendln #13
  47. endif
  48.         goto next
  49. ;logging info
  50.         :next
  51. getenv 'USERNAME' username
  52. gettime timestr "%Y%m%d-%H%M%S"
  53.         sprintf2 filename 'console_%s_%s.log' username timestr
  54.         sprintf2 dirname 'C:\Documents and Settings\%s\desktop' username
  55. changedir dirname
  56. logopen filename 0 0
  57.  
  58. timeout = iTime
  59. inputbox 'Which NE:' 'Macro Help'
  60.         sendln 'nelogin' #32 inputstr
  61.             waitrecv 'Enter' 5 1
  62.         sendln 'dkeene'
  63.             waitrecv 'Password' 8 7
  64.         sendln '****'
  65.             waitrecv 'MORE' 7 1
  66.             pause p1 * m1
  67.         sendln #13
  68.             pause p1 * m1
  69.         sendln '3'
  70.             waitrecv 'For' 3 1
  71.             pause p2 * m1
  72.         sendln 'sysmon'
  73.             waitrecv 'SYSMON:' 7 1
  74.         sendln 'cpstats all'
  75.             pause p2 * m1
  76.                 for i 1 4
  77.                     sendln #13
  78.                     pause p1 * m1
  79.                     timeout = sTime
  80.                     waitrecv 'MORE' 7 1
  81.                 next
  82.         sendln #13
  83.        
  84. yesnobox 'Note alarms & stats, continue?' 'Macro Help'
  85.     if result = 1 then
  86.         sendln 'eq proc a'
  87.             pause p3 * m1
  88.         sendln 'eq proc b'
  89.             pause p3 * m1
  90.                 yesnobox 'Click Yes to continue with SWACT.' 'Macro Help'
  91.                     if result = 0 then
  92.                        r1 = result
  93.                         yesnobox 'Logout?' 'Macro Help'
  94.                             if result = 1 then
  95.                                     sendln 'logout'
  96.                                     timeout = iTime
  97.                                     waitrecv 'Press' 5 1
  98.                                     sendln #13
  99.                             else
  100.                             exit
  101.                             endif
  102.                     else if r1 = 1 then
  103.                                 sendln '9'
  104.                                     pause p1 * m1
  105.                                 sendln 'y'
  106.                                     waitrecv 'Press' 5 1
  107.                                     timeout = iTime
  108.                                 sendln #13
  109.                     endif
  110.     endif
  111. exit
  112.  


Thanks in advance.

David


Top
 Profile E-mail  
 
 Post subject: Re: code efficiency
PostPosted: Fri Nov 20, 2009 7:24 am 
Offline
Guru

Joined: Wed Jan 25, 2006 7:28 pm
Posts: 532
Location: Denver, Colorado, USA
Suggestions? Sure.

Your indent style is a little strange and inconsistent, but that is just personal preference.

Never, ever, ever use goto statements for any reason whatsoever. They WILL bite you, sooner or later.

This:
  1.  
  2. crbegin = 1
  3. if crbegin = 1 then
  4.         sendln #13
  5. endif
  6.  


Can be replaced by:
  1.  
  2. crbegin=1
  3. sendln #13
  4.  


Other than that, looks good.


Top
 Profile  
 
 Post subject: Re: code efficiency
PostPosted: Mon Dec 07, 2009 4:31 am 
Offline
Newbie

Joined: Wed Dec 02, 2009 12:05 am
Posts: 3
Hi All,

Can anybody from here give me a detailed explantion of ABAP/4 Development Code Efficiency Guidelines.

Thanks in advance

_________________
netzwerkkabel


Top
 Profile E-mail  
 
 Post subject: Re: code efficiency
PostPosted: Mon Dec 07, 2009 10:18 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1141
Location: Seattle, WA, USA
sjohn,

SAP programming has nothing to do with TeraTerm, so you rather ask this question in the "right" forum. Also, please check our forum Rules and Regulations that are more strict than on many other web sites - irrelevant postings can cost you warning or even account termination.

As for your question - I just Goggled "ABAP/4" and found this link that may be helpful. No sure about the terms of copyright though, so use your own judgment.

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group