SAP Community
Products and Technology
Additional Blogs by SAP
Tasting the mix of Ruby and SAP - Volume 4
Additional Blogs by SAP
All community
This category
Blog
Knowledge base
Users
Managed tags
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Search instead for
Did you mean:
Tasting the mix of Ruby and SAP - Volume 4
former_member18
2779
Active Contributor
Options
Subscribe to RSS Feed
Mark as New
Mark as Read
Bookmark
Subscribe
Printer Friendly Page
Report Inappropriate Content
2007 May 29
7:24 PM
0
Kudos
382
Before you start to call me Cheater! , Points Hunter! and whatever you want...Let's make things clear -:) I know that I already blog about ST22 Emulation on Tasting the mix of PHP and SAP - Volume 8 (
Tasting the mix of PHP and SAP - Volume 8
) and also John Astill (
http://tinyurl.com/y6x62l
) made a Widget version on Yahoo Widget for ST22 (
Yahoo Widget for ST22
) You may be asking yourself...So...What's new??? Ok...First, we are using WxRuby (Widgets for Ruby) and also, we are adding a new functionality to the application...We can show the description of the error, that means that we can get the source code where the error was found -;) Nice, isn't it -:D Enough talking...let's start coding... We need two functions...One for read the dumps and the other one for read the error source code... ZGET_ST22 FUNCTION ZGET_ST22. *"---- ------------------------------------------------------------ *"*"Local interface: *" IMPORTING *" VALUE(DATUM_INI) LIKE SY-DATUM OPTIONAL *" VALUE(DATUM_END) LIKE SY-DATUM OPTIONAL *" VALUE(UZEIT_INI) LIKE SY-UZEIT OPTIONAL *" VALUE(UZEIT_END) LIKE SY-UZEIT OPTIONAL *" VALUE(UNAME_INI) LIKE SNAP_BEG-UNAME OPTIONAL *" VALUE(UNAME_END) LIKE SNAP_BEG-UNAME OPTIONAL *" TABLES *" FLIST STRUCTURE SNAP_BEG *"---- ------------------------------------------------------------ DATA: W_TABIX TYPE SY-TABIX, ID(2) TYPE C, LEN(3) TYPE C, PROG_POS TYPE SY-FDPOS, NAME_POS TYPE SY-FDPOS, PROG_AUX TYPE STRING, CM_POS TYPE SY-FDPOS, CM_LEN TYPE SY-FDPOS, CM_AUX TYPE SY-FDPOS, CM_POSX TYPE SY-FDPOS, LENGTH TYPE I, LONG TYPE I. DATA: BEGIN OF R_DATUM OCCURS 1, SIGN(1), OPTION(2), LOW TYPE SY-DATUM, HIGH TYPE SY-DATUM, END OF R_DATUM. DATA: BEGIN OF R_UZEIT OCCURS 1, SIGN(1), OPTION(2), LOW TYPE SY-UZEIT, HIGH TYPE SY-UZEIT, END OF R_UZEIT. DATA: BEGIN OF R_UNAME OCCURS 1, SIGN(1), OPTION(2), LOW TYPE SNAP_BEG-UNAME, HIGH TYPE SNAP_BEG-UNAME, END OF R_UNAME. R_DATUM-SIGN = 'I'. IF DATUM_INI EQ '00000000' AND DATUM_END EQ '00000000'. R_DATUM-OPTION = ' '. ELSEIF DATUM_INI NE '00000000' AND DATUM_END NE '00000000'. R_DATUM-OPTION = 'BT'. MOVE DATUM_INI TO R_DATUM-LOW. MOVE DATUM_END TO R_DATUM-HIGH. APPEND R_DATUM. ELSE. R_DATUM-OPTION = 'EQ'. MOVE DATUM_INI TO R_DATUM-LOW. APPEND R_DATUM. ENDIF. R_UZEIT-SIGN = 'I'. IF UZEIT_INI EQ '000000' AND UZEIT_END EQ '000000'. R_UZEIT-OPTION = ' '. ELSEIF UZEIT_INI NE '000000' AND UZEIT_END NE '000000'. R_UZEIT-OPTION = 'BT'. MOVE UZEIT_INI TO R_UZEIT-LOW. MOVE UZEIT_END TO R_UZEIT-HIGH. APPEND R_UZEIT. ELSE. R_UZEIT-OPTION = 'EQ'. MOVE UZEIT_INI TO R_UZEIT-LOW. APPEND R_UZEIT. ENDIF. R_UNAME-SIGN = 'I'. IF UNAME_INI EQ SPACE AND UNAME_END EQ SPACE. R_UNAME-OPTION = ' '. ELSEIF UNAME_INI NE SPACE AND UNAME_END NE SPACE. R_UNAME-OPTION = 'BT'. MOVE UNAME_INI TO R_UNAME-LOW. MOVE UNAME_END TO R_UNAME-HIGH. APPEND R_UNAME. ELSE. R_UNAME-OPTION = 'EQ'. MOVE UNAME_INI TO R_UNAME-LOW. APPEND R_UNAME. ENDIF. SELECT DATUM UZEIT AHOST UNAME MANDT FLIST INTO CORRESPONDING FIELDS OF TABLE FLIST FROM SNAP_BEG WHERE DATUM IN R_DATUM AND UZEIT IN R_UZEIT AND UNAME IN R_UNAME AND AHOST EQ SY-HOST. DELETE FLIST WHERE NOT FLIST(2) EQ 'FC'. IF NOT FLIST[] IS INITIAL. LOOP AT FLIST. W_TABIX = SY-TABIX. LENGTH = STRLEN( FLIST-FLIST ). ID = FLIST-FLIST+0(2). IF ID EQ 'FC'. LEN = FLIST-FLIST+2(3). SEARCH FLIST-FLIST FOR 'CM'. CM_LEN = SY-FDPOS. CM_POS = LENGTH - CM_LEN. CM_AUX = CM_LEN + 2. CM_POSX = FLIST-FLIST+CM_AUX(3). CM_LEN = CM_LEN + CM_POSX. CM_POS = CM_POS - CM_LEN. PROG_AUX = FLIST-FLIST+CM_LEN(CM_POS). LONG = STRLEN( PROG_AUX ). SEARCH PROG_AUX FOR 'AP'. PROG_POS = SY-FDPOS + 5. LONG = LONG - PROG_POS. CATCH SYSTEM-EXCEPTIONS STRING_OFFSET_LENGTH_TOO_LARGE = 5. CONCATENATE FLIST-FLIST+5(LEN) PROG_AUX+PROG_POS(40) INTO FLIST-FLIST SEPARATED BY '/'. ENDCATCH. IF SY-SUBRC EQ 5. CONCATENATE FLIST-FLIST+5(LEN) PROG_AUX+PROG_POS(LONG) INTO FLIST-FLIST SEPARATED BY '/'. ENDIF. MODIFY FLIST INDEX W_TABIX TRANSPORTING FLIST. ENDIF. ENDLOOP. ENDIF. ENDFUNCTION. ZGET_ST22_DESCRIPTION FUNCTION ZGET_ST22_DESCRIPTION. *"---- ------------------------------------------------------------ *"*"Local interface: *" IMPORTING *" VALUE(DATUM) LIKE SY-DATUM OPTIONAL *" VALUE(UZEIT) LIKE SY-UZEIT OPTIONAL *" VALUE(UNAME) LIKE SNAP_BEG-UNAME OPTIONAL *" TABLES *" T_SNAPT STRUCTURE SNAPT *"---- ------------------------------------------------------------ TYPES: BEGIN OF TY_FDESC, ID(2) TYPE C, LEN(3) TYPE C, VALUE(256) TYPE C, END OF TY_FDESC. TYPES: BEGIN OF TY_PS, LINE(72), END OF TY_PS. DATA: T_SNAP TYPE STANDARD TABLE OF SNAP WITH HEADER LINE, T_FDESC TYPE STANDARD TABLE OF TY_FDESC WITH HEADER LINE, T_PS TYPE STANDARD TABLE OF TY_PS WITH HEADER LINE. DATA: W_VALUE TYPE TY_FDESC-VALUE, W_CLINNO TYPE I, W_CINCLU LIKE SY-REPID, FROM_LINE TYPE I, TO_LINE TYPE I, W_LINE TYPE STRING. FIELD-SYMBOLS: require 'wxruby' require 'rubygems' require "SAP/Rfc" include Wx gem 'saprfc' Btn_Connect = 1000 Btn_Show = 1001 Btn_Text = 1002 class MyFrame < Frame def initialize(frame, title, pos, size) super(frame, -1, title, pos, size) panel = Panel.new(self) #Server Input---- ------------------------------------------------------------------ m_Server = StaticText.new(panel, -1, "Server",Point.new(10, 12),Size.new(40, 20)) @mServer = TextCtrl.new(panel, -1, "Huroncebrio",Point.new(90, 10),Size.new(80, 20)) #System Number Input---- ----------------------------------------------------------- m_SysNum = StaticText.new(panel, -1, "System Number",Point.new(10, 32),Size.new(80, 20)) @mSysNum = TextCtrl.new(panel, -1, "000",Point.new(90, 30),Size.new(30, 20)) #Client Input---- ------------------------------------------------------------------ m_Client = StaticText.new(panel, -1, "Client",Point.new(10, 52),Size.new(80, 20)) @mClient = TextCtrl.new(panel, -1, "00",Point.new(90, 50),Size.new(20, 20)) #User Input---- -------------------------------------------------------------------- m_User = StaticText.new(panel, -1, "User",Point.new(10, 72),Size.new(80, 20)) @mUser = TextCtrl.new(panel, -1, "bcuser",Point.new(90, 70),Size.new(80, 20)) #Password Input---- -------------------------------------------------------------------- m_Password = StaticText.new(panel, -1, "Password",Point.new(10, 92),Size.new(80, 20)) @mPassword = TextCtrl.new(panel, -1, "minisap",Point.new(90, 90),Size.new(80, 20)) btnConnect = Button.new(panel, Btn_Connect, "Connect", Point.new(50, 130),Size.new(80, 20)) show(TRUE) evt_button(Btn_Connect) {onButtonConnect} end def onButtonConnect() rfc = SAP::Rfc.new(:ashost => @mServer.get_value(), :sysnr => @mSysNum.get_value(), :lang => "EN", :client => @mClient.get_value(), :user => @mUser.get_value(), :passwd => @mPassword.get_value(), :trace => 0) show(false) myGridFrame = GridFrame.new(nil, "ST22 Emulator", Point.new(50, 50), Size.new(600, 400)) myGridFrame.fill_dumps(rfc) end def onQuit close(TRUE) end end class GridFrame < Frame def initialize(frame, title, pos, size) super(frame, -1, title, pos, size) @panel = Panel.new(self) #User Input---- ------------------------------------------------------------------ m_Date = StaticText.new(@panel, -1, "Date",Point.new(180, 12),Size.new(40, 20)) @mDate_Ini = TextCtrl.new(@panel, -1, " ",Point.new(220, 10),Size.new(80, 20)) @mDate_End = TextCtrl.new(@panel, -1, " ",Point.new(310, 10),Size.new(80, 20)) m_Time = StaticText.new(@panel, -1, "Time",Point.new(180, 32),Size.new(40, 20)) @mTime_Ini = TextCtrl.new(@panel, -1, " ",Point.new(220, 30),Size.new(80, 20)) @mTime_End = TextCtrl.new(@panel, -1, " ",Point.new(310, 30),Size.new(80, 20)) m_User = StaticText.new(@panel, -1, "User",Point.new(180, 52),Size.new(40, 20)) @mUser_Ini = TextCtrl.new(@panel, -1, " ",Point.new(220, 50),Size.new(80, 20)) @mUser_End = TextCtrl.new(@panel, -1, " ",Point.new(310, 50),Size.new(80, 20)) btnShow = Button.new(@panel, Btn_Show, "Show Dumps", Point.new(230, 80),Size.new(70, 20)) btnText = Button.new(@panel, Btn_Text, "Get Description", Point.new(305, 80),Size.new(80, 20)) show(true) evt_button(Btn_Show) {onButtonShow} evt_button(Btn_Text) {onButtonText} end def onButtonShow() $Boolean = @mDate_Ini.get_value.to_s.strip.empty? if $Boolean == false @Aux_Date = @mDate_Ini.get_value.split('.') @itab.DATUM_INI.value = @Aux_Date[2] << @Aux_Date[1] << @Aux_Date[0] @Aux_Date = @mDate_End.get_value.split('.') @itab.DATUM_END.value = @Aux_Date[2] << @Aux_Date[1] << @Aux_Date[0] end $Boolean = @mTime_Ini.get_value.to_s.strip.empty? if $Boolean == false @Aux_Time = @mTime_Ini.get_value.split(':') @itab.UZEIT_INI.value = @Aux_Date[0] << @Aux_Date[1] << @Aux_Date[2] @Aux_Time = @mTime_End.get_value.split(':') @itab.UZEIT_END.value = @Aux_Date[0] << @Aux_Date[1] << @Aux_Date[2] end @itab.UNAME_INI.value = @mUser_Ini.get_value.upcase @itab.UNAME_END.value = @mUser_End.get_value.upcase
@RFC
.call(@itab) @flist = Array.new @flist_Fields = Array.new @flist_Datum = Array.new @flist_Uzeit = Array.new @flist_Ahost = Array.new @flist_Uname = Array.new @flist_Data = Array.new @itab.FLIST.hashRows {|field| @flist.push(field) } $flist_Len = @flist.length @itab.FLIST.hashRows {|field| @flist_Datum.push(field['DATUM'].to_s.strip)} @itab.FLIST.hashRows {|field| @flist_Uzeit.push(field['UZEIT'].to_s.strip)} @itab.FLIST.hashRows {|field| @flist_Ahost.push(field['AHOST'].to_s.strip)} @itab.FLIST.hashRows {|field| @flist_Uname.push(field['UNAME'].to_s.strip)} @itab.FLIST.hashRows {|field| @flist_Data.push(field['FLIST'].to_s.strip)} @grid = Grid.new(@panel,:grid.object_id,Point.new(0,110),Size.new(585,320)) @grid.set_editable(false) @grid.set_scroll_y(1) @grid.create_grid($flist_Len,6) @grid.set_col_label_value( 0, "Date" ) @grid.set_col_size( 0, 60 ) @grid.set_col_label_value( 1, "Time" ) @grid.set_col_size( 1, 50 ) @grid.set_col_label_value( 2, "Host" ) @grid.set_col_size( 2, 65 ) @grid.set_col_label_value( 3, "User" ) @grid.set_col_size( 3, 65 ) @grid.set_col_label_value( 4, "Error" ) @grid.set_col_size( 4, 140 ) @grid.set_col_label_value( 5, "Program" ) @grid.set_col_size( 5, 120 ) for j in 0...$flist_Len $Aux_Date = @flist_Datum[j]; $Year = $Aux_Date.slice(0,4) $Month = $Aux_Date.slice(4,2) $Day = $Aux_Date.slice(6,2) $Aux_Date = $Day << "." << $Month << "." << $Year @grid.set_cell_value( j, 0, $Aux_Date ) $Aux_Date = @flist_Uzeit[j]; $Hour = $Aux_Date.slice(0,2) $Minute = $Aux_Date.slice(2,2) $Second = $Aux_Date.slice(4,2) $Aux_Date = $Hour << ":" << $Minute << ":" << $Second @grid.set_cell_value( j, 1, $Aux_Date ) @grid.set_cell_value( j, 2, @flist_Ahost[j] ) @grid.set_cell_value( j, 3, @flist_Uname[j] ) $list_split = @flist_Data[j].split('/') @grid.set_cell_value( j, 4, $list_split[0] ) @grid.set_cell_value( j, 5, $list_split[1] ) end evt_grid_range_select do |evt| $top = evt.get_top_left_coords
@Top
_line = $top[0] end end def onButtonText() textGridFrame = GridFrameText.new(nil, "Dump Description", Point.new(50, 50), Size.new(600, 400)) textGridFrame.show(true) textGridFrame.fill_description(@rfc,@flist_Datum, @flist_Uzeit, @flist_Uname,
@Top
_line) end def fill_dumps(rfc) @itab = rfc.discover("ZGET_ST22")
@RFC
= rfc end def onQuit close(TRUE) end end class GridFrameText < Frame def initialize(frame, title, pos, size) super(frame, -1, title, pos, size) @panel = Panel.new(self) @m_text = TextCtrl.new(self, -1, "", Point.new(0, 0), Size.new(590, 360), TE_MULTILINE | TE_READONLY) end def fill_description(rfc, flist_Datum, flist_Uzeit, flist_Uname, top_line) @itab_text = rfc.discover("ZGET_ST22_DESCRIPTION")
@RFC
= rfc @itab_text.DATUM.value = flist_Datum[top_line] @itab_text.UZEIT.value = flist_Uzeit[top_line] @itab_text.UNAME.value = flist_Uname[top_line]
@RFC
.call(@itab_text) @snapt = Array.new @snapt_tline = Array.new @itab_text.T_SNAPT.hashRows {|field| @snapt.push(field) } $snapt_Len = @snapt.length @itab_text.T_SNAPT.hashRows {|field| @snapt_tline.push(field['TLINE'].to_s.strip)} @m_text.clear() for j in 0...$snapt_Len @m_text << @snapt_tline[j] << "
" end end end class SapLogin < App def on_init myNewFrame = MyFrame.new(nil, "ST22 Emulator", Point.new(50, 50), Size.new(200,200)) set_top_window(myNewFrame) end end a = SapLogin.new a.main_loop() Some nice pics are we are done -:)
abap
alvaro tejadagalindo3
Retagging Required
ruby
scripting languages
6 Comments
Labels in this area
Business Trends
2
Event Information
1
Expert Insights
4
Related Content
Explosion of SAP Cloud:SAP Data/Integration Tool Procurement Guidelines to Migrate/Integrate data into Cloud from/to On-Premise Systems
in
Technology Blogs by Members
2019 Jul 19
Bridging two worlds : Integration of SAP and Hadoop Ecosystems
in
Technology Blogs by SAP
2017 Jul 19
SAP HANA 1.0 editions and options - by the SAP HANA Academy
in
Technology Blogs by SAP
2016 Jun 07
Uniting AMQP and MQTT Message Brokering with RabbitMQ
in
Technology Blogs by Members
2016 Feb 21
SAP HANA and Python? Yes Sir!
in
Technology Blogs by SAP
2012 Jun 08
Popular Blog Posts
Now live: 2014 SAP HANA and SAP HANA Cloud Applications Challenge voting
My Personal Ux, Fiori, Portal and Cloud Cheat Sheet
Web Dynpro ABAP Demonstration Videos
Top kudoed authors
User
Count
AviadRivlin
1
monikar03
1
onno_bagijn
1
View all