Você está na página 1de 20
ES ABAP CHANNELS DEMOS ABAP Channels in Developer Edition AS ABAP 7.5 December 2015 Olga Dolinskaja / SAP SE ABAP Channels in Developer Edition AS ABAP 7.5 TABLE of Contents TABLE of Contents AJNTRODUCTION .. GENERAL INFORMATION. MOTIVATION 8, DEMO ABAP PUSH CHANNEL (APC) INTRODUCTION... Demo SUMMARY.. C. DEMO ABAP MESSAGING CHANNEL (AMC) 2 INTRODUCTION. 2 DEMO SUMMARY 15 . DEMO COLLABORATION USING ABAP CHANNELS.. INTRODUCTION. 16 DEMO SUMMARY 19 ABAP Channels in Developer Edition AS ABAP 7.5 A.INTRODUCTION General information ‘Welcome to the ABAP Channels demos in the Developer Edition of AS ABAP 7.5. In this document you will find descriptions about how to use: B. Demo ABAP Push Channel (APC) ©. Demo ABAP Messaging Channel (AMC) D. Demo collaboration using ABAP Channels Before you start, here is some technical information on the prerequisites, demo packages, etc. that you will use: Oe Eclipse Mars 4(4.5.1) ‘ABAP Development Tools ‘ABAP Development Tools 2.51 Ul Development Kit for HTMLS UL Development Kit for HTMLS 1.32 BAPUIG ABAP Repository Team SAPUI5 ABAP Repository Team Provider 1.32 ABAP System AH ‘ABAP Client 004 ABA Username DEVELOPER 'ABAP Channels Demo Package DEMO_CHANNELS SAPUI6 application ZAPC_CHAT Motivation Most ABAP applications use polling techniques to achieve an event-driven communication. For pushing an event from an ABAP backend to a browser based user agent ike SAPUIS, Web Dynpro ‘ABAP, Business Server Pages (BSP) or WebGUI, the polling in multi-seconds interval is frequently Used. This is a quite system resource consuming technique. The ABAP Channels technology targets to replace such inefficient eventing based on polling techniques through Web Sockets (ABAP Push Channel) and publish/subscribe mechanism (ABAP Messaging Channel), Now, enjoy the demos! ABAP Channels in Developer Edition AS ABAP 7.5 B. DEMO ABAP PUSH CHANNEL (APC) Introduction Immediate access on Ul to the frequently changing business information and data in ABAP backend will suppor timely business insights, decision making and productivity. ‘The examples for this can be for instance bringing the irregularly and often changing product information and sale conditions to browser UI (SAPUIS, Web Dynpro ABAP, BSP) as soon as data change takes place in the ABAP backend, pushing short-lived financial data relevant for trades to the browser Ul, statistics, process information (sales figures in different areas, financial statistics, manufacturing process status). In all these cases the data presentation on UI (charts, diagrams, text and numbers) must be updated immediately accordingly to the modified data in the ABAP backend. In such situations in order to present the latest up-to-date information from the ABAP backend in real- time on the browser based UI most ABAP applications used polling techniques with multi-seconds intervals or refresh button periodically to get newest updates to Ul. These approaches are quite resource consuming result in insufficient performance and poor user experience. The availabilty of real-time data in ABAP backend is unpredictable and it is unnecessary effort to make requests and open and close HTTP connections. ‘The ABAP Push Channel (APC) technology replaces such inefficient polling approach through Web Sockets. ABAP Push Channel is bi-directional message based communication channel representing the Web Socket integration in ABAP, allowing e.g.to push notification to the Ul as soon as data change in ABAP backend happens. This is a sign for a user to request the changed data from ABAP backend and update Ul. For introduction to ABAP Channels please refer to hito://scn.sap.com/community/abap/connectivity/blog/2014/1 1/27/introduction-to-abap-channels More detailed information about how to use ABAP Push Channel: http://scn.sap.com/community/abap/connectivity/blog/2013/1 1/1 8/websocket-communication-using- abap-push-channels Video Tutorials: hitp:scn, m4 15/03/09now-to-impl nds channets~video-tutorials Demo In this demo you can investigate simple SAPUIS application (Chat program) which uses ABAP Push Channel as Web Socket communication with ABAP backend system. It works as following. You put any text into the text field and press the arrow button. The text is sent to the ABAP backend system over the ABAP Push Channel (Web Socket). The ABAP System enriches the text with date, time and user and sends it back. The Ul displays the text below the text field IS sss = 6] 6 resorcterr DEVELOPER: neo! Dee 1, 2015, 122241 PM ABAP Channels in Developer Edition AS ABAP 7.5 In this demo you can see how + ABAP Push Channel (APC) is implemented + ABAP Push Channel is used in the SAPUIS application 4. Start Eclipse, your Integrated Development Environment (DE), 2. Switch to the ABAP perspective by clicking the Open Perspective button or using the Menu Window > Open Perspective > Other. fantaces ff "Dt (ems Coll el 3. Create ABAP Project (using connection data to your ABAP backend system of the AS. ‘ABAP Developer Edition. File > New > ABAP Project... and follow then the suggested wizard steps. File Edt Navigate Search Project Run Window Help PO 08 ~ SiS Mimi e- O- B-€ Ib Project nporer £2 4, Add DEMO_CHANNELS as favorite package to your project (Favorite Packages > Add a Package) 4 GB Ast 001 developer.en Pret pore £2 4 MH 01 developer ent 01, DEVELOPER, 42 9 Favorite Packages » A STM - DEVELOPER mh Sytem Library ABAP Channels in Developer Edition AS ABAP 7.5 5. Now create SAPUIS project for the Ul application, File > New > Other > SAPUIS Application Development > Application Project and click Next button Select a wizard Create an Appiation Project ‘ype kere © Oomph 4 © SAPUS Appiation Development View Nex> ® 6. Enter as project name "CHAT and click Next Cromte an Application Project for tne: [aca] Beran ray @spm Options 7 crestean inti view ABAP Channels in Developer Edition AS ABAP 7.5 7. Enter as View name chat, choose x11. as development paradigm and click Next button, On the last wizard screen print Finish button. You have created the empty SAPUIS project 2aPC_CHAT Create a New View Choose a preject anda name and spec the developer paresigm Projet? [ape chat Felder | WebContentape, chat ven ET Development Paredige “Es Deployment Descriptor zape_chat 2 Java Resources A devaScript Resources 8. Now retrieve the Ul application sources from the SAPUIS ABAP Repository. In the Project Explorer mark your ZAPC_CHAT SAPUIS Project we cae and select in the context menu ncene Team > Share Project. © WeB.INF 4 mpc chat Ty chatconroere ful Chatviowart 9. Choose SAPUIS ABAP Chore Pret Repository from the list and henmeatony pg click Next button, sitteundtomacbereeded Sete petoy pe Seman fe Sem ABAP Channels in Developer Edition AS ABAP 7.5 10. Select your system connection using Browse button, click Next button Enter your logon data, click ‘Next button Select the zAPC_CHAT BSP application from the SAPUIS ABAP Repository and click Finis button. System Connection @ Secure Network Communication (SNC) is disabled forthe selected system connection, For securty reasons enable SNC Logon to System e& SpemiO: Aa cane [100 Pasmor” | eoeeeseed Language” Spc 9 apn 1 Set 2 89 Appice ame aston 1. Now retrieve the sources of the ZAPC_CEAT application from the SAPUIS ABAP Repository using the context menu Team > Retrieve. METAINE WeB-INF 2 Gy >< zape_chat ‘ty >< Chatcontolere «< Chetsview aml indechtm ABAP Channels in Developer Edition AS ABAP 7.5 All resources must be selected Click Finish button. Select Resources to Retiove 4 Cenfcting fee be verte Fe ‘Sect 7B webConteninder tet [9D Wes Conten META MANIFEST 1 Wee CortentWEB-NF ebm! I) webContetsape, hatchet vend pees eee (9 wencontentsape hatch contra. 2 == = 12. Now take a look at the ABAP | 4 &} ZDEMO_CHANNELS Push Channel (APC) > @ BSP Library 2RPC_CEAT by double-clicking 4 © Connectivity itor using SAFC transaction ABAP Messaging Channels (shortout 21t+F8 to run ABAP application in embedded SAPGUI in Eclipse, type SAPC), 4 @ ABAP Push Channels (zc CHAT ‘The associated service /2ap/bc/ape/sap/ zap (you can find it in the e°|\9S BR A*EAZDR transaction SICF) and the re corresponding ABAP Push —— [Demo ABP Games Channel application class were generated by Generate Class and Service button. The service gels activated automatically after generation The V10.2CP.SAP.COM value stays for the SAP's common message exchange protocol PCP to exchange messages in the PCP format. 43. Open the corresponding ABAP Push Channel class 2CL_APC_WSP_EXT_ZAPC_CH aT inthe editor and ake alook | > @ Bicionay atthe 4 © Source Code ibray Sp Rec WSP_ENT_ECE-ow +e ESSAGE_method. The relevant : code lines are on the pecans screenshot. ‘The importing parameter of this ¥ 12 represents the message which is delivered through APC. First, the text is ABAP Channels in Developer Edition AS ABAP 7.5 collected from the i_me: Then the message gets enriched with author and dato and prepared for the Ul display in the method prepare_message_for_ui( ). Then thie message is sent back with the i_message_manager through APC to the Ul dace (Iy_tex: str) =< message-oget_text( )- 4 message>aer_rext( Iv text |S message sanager->eend( 4 message ). ee) 14. Now examine how the Ul part ‘establishes the WebSooket connection, In the Project Explorer navigate to the oninit ()method of the Chat controller (Chat.controilerjs) and double click ito open in the editor window. On the screenshot you see the source code line, which establishes the Web Socket connection Remark: In the ontnit () method the Web Socket connection is established to the registered servi /sap/be/ape/sap/zape_ch ‘at (ABAP Push Channel) with SAP's common message ‘exchange protocol PCP. Furthermore the callback function is registered on Web Socket events and the Ul model is set. Ifa message arrives, its data get parsed, formatted and added as a new entry to the UI model. By using unshift () the newest entry gets displayed on the top of the list. The method refresh () Updates the Ul model on the screen. 10 ABAP Channels in Developer Edition AS ABAP 7.5 45, Run ZAPC_CHAT application: | « 28 » zape chats 0, DEVELOPER. EN select index.htm! and execute it {Bs Deployment Descriptor zape.chat ‘on the ABAP Server: Run As > 23 Jove Resources Run on ABAP Server. A lvaScript Resources build WebContent ey MeTaANe y WEB-NE 4 iy rpcchat ‘Chatcontrllere Hover Validate Runs sf) Runon Server Debug As (FG) 2Run en ABAP Server Profiles E_ 3 Web App Preview: 46. After entering your user and |g ingexhimi 52 = password you can use the Chat rogram. Type text into the text | | ip//vhcalatheidummy.nedomsins0000/) field and press the ‘arrow’ button. The text gets displayed Chat ‘on top of the list below the text field eto DEVELOPER: nelio! Doe 3, 2015, 9:43:47 AM Summary This demo creates the ABAP Push Channel (Web Socket) using the SAPC transaction and uses it in the SAPUIS application (Chat program) to exchange the messages through the ABAP Push Channel between the SAPUI application and the ABAP system, "1 ABAP Channels in Developer Edition AS ABAP 7.5 C. DEMO ABAP MESSAGING CHANNEL (AMC) Introduction Event-criven communication between ABAP sessions across the boundaries of ABAP application servers will streamline the business process workflow, speed up performance and reduce the rate of consumption of database resources. An ABAP application might need to identify and react to certain events in the other ABAP session as soon as they occur. Moreover an ABAP application might involve data processing in order to provide some output to be delivered to another application, running in another ABAP session and therefore has to send notification. Traditionally to realize such real-time event-driven behavior ABAP applications often poll periodically for the state information on the database. Bottleneck problems on the database may occur with numerous active polling from many ABAP applications simultaneously. Instead of using periodically polling technique, a publish/subscribe mechanism can be used for prompt notification which can eliminate unnecessary database load. ABAP Messaging Channel (AMC) infrastructure replaces the polling through publish/subscribe mechanism and acts as a broker for the message exchange between different ABAP sessions, which can reside on different ABAP application servers, After ABAP sessions act as publisher and subscribers respectively, as soon as an ABAP session publishes notification to AMC, all subscriber ABAP sessions get notified For introduction to ABAP Channels please refer to httpxl/scn.sap.com/community/abap/connectivity/blog/2014/11/27/introduction-to-abap-channels More detailed information about how to use ABAP Messaging Channel http://scn.sap.com/community/abap/connectivity/blog/2014/03/26/abap-channels-part-2-publish- subscribe-messaging-using-abap-messaging-channels Video Tutorials: hitp:/scn, 1m 15/03/09mnow-to-impl nds channels-video-tutorials Demo This demo implements communication with the ABAP Messaging Channel (AMC) between two simple ‘ABAP programs AMC sender and AMC receiver which are executed in two parallel ABAP sessions. While the AMC receiver program subscribes to the AMC channel /ping and waits for incoming messages, the AMC sender program sends messages to the AMC channel /ring and the AMC receiver program receives them @ AMC sender program yy @ */48'6@@ CHK DDH” (AMC sender program s sessace ines! Boyan Gee Goto Stem He ae” e+) 48 C@e@ BHR Bn” AMC receiver program ® nso. r war see a 12 ABAP Channels in Developer Edition AS ABAP 7.5 ‘After executing the AMC message receiver program it shows sand glass and is in the wailing state. ‘After executing the AMC sender program, the message ‘Hi there!’ is sent through the AMC channel ‘/ping and the AMC message receiver receives and displays the message on the UL © AMC sender program A © "48 CO@ DWH DDE” e; +dqu eee cam on” (AE CR 0, In this demo you can see how + ABAP Messaging Channel is implemented + ABAP Messaging Channel is used for the communication between two ABAP sessions 1. Switch in the Eclipse to the ABAP. Perspective. Undet Connectivity of the package ZDEMO_CHANNELS you will find within ABAP Messaging Channels the AMC application 2AMC_CEAT. Double click to open it in the embeddea ‘SAPGUI in Eclipse (or use shortcut ALt+P2 to run ABAP application in the SAPGUI, type SAM) 4 {8 ZDEMO_CHANNELS > BSP Library 4 & Connectivity 4 @ ABAP Messaging Channels (BZAMC_cHaT| (@ ARAP Pusch Channele Double click the channel /ping. The authorized programs to send and receive messages through the AMC channel jping are ZANC_SEND_MESSAGE_TEXT and ZANC_RECEIVE_MESSAGE_TEXT Remark: In this demo messages are exchanged in simple toxt format (TEXT) within activity scope client (Client). ‘aan ote) pe hd 3 ABAP Channels in Developer Edition AS ABAP 7.5 3. Inthe Source Code Library of the package ZDEMO_CHANNELS you will find the ABAP programs: ZAMC_SEND_MESSAGE_TEXT as ‘AMC Sender and ZANC_RECEIVE_MESSAGE_TEXT as AMC receiver. 4B ZDEMO_CHANNELS BSP Libray © Connectivity & Dictionary 44 @ Source Code Library © Clases 4 @ Programs @ ZaMc RECENE MESSAGE TET @ ZANC SEND MESSAGE TEXT Ss Teansomations 4, Open the AMC sender program ZAMC_SEND_MESSAGE_TEXT in the editor window and take a look at its implementation. This program sends out the message ‘ei there!’ through the AMC. First the olass factory cl_ame_channel_manager creates AMC producer object for the AMC application zac _CHAT and AMC channel /oing. Then the message is published with the provided interface method senci() to the AMC, RTA: ie_preduoes cent TYPE REP TO if_ano_neovage produces eax? 5. Open the AMC recsiver program ZAMC_RECEIVE MESSAGE_TEXT in the editor window and take a look at its implementation. This program acts as a receiver of the text message sent with AMC. First the class factory cl_ame_channel_manag: creates the AMC receiver object for the AMC application ZANC_CHAT and AMC channel /ping. Receiving messages can be started with the provided interface method start_message_delivery(). To be able to receive messages the session has to be in an “Interrupted” state and not busy. This can be achieved in two ways. Either explicitly with the new ABAP statement WATT FOR MESSAGING CHANNELS [UP TO

Você também pode gostar