Quick Development Of A Mobile CICS Application Using Lua

2y ago
26 Views
2 Downloads
1.63 MB
37 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Philip Renner
Transcription

Quick development of amobile CICS applicationusing LuaEzriel GrossCircle SoftwareDavid CrayfordFundi SoftwareWednesday 6 August 2014Session 15892Copyright 2014 Fundi Software

Agenda 2Got a CICS 3270 app, want it mobile now!Some optionsWhat’s Lua?Why Lua?Using Lua to mobilize a CICS 3270 appOther uses for Lua on z/OSIntroducing Lua4z

Want to mobilize an existing CICS 3270 appGot thisWant thisCICS application3270interface3WebMobiledevice

The CICS 3270 application: box office ticketingTicketingFBOCCM02FUNDI BOX OFFICESelect an Action Code :Available Actions : 1234Enter - Select4PF3 - EndFindBookReserveCancelPF12 - Cancel

The CICS 3270 application: box office ticketingTicketingFunc : BOOKFBOCCM07FUNDI BOX OFFICEComplete the details below, then press ENTERCompany IdDateVenue IdTierSeats Requested:::::Seat(s)AisleRowBlock::::Enter - Select5PF3 - EndPF12 - Cancel

The CICS 3270 application: box office ticketingTicketingFunc : BOOKFBOCCM07FUNDI BOX OFFICEComplete the details below, then press ENTERCompany IdDateVenue IdTierSeats owBlock::::10310204OK, seat(s) bookedEnter - Select6PF3 - EndPF12 - Cancel

DetailsCICS application3270interfaceDB2 database7CICS3270bridge?WebMobiledevice

Transforming between 3270 and JSON8COBOL copybookJSON01{M07DETI.02 FILLER PIC X(12).02 M07FUNCLCOMP PIC S9(4).02 M07FUNCFPICTURE X.02 FILLER REDEFINES M07FUNCF.03 M07FUNCAPICTURE X.02 FILLERPICTURE X(2).02 M07FUNCI PIC X(7).02 M07COIDLCOMP PIC S9(4).02 M07COIDFPICTURE X.02 FILLER REDEFINES M07COIDF.03 M07COIDAPICTURE X.02 FILLERPICTURE X(2).02 M07COIDI PIC X(05).02 M07DATELCOMP PIC S9(4).02 M07DATEFPICTURE X.02 FILLER REDEFINES M07DATEF.03 M07DATEAPICTURE X.02 FILLERPICTURE X(2).02 M07DATEI PIC X(10).02 M07VUIDLCOMP PIC S9(4).02 M07VUIDFPICTURE X.02 FILLER REDEFINES M07VUIDF. "seats requested" : 2,"venueID" : 263,"tier" : "G","date" : "2014-07-01","companyID" : "EZTIK"}Transformation logic

Some programming language options COBOL (or any “traditional” CICS programming language,such as C, PL/I, or assembler) Java REXX PHP– CICS TS Feature Pack for Dynamic Scripting V2.0– PHP scripts interpreted by Java runtimeand now Lua9

What’s Lua? Powerful, fast, lightweight, embeddable scripting languageProven and robustOpen sourceMany useful extensionsPortable– Fundi has ported Lua, and various extensions, to z/OS– We’ve developed patches and extensions for z/OS Lua website: www.lua.org10

Why Lua? Fast execution speed Easy to learn, concise syntax– Especially if you already know JavaScript Many useful open-source extensions:– Multi-threaded web application stack– Support for XML and JSON Easy to extend– We developed new Lua functions that call the CICSLink3270 bridge Easy to embed in your existing application11

Architecture of a Lua-based solutionLua scriptsspecifically developed for this solutionLuaCICSCICS APILuaSQLOrbitDatabaseconnectivity APIMVC web framework APILINKWSAPIWeb server APICICS Web support3270bridgeCICS 3270application12ODBCHTTPDB2databaseMobiledevice

Our rapid development environmentLua scriptsspecifically developed for this solutionLuaCICSCICS APILuaSQLOrbitDatabaseconnectivity APIMVC web framework APIEXCIWeb server APIXavanteCICS3270bridgeCICS 3270application13WSAPIWeb serverODBCHTTPDB2databaseMobiledevice

What do the Lua scripts do?Lua scripts Map request URL to an actionInteract with the CICS 3270 applicationQuery DB2Transform: JSON to 3270, JSON to SQL,SQL results to JSON Return JSONCICS 3270application14DB2databaseMobiledevice

Lua scriptscicsmap.luaDefines helper functionsto map fields on CICS3270 screenorbit.luaStarts web server 50 lines of coderunsrefers tofunbox.luaUses Orbit API to maprequest URLs tofunctions (dispatchers) 20 lines of code15model.luarefers toDefines functions(e.g. run CICS app thenreturn response) 100 lines of code

Model-view-presenter (MVP) design patternViewindex.htmlSingle-page HTML aMaps request URLs to functionsModelmodel.luaDefines functions that performactions requested by the user16

Mapping request URLs to functionsfunbox.lua17RESTful APIrequest URLHTTPmethodFunction(defined in model.lua)/funbox/eventsGetlist events( )/funbox/venuesGetlist venues( )/funbox/venues/venueidGetlist venues( ,venueid)/funbox/book?detailsPostbook event( )

Mapping request URLs to functionsfunbox.lualocal orbit require("orbit")local Model require("model")local R ains our functions a few other required modules local funbox orbit.new()local model Model.new()-- Dispatcher for static HTML filefunbox:dispatch static("/index%.html")-- Dispatcher for venuesfunbox:dispatch get(function (web, parms) return model:list venues(web, parms.id) end,R "/funbox/venues/:id")other dispatchers 18Call this function whenthe client requests this URL(:id is a variable value)

Submitting SQL queries, returning JSONmodel.lua preamble code and helper functions shown on next slide Create anSQL queryAddWHEREclause forspecificvenuefunction model:list venues(web, id)local query enue")if id thenquery:where("venueid ", id)return get response(web, get query(self, query))endreturn get response(web, list query(self, query))endAlternative code path handlesa request for all venues (novenue ID in URL)19

local class require "middleclass"local luasql require "luasql.odbc"local json require "cjson"local QueryBuilder require("query")local model class("funbox.model") -- this class-- Constructorfunction model:initialize()local env luasql.odbc()self.dbcon assert( env:connect() )end-- Submits SQL querylocal function get query( self, query )query tostring(query)local cur assert( self.dbcon:execute( query ) )return cur:fetch( {}, "a" )end-- Returns the response from a GET requestlocal function get response(web, res)if not res thenweb.status 404return nilendweb.headers["content-type"] "application/json";return json.encode(res)end20

Mapping CICS 3270 application datacicsmap.lualocal struct require "struct"-- Format stringlocal fmtstr "c24 H c3 c5 h c3 c10 h c3 c5 h c3 c h c3 c2 c47 h c3" ."c2 c40 h c3 c2 c32 H c3 c2 c12 H c3 c2 c71 c64 c5 c64 c53"-- Length of the structurelocal LENGTH 488-- Helper function to unpack the structurelocal function unpack(self, s)self.filler0, self.companyid len, self.filler1, self.companyid,self.date len, self.filler2, self.date, self.venueid len, self.filler3,self.venueid, self.tier len, self.filler4, self.tier, self.num seats len,self.filler5, self.num seats, self.filler6, self.seats length, self.filler7,self.seats, self.filler8, self.ailse len, self.filler9, self.aisle,self.filler10, self.row length, self.filler11, self.row, self.filler12,self.block len, self.filler13, self.block, self.fillerbig, self.msg,self.filler14, self.msg2,self.filler15 struct.unpack(fmtstr, s)end21continued

continued from previous slide-- Unpack methodfunction M:unpack(s)unpack(self, s)end-- Unpack method to pack the table to a stringfunction M:pack()return struct.pack(fmtstr,self.filler0, self.companyid len, self.filler1, self.companyid,self.date len, self.filler2, self.date, self.venueid len, self.filler3,self.venueid, self.tier len, self.filler4, self.tier, self.num seats len,self.filler5, self.num seats, self.filler6, self.seats length, self.filler7,self.seats, self.filler8, self.ailse len, self.filler9, self.aisle,self.filler10, self.row length, self.filler11, self.row, self.filler12,self.block len, self.filler13, self.block, self.fillerbig, self.msg,self.filler14, self.msg2,self.filler15)endreturn M22

Interacting with the CICS 3270 applicationmodel.lualocal mapper require "cicsmap"local link3270 require "cics.link3270x"function model:book event(web, parms)-- Decode the POST JSON payloadlocal req json.decode(web.POST.post data)-- Open the Link3270 bridge sessionlocal br link3270.open {applid "LUATCIC1",wait interval 300,}-- Create the screen mapperlocal ads mapper.new()ads.companyid req.companyID;ads.companyid len #req.companyID;ads.venueid id len #ads.venueidads.date req.dateads.date len #req.date23continued

continued from previous slide-- Run the transaction with no input to simulate running from 3270br:exec("FBTB")-- Receive map, TRANSID(FBTB) MAP(M07DET) MAPSET(FBOMSET)local resp br:receive map("FBTB", "M07DET", "FBOMSET",ads:pack())-- Check the resultlocal sent map ads:unpack(resp)if sent map.msg:sub(1,2) "OK" then -- No "OK" messageweb.status "400 Transaction Failed"return sent map.msgendend24

Complete listing of funbox.lualocallocallocallocallocalorbit require("orbit")R require("orbit.routes")Model require("model")funbox orbit.new()model Model.new()-- Dispatcher for static filefunbox:dispatch static("/index%.html")-- Dispatcher for venuesfunbox:dispatch get( function (web, parms)return model:list venues(web, parms.id) end, R "/funbox/venues/:id")-- Dispatchers for eventsfunbox:dispatch get( function (web, parms)return model:list events(web, parms) end, R "/funbox/events")funbox:dispatch post( function (web, parms)return model:book event(web, parms) end, R "/funbox/book")return funbox25

Running the solution from an MVS batch job/ORBITJOB CLASS W,MSGCLASS T,NOTIFY &SYSUID//*//LUAEXEC PGM LUA,PARMDD SYSIN//STEPLIB DD DISP SHR,DSN LUA.LOAD//DD DISP SHR,DSN CICS.V690BASE.CICS.SDFHLOAD//DD DISP SHR,DSN CICS.V690BASE.CICS.SDFHEXCI//SYSPRINT DD SYSOUT *//DSNAOINI DD DISP SHR,DSN FUNBOX.CNTL(DSNAOINI)//LUADD DISP SHR,DSN FUNBOX.LUA//HTMLDD DISP SHR,DSN FUNBOX.HTML//SYSINDD *posix(on) / orbit -p 7030 //lua(funbox)/*26

SYSIN: input to the Lua interpreterLanguageEnvironmentoptionsName ofLua scriptto runLua script parametersposix(on) / orbit -p 7030 //lua(funbox)Webserverlistens onthis port27Lua script that definesdispatchers

Mobile web interface:Listing events1. User opens index.html (oursingle-page app, or SPA) intheir web browser2. SPA uses jQuery API to sendAjax get request for the URLfunbox/events3. Lua function list events()submits SQL query, returnslist of events in JSON4. SPA presents list of eventsusing jQuery Mobile Listviewwidget5. User selects an event 28

jQuery Ajax get wEvents); function getJSON(url) {Getsreturn .ajax({type : "GET",url : url,dataType : "json",beforeSend : function() {Mobile ) { .mobile.loading("hide");}).fail(function(jqXHR, textStatus) {alert("Request failed: " textStatus " - " jqXHR.responseText "\nurl: " this.url);});}29

Mobile web interface:Viewing event details1. SPA sends Ajax getrequest for the event2. Lua function returnsevent details as JSON3. SPA presents eventdetails, using GoogleMaps API to showvenue4. User selects number oftickets and tier, clicksBook now30

Mobile web interface:Booking confirmation1. SPA sends Ajax “Post”request with desired ticketdetails2. Lua script interacts withCICS application3. If the response from theCICS application indicatessuccess, the Lua scriptreturns a “success” (OK)response4. SPA displays confirmationmessage31

Other uses for Lua on z/OS Alternative to REXX:– Much faster execution– Concise syntax– Built-in (standard library) support for regular expressions– Thread support– Many useful open-source extensions, including webframeworks, XML parsing, JSON and many, many more:see the list on the Lua users wiki atlua-users.org/wiki/LibrariesAndBindings– Modular source structure via require() function– Active user and development community Embedding in your own applications32

Lua4z: a binary distribution of Lua for z/OS,with extensions Runs in MVS batch,TSO batch orforeground, z/OS UNIX Work in progress:alpha release comingsoon! Initial plan:– Free version with no supportcontract– Support contracts– For-money extensions, suchas LuaCICSBuilt on z/OSLua 5.1.5sourcedistribution33 A selectionof Luaextensions Lua4z

Lua extensions we might include with as TimerCosmoCoxpcalldkjsoninspectLDoclpackLpegLua BitOpLua CJSONLua HamlLua Laneslua patLuaFileSystem34A simple Lua function for printing to the console in colorAlternative to the standard Lua bit32 libraryUnit testing frameworkTool for creating dynamic web pages and manipulating input data from web formsCommand-line argument parser for LuaCoroutine Oriented Portable Asynchronous Services for LuaSocket schedulerSafe templates engineCoroutine-safe xpcall and pcall versionsA module for encoding and decoding JSONLua table visualizer, ideal for debuggingA Lua documentation toolLua library for packing and unpacking binary dataParsing Expression Grammars For LuaLua Bit Operations ModuleProvides JSON support for LuaImplementation of the Haml markup languageMultithreading libraryInterface to zlibLua4z extension for CICSMessagePack implementation and bindings for LuaLua frontend to the OpenSSL cryptographic libraryDate and time moduleA database interface librarySAX XML parser based on the Expat libraryFile system librarycontinued

Lua extensions we might include with WSAPIXavante35POSIX iconv binding (performs character set conversions)Lua4z extension for ISPF servicesCustomizable JSON decoder/encoderA simple API to use logging featuresLua bindings for POSIX (including curses)A binding for the OpenSLL library to provide TLS/SSL communicationNetwork supportGeneric ReST client (SPORE: Specification to a POrtable Rest Environment)Database connectivity APIExtends Lua's built-in assertionsA unit-testing frameworkWebsockets: provides sync and async clients and servers for copasA pure-Lua implementation of the Markdown text-to-HTML markup systemA Sinatra-like web framework (or DSL, if you like) for creating web applications in LuaA simple OOP library for LuaA programmer friendly language that compiles to LuaAn MVC framework for LuaA self-contained personal web frameworkLua utility libraries loosely based on the Python standard librariesA Lua client library for the redis key value storage systemCreate new Lua states from within LuaString hashing/indexing library: useful for internationalizationLibrary for converting data to and from C structsA test/spec library for LuaFunctions for manipulating binary dataWeb server APIWeb server

Contact Send email to:info@lua4z.com Ask questions about Lua4z Register your interest inbecoming a Lua4z alpha tester36Please evaluate thissession

Questions?37

Aug 06, 2014 · their web browser 2. SPA uses jQuery API to send Ajax get request for the URL funbox/events 3. Lua function list_events() submits SQL query, returns list of events in JSON 4. SPA presents list of events using jQuery Mobile Listview widget 5. User selects an event

Related Documents:

Strategy 6: Mobile Workload Mobile devices are increasingly driving mainframe workloads April 2014: Mobile Workload Pricing – 60% reduction in mobile workload CPU to R4HA peak MUST be from mobile device MUST show connection to mobile device – Mobile Safari good – Desktop Safari not good Mobile to mainframe is .

the mobile marketing activities performed by retailers are the creation of mobile websites and development of mobile shopping applications, mobile customer service, communication through mobile email and messaging, mobile advertising and mobile couponing (Thakur, 2016). The fashion industry is globally worth more than 2 trillion (McKinsey, 2020).

The Definitive Guide to Enterprise Mobile Development The definitive guide to Enterprise Mobile Development v1.1 - 2 Table of contents Architecture of a Mobile Platform 3 Push notifications Design and build Mobile services 4 Deploying mobile applications Publish Mobile Services 6 Continuous Integration Connecting to backend data 7 Config Legacy Connectors 8 Cloud or on premises

Mobile Communication Services . Offerings Detail Samsung SDS America Public Sector Capabilities Mobile ERP Health IT Mobile Groupware SAP Mobile BI Dashboard Oracle/Siebel Mobile CRM for Pharmaceutical Sales Mobile Device Management Mobile Applications (Android OS) . Android Mobile App & UI. 10 Offerings Detail Conceptual .

Mobile 3G/4G, pushing wireless boundaries to enable the best mobile experiences 2 Mobile connectivity is an amazing technical achievement, 4 critical to the mobile experience Wireless fundamentals are the foundation to mobile powered by Mobile 3G/4G technologies Appreciating the magic of mobile requires un

Mobile advertising helps developers of mobile apps obtain revenue without directly charging users. Therefore, advertising is a key component of the mobile app ecosys-tem. Mobile advertising is typically integrated into mobile apps via an advertising library or SDK (AdSDK), which fetches and displays mobile ads while the app is running.

SAP Mobile SDK or SAP Mobile Server installed, you must provide a license. See Obtaining a License on page 1. If you are installing SAP Mobile SDK on a system where a version of SAP Mobile Platform Runtime is already installed, the SAP Mobile SDK installer installs using the SAP Mobile Server license. See Chapter 2, Installing SAP Mobile SDK on .

Mobile Marketing with Channel Mobile It's time to harness the power of mobile!! The Power of Mobile The Power of Mobile Operator revenues - 5.4 trillion cumulative 2013 - 2017 Analysts predict a SIM penetration of 97% in 2017 Mobile data traffic expected to grow by 79% annually from 2012 - 2017