Sunday, November 18, 2007

Netweaver Notes (WebAS 6.40 SP18)

When checking out or bringing down in read only mode, the most current code is the Inactive DCs.

Everything is organized as follows

Group Track Proj Package
Mit.edu.mitc1 mm po web (or proxy or dao or dto, etc)

Create project to bring code from DTR (design time repository) to local machine. . I think I follow instructions on web: http://userdocs.mit.edu/IDD/netweaver/j2eedev.html#import

Brendan talked about public parts at this point. Defined in the blurb on Development Components (DC):
http://fuller.mit.edu/netweaver/nwdi.html#dc
Instructions on creating public parts:
http://userdocs.mit.edu/IDD/netweaver/j2eedev.html#dcspublic


Amy's M-V-C Diagram (Model, View & Control)

Model, View & Control Diagram

DC = Development Component (SAP Netweaver jargon - see the Netweaver Development Infrastructure WIKI)

Standard jargon
J2SE - Java version 2, standard edition (an API - application programming interface)
J2EE - Java version 2, enterprise edition (an API & a framework), also sometimes referred to as JEE

Framework - In software development, a framework is a defined support structure in which another software project can be organized and developed. A framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. According to Wikipedia, Struts is a framework and there are references on the web to J2EE as a framework with components. The Web & EJB Containers are listed as standard J2EE components.

(In Netweaver the J2EE components are the EAR, Service (EJB) & Web DCs. The Java components are DTO, DAO & Proxy DCs. But the EAR is really a bundling of all the DCs, both the J2EE components, EJB & Web, and the Java components, DTO, DAO & Proxy. Not sure if breaking down the areas between J2EE components & Java components is unique to Netweaver or standard but the standard literature does talk about the Web & EJB Containers as being components within the J2EE framework.)

DAO = Data Access Object - turns data into something useful for the rest of the chain (Java component)
DTO = Data Transfer Object - holds the data (Java component)
EAR - Enterprise archive (files bundled together, deployable - includes the other J2EE components and the Java components but is considered to be one of the J2EE components in Netweaver)
EJB = Enterprise Java Beans (In Netweaver package called Service - a J2EE component)
JSP = Java Server Pages (part of the Web DC which is a J2EE component)
JAR - Java archive (files bundled together)
Proxy - From Wikipedia - "Proxy may refer to something which acts on behalf of something else as in Proxy pattern, a software design pattern in computer programming. A proxy, in its most general form, is a class functioning as an interface to another thing." In Netweaver I assume this other thing is the ABAP RFC (a function module that is Remote-enabled). (a Java component)
WAR - Web archive (files bundled together)
Web - The web tier in the M-V-C diagram above. It includes a JSP file for each web page within an application under Netweaver's webContent directory. It also includes all the configuration XML files, such as web.xml, struts-config.xml, tiles-def.xml, etc. And it includes the Actions (Java classes that interface with the EJB) & ActionForms (Java classes that define all the variables used by an application).


After project is set up:

  1. Create packages for Proxy, DTO & DAO DCs.
    In the Java perspective >> Package Explorer view, select and R-click on the desired DC and choose New >> Package. Packages must use as a base the MIT namespace followed by the same naming structure as the DC, as follows:
    edu.mit.mitc1... e.g. mit.edu.mitc1.ca.pdf.proxy & don't forget that Proxy needs 2 packages (e.g., mit.edu.mitc1.ca.pdf.proxy.util & mit.edu.mitc1.ca.pdf.proxy)
    The exception to this rule is if either the area or application name is an invalid Java name, such as 001. Had to change 001 to p001.
  2. Add the 3 SAP Public Parts to the project's Proxy Used DCs (done via the Java perspective -> Java DC Explorer view):
    sap.com_SAP-JTECHS_1 >> com.sap.aii.proxy.framework >> DC Metadata >> Public Parts >> default
    sap.com_SAP-JTECHS_1 >> com.sap.aii.util.misc >> DC Metadata >> Public Parts >> default
    sap.com_SAP-JEE_1 >> com.sap.mw.jco >> DC Metadata >> Public Parts >> default
  3. Create Compilation and Assembly Public Parts for the three Java DCs,Proxy, DTO & DAO (done via the Java perspective -> Java DC Explorer view)
    - Expand the DC. Within its DC Metadata node, select & R-click on Public Parts and choose New Public Part.
    - A dialog window opens. Specify a name for the Public Part Compilation or Assembly (e.g. ProxyCompilation) & select the appropriate checkbox under "The exposed items can be used as a library that," "Provides an API..." for Compilation & "Can be packaged..." for Assembly.
    compilation

    assembly
    - Under Optional Fields, specify a brief description in the Caption field (e.g. compilation PP for java proxy)
    - Click Next. Under Select Entry Type, select Java Package Tree. Under Select Entries, expand the package tree to its lowest level and select the package(s) to be included in the Public Part by selecting its checkbox. Under Add Entity to Public Part, select the as Class checkbox.
    java package tree
    - Click Finish. The Public Part is created as a JAR file and the DC's packatges may now be referenced by classes from other DCs.
    - Build the DC.
  4. Add the DTO & Proxy compilations to the DAO Used DCs (done via the Java perspective -> Java DC Explorer view)
    - Expand the DC to which the Used DC will be added. Within its DC Metadata -> DC Definition node, select and R-click on Used DCs and choose Add Used DC.
    - A dialog window opens. If the desired DCs are available from the Active tab, use that tab, otherwise the Inactive tab may be used. Expand the hierarchy to the desired DC, then expand its DC Metadata -> Public Parts node, and select the desired Public Part (compilation). Under Dependency Type, slect only the Build Time checkbox.
    - Click Finish. The selected Public Part is added as a Used DC and its packages may be referenced by classes within this DC.
    - Build the DC.
  5. Add to the J2EE Component's Used DCs (done via the J2EE Development perspective -> J2EE DC Explorer view): EAR - the DTO, DAO & Proxy assemblies (ejbjar & war?) and Service (EJB) - the DTO & DAO compilations
  6. Create package for the EJB
    In the J2EE Development perspective -> J2EE DC Explorer view, select and R-click on the Service DC and choose New >> Package. Packages must use as a base the MIT namespace followed by the same naming structure as the DC, as follows:
    edu.mit.mitc1... e.g. mit.edu.mitc1.fi.jvsuite.service
  7. Create the EBJ for a stateless session bean from the JAVA perspective -> Package Explorer view - this failed! why???

Netweaver generates the Proxy via SAP Connectivity (see Creating Proxy)

Proxy, DAO, DTO - Services (EJB) ~ JAR (a Java Archive for the Business & EIS Tiers)
Web (entire web tier) ~ WAR (J2EE Web Archive for the Web Tier)

From back-end to front ignoring the grey boxes:

Model (business logic - the Business & EIS Tiers & the Action Form within the Web Tier)

  1. SAP = RFC Function Module
  2. Java Proxy (SAP Connectivity -> RFC) J11_MM_D~MITC1_MM_PO_PROXY_MIT.EDU
  3. DAO (Data Access Object) This talks to the proxy to turn it into something the rest of the chain can use J11_MM_D~MITC1_MM_PO_DAO_MIT.EDU
  4. DTO (Data Transfer Object) This holds data. It is data structures J11_MM_D~MITC1_MM_PO_DTO_MIT.EDU
  5. EJB (Enterprise Java Beans) Services Layer – package is called service. Wrapper around DAO J11_MM_D~MITC1_MM_PO_SERVICE_MIT.EDU
  6. Web Tier all under Web Package – Action Form is all that is part of the Model J11_MM_D~MITC1_MM_PO_WEB_MIT.EDU
    1. Bulk of application code is here under Action Forms

Don't need to worry about utility class, Service Locator

Deployable Components:

  • EAR (Enterprise Archive like JAR or WAR for the entire project)
  • WAR (J2EE Web Archive for Web Tier)
    • WEB-INF at root level of archive
      1. struts-config.xml
        • Forms are defined in the Form Beans section (ReqExtForm)
        • Actions are mapped within the Action Mappings section
          • Entry Actions ( EntryToReqAction)
          • Navigation Actions which extend the form defined within the Entry Action (ReqCreateNavAction)
      2. tiles-def.xml
        • JSP is mapped & page action defined
      3. Lib
      4. Classes
  • JAR (a Java Archive for the Business & EIS Tiers)

Netweaver J2EE Explorer (button on bottom of first frame) – I didn't see anything from this button because this is for objects not centrally managed. We manage everything in the DTR on the server so we don't use the J2EE Explorer.


I switched to J2EE DC Explorer and could see what Brendan described. The J2EE DC Explorer will have all the deployable components. It is also where I would work on Actions & Action Forms (and EJBs if we ever use them) because it is the only place I can work on the public parts of these packages.

Three deployable components (packages) appear

  1. EAR (Enterprise Archive for entire project)
  2. Service (JAR – EJB - Java Archive for Business & EIS Tiers)
  3. Web (WAR – bulk of application code - J2EE Web Archive for Web Tier)

Under Web

  1. WEB-INF
    1. Config Files (struts-config.xml important to define forms & map actions)
    2. Classes
      • Properties (error messages)
  2. Source
    1. Web
      • Struts (All source code -> Actions & Action forms)
  3. Web Content
    1. Images
    2. JSP

Working Environments

Most of my work will be done in the J2EE Development Perspective.

    1. I will be working in the Package Explorer for the Proxy, DAO & DTO because these are not deployable (I can also access these non-deployable non-J2EE DCs from the Java Perspective).
      1. J11_MM_D~MITC1~MM~PO~PROXY~MIT.EDU
      2. J11_MM_D~MITC1~MM~PO~DAO~MIT.EDU
      3. J11_MM_D~MITC1~MM~PO~DTO~MIT.EDU
    1. I will be working in the J2EE DC Explorer for the JSP & Action & ActionForm because these are part of WAR (J2EE Web Archive for Web Tier) which is deployable. The Web, EJB (Service) & EAR are J2EE components which is why you work with them in the J2EE DC Explorer.
      1. J11_MM_D~MITC1~MM~PO~WEB~MIT.EDU
        1. webContent – JSP
        2. source (edu->mit->mitc1->mm->po->web->struts) Action & ActionForm
    1. I will work in Navigator to rename a file

The only other Perspective I will use is the Development Configurations Perspective to sync the source files or check in my activities.


Creating Proxy (SAP Connectivity) for RFC

Always Sync Inactive DCs first (see Refresh local programs from DTR).

If there are no pre-existing proxies make sure you do bring in SAP DCs first.

  • J2EE Development Perspective
    • Package Explorer

Since we are reusing some proxy code we need to check it out so we can modify it during process. Best to check out everything in Proxy & Proxy. Util
In the PROXY package (J11_MM_D~MITC1~MM~PO~PROXY~MIT.EDU) these two can be found under SRC/PACKAGES.

  • Select all under Proxy first. Then repeat for Proxy.util
  • Right click
    • DTR
      • Edit

This creates a new activity. There is a naming convention for activities because they are ultimately transported between environments. The naming convention allows us to sort them into a logical order for the transport.

Proj Year MM DD Krbid Description
po 2006 01 19 fuller This is to create a proxy for Z_MM_PO_HISTORY_DISPLAY

  • Package Explorer (button at bottom of left upper frame)
  • J11_MM_D~MITC1~MM~PO~PROXY~MIT.EDU
    • Right click on SRC/PACKAGES within this package
    • New->Other->SAP Connectivity
      • Package – browse and select the Proxy (J11_MM_D~MITC1~MM~PO~PROXY) or (type in mit.edu.mitc1.ca.pdf.proxy if first proxy and package has not been created)
      • Name – give it the same name as the RFC (all caps?)
      • Hostname, System # , client & logon name vary depending upon whether we are connecting to SF2 (maple.mit.edu & 01 & 030 & ZZSF2030MDI) or SF8 (sapling & 00 & 025 & ZZSF2025MDI)
        sap logon
      • Password xxxx (stored in ABAP see web documentation https://web.mit.edu/people/aeking/work/netweaverInstructions.shtml#proxies There are problems with the program in SF2 that stores the password. So I have a copy in my key chains. Seth also has it.
      • Enter RFC -> Check it -> Finish (If you encounter a PERMISSION_ERROR, request authorization to create proxy for function group)
        PERMISSION_ERROR
      • Ok
      • Select the activity you created earlier
      • A bunch of Oks

Modifying JSP

  • J2EE Development Perspective
    • J2EE DC Explorer
      • J11_MM_D~MITC1~MM~PO~WEB~MIT.EDU
        • webContent (display_payhistory)

I need to check it out in edit mode and start my changes after the end of messages. I need to make such changes as return to search results to return to display PO.

For instance on the Action.do reference

I can globally change PoDisplayForm to DisplayPayHistoryForm or whatever I decide to name my Form code. Must be in "source" mode not "preview" mode. Control/F for global replace.

The question marks in property="???" should be replaced with my field names.

Bill created createreq_ext.jsp using "GlobalForm" for messages and "ReqExtForm" for Create External Requisition specific fields. He also modified tiles-def.xml under WEB-INF to map po.createreq_ext to createreq_ext.jsp with a page action ReqSubmitAction.do.

struts-config.xml - (under WEB-INF) copied the section on EntryAction to a new section EntryToReqAction which contains the "GlobalForm" and points to the next chain ReqCreateNavAction.do.
struts-config.xml - I also copied PoSearchNavAction to ReqCreateNavAction, which contains the "ReqExtForm".
struts-config.xml - I also needed to add the ReqExtForm to the form-beans section.


Creating FORM, ACTION

  • J2EE Development Perspective
    • J2EE DC Explorer
      • J11_MM_D~MITC1~MM~PO~WEB~MIT.EDU
        • source
          • web
            • struts

Right click "struts" -> New -> Java Class
Name should NOT include the extension, ".Java"
Copy FORM or ACTION from a similar Brendon Java program and modify

EntryToReqAction (exact copy of EntryAction) – The reason this exact copy is necessary is because in the struts-config.xml, these initial entry actions point to their respective next actions, which will contain their specific forms.
ReqCreateNavAction (set fields mentioned in jsp bean writes) – The next action for EntryToReqAction which references the specific form ReqExtForm (see struts-config.xml)


Creating DTO

  • J2EE Development Perspective
    • Package Explorer
      • J11_MM_D~MITC1~MM~PO~DTO~MIT.EDU
        • src/packages
          • edu.mit.mitc1.mm.po.dto

Right click "edu.mit.mitc1.mm.po.dto" -> New -> Other…->Java->Class
Copy DTO from a similar Brendon Java program and modify

Since the DTO is a different package from the FORM & ACTION the FORM/ACTION EAR might need rebuilding before the new DTO is recognized:

  • J2EE Development Perspective
    • J2EE DC Explorer
      • J11_MM_D~MITC1~MM~PO~EAR~MIT.EDU

Right click -> Development Component -> Build…


Check it in:

If folders are involved in activity – talk to Bill. This is tricky.

  • Go to Development Configuration Perspectives
  • Highlight MM_DEV – takes a very long time the first time
  • Right frame open activities and expand (If activity has red ribbon indicating someone else has been modifying same code go see Bill or Brendan.
  • Highlight activity not file & right click
    • Check In
    • Activate (if no dependences – "Predecessor activity detected" means a dependency – see Brendan)
    • Ok or Open Request View (will activate and display)

Each window has refresh button – must refresh because not self refreshing. When doing multiple checkins wait until Running guy turns into white check on green background.

Deployment

  • J2EE Development Perspective
    • J2EE DC Explorer
      • J11_MM_D~MITC1~MM~PO~EAR~MIT.EDU
        • edu.mit~mitc1~mm~po~ear.ear (delete this file)

After deleting the EAR file, select J11_MM_D~MITC1~MM~PO~EAR~MIT.EDU Right click -> Development Component -> Build.
This will rebuild the edu.mit~mitc1~mm~po~ear.ear file. Once it is rebuilt, select it Right click ->Deploy to J2EE Engine->sdm password = xxxxxx (make sure the SAP J2EE Engine is configured in preferences to use Server Host larch.mit.edu & Message server port 3673)


Refresh local programs from DTR (design time repository):

  1. Development Configuration Perspective
  2. Inactive DCs
  3. Highlight MM_DEV or lower down the chain all the packages starting with mitc1/mm/po/xxxxx
  4. Highlight code you want refreshed
  5. Right click
  6. Sync Sources

To Update (Remove and Import) a DC Track
Go to the Development Configurations Perspective. Select the track in Inactive DC's (MM_Dev). Right click on it and select "Remove Configuration". It will take quite awhile to work and it will look as if nothing is happening, but clicking around will cause Netweaver to freeze up. When the dialog box appears asking if you want to delete the root folder, say Yes.

To reimport the Track: Go to the Local DC's view and right click anywhere in it. Select Import Configuration. (If right click does not do anything, there is button underneath the menus "Wizard for Import of Development Configuration." This button is the equivalent of right clicking within the "Local DC" box and selecting "Import Configuration.") Click remote and expand the track you want until it can't be expanded any more. Select the one with _dev at the end. Then hit Next and then Finish. You will still need to Create a Project for each track. To do this follow Amy's instructions at https://web.mit.edu/people/aeking/work/netweaverInstructions.shtml#existingDcs. Follow steps 2 & 3.

Delete Activity

  • Development Configurations Perspective
  • Select files within activity and Right Click -> Revert
  • Select activity and Right Click -> Delete

Common UT code

GlobalForm. java and GlobalEntryAction.java can be found in the Development Configuration Perspective after importing track UT_dev:

UT_dev DC -> mit.edu_UT_1 -> mitc1/ut/common -> src -> packages -> edu -> mit -> mitc1 -> ut -> common -> action

Create a project on for mitc1/ut/common

J2EE Development Perspective -> Package Explorer -> J11_UT_D~mitc1~ut~common~mit.edu -> src/packages -> edu.mit.mitc1.ut.common.action -> GlobalEntryAction.java & GlobalForm.java

GlobalEntryAction is setting the value of sapSystemId (SF2, SF5, PS1, etc), wasSystemId (J02, J11, J41, etc), wasHost (maghogony, minosa, hawthorne, etc) & userHome based on information from the session request.

If you make a modification to one of the UT programs such as GlobalEntryAction:

Added variable "server" (e.g., mahogany.mit.edu) to GlobalForm and populated it in GlobalEntryAction.

J2EE Development Perspective -> Package Explorer -> J11_UT_D~mitc1~ut~common~mit.edu

  1. Right Click
  2. Development Component -> Build

If no errors:

  1. Development Configuration Perspective
  2. Highlight UT_DEV – takes a very long time the first time & Check-in
  3. Click on Transport View (button on the bottom frame labeled "Open Activities" after check-in)
  4. Drill down to activity that you just checked in – find it under "Waiting"
  5. Right Click -> Release
  6. Send email requesting that the activity be transported to consolidation
  7. Once it is in consolidation follow instructions to remove and re-import UT track
  8. J2EE Development Perspective -> J2EE DC Explorer -> J11_MM_D~MITC1~MM~PO~WEB~MIT.EDU
    1. DC Meta Data -> DC Definitions -> Used DCs -> mitc1/ut/common (commonCompilation) ->Right Click -> Remove Used DC
    2. Used DC -> Right Click -> Add Used DC…
      1. Try inactive but if no UT track switch back to active
      2. MM_dev -> mit.edu_UT_1 -> mitc1/ut/common -> DC MetaData -> Public Parts -> commonCompilation -> Finish (button at bottom)
  9. J2EE Development Perspective -> J2EE DC Explorer -> J11_MM_D~MITC1~MM~PO~EAR~MIT.EDU
    1. DC Meta Data -> DC Definitions -> Used DCs -> mitc1/ut/common (commonAssembly) ->Right Click -> Remove Used DC
    2. Used DC -> Right Click -> Add Used DC…
      1. Try inactive but if no UT track switch back to active
      2. MM_dev -> mit.edu_UT_1 -> mitc1/ut/common -> DC MetaData -> Public Parts -> commonAssembly -> Finish (button at bottom)
  10. Rebuild application and test

Displaying Error Messages on Web Page

1) If your application uses the logic in IDDAction to display
messages on the screen, there must be at least one entry in the
ApplicationResources.properties file. This file can be found in the
web tier under WEB-INF under classes. For example:

J11_EHS_D~mitc1~ehs~injury~web~mit.edu
WEB-INF -> classes -> ApplicationResources.properties

The required entry is message.trackName.message=Message: {0}

For example:

message.injury.message=Message: {0}

Without this entry nothing will be printed on the web page. Other
entries can appear in this file that will intercept the message from
either the back-end or the actions and replace it with a better
message. Check out this file in the MM/PO track for examples.

2) The second problem I encountered was due to the fact that the
exceptions that were thrown did not have an accompanying message. For
example:

throw new SystemException();

When I changed this to the following a very detailed error message
appeared on the screen:

throw new SystemException(EhsConstants.FAILED_JCO_CONNECTION +
this.getSapSystemId() + " Message returned was: " + e.getMessage());

This code returns the following overly detailed error message to the
web page:

System exception occurred:
edu.mit.mitc1.ut.common.exceptions.SystemException: JCO.Client could
not establish connection to SAP system SF2 String returned was:
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect
to message server host failed Connect_PM TYPE=B MSHOST=maple
GROUP=DEV_SAPWEB+ R3NAME=SF2 MSSERV=sapmsSF2 SNC_MODE=1 SNC_QOP=9
SNC_MYNAME="p:sap/larch.mit.edu@ATHENA.MIT.EDU"
SNC_PARTNERNAME="s:sap@maple.mit.edu" PCS=1 LOCATION CPIC (TCP/IP) on
local host with Unicode ERROR Group DEV_SAPWEB+ not found TIME Fri
Oct 6 11:01:00 2006 RELEASE 640 COMPONENT LG VERSION 5 RC -6 MODULE
lgxx_mt.c LINE 3498 DETAIL LgIGroup COUNTER 1

I'm going to change this code to read:

throw new SystemException(EhsConstants.FAILED_JCO_CONNECTION +
this.getSapSystemId() + " (See log for details.)");

I've encountered a third problem that I can't resolve. It looks like
we are not capturing all possible exceptions so some will continue to
be eaten by our EJB services and spit out the following:

Exception occurred:
com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in
method initInjuryReport.

I've given up attempting to resolve this. When it is encountered I
will just check the logs for more detailed information. It does
appear that the logs in the UT track are complete.

No comments:

Blog Archive