Sei sulla pagina 1di 13

7th JUNE SAP TO Internet Communications

SAP systems to NON SAP System Communications

1. SAP to Internet ( SAP Netweaver ).

2. SAP to NON SAP.

9th JUNE Web To SAP Communication

HTML : Hyper Text Markup Language.

Hyper : Communication between pages.


Text : Using Text data communications can be established
Markup: Applying styles (Bold,Italic,Under line , font size etc).

HTML is the programming language for Web page designing.

HTML is a collection of tags.

<HTML>
<HEAD>
<TITLE> Welcome to Web Programming </title>
</HEAD>
<BODY>
WEB APPLICATION PROGRAMMING
<INPUT TYPE="TEXT" NAME="A" SIZE="10">
</BODY>
</HTML>

<HTML> </HTML> : represents web browser


<HEAD> </HEAD> : represents Header area of Browser
<BODY> </BODY> : represents application area of browser
<INPUT TYPE="TEXT"> used to Generate Input Fields
<INPUT TYPE="SUBMIT"> used to Generate a pushbutton on Browser for sending the
data from current page to destination page with help of FORM tag.
<FORM> </FORM> is used to specify Destination URL page where data of current page
to be submited. This tag redirects the data when ever action is perfrmed on SUBMIT
button.
<H1> </H1> .. <H6> </H6> ARE THE TAGS USED IN HTML to Generate Header data.
<TABLE> </TABLE> IS THE TAG TO MAKE DATA UNDER TABULAR FORMAT.
<TR> </TR> Represents a table row.
<TD> </TD> Represents a table data ( column).
Example Code.
<HTML>
<HEAD>
<TITLE> Welcome to Web Programming </title>
</HEAD>
<BODY>
<CENTER>
<H2> Vendor Master data </h2>
<form action="http://class:7001/examplesWebApp/DEST1.JSP">
<TABLE>
<TR>
<TD>Vendor Number </TD>
<TD>
<input type="text" name="lifnr" size="10"> </TD>
</TR>
<TR>
<TD>
Vendor Name </TD>
<TD> <input type="text" name="NAME1" size="35"> </TD>
</TR>
<TR>
<TD>Vendor Country </TD>
<TD>
<input type="text" name="land1" size="3"> </TD>
</TR>
<TR>
<TD>Vendor City </TD>
<TD>
<input type="text" name="ort01" size="25"> </TD>
</TR>
<TR>
<TD></TD>
<TD>
<input type="submit"> </TD>
</TR>
</TABLE>
</form>
</CENTEr>
</BODY>
</HTML>

* JSP CODE TO COLLECT THE DATA FROM HTML PAGES.


<%
String v1 = request.getParameter("lifnr");
String v2 = request.getParameter("NAME1");
String v3 = request.getParameter("land1");
String v4 = request.getParameter("ort01");
out.println("LIFNR value is " + v1 +"<br>");
out.println("NAME1 value is " + v2 +"<br>" );
out.println("LAND1 value is " + v3 +"<br>");
out.println("ORT01 value is " + v4 );
%>

* SAVE HTML files / JSP files in Weblogic server under


"C:\bea\weblogic81\samples\server\examples\build\examplesWebApp" path.

* start Weblogic Server using Following path


start menu -> program files -> bea weblogic 8.1 -> examples -> Weblogic Server
Examples -> Launch Weblogic Server example -> Starts The services and Opens the
Browser Automatically.

* Execute the Copied HTML Application using


"http://class:7001/examplesWebApp/demo.html"

Path we use in Borower to execute the application is called as "URL".

Base java code

import com.sap.mw.jco.*;
public class Example1 {
public static void main(String[] argv)
{
JCO.Client client = null;

try {
System.out.println("\n\nVersion of the JCO-library:\n" +
"---------------------------\n" + JCO.getMiddlewareVersion());

client = JCO.createClient( "000", // SAP client


"johndoe", // userid
"*****", // password
"EN", // language
"appserver", // host name
"00" ); // system number client.connect();

// Get the attributes of the connection and print them

JCO.Attributes attributes = client.getAttributes();


System.out.println("Connection attributes:\n" +
"----------------------\n" + attributes);
boolean is_backend_unicode = attributes.getPartnerCodepage().equals("4102") ||
attributes.getPartnerCodepage().equals("4103");

// Create metadata definition of the input parameter list


JCO.MetaData input_md = new JCO.MetaData("INPUT");
input_md.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255, 255 *
(is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);

// Create the input parameter list from the metadata object


JCO.ParameterList input = JCO.createParameterList(input_md);

// Set the first (and only) input parameter


input.setValue("This is my first JCo example.", "REQUTEXT");

// Create metadata definition of the output parameter list


JCO.MetaData output_md = new JCO.MetaData("OUTPUT");

// Specify the parameters types of the function will be returned


output_md.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255, 255 *
(is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
output_md.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255, 255 *
(is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);

// Create the output parameter list from the metadata object


JCO.ParameterList output = JCO.createParameterList(output_md);

// Call the function


client.execute("STFC_CONNECTION", input, output);

// Print the result


System.out.println("The function 'STFC_CONNECTION' returned the following
parameters:\n" +
"-----------------------------------------------------------------");
for (int i = 0; i < output.getFieldCount(); i++) {
System.out.println("Name: " + output.getName(i) + " Value: " +
output.getString(i));
}//for

// All done
System.out.println("\n\nCongratulations! It worked.");
}
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
}
finally {
// do not forget to close the client connection
if (client != null) client.disconnect();
}
}
}

web communication with SAP

JCO.Client : Is the class used to establish the connection between Java systems with
SAP systems.

Note : java / vb / non sap systems can't use any query to communicate with SAP systems.
Only FunctionModules of SAP can be accessed by Non SAP Systems.

JCO.MetaData : Is the class used in JSP to Set Required Data type for the Function
Module to be sent as arguments.

JCO.MetaData input_md = new JCO.MetaData("INPUT");


input_md.addInfo("LIFNR", JCO.TYPE_CHAR, 10, 255 * 2,
-1, 0, null, null, 0, null, null);
input_md.addInfo("LAND1", JCO.TYPE_CHAR, 3, 255 * 2,
-1, 0, null, null, 0, null, null);
input_md.addInfo("NAME1", JCO.TYPE_CHAR, 35, 255 * 2,
-1, 0, null, null, 0, null, null);
input_md.addInfo("ORT01", JCO.TYPE_CHAR, 25, 255 * 2,
-1, 0, null, null, 0, null, null);

* JCO.ParameterList : Is the class used in JSP


to values to the arguments added by metadata
fields.

JCO.ParameterList input = JCO.createParameterList(input_md);


input.setValue("demov1", "LIFNR");
input.setValue("in", "LAND1");
input.setValue("NAME VENDOR", "NAME1");
input.setValue("HYDERABAD", "ORT01");

JCO.MetaData output_md = new JCO.MetaData("OUTPUT");


input_md.addInfo("RET", JCO.TYPE_CHAR, 255, 255 * 2,
-1, 0, null, null, 0, null, null);
JCO.ParameterList output = JCO.createParameterList(output_md);

client.execute("ZVENJSP", input, output);

for (int i = 0; i < output.getFieldCount(); i++) {


String s1 = output.getString(i);
s1 = s1.trim();
if( s1.equals("INSERTED"))
{
out.println("Record is inserted in SAP data base");
}
else
{
out.println("Record is already existing in SAP Data base");
}
}

10th JUNE JSP TO SAP Communications

JSP TO SAP COMMUNICATIONS.


* Required JCO( Java Connectors ) Software.
* This JCO should be configured with Operating System using
Copy Following 4 dll files from JCO folder into "C:\Winnt\System32"
1) librfc32.dll
2) sapjcorfc.dll
3) msvcp71.dll
4) msvcr71.dll

* Configuring SAP JCO with Weblogic Server. To do this copy "sapjco.jar" into
following paths.

1) C:\bea\weblogic81\samples\server\examples\build\clientclasses\sapjco.jar
2) C:\bea\weblogic81\samples\server\examples\build\examplesWebApp\WEB-
INF\lib\sapjco.jar

JCO.Client : Is one of the class used in JSP to connect with SAP Systems.
This class is defined under a package called as "com.sap.mw.jco.*". By default JSP
applications can't use above package classes, So Internally JSP Says Syntax Errors. To
avoid the Syntax errors import the classes into JSP using Following Syntax.

<%@ page import="com.sap.mw.jco.*" %>


<%

%>

12Th WEB Reporting Code

Demo example code for web reporting from SAP to JSP.


1) FM code.
FUNCTION ZITMSALE.
*"*"Local interface:
*" EXPORTING
*" VALUE(RET) TYPE STRING
DATA : BEGIN OF WA,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
ERNAM LIKE VBAK-ERNAM,
KUNNR LIKE VBAK-KUNNR,
MATNR LIKE VBAP-MATNR,
WERKS LIKE VBAP-WERKS,
LGORT LIKE VBAP-LGORT,
END OF WA.
DATA : STR(255).
SELECT V~VBELN V~ERDAT V~ERNAM V~KUNNR P~MATNR P~WERKS
P~LGORT INTO WA
FROM VBAK AS V LEFT OUTER JOIN VBAP AS P ON V~VBELN = P~VBELN UP
TO 20
ROWS.
CONCATENATE WA-VBELN WA-ERDAT WA-ERNAM WA-KUNNR WA-MATNR
WA-WERKS
WA-LGORT INTO STR SEPARATED BY ','.
CONCATENATE RET STR INTO RET SEPARATED BY ';'.
ENDSELECT.
ENDFUNCTION.
2) JSp code.
<%@ page import="com.sap.mw.jco.*,java.util.*" %>
<center> <h2> Material Sales Info </h2>
<%
JCO.Client client = null;
try
{
client = JCO.createClient("800","sapuser","oracle","EN","192.8.8.3","00");
client.connect();
JCO.MetaData input_md = new JCO.MetaData("INPUT");
JCO.ParameterList input = JCO.createParameterList(input_md);
JCO.MetaData output_md = new JCO.MetaData("OUTPUT");
output_md.addInfo("RET", JCO.TYPE_CHAR, 8255, 255 * 2 ,-1, 0, null, null, 0,
null, null);
JCO.ParameterList output = JCO.createParameterList(output_md);
client.execute("ZITMSALE", input, output);

for (int i = 0; i < output.getFieldCount(); i++) {


String rs = output.getString(i).toString();
StringTokenizer stz = new StringTokenizer(rs,";");
out.println("<table border=1>");
out.println("<tr>");
out.println("<th>VBELN</th>");
out.println("<th>ERDAT</th>");
out.println("<th>ERNAM</th>");
out.println("<th>KUNNR</th>");
out.println("<th>MATNR</th>");
out.println("<th>WERKS</th>");
out.println("<th>LGORT</th>");
out.println("</tr>");
while(stz.hasMoreElements())
{
out.println("<tr>");
String s2 = stz.nextElement().toString();
StringTokenizer stz1 = new StringTokenizer(s2,",");
while(stz1.hasMoreElements())
{
out.println("<td>"+stz1.nextElement()+"</td>");
}
out.println("</tr>");
}
out.println("</table>");
}
}catch(Exception e)
{
out.println("error due to " +e);
}
%>
</center>
12th JUNE Web Reporting

Web Reporting:
Data existing In SAP to be accessed by Web Applications for Reporting.

VBAK
VBELN
ERDAT
ERNAM
KUNNR
VBAP
VBELN
MATNR
WERKS ( Plant )
LGORT ( Storage Location)

Becaule of "ERM" ( Entity Relational Model) SAP is very Faster While Inserting or
Updating. But as the data is stored in Many table in EMP, causes delay while gerating
reports.

To avoid This delay of time for reporting We migrate the data from SAP R/3 into BW
system. AS bw Maintains the data in MDM ( Multi Dimensional Model) Reporting is
very very Faster.

; f1,f2,f3; f1,f2,f3; f1,f2,f3; f1,f2,f3; f1,f2,f3;


13th JUNE Lock Objects

Lock Objects
Naming convension is should start with "EZ/EY".
Exclusive lock
The locked data can be read or processed by one user only. A request for another
exclusive lock or for a shared lock is rejected.
Shared lock
Several users can read the same data at the same time, but as soon as a user edits the data,
a second user can no longer access this data. Requests for further shared locks are
accepted, even if they are issued by different users, but exclusive locks are rejected.
Exclusive but not cumulative lock
Exclusive locks can be requested by the same transaction more than once and handled
successively, but an exclusive but not cumulative lock can only be requested once by a
given transaction. All other lock requests are rejected.

Using this lock objects, SAP provides better Transaction services.

Navigations:

SE11 -> SELECT Object type as "Lock Objects" -> Name the Lock Object ( EZlock91 )
-> Click on Create -> Opens an interface -> Enter Short Text ( any ) -> Click on tables
tabbutton -> Name the table to be locked ( KNA1) -> Set the lock mode ( Exclusive/
Shared/Execlusive But not Cumulative) -> If required to add Secondary tables to be
locked which are related to Primary table , click on Add pushbutton from Secondary table
list -> opens the List of tables -> select any required table from the list -> click on
Continue -> Click on Lock parameters , by default all key fields of the tables are locked
by sap, if MANDT field is locked , only one client can use the table other client can't. If
Mandt field is deselected then Many client can access the table but under one client
locking concepts are applied -> Save the Object Under a package -> Activate.

Locking is by default applied only for specified transaction. As soon as transactions are
completed then Locks are released.

Application Administration , User Administration and Client Administration etc are under
BASIS module of SAP Administration.

13th JUNE BAPI Programming

* refer to "MSDN 2003 CD's" For More Number of Examples.


* or Refer to "773.chm" For SAP Examples
Example code for VB Applications to be connected to SAP.
Dim oBAPICtrl As Object
Dim oLogonCtrl As Object
Dim boBapiSercice As Object
Dim str As String
Private Sub Form_Load()
Set oBAPICtrl = CreateObject("SAP.BAPI.1")
Set oLogonCtrl = CreateObject("SAP.Logoncontrol.1")
Set oBAPICtrl.Connection = oLogonCtrl.NewConnection
oBAPICtrl.Connection.System = "00"
oBAPICtrl.Connection.Client = "800"
oBAPICtrl.Connection.User = "sapuser"
oBAPICtrl.Connection.Password = "oracle"
oBAPICtrl.Connection.Language = "en"
If oBAPICtrl.Connection.Logon(Form1.hWnd, False) = True Then
MsgBox "Vb Applications are connected to SAP Applicationserver"
Set boBapiService = oBAPICtrl.GetSAPObject("BapiService")
boBapiService.MessageGetDetail id:="ZMSG1130", _
Number:="3", _
Language:="EN", _
Textformat:="ASC", _
message:=str
MsgBox "message returned from SAP is : " & str
Else
MsgBox "Vb unable to connect with SAP"
End If
End Sub

14th JUNE Workflows

CA : WORKFLOW

Setting Business Rules for the Industry is called as Workflow.

Graphical Representation of Programming Flow is "Flow Chart"


Graphical Represenation of Business Flow is "Workflow"

"SWDB" is the code for Creating Workflows ( Workflow Builder ). This tool depends on
TASKs in SAP.

PFTC_INS : is another Tool used to Define task.


Task is the object defined in SAP assigned for an application to be assigned to the
workflows to Generate Relations Between Applications.

Use Following Navigations to Create Task.

PFTC_INS -> Select Object type as "standard task" -> Click on Create From Application
toolbar -> Opens another Interface -> Enter Abbrivation for task -> Name the task ( task
for Inquiry ) -> Specify work Item text ( SAPMV45A ) { name of the application to be
added to the task } -> Click on Description -> Click on Change Text Pushbutton -> Enter
description for task in SAP Script Editor -> come back -> Save the task ( If Prefix
number is missing for the client, data can't be saved. To rectify this problem HR Module
of SAP should be Configured ) -> come back.

* Navigations to create WorkFlows.


SWDB (Workflow builder) -> opens an interface -> Click on Continue from welcome
Screen -> Opens workflow Builder with Three tasks Basically as "Workflow Started" ,
Undefined task and "Workflow ended" -> To extend the Links Right Click on Undefined
task -> Create -> Double click on Undefined task , in the same way extend the undefined
task up to required task to be added under workflow -> For each Undefined task , add an
activity using -> Right Click on Undefined task -> Create -> Double click on Activity ->
Opens another Interface -> Name the task to be assigned for the activity -> Save the
Entries -> Using the same navigations add all activities for all undefined tasks -> Save
the workflow -> Activate the Workflow -> Click on execute to test workflow Created.

15th JUNE Project1

Project
1. Extracting ( Data Modeling ).
data maintained in Flat Files in three Formats

i) Entry format data


The File consisting of data in two Field Formats, Initial first 9 character are
belongs to First Field Data and data from 10th character onwards belong to Second field
data.
As ABAPer Extract Only the Data who as First Field starts with "IPR" as character.

ii) Pattern format data


The file consisting of Three Fields data , First Row in the file belogs to First Field
in table , Second row in the file belongs to Second Field in the table and data from third
row onwards should be populated into Third Field of table.

Where Pattern table first Field need to have a relation with Entry table of the First Field.
( Foreign key should be generated for first field in pattern table with primary key field
of Entry table ).

iii) Sequence Format data


This table Second field as "AC" is having a Foreign key with Third Field of Pattern
table.
This table is consisting of 31 fields, Where data in source file contains First Two
Character as field Name and data from 5th character onwards belongs Field data. As
ABAPer we need to read field data from the File which may be maintained in Single row
or Multiple Rows into Related fields of the sequence table.
While extracting the data IN CC field starts with -!- till the data ---------------- to be
ignored.
and also the line data who has "---------------" also to be ignored.
EACH RECORD IN THE FILE IS SEPARATED WITH "//"

SQ : Data is maintained in With Field Name as "SQ" and Continuation data with
BLANK field id.

2. Reporting.

reporting format should be as Interactive reports.


Initial report should display all test informations which are maintained in Entry table.
As we double click on First field in the report, cursor should go to second level report in
that display related record information from pattern table. The report should display all
three fields data.
As we double click on Third field cursor should to to next level report to display the
record information which are maintained in "Sequence" table.

Potrebbero piacerti anche