You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "Stefan Schnell" is male
  • "Stefan Schnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

1

Wednesday, April 15th 2009, 7:23am

How to connect SAP with Jabaco via JCo (Java Connector)

Hello community,
here is a small code snippet to connect SAP. It is necessary to load and install the JCo first. You can download JCo from http://service.sap.com/connectors. You need a registration in the SAP marketplace. Now, at first the class:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'-Begin Class myDestinationDataProvider---------------------------------
  Implements DestinationDataProvider
  
  '-Variables-----------------------------------------------------------
    Private eL As DestinationDataEventListener
    Private ABAP_AS_Prop As Properties
  
  '---------------------------------------------------------------------
    Private Sub Class_Initialize()
      Set ABAP_AS_Prop = New Properties
    End Sub    
  
  '---------------------------------------------------------------------
    Public Function getDestinationProperties(destName As String) As _
      Properties
      If (destName = "ABAP_AS") And (ABAP_AS_Prop <> Null) Then
        getDestinationProperties = ABAP_AS_Prop
      Else
        getDestinationProperties = Null
      End If
    End Function  
  '---------------------------------------------------------------------
    Public Sub setDestinationDataEventListener(EventListener As _
      DestinationDataEventListener)
      eL = EventListener
    End Sub  
  '---------------------------------------------------------------------
    Public Function supportsEvents() As Boolean
      supportsEvents = True
    End Function  
  '---------------------------------------------------------------------
    Public Sub ChangePropertiesForABAPAS(Prop As Properties)
      If Prop = Null Then
        eL.deleted("ABAP_AS")
        ABAP_AS_Prop = Null
      Else
        If (ABAP_AS_Prop <> Null) And (ABAP_AS_Prop <> Prop) Then
          eL.updated("ABAP_AS")
          ABAP_AS_Prop = Prop
        End If
      End If
    End Sub  
'-End-------------------------------------------------------------------

Now the module to connect the SAP system:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Public Sub CallSAP()
   Dim propConn As Properties
   Set propConn = New Properties
   
   Dim destDataProv As DestinationDataProvider
   
   propConn.setProperty(destDataProv.JCO_ASHOST, "10.100.200.100")
   propConn.setProperty(destDataProv.JCO_SYSNR, "99")
   propConn.setProperty(destDataProv.JCO_CLIENT, "999")
   propConn.setProperty(destDataProv.JCO_USER, "bambi")
   propConn.setProperty(destDataProv.JCO_PASSWD, "hugo")
   propConn.setProperty(destDataProv.JCO_LANG, "DE")
   
   Static myDestDataProv As New myDestinationDataProvider
   Set myDestDataProv = New myDestinationDataProvider
   com#sap#conn#jco#ext#Environment.registerDestinationDataProvider(myDestDataProv)
   myDestDataProv.ChangePropertiesForABAPAS(propConn)
   
   Dim dest As com#sap#conn#jco#JCoDestination
   Set dest = com#sap#conn#jco#JCoDestinationManager.getDestination("ABAP_AS")
   'dest.ping()
   
   Form1.Outputbox.appendText dest.getAttributes().toString()

   com#sap#conn#jco#ext#Environment.unregisterDestinationDataProvider(myDestDataProv)
   propConn.clear()

End Sub

I call it from a form called Form1 with a button and a richtextbox. The button proceed CallSAP and in the last line of this Sub you get the result.
Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

This post has been edited 2 times, last edit by "StefanSchnell" (Oct 5th 2010, 9:47am)


  • "Stefan Schnell" is male
  • "Stefan Schnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

2

Wednesday, April 15th 2009, 7:44pm

How to read tables from SAP via RFC_READ_TABLE

Hello community,
here is the next step, a snippet to read tables from SAP

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'-Read tables with RFC_READ_TABLE-----------------------------------------
   
   Dim i, j As Integer
  '-Get repository instance-----------------------------------------------
    Dim repos As JCoRepository
    Set repos = dest.getRepository()
  
  '-Define function------------------------------------------------------- 
    Dim func As JCoFunction
    Set func = repos.getFunction("RFC_READ_TABLE")
   
  '-Set arguments for function--------------------------------------------
    func.getImportParameterList().setValue("QUERY_TABLE", "SFLIGHT")
    func.getImportParameterList().setValue("DELIMITER", "~")
   
  '-Execute function------------------------------------------------------
    com#sap#conn#jco#JCoContext.begin(dest)
      func.execute(dest)
    com#sap#conn#jco#JCoContext.end(dest)
   
  '-Get field names-------------------------------------------------------
    Dim fields As JCoTable
    Set fields = func.getTableParameterList().getTable("FIELDS")
   
    Dim fcnt As Integer
    fcnt = fields.getNumRows() - 1
   
    '-Set field names as header in the grid-------------------------------
      For i = 0 To fcnt
        fields.setRow(i)
        Form1.Grid.Header(i) = fields.getString("FIELDNAME")
        Form1.Grid.Refresh
      Next
   
  '-Get table content-----------------------------------------------------
    Dim table As JCoTable
    Set table = func.getTableParameterList().getTable("DATA")
   
    Dim cnt As Integer
    cnt = table.getNumRows()
   
    Dim felder(0 To fcnt) As String
    '-Set table in the grid-----------------------------------------------
      For i = 0 To cnt - 1
        table.setRow(i)
        felder = table.getString("WA").split("~")   
        For j = 0 To fcnt - 1
          Form1.Grid.TextMatrix(i, j) = felder(j)
        Next
      Next

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

This post has been edited 2 times, last edit by "Stefan_Schnell" (Apr 19th 2009, 10:37am)


  • "Stefan_Schnell" is male
  • "Stefan_Schnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

3

Sunday, April 19th 2009, 11:02am

Explanation note how to use SAP with Jabaco

With this explanation note I want to create a relation between the SAP system and the Jabaco code:

  • At first start the SAP logon pad.



  • Select the system where you want to connect to and push the button "Eintrag ändern..." ("Change entry..."). It open a dialog where you see necessary informations for the connection object. Look at the fields "Anwendungsserver" ("Application server") and "Systemnummer" ("System number").



  • Login to system and on the login screen you see the next informations you need "Client" ("Mandant"), "User" ("Benutzer"), "Password" ("Kennwort") and "Language" ("Sprache").


  • Now you can build your connection object:

    Jabaco Source

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    Dim propConn As Properties
      Set propConn = New Properties
    
      '-Application server (Anwendungsserver)-------------------------------
        propConn.setProperty(destDataProv.JCO_ASHOST, "localhost")
      '-System number (Systemnummer)----------------------------------------  
        propConn.setProperty(destDataProv.JCO_SYSNR, "00")
      '-Client (Mandant)----------------------------------------------------  
        propConn.setProperty(destDataProv.JCO_CLIENT, "000")
      '-User (Benutzer)-----------------------------------------------------
        propConn.setProperty(destDataProv.JCO_USER, "bambi")
      '-Password (Kennwort)-------------------------------------------------  
        propConn.setProperty(destDataProv.JCO_PASSWD, "hugo")
      '-Language (Sprache)--------------------------------------------------  
        propConn.setProperty(destDataProv.JCO_LANG, "DE")


  • So you can connect the SAP system and call the functions you want. Let us look at the function module RFC_READ_TABLE. Call transaction SE80 and push "Repository Information System". Choose function modules and type the name of the module "RFC_READ_TABLE" in the corresponding field.

  • After you open the function module you see the description of the module. You need the "Importing" to call the module and the "Tables" to get the results.



    Now you can call the module (Importing):

    Jabaco Source

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    '-Define function----------------------------------------------------- 
        Dim func As JCoFunction
        Set func = repos.getFunction("RFC_READ_TABLE")
       
      '-Set arguments for function------------------------------------------
        func.getImportParameterList().setValue("QUERY_TABLE", "SFLIGHT")
        func.getImportParameterList().setValue("DELIMITER", "~")
       
      '-Execute function----------------------------------------------------
        com#sap#conn#jco#JCoContext.begin(dest)
          func.execute(dest)
        com#sap#conn#jco#JCoContext.end(dest)


    And get the results and put it in the Jabaco grid (Tables):

    Jabaco Source

    1
    2
    3
    4
    5
    6
    7
    
    '-Get field names-----------------------------------------------------
        Dim fields As JCoTable
        Set fields = func.getTableParameterList().getTable("FIELDS")
    
      '-Get table content---------------------------------------------------
        Dim table As JCoTable
        Set table = func.getTableParameterList().getTable("DATA")

  • In the example I use the table "SFLIGHT", the SAP standard instruction example. Here you see the result table on the Jabaco Form in the JBGrid.



Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

4

Friday, April 24th 2009, 7:51pm

Mor information about SAP and JCo

Hello community,
you find a lot of information about SAP on the help portal. Special informations about the JCo you find here. You find a lot about JCo functions, client programming etc. It is a part of the SAP NetWeaver Library.
Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

5

Sunday, August 23rd 2009, 11:39am

A small ABAP debug example

Hello community,
ABAP stores the break points of his debugger in the tables

  • ABDBG_BPS = Table with all BPs
  • ABDBF_INFO = Table with the validities of the BPs
  • ICFATTRIB = Description of attributes for trace and debugging

The following source read this tables and give the information in three grids back. It is a monitor for all BP in a SAP system.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'-Begin------------------------------------------------------------------

  '-CallSAP--------------------------------------------------------------
    Private Function CallSAP() As com#sap#conn#jco#JCoDestination
      Dim propConn As Properties
      Set propConn = New Properties
   
      Dim destDataProv As DestinationDataProvider
   
      propConn.setProperty(destDataProv.JCO_ASHOST, "10.100.100.100")
      propConn.setProperty(destDataProv.JCO_SYSNR, "99")
      propConn.setProperty(destDataProv.JCO_CLIENT, "099")
      propConn.setProperty(destDataProv.JCO_USER, "hugo")
      propConn.setProperty(destDataProv.JCO_PASSWD, "bambi")
      propConn.setProperty(destDataProv.JCO_LANG, "DE")
   
      Static myDestDataProv As New myDestinationDataProvider
      Set myDestDataProv = New myDestinationDataProvider
      com#sap#conn#jco#ext#Environment.registerDestinationDataProvider(myDestDataProv)
      myDestDataProv.ChangePropertiesForABAPAS(propConn)
   
      CallSAP = com#sap#conn#jco#JCoDestinationManager.getDestination("ABAP_AS")
    End Function

  '-DeRegister------------------------------------------------------------
    Private Sub DeRegister(DestDataProv As DestinationDataProvider, ByRef propConn As Properties)
      com#sap#conn#jco#ext#Environment.unregisterDestinationDataProvider(DestDataProv)
      propConn.clear()
    End Sub

  '-outGrid---------------------------------------------------------------
    Private Sub outGrid(GridName As JBGrid, JFunc As JCoFunction)
      Dim fields As JCoTable
      Dim table As JCoTable
      Dim fcnt As Integer
      Dim cnt As Integer
      '-Get field names---------------------------------------------------
        Set fields = JFunc.getTableParameterList().getTable("FIELDS")
   
      fcnt = fields.getNumRows() - 1
   
      '-Set field names as header in the grid-----------------------------
        For i = 0 To fcnt
          fields.setRow(i)
          GridName.Header(i) = fields.getString("FIELDNAME")
        Next
        GridName.Refresh
      '-Get table content-------------------------------------------------
        Set table = JFunc.getTableParameterList().getTable("DATA")
   
      cnt = table.getNumRows()
   
      Dim felder(0 To fcnt) As String
      '-Set table in the grid---------------------------------------------
        For i = 0 To cnt - 1
          table.setRow(i)
          felder = table.getString("WA").split("~")   
          For j = 0 To fcnt - 1
            GridName.TextMatrix(i, j) = felder(j)
          Next
        Next
        GridName.Refresh
      
      table.clear()
      fields.clear()  
    End Sub

  '-getDebug_Click--------------------------------------------------------
    Public Sub getDebug_Click()
   
      Dim i, j As Integer
      Dim dest As com#sap#conn#jco#JCoDestination
      Dim fields As JCoTable
      Dim func As JCoFunction
      Dim repos As JCoRepository
      '-Read tables with RFC_READ_TABLE-----------------------------------
        Set dest = CallSAP()
      '-Get repository instance-------------------------------------------
        Set repos = dest.getRepository()
      '-Define function---------------------------------------------------
        Set func = repos.getFunction("Z_RFC_READ_TABLE")
   
      '-Set arguments for function----------------------------------------
        func.getImportParameterList().setValue("DELIMITER", "~")
   
      '-Execute function--------------------------------------------------
        com#sap#conn#jco#JCoContext.begin(dest)
          '-Read table ABDBG_INFO-----------------------------------------
            func.getImportParameterList().setValue("QUERY_TABLE", "ABDBG_INFO")
            func.execute(dest)
            outGrid(GridABDBGInfo, func)
          '-Read table ABDBG_BPS------------------------------------------
            func.getImportParameterList().setValue("QUERY_TABLE", "ABDBG_BPS")
            func.execute(dest)
            outGrid(GridABDBGBPS, func)
      
          '-Read table ICFATTRIB------------------------------------------
            Set fields = func.getTableParameterList().getTable("FIELDS")
            fields.appendRow()
            fields.setValue("FIELDNAME", "USERNAME")
            fields.appendRow()
            fields.setValue("FIELDNAME", "SERVER")
            fields.appendRow()
            fields.setValue("FIELDNAME", "CHOST")
            fields.appendRow()
            fields.setValue("FIELDNAME", "DEBUGID")
          func.getImportParameterList().setValue("QUERY_TABLE", "ICFATTRIB")
          func.execute(dest)
          outGrid(GridICFATTRIB, func)
        com#sap#conn#jco#JCoContext.end(dest)
   
    End Sub
'-End--------------------------------------------------------------------


But before you use this source it is absolut necessary to copy the function module RFC_READ_TABLE to your own namespace and change the name to Z_RFC_READ_TABLE. Now change the following coding block, save it and do not forget to activate:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
old code:-->
   data: begin of work, buffer(30000), end of work.
   field-symbols: <wa> type any, <comp> type any.
   assign work to <wa> casting type (query_table).
   if rowcount > 0.
     rowcount = rowcount + rowskips.
   endif.

New Code :-->
  data: dref type ref to data.           
  field-symbols: <wa> type any, <comp> type any.
  create data dref type (query_table).  
  assign dref->* to <wa>.  


Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

This post has been edited 3 times, last edit by "StefanSchnell" (Oct 5th 2010, 9:59am)


  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

6

Sunday, August 23rd 2009, 11:46am

An addition

Hello community,

before I forget it, look at the OSS note 382318, it describes a problem occurs in function module RFC_READ_TABLE and the simple solution, do not use function module RFC_READ_TABLE.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

7

Tuesday, September 1st 2009, 12:01am

A realization of the debug example in Java

Hello community,

you find a full realization of of the debug example above in Java here. I create this solution, because I get so many requests for an excutable example in Java from users around the world. Hope you enjoy it. :D

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

8

Thursday, July 5th 2012, 7:57am

Jabaco source with JCo on Linux

Hello community,

it is long time ago after my last post on this thread - but it losts nothing of its relevance.
The source codes works with the actual version of JCo and Java 7 perfect.
You can very easy create executable Java archive files (JAR) with Jabaco. So it is possible to run it in a Linux environment. Linux is one of the most used platforms in business and professional environment. So you can create server applications for SAP environments -Jabaco offer an excellent basis for it.

Here is an impression of the first example with Puppy Linux.



Copy the JAR file, sapjco3.jar and libspjco3.so in the same directory, that is all. It is not necessary to edit the LIB path.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

Rate this thread
WoltLab Burning Board