Skip to Content

Part I: Develop your first SAP Customer Checkout Plugin

In the first part of this five-part blog series we are going to develop our first SAP Customer Checkout plugin. We are going to learn how to setup our eclipse project, use the cco API and build our plugin. To deep dive into the development, there are some prerequisites:

  • Eclipse and Maven installed
  • some experience in Java
  • SAP Customer Checkout 2.0 FP06 PL02 (with B1 Integration) installed and configured

After you started your Eclipse, right click in the package explorer and we will create a new Maven Project. I’ll explain why we use maven later on.

Click Next in the „New Maven Project“-wizard until you reach the screen where we need to set the Group Id and the Artifact Id.

You can choose whatever namespace you want to use, just make sure it does not collide with any other java packages (e.g. use your surname in the namespace or your company). Click finish.

Eclipse will now create a structure for your plugin and also a pom.xml which will be used for external dependencies and also for the creation of the MANIFEST file. Open the pom.xml with a text editor (I strongly recommend using the Spring Web Flow XML Editor which is part of the Spring Tools Suite you install at the eclipse marketplace).

The pom.xml should look something like this.

We will make some changes to it. Within the <properties> Tag add the following new properties:

<sap.scco.pluginClass>com.be1eye.cco.blogpluginpart1.App</sap.scco.pluginClass>
<sap.scco.POSVersions>n/a, 2.0 FP06</sap.scco.POSVersions>

In the sap.scco.pluginClass enter your namespace (your groupId) followed by the pluginname (your artifactId) and followed by App which will be our main class Eclipse already created for us. In the second property sap.scco.POSVersion you can enter a list for all CCO Versions your plugin can is compatible to. In our case this is 2.0 FP06.

After that, we also need some instructions for maven, so that maven will build our plugin correctly. Just copy and paste this part right under the </dependencies> part.

 

<build>
  <resources>
    <resource>
      <directory>resources</directory>
    </resource>
  </resources>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <artifactSet>
              <excludes>
                <exclude>com.sap:scco:*</exclude>
              </excludes>
            </artifactSet>
            <filters>
              <filter>
                <artifact>*:*</artifact>
                <excludes>
                  <exclude>META-INF/*.SF</exclude>
                  <exclude>META-INF/*.DSA</exclude>
                  <exclude>META-INF/*.RSA</exclude>              
                </excludes>
            </filter>
           </filters>
           <transformers>
             <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
               <manifestEntries>
                 <PluginName>${project.name}</PluginName>
                 <CashdeskPOSPlugin>${sap.scco.pluginClass}</CashdeskPOSPlugin>
                 <CashDeskVersions>${sap.scco.POSVersions}</CashDeskVersions>
                 <Version>${project.version}</Version>
                 <Specification-Title>${project.name}</Specification-Title>
                 <Specification-Version>${project.artifact.selectedVersion.majorVersion}.${project.artifact.selectedVersion.minorVersion}</Specification-Version>
                 <Specification-Vendor> ${project.organization.name}</Specification-Vendor>
                 <Implementation-Title>${project.name}</Implementation-Title>
                 <Implementation-Version>${project.version}</Implementation-Version>
                 <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                 <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                 <Implementation-URL>${project.url}</Implementation-URL>
                </manifestEntries>
              </transformer>
            </transformers>
          </configuration>
        </execution>
      </executions>
     </plugin>
   </plugins>
</build>

Your pom.xml now should look something like this:

These are classes to test your code but writing tests for our plugin is not scope of this blog series so we get rid of them.

Now we are going to add the ENV.jar of our SAP Customer Checkout Installation. Right Click your plugin name -> Build Path -> Configure Build Path…

Go to the tab Libraries and click on Add External JARs. Navigate to your SAP Customer Checkout installation and add the ENV.jar to your build path.

Click on Apply and Close. Now open the App.java file in your project.

Remove the static main method and extend the BasePlugin Class from SAP Customer Checkout.

Make sure you add the import afterwards. Just hover your mouse over BasePlugin and add the import.

Now we have to implement some methods so that SAP Customer Checkout knows how our plugin is called and which version it is. Just add these unimplemented methods by hover with your mouse over App and click add unimplemented methods.

You will see, that Eclipse has added 3 Methods getId(), getName() and getVersion().

Change the return values according your pluginid, name and version.

Notice the return value of the getVersion(). It will always output the version you set in your pom.xml.

Now we just have to build our plugin, copy it into the SAP Customer Checkout installation and we’ll see our first plugin running.

Right Click on our plugin folder -> Run as -> Maven Build…

Give this build configuration a name, set the goal to package, skip tests, apply and run. You should see the maven output in the bottom of your eclipse windows. If everything went well, you should see a folder named target. In this folder you will see a jar file with your artifactId and your version.

When successfull you can start the build from now on from eclipse directly.

Sometimes the build is failing, so please right click on your project -> Maven -> Update Project… and

update your project. The next build will be successfull eventually.

Copy the plugin jar file into the following folder [SAP Customer Checkout Installation folder]/cco/POSPlugins/AP

To be able to debug our plugin later, we need to add some parameters to the run.bat. So open run.bat with your prefered editor and search for the following part and the marked lines:

The first line will open a socket everytime Customer Checkout starts. The second line prevents cco from closing your browser everytime you restart or close cco.

Start your SAP Customer Checkout, log in and click on the cogwheel to open the CCO Backend. In the tab Plug-Ins you will now see, that our plugin successfully connected to Customer Checkout. Congratulations you just developed your first SAP Customer Checkout Plugin!

In the next part of this series, we will learn how to store and read our own plugin properties, how to write to the SAP Customer Checkout log and many more. So stay tuned!

If you have any questions do not hesitate to contact me.

 

The source is also hosted on gitlab: https://gitlab.com/ccoplugins/blogpluginpart1

 

Part II

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply