JMeter, IDoc, XML & SAP

It can be useful for load testing / Performance testing in scenarios where we have to create multiple IDocs for test. API’s can also be tested through JMeter.

JMeter can be downloaded from here.

Open JMeter → Right click on Test Plan → Add → Threads(Users) → Thread Group

Enter the thread name → Continue → Enter number of threads, Ramp up period & Loop count. Here Number of threads is 10 and Loop count is 1, so while execution it will create 10 * 1 = 10 IDocs (10 calls to SAP System).

Add URL → Right click on Thread → Add → Sampler → HTTP Request

Enter Protocol → Server name (you can get it from Basis) → Enter Port → Select checkboxes → in Body Data tab Enter payload. Click here to get the details about preparing Payload.

In each call DOCNUM and PO should be unique, so declare it as variable as displayed below

Right click on HTTP Request → Add → Pre Processors → BeanShell PreProcessor

Enter below script

import org.apache.commons.codec.binary.Base64;
byte[] encodedUsernamePassword = Base64.encodeBase64("yoursapid:yoursappassword".getBytes());
vars.put("base64HeaderValue",new String(encodedUsernamePassword));

Add HTTP Header Manager

Click on Add → Enter Name: Authorization and Value: Basic ${base64HeaderValue}

Now need to add two random variables, one for Docnum and another for PO Number.

Variable: poNumber

Variable: docNumber

Add ‘View Results Tree’ & ‘Aggregate Report’ to check the result

To execute → Select the Thread → Click on green button

After execution → 10 responses for 10 Threads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s