Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@js1972
js1972 / write_file.groovy
Created May 16, 2014 07:42
How to write content to a new file (overwrite if already existing) in Groovy.
//
// Write the mock request payload to a file for checking later...
// newWrite() is the important it to ensure you get a *new* file each time.
//
def filename = "C:\\MyScratchFolder\\soapUI projects\\Testing\\procon\\mock_po_activity_request.xml"
def file = new File(filename)
def w = file.newWriter()
w << mockRequest.requestContent
w.close()
@js1972
js1972 / basic_auth_check.groovy
Created May 1, 2014 08:41
Basic Auth check in groovy for SoapUI. When using a SOAP Mock in SoapUI there is no standard way to check the authentication provided by the caller. This script can be added to your mock in the "OnRequest Script" section and allows you to check for the correct credentials. If you test this from SoapUI as well then you need to set the Authenticat…
import com.eviware.soapui.support.types.StringToStringsMap
def authSucceeded = false
// get the request headers
StringToStringsMap headers = mockRequest.getRequestHeaders()
headers.each {
if (it.key.equals("Authorization")) {
String content = it.value
String[] contentArray = content.split()
@js1972
js1972 / zcl_advance_shipg_notice_maint - Class Relevant Local Types.abap
Created May 12, 2014 02:57
Example ABAP class with local classes and test cases showing the use of test doubles, etc.
*"* use this source file for any type of declarations (class
*"* definitions, interfaces or type declarations) you need for
*"* components in the private section
types:
begin of event_rec,
evt_name type string,
sort_order type i,
end of event_rec.
@js1972
js1972 / local_storage_model.js
Created June 20, 2017 04:41
SAPUI5 Local Storage Model
sap.ui.define([
"sap/ui/model/json/JSONModel",
"jquery.sap.storage"
], function(JSONModel, jQuery) {
"use strict";
return JSONModel.extend("sap.ui.demo.cart.model.CartModel", {
_STORAGE_KEY : "LOCALSTORAGE_MODEL",
_storage : jQuery.sap.storage(jQuery.sap.storage.Type.local),
@js1972
js1972 / abap_brf_plus.abap
Created August 18, 2014 02:35
ABAP program to execute a BRF+ Function. In production code SAP recommends using program fdt_template_function_process to generate the required ABAP code. This gist is for testing...
report y_brfplus_function_test.
data: lo_admin_data type ref to if_fdt_admin_data,
lo_function type ref to if_fdt_function,
lo_context type ref to if_fdt_context,
lo_result type ref to if_fdt_result,
"lx_fdt type ref to cx_fdt,
result type abap_bool,
event_code type string.
@js1972
js1972 / abap_cds_ddl.abap
Created October 13, 2014 01:39
ABAP CDS Views. As of ABAP 7.40 sp5 we can create and use CDS view in ABAP. From ADT you can create a CDS view via menu New -> Other Repository Object -> Dictionary -> CDS View. See these blogs for some futher info: http://scn.sap.com/community/abap/eclipse/blog/2014/02/04/new-data-modeling-features-in-abap-for-hana (sp5) http://scn.sap.com/comm…
@AbapCatalog.sqlViewName: 'ZPURITEMS'
define view PurchaseOrderItem
as select from ekko inner join ekpo on ekko.ebeln = ekpo.ebeln {
key ekko.ebeln as id,
key ebelp as item_no,
lifnr as vendor,
ernam as created_by,
ekko.aedat as created_on,
txz01 as text,
@js1972
js1972 / new_abap_740.abap
Created October 1, 2014 06:12
Some new ABAP 7.40 example code
report y_test_abap_740.
interface lif_test.
methods:
print
importing msg type string.
endinterface.
class lcl_test definition.
public section.
@js1972
js1972 / pi_java_udf_asma.java
Created July 29, 2014 02:52
How to set a Dynamic Configuration attribute (asma) in a mapping UDF function. This sample sets two attributes. The second one is for dynamically setting the soap-action attribute on the receiver SOAP adapter. [For the receiver SOAP channel - in the Advanced tab: set Use Adapter-specific Message Properties as well as Transport Binding. Also spec…
@LibraryMethod(title="", description="", category="User-Defined", type=ExecutionType.SINGLE_VALUE)
public String setASMA (
@Argument(title="setASMA") String s,
Container container) throws StreamTransformationException{
DynamicConfiguration dc = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey dck = DynamicConfigurationKey.create("urn_asma_test", "Z_ASMA");
dc.put(dck, "ASMA ASMA ASMA Oi Oi Oi");
@js1972
js1972 / abap_log.abap
Last active May 20, 2021 14:54
Example ABAP code using the IF_RECA_MESSAGE_LIST interface for application log logging. Note there needs to be a commit somewhere after the store() call.
" Create MDG change pointers if email or street2 have changed
try.
data(mdg_cp) = value mdg_cp_s_cp( object_key = vendor ).
"Create a MDG Change Pointer so Vendor can be replicated later via DRF (TCODE DRFOUT)
call method cl_mdg_change_pointer=>create_cp
exporting
iv_business_object = 'ZM_VENDOR'
is_change_pointer = mdg_cp.
@js1972
js1972 / abap_json.abap
Created September 25, 2014 05:16
Example ABAP code using sql host variables (@) which is the standard as of 7.40 and showing the SAP standard way to do JSON conversion.
report y_test_json_output.
DATA purchaseorders TYPE STANDARD TABLE OF ekko.
SELECT * FROM ekko
INTO TABLE @purchaseorders
where bukrs = '2000'
and ernam = 'JSCOTT'.
DATA(lo_json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).