Skip to content

Instantly share code, notes, and snippets.

View js1972's full-sized avatar

Jason Scott js1972

  • Perth, Australia
View GitHub Profile
@js1972
js1972 / types_testing.scala
Created September 16, 2014 07:27
Example of solving problems using Types (using shapeless 2). Won't compile in eclipse nor SBT!
package shapeless.stuff
import shapeless._
import nat._
import ops.nat._
import ops.hlist._
/**
* The goal is to determine whether a list of numbers is the appropriate length
* (nine) and has a valid checksum, which is calculated by taking the sum of
@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 ).
@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 / 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 / clear_text_on_cancel.abap
Created October 7, 2014 03:49
ABAP enhancements to function CATSXT_SIMPLE_TEXT_EDITOR so that the focus is initially set on the editor and that it appropriately returns no test on the cancel command.
function catsxt_simple_text_editor.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(IM_TITLE) TYPE SYTITLE
*" REFERENCE(IM_DISPLAY_MODE) TYPE XFELD DEFAULT SPACE
*" REFERENCE(IM_START_COLUMN) TYPE I DEFAULT 10
*" REFERENCE(IM_START_ROW) TYPE I DEFAULT 10
*" CHANGING
*" REFERENCE(CH_TEXT) TYPE CATSXT_LONGTEXT_ITAB
@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 / ppo_order_abap.abap
Created October 31, 2014 03:34
Create a PPO order for error management in ABAP.
report y_create_ppo_order.
"
" Sample program to create a PPO Order for error management.
"
" The PPO Component and Business Process is configured in SPRO
" under Cross Application Components -> General Application
" Functions -> Postprocessing Office.
"
" The OBJTPYE (ZJASON below) is what the PPO desktop (worklist)
@js1972
js1972 / ppo_order_enhancement_send_email.abap
Created November 4, 2014 08:02
Implementation of PPO order enhancement /SAPPO/CREATE_ORDER (SE18) to raise ALM alerts (and hence email notifications) when PPO orders are created.
*----------------------------------------------------------------------*
* CLASS ZCL_PPO_ORDER_ONCREATE DEFINITION
*----------------------------------------------------------------------*
* This BAdI implementation allows us to send a notification
* whenever a Post-Processing Office Order is created.
*
* Emails are sent via an ALM alert, the PPO worklist is used to
* determine who should receive the alert.
*
* PPO provides config to allow smartforms to be used but
@js1972
js1972 / test_speed_openui5.html
Created December 1, 2014 02:41
Test OpenUI5 load speed
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>test</title>
<script id="sap-ui-bootstrap"
xxxsrc="https://openui5.netweaver.ondemand.com/resources/sap-ui-core.js"
@js1972
js1972 / is_xml_view.js
Created December 1, 2014 06:39
Help functions to determine if a given control is an XML View and to find the XML View that a control is in...
isXMLView = function(oControl) {
return oControl.getMetadata().getName() === "sap.ui.core.mvc.XMLView";
}