Skip to content

Instantly share code, notes, and snippets.

@js1972
js1972 / proxy_serialize.abap
Created June 30, 2014 05:26
How to set a sender proxy message to EOIO (serialization). Call this serialize() method just prior to execute().
method serialize.
"importing io_proxy type ref to cl_proxy_basis
"raising cx_ai_system_fault
data:
lo_async_messaging type ref to if_wsprotocol_async_messaging.
queue = get_queue_name( ).
check not queue is initial.
@js1972
js1972 / execute_proc.sql
Created June 26, 2014 08:58
Execute a simple SQLServer procedure
EXECUTE PersonsListByPostcode @pc = '6000'
@js1972
js1972 / proc.sql
Created June 26, 2014 08:57
Create a simple SQLServer procedure
CREATE PROCEDURE PersonsListByPostcode @pc nvarchar(255)
AS
SELECT *
FROM T_PERSON
WHERE postcode = @pc
@js1972
js1972 / select_changes_then_merge.sql
Created June 26, 2014 08:56
SQLServer procedure to select changes between two tables based on a hash field, then update (merge) the second table with the changes. Change ALTER to CREATE/DROP to create or delete the procedure. Note: The PI JDBC Adapter does not like any blank lines in the Procedure!
alter procedure PersonDelta
as
SET NOCOUNT ON;
/* temp table - fill with changes between tables based on hash field */
declare @rows table(name nvarchar(255), street nvarchar(255), city nvarchar(255), postcode nvarchar(255), state nvarchar(255), hash nvarchar(255));
insert into @rows (name, street, city, postcode, state, hash)
select p.name, p.street, p.city, p.postcode, p.state, p.hash from T_PERSON as p left outer join T_PERSON_HIST as h on p.name = h.name where p.hash <> isnull(h.hash,'-1');
/* merge the cahnges into the second table */
merge into T_PERSON_HIST as target using @rows as source
on target.name = source.name
@js1972
js1972 / dynamic_config_udf.java
Created June 25, 2014 02:32
Dynamic Configuration (ASMA) in a mapping UDF (User Defined Function). Note that the getTransformationParameters() method is deprecated; but it is the only way it seems to work within an ICO (iflow). Note: You create UDF's in a function library with NWDS and not in the mapping directly.
package pi_test_purchaseorder_es;
import com.sap.aii.mapping.api.*;
import java.io.*;
import java.util.*;
import com.sap.aii.mappingtool.tf7.rt.*;
import com.sap.aii.mapping.lookup.*;
import java.lang.reflect.*;
import com.sap.ide.esr.tools.mapping.core.LibraryMethod;
import com.sap.ide.esr.tools.mapping.core.ExecutionType;
@js1972
js1972 / sap_ui_getcore_by_id.js
Created June 24, 2014 03:04
Access a sapui5 element by id
sap.ui.getCore().byId("element_id")
@js1972
js1972 / Pouring.scala
Created June 17, 2014 02:27
Solution to the Water Pouring problem in Scala
package week7
class Pouring(capacity: Vector[Int]) {
// States
type State = Vector[Int]
val initialState = capacity map (x => 0)
// Moves
@js1972
js1972 / infinite_streams.scala
Created June 17, 2014 01:09
Infinite Streams in Scala. Using infinite streams to efficiently calculate primes and square roots in a Scala Worksheet.
package week7
object primes {
//infinite stream builder
def from(n: Int): Stream[Int] = n #:: from(n + 1)
//> from: (n: Int)Stream[Int]
//infinte stream of all natural numbers
val nats = from(0) //> nats : Stream[Int] = Stream(0, ?)
val m4s = nats map (_ * 4) //> m4s : scala.collection.immutable.Stream[Int] = Stream(0, ?)
@js1972
js1972 / ZCCA_ENJOY_TXN_LAUNCHER.abap
Created May 26, 2014 04:28
How to launch and external SAPGUI transaction from an FPM application. Note that the SAPGUI launches within a browser, but it is the *real* sapgui rendering within it.
*&---------------------------------------------------------------------*
*& Report ZCCA_ENJOY_TXN_LAUNCHER
*&
*&---------------------------------------------------------------------*
*& This program is used to launch the sap enjoy transactions from FPM
*& apps. The enjoy transactions such as ME53N (pur. req. display) do
*& not allow proper passing of paramters within the webgui. However the
*& old sap transaction such as ME53 do (it requires a selection screen).
*& This program presents a simple selection screen which can be
*& populate with a document type and document number.
@js1972
js1972 / web_dynpro_launch_tcode.abap
Created May 26, 2014 04:25
Sample ABAP code to launch a SAPGUI transaction from WebDynpro. This is similar to how its done with FPM (if_fpm_navigate_to). See the example GIST on that.
ls_transaction-tcode = 'BSSP_BOR_OBJECT'.
ls_transaction-gui_type = 'WIN_GUI'.
ls_transaction-system_alias = 'SAP_LocalSystem'.
ls_lpd_tx_para-key = 'SWO_TYPEID'. "'OBJKEY'.
ls_lpd_tx_para-value = ld_string+6(70).
INSERT ls_lpd_tx_para INTO TABLE ls_transaction-parameter.
ls_lpd_tx_para-key = 'OJ_NAME'. "'OBJTYPE'.
ls_lpd_tx_para-value = ld_string+76.
INSERT ls_lpd_tx_para INTO TABLE ls_transaction-parameter.
ls_lpd_tx_para-key = 'RFCDEST'.