Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 ).
@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 / msg_attachment_udf.java
Created August 25, 2014 05:12
Example PI UDF showing how to add an attachment to a message. In this case its sent to the MAIL adapter so is a text file attachment to the email. UDF function imports: public void setAttachment(String[] OrgFormatName, String[] StreetName, String[] HouseId, String[] Email, String[] RegionName, String[] CityName, String[] CountryName, String[] St…
/* This UDF reads all contents and creates an output along with an attachment to SAP PI message, which has data in CSV foramt as expected by DB Schenker.
Please note that DB Schenker expect some of the fields as empty and hence only commas are added in the payload. For future enhancements if further fields are required to be added, pass them as input to UDF and update the
content field to use that input
*/
AbstractTrace trace = container.getTrace();
String firstRow = "Organization Name,,Contact Name,Email Address,Phone Number,Handling Office,Trucker,US Principal Party of Interest / ISF Importer,Factory,Consignee/Destination/ISF Ship To,Freight Forwarder,Third Party,Equipment Stuffing Location,Secondary Name/3rd Party Description,Address (Line 1),Address (Line 2),Address (Line 3),Email Address,State,City,Country (ISO Country Code),Postal Code,Phone,Fax,Internal Customer Account #,Importer of Record Number,Type (EIN, SSN, Foreign),Consignee #,Type (EIN, SSN, Foreign),Vendor Name,Vendor Code,Contact Name";
St
@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.