Skip to content
Jacques Nomssi edited this page Jan 1, 2018 · 69 revisions

Welcome to the abap_scheme wiki!

Introduction to Scheme

ABAP Scheme

ABAP Integration

Interpreter

Class lcl_lisp_interpreter evaluates your Scheme code in a string code, using either method eval_repl( code ) which throws an exception on errors, or method eval_source( code ) catches exception:

  DATA(response) = NEW lcl_lisp_interpreter( )->eval_source( code ).

Access to ABAP Fields

For a dynamic IF statement ( PLAAB = '02' ) and ( DELKZ = 'BB') and ( LIFNR > '' ) and ( PLUMI = '-') we concatenate the following Scheme expression in a string variable code and evaluate.

(let 
; Define local fields
     (PLAAB (ab-data "GS_MDPS-PLAAB" ))
     (DELKZ (ab-data "GS_MDPS-DELKZ" ))
     (LIFNR (ab-data "GS_MDPS-LIFNR" ))
     (PLUMI (ab-data "GS_MDPS-PLUMI" ))
  (and (= PLAAB '02') (= DELKZ 'BB') (> LIFNR '') (= PLUMI '-')) )

The result on the expression either #t or #f.

Function Module Call

(let (( profiles
  (let ( (f3 (ab-function "BAPI_USER_GET_DETAIL"))  )
    ( begin (ab-set f3 "USERNAME" (ab-get ab-sy "UNAME") )
              (f3) (ab-get f3 "PROFILES")  ) )
    ) )
 (let ((profile (ab-get profiles 1)) )
            (ab-get profile "BAPIPROF" )  )

Optional: Console Interface

  INTERFACE lif_port.
    METHODS write IMPORTING element TYPE REF TO lcl_lisp
                  RETURNING VALUE(rv_input) TYPE string.

    METHODS read IMPORTING iv_input        TYPE string OPTIONAL
                 RETURNING VALUE(rv_input) TYPE string.
  ENDINTERFACE.
Clone this wiki locally