{"id":20454800,"url":"https://github.com/nomssi/abap_scheme","last_synced_at":"2025-04-13T03:35:31.481Z","repository":{"id":38859935,"uuid":"109576420","full_name":"nomssi/abap_scheme","owner":"nomssi","description":"ABAP Scheme","archived":false,"fork":false,"pushed_at":"2023-04-03T01:11:18.000Z","size":7556,"stargazers_count":15,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T20:51:18.146Z","etag":null,"topics":["abap","abap-scheme","lisp-interpreter","sap-netweaver","scheme-interpreter","workbench"],"latest_commit_sha":null,"homepage":"","language":"ABAP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nomssi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T12:12:27.000Z","updated_at":"2025-01-31T09:27:12.000Z","dependencies_parsed_at":"2022-08-30T02:42:08.493Z","dependency_job_id":null,"html_url":"https://github.com/nomssi/abap_scheme","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomssi%2Fabap_scheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomssi%2Fabap_scheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomssi%2Fabap_scheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomssi%2Fabap_scheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nomssi","download_url":"https://codeload.github.com/nomssi/abap_scheme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248660013,"owners_count":21141223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abap","abap-scheme","lisp-interpreter","sap-netweaver","scheme-interpreter","workbench"],"created_at":"2024-11-15T11:17:07.415Z","updated_at":"2025-04-13T03:35:31.460Z","avatar_url":"https://github.com/nomssi.png","language":"ABAP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ABAP Scheme\n[![Language: ABAP](https://img.shields.io/badge/Language-ABAP-blue.svg?style=flat)](https://www.sap.com/developer/topics/abap-platform.html)\n[![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat)](https://opensource.org/licenses/MIT)\n\n- is an interpreter for Scheme, a Lisp dialect with exceptionally clear and concise semantics and a focus on functional programming\n- provides a SAP GUI based workbench for Scheme\n- is written in, and can be called from ABAP\n\n## Getting Started\nThe code can be cloned with [ABAP GIT](http://docs.abapgit.org/).\n\n- The main version is developed on Netweaver 7.5 and should work on ABAP Netweaver 7.4. \n- Milestones are downported to other branches (7.02). \n- The legacy code on [SCN Code Gallery](https://wiki.scn.sap.com/wiki/display/Snippets/Lisp+Interpreter+in+ABAP) should work on older releases.\n\nTo check your installation, execute this \u003ci\u003eguess my number\u003c/i\u003e game...\n\n```Scheme\n      (begin (display \"Please enter a number between 1 - 100: \")\n          (do ((quit #f)\n               (guess 0)   \n               (answer (+ 1 (random 100))) )\n          (quit)\n          (begin (set! guess (read)) (display guess) )\n          (cond ((and (number? guess) (\u003c guess answer)) (display \"\\nToo low. Please guess again: \") )\n                ((and (number? guess) (\u003e guess answer)) (display \"\\nToo high. Please guess again: \") )\n                (else (set! quit #t) (if (number? guess) (display \"\\nCorrect!\")\n                                                         (display \"\\nGood bye...\") ) ) ) ) )\n```\n\nScheme syntax is based upon nested parenthesization. The [wiki pages](https://github.com/nomssi/abap_scheme/wiki) are a good place to start.\n\n* I suggest you check the [syntax](https://github.com/nomssi/abap_scheme/wiki/Learn-Try-Scheme) and understand [Lists](https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Lists.html#Lists).\n* For questions/comments/bugs/feature requests/wishes please create an [issue](https://github.com/nomssi/abap_scheme/issues)\n* How to [enable the new editor](/editor)\n\n## Why Scheme?\n- [Scheme](https://en.wikipedia.org/wiki/Scheme_%28programming_language%29) is one of the main Lisp dialects, alongside *Common Lisp* and *Clojure*. Conrad Barski's [Land of Lisp](http://landoflisp.com), Martin Ceronio's [LISP interpreter in ABAP](https://blogs.sap.com/2015/06/24/a-lisp-interpreter-in-abap/) and [Peter Norvig](http://norvig.com/lispy2.html) inspired me to learn Lisp. It is common to [Make your own Lisp](https://github.com/kanaka/mal/blob/master/process/guide.md) to really understand Lisp's core concepts.\n\n[![LISP Inside](https://github.com/nomssi/abap_scheme/blob/master/img/lisplogo_256.png)](http://lisperati.com/logo.html)\n\n- Scheme's uses *symbolic expressions* (S-exps) to represent code *and* data. Expressions are then [evaluated](https://docs.racket-lang.org/reference/eval-model.html). Those  concepts cannot be expressed in ABAP, except by first implementing a Lisp interpreter in ABAP ([Greenspun 10th rule](http://www.paulgraham.com/quotes.html) ).\n\n- My initial plan was to write a Lisp workbench for [Martin's Lisp interpreter](https://github.com/mydoghasworms/abap-lisp). I changed the target language after reading the *Revised \u003csup\u003e7\u003c/sup\u003e Report on the Algorithmic Language Scheme* aka [R7RS small](http://www.r7rs.org/) that offers a lot of examples to verify the interpreter. With this I can aim at compatibility with open source Scheme code.\n\n- In constrast to ABAP, Scheme has a very small number of rules for forming expressions that can be composed without restrictions. Scheme is lexically scoped and requires proper tail call optimization. Scheme is apt at [symbolic processing](https://github.com/nomssi/abap_scheme/wiki/Learn-Try-Symbolic-Derivation).\n\n### Features\n- ABAP Scheme supports a subset of [R7RS](http://www.r7rs.org/) with some [Racket](https://docs.racket-lang.org/) extensions. Check the current [list of features](https://github.com/nomssi/abap_scheme/wiki/Features)\n- This documentation is the source of many of the 500+ tests implemented in the ABAP unit test suite. \n- Access to ABAP global fields and function modules\n- a programming environment to make it fun to use, featuring the editor and console views, a trace view, a graphical S-Expression viewer\n\nS-expression for (* 2 (+ 3 4)) | workbench view\n--- | ---\n![s-exp](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Corrected_S-expression_tree_2.png/220px-Corrected_S-expression_tree_2.png) |  ![workbench view](https://github.com/nomssi/abap_scheme/blob/master/img/sexpr_new.PNG)\n\n- R7RS alignment makes it easier to run open source Scheme code. This is however limited, as *first class continuations* (call cc) and *hygienic macros* (define-syntax) are missing\n\n### Architecture\n\n- Report ZZ_LISP_IDE - Main report for the workbench\n- Include YY_LIB_LISP - Complete ABAP LISP library\n- Include YY_LISP_AUNIT - a large _ABAP Unit_ regression test suite\n- Include YY_LISP_IDE - Editor/Tools\n\n### ABAP Integration\n#### Interpreter\nClass `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:\n\n```ABAP\n      DATA(response) = NEW lcl_lisp_interpreter( io_port = port \n                                                 ii_log = log )-\u003eeval_source( code ).\n```\n`port` is a buffered port that can allow input or output. `log` implements a simple logging interface with 2 methods, put( ) and get( ).\n#### Access to ABAP Fields\nFor a [dynamic IF statement](https://blogs.sap.com/2016/02/29/dynamic-if-condition/)\n     `( PLAAB = '02' ) and ( DELKZ = 'BB') and ( LIFNR \u003e '' ) and ( PLUMI = '-')` \nwe concatenate the following Scheme expression in a string variable `code` and evaluate. \n\n```Scheme\n    (let \n    ; Define local fields\n        ((PLAAB (ab-data \"GS_MDPS-PLAAB\" ))\n         (DELKZ (ab-data \"GS_MDPS-DELKZ\" ))\n         (LIFNR (ab-data \"GS_MDPS-LIFNR\" ))\n         (PLUMI (ab-data \"GS_MDPS-PLUMI\" )))\n      (and (= PLAAB '02') (= DELKZ 'BB') (\u003e LIFNR '') (= PLUMI '-')) )\n```\n\nThe result on the expression either `#t` or `#f`.\n\n#### Function Module Call\n\n```Scheme\n    (let (( profiles\n      (let ( (f3 (ab-function \"BAPI_USER_GET_DETAIL\"))  )  \n        ( begin (ab-set f3 \"USERNAME\" (ab-get ab-sy \"UNAME\") )  ; param USERNAME = sy-uname\n                  (f3)                                          ; function module call\n                  (ab-get f3 \"PROFILES\")  ) )                   ; return table PROFILES\n        ) )\n     (let ((profile (ab-get profiles 1)) )         ; read table PROFILES index 1 INTO profile \n                (ab-get profile \"BAPIPROF\" )  ) )  ; read field profile-bapiprof\n```\n\n#### Optional: Console Interface\n\n```ABAP\n      INTERFACE lif_input_port.\n        METHODS read IMPORTING iv_title        TYPE string OPTIONAL\n                     RETURNING VALUE(rv_input) TYPE string.\n        METHODS peek_char RETURNING VALUE(rv_char) TYPE char01.\n        METHODS is_char_ready RETURNING VALUE(rv_flag) TYPE flag.\n        METHODS read_char RETURNING VALUE(rv_char) TYPE char01.\n        METHODS put IMPORTING iv_text TYPE string.\n      ENDINTERFACE.\n    \n      INTERFACE lif_output_port.\n        METHODS write IMPORTING element TYPE REF TO lcl_lisp.\n        METHODS display IMPORTING element TYPE REF TO lcl_lisp\n                        RAISING   lcx_lisp_exception.\n      ENDINTERFACE.\n```\n\n### Workbench\n![abap_scheme](https://github.com/nomssi/abap_scheme/blob/master/img/abap_scheme_workbench.png)\n![abap_trace](https://github.com/nomssi/abap_scheme/blob/master/img/abap_lisp_trace.png)\n![abap_expression](https://github.com/nomssi/abap_scheme/blob/master/img/SExpressionViewer.png)\n\n\nRead the ABAP Scheme [announcement](https://blogs.sap.com/2018/02/01/announcing-the-abap-scheme-workbench/) blog\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomssi%2Fabap_scheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnomssi%2Fabap_scheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomssi%2Fabap_scheme/lists"}