Skip to content

Instantly share code, notes, and snippets.

View larshp's full-sized avatar
🤷‍♂️
ABAP and more ABAP 拉尔斯

Lars Hvam larshp

🤷‍♂️
ABAP and more ABAP 拉尔斯
View GitHub Profile
METHOD zif_abapgit_exit~change_committer_info.
DATA lv_username TYPE string.
IF sy-uname = 'FOO'.
cl_gui_frontend_services=>get_user_name(
CHANGING
user_name = lv_username
EXCEPTIONS
cntl_error = 1
METHOD zif_abapgit_exit~wall_message_repo.
IF is_repo_meta-local_settings-flow = abap_true.
ii_html->add( zcl_abapgit_gui_chunk_lib=>render_error(
iv_error = |WARNING: This repository is flow enabled, use this view at own risk| ) ).
ENDIF.
ENDMETHOD.
@larshp
larshp / guidv4.abap
Last active June 20, 2025 05:03
GUID v4 implementation in ABAP
* GUID v4 implementation in ABAP
* Also see SAP note 2619546 !
* https://answers.sap.com/questions/11928657/generating-uuid-in-abap.html
* http://www.cryptosys.net/pki/uuid-rfc4122.html
* https://tools.ietf.org/html/rfc4122#page-14
DATA guid TYPE c LENGTH 36.
DATA hex TYPE x LENGTH 16.
@larshp
larshp / zupdate_credit.abap
Created April 28, 2021 12:45
Update credit limit
REPORT zupdate_credit.
* quick and dirty
PARAMETERS p_part TYPE ukmbp_cms_sgm-partner OBLIGATORY.
PARAMETERS p_segm TYPE ukmbp_cms_sgm-credit_sgmnt OBLIGATORY.
PARAMETERS p_limit TYPE ukmbp_cms_sgm-credit_limit OBLIGATORY.
START-OF-SELECTION.
PERFORM run.
@larshp
larshp / abaplint-cla.md
Created October 5, 2024 05:22
Contributor License Agreement

Contributor Agreement

Individual Contributor Exclusive License Agreement

(including the Traditional Patent License OPTION)

Thank you for your interest in contributing to Heliconia Labs ApS's abaplint ("We" or "Us").

The purpose of this contributor agreement ("Agreement") is to clarify and document the rights granted by contributors to Us. To make this document effective, please follow the instructions at https://github.com/abaplint/cla.

@larshp
larshp / mgf1.abap
Last active April 9, 2024 12:29
Mask generation function in ABAP
METHOD mgf1.
* https://en.wikipedia.org/wiki/Mask_generation_function
DATA lv_counter TYPE i.
DATA lv_sha1 TYPE xstring.
DATA lv_xstr TYPE xstring.
DATA lv_c TYPE x LENGTH 4.
WHILE xstrlen( rv_mask ) < iv_length.
REPORT zlocals.
DATA lt_locals TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
FIELD-SYMBOLS <val> TYPE i.
DATA: BEGIN OF ls_locals,
val1 TYPE i,
val2 TYPE i,
val3 TYPE i,
val4 TYPE i,
val5 TYPE i,
CONSTANTS lc_iterations TYPE i VALUE 5000.
DATA hex TYPE x LENGTH 4.
DATA str TYPE string.
GET RUN TIME FIELD DATA(lv_start).
DO lc_iterations TIMES.
hex = '11223344'.
str = hex.
str = reverse( str ).
hex = str.
DATA(lo_ddl) = NEW zcl_abapgit_object_tabl_ddl( ).
SELECT obj_name FROM tadir WHERE pgmid = 'R3TR' AND object = 'TABL' AND masterlang = 'E' INTO TABLE @DATA(lt_tadir).
LOOP AT lt_tadir INTO DATA(ls_tadir).
* IF ls_tadir-obj_name <> 'SOMETHING'.
* CONTINUE.
* ENDIF.
IF sy-tabix MOD 10 = 0.
cl_progress_indicator=>progress_indicate(
i_text = |{ sy-tabix }/{ lines( lt_tadir ) }|
@larshp
larshp / abapgit_exit_wall_topics.abap
Created October 12, 2023 06:27
abapGit, user exit, encourage adding topics
METHOD zif_abapgit_exit~wall_message_repo.
DATA(lv_url) = is_repo_meta-url.
DATA(lo_agent) = zcl_abapgit_factory=>get_http_agent( ).
IF zcl_abapgit_login_manager=>get( lv_url ) IS NOT INITIAL.
lo_agent->global_headers( )->set(
iv_key = 'Authorization'
iv_val = zcl_abapgit_login_manager=>get( lv_url ) ).