Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[CAP] Add SQLite DB for development

# install SQLite
npm i sqlite3 -D 

# create db, save configuration in package.json, stores mock data into db
cds deploy --to sqlite:db/my-app.db

# test cds deploy command with --dry. Displays ever table and view it creates
cds deploy --to sqlite:db/my-app.db --dry

# get and overview of your tables with .tables
sqlite3 db/my-app.db .tables

# open and view newly created db
sqlite3 db/my-app.db -cmd .dump

# and select single field with
SELECT field FROM mytable WHERE mykeyfield= "00505601194D1EE9B7BFC518B85";

# update a field with
UPDATE mytable SET field = "test" WHERE mykeyfield= "00505601194D1EE9B7BFC518B85";

[ABAP] Provide values of a domain in a dropdown list on selection screen

  
  PARAMETER p_test TYPE c OBLIGATORY AS LISTBOX VISIBLE LENGTH 32 DEFAULT 1.

  INITIALIZATION.

  cl_reca_ddic_doma=>get_values( EXPORTING id_name   = 'Z_MYDOMAIN'
                                 IMPORTING et_values = DATA(lt_rsdomaval) ).

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = 'P_TEST'
      values = VALUE vrm_values( FOR dvalue IN lt_rsdomaval ( key  = dvalue-domvalue_l 
                                                              text = dvalue-ddtext ) ).

[ABAP] Read personnel area with text

  DATA p0001 TYPE p0001.
  cl_hcmfab_utilities=>read_infotype_record( EXPORTING iv_pernr = pernr
                                                       iv_infty = '0001'
                                             IMPORTING es_pnnnn = p0001 ).
  DATA(personnel_area_id)   = p0001-werks.
  DATA(personnel_area_text) = cl_hr_t500p=>read( p0001-werks )-name1.

Or using the class CL_HCMFAB_EMPLOYEE_API.

  DATA(lv_employee_details) = cl_hcmfab_employee_api=>get_instance( )->get_employee_details( iv_pernr          = pernr
                                                                                             iv_application_id = if_hcmfab_constants=>gc_application_id-mypersonaldata ).
  DATA(personnel_area_id)   = lv_employee_details-personnel_area_id.
  DATA(personnel_area_text) = lv_employee_details-personnel_area_text.

[ABAP] Set Select-Option to invisble via Radiobuttons and MODIF ID

REPORT ztest.

TABLES pa0002.

*-----------------------------------------------------------------------
* Selection screen
*-----------------------------------------------------------------------
PARAMETERS: p_radio1               RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND rad. "set s_pernr visible
PARAMETERS: p_radio2               RADIOBUTTON GROUP rad1.                              "set s_pernr invisible

SELECT-OPTIONS : s_pernr           FOR pa0002-pernr MODIF ID 100.

*----------------------------------------------------------------------
* AT SELECTION-SCREEN
*----------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT. " PBO

  LOOP AT SCREEN.
    CASE screen-group1.
      WHEN '100'.
        screen-invisible = COND #( WHEN p_radio1 = abap_true THEN 0 ELSE 1 ).
        MODIFY SCREEN.
    ENDCASE.
  ENDLOOP.

[ABAP] Parse SF Entity Key from URI

  METHOD get_entitykey_from_uri.

    " Pattern: Entity\((.*)\), 
    DATA(pattern) = iv_entity && `\((.*)\)`.

    TRY.
        DATA(matcher) = cl_abap_matcher=>create( pattern     = pattern
                                                 text        = iv_uri
                                                 ignore_case = abap_true ).
      CATCH cx_sy_invalid_regex.
    ENDTRY.

    TRY.
        DATA(lt_matches) = matcher->find_all( ).
        ASSIGN lt_matches[ 1 ] TO FIELD-SYMBOL(<s>).

        rv_entity_key = substring( val = iv_uri off = <s>-offset len = <s>-length ). 

      CATCH cx_sy_no_current_match.
    ENDTRY.

  ENDMETHOD.

[ABAP] Dropdown list on selection screen

PARAMETER p_list  TYPE c AS LISTBOX VISIBLE LENGTH 32.  "Add OBLIGATORY to get rid of the empty line. Use DEFAULT to set the inital selection.

INITIALIZATION.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_LIST'
      values          = VALUE vrm_values( ( key = '1' text = 'Case 1' )
                                          ( key = '2' text = 'Case 2' )
                                          ( key = '3' text = 'Case 3' ) )
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.


AT SELECTION-SCREEN ON p_list.

  DATA(dynprofields) = VALUE dynpread_tabtype( ( fieldname = 'P_LIST' ) ).
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = sy-cprog
      dynumb             = sy-dynnr
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynprofields.  "find your selected value in column fieldvalue or directly in p_list