" Filter, Sort, Paging
/iwbep/cl_mgw_data_util=>filtering( EXPORTING it_select_options = it_filter_select_options
CHANGING ct_data = et_entityset ).
/iwbep/cl_mgw_data_util=>orderby( EXPORTING it_order = it_order
CHANGING ct_data = et_entityset ).
/iwbep/cl_mgw_data_util=>paging( EXPORTING is_paging = is_paging
CHANGING ct_data = et_entityset ).
Tag: abap
[ABAP] Delete all rows from index
If you want to delete all lines from a certain index, e.g. 6, you can do the following:
DELETE lt_data FROM 6 TO lines( lt_data ).
As result, your table will only hold the first 5 rows.
[ABAP] OData – Get the “low” value from a filter range
DATA(lt_filter) = io_tech_request_context->get_filter( )->get_filter_select_options( ).
IF line_exists( it_filter[ property = 'MYKEY' ] ).
DATA(lv_input) = it_filter[ property = 'MYKEY' ]-select_options[ 1 ]-low.
" ...
ENDIF.
[ABAP] Read ACTION_COMMENTS from a Workitem
If you want to use the decision note / action comment of a Workitem in a mail step, you have to write a method to read the comment and then pass it to the mail step. To do this, I always create a method in my Workflow helper class called READ_DECISION_NOTE with the following parameters:

For the importing parameter, you must store the Workitem ID of your Decision Step in you Workflow Container, by creating a Container Element like DecisionWIID of type SWW_WIID and fill it with the Workitem ID of your decision step. Then use it later for calling your method READ_DECISION_NOTE.
Regarding the exporting parameter; If you want to send a mail via class cl_cbs you’re a fine reading the comment as string. But if you want to use the default workflow mail step, and you are expecting comments with more than >255 characters, you will need the comment as SOLI_TAB.
If you take a look at the decision Workitem, you will properly find the Attribute ACTION_COMMENTS, which is of type SWC_VALUE and is of type char with length 255. But this is only the case, if the entered text has less than < 255 characters.

If the user entered a text with more than 255 characters, the text is split and there are more elements named with ACTION_COMMENTS_1, ACTION_COMMENTS_2 etc. (Note 3017539)

There is the function module SAP_WAPI_READ_CONTAINER to read Workitems. As input for the function module, you need the Workitem ID from the decision step. You will then find the ACTION_COMMENTS in the simple_container table.
DATA: return_code TYPE sy-subrc,
simple_container TYPE TABLE OF swr_cont,
message_lines TYPE TABLE OF swr_messag,
message_struct TYPE TABLE OF swr_mstruc,
subcontainer_bor_objects TYPE TABLE OF swr_cont,
subcontainer_all_objects TYPE TABLE OF swr_cont,
object_content TYPE TABLE OF solisti1.
" Read the work item container from the work item ID
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
workitem_id = iv_wiid
IMPORTING
return_code = return_code
TABLES
simple_container = simple_container
message_lines = message_lines
message_struct = message_struct
subcontainer_bor_objects = subcontainer_bor_objects
subcontainer_all_objects = subcontainer_all_objects.
TRY.
DATA(text) = simple_container[ element = 'ACTION_COMMENTS' ]-value.
CATCH cx_sy_itab_line_not_found.
" Check for ACTION_COMMENTS_1 etc.
" or follow the approach below
ENDTRY.
The comment is also added as SOFM-Object (SAP-Office-Document) to the Workitem. Just check the table subcontainer_all_objects, which is also returned by the previous function module, for attribute _ATTACH_COMMENT_OBJECTS (or _ATTACH_OBJECTS or DECISION_NOTE or _DECISION_COMMENT). With function module SO_DOCUMENT_READ_API1 you can then get the actual comment.
" Read the _ATTACH_COMMENT_OBJECTS element
" There can be more than one comment, just take the last one
LOOP AT subcontainer_all_objects INTO DATA(comment_object) WHERE element = '_ATTACH_COMMENT_OBJECTS'.
ENDLOOP.
CHECK comment_object-value IS NOT INITIAL.
" Read the SOFM Document
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = CONV so_entryid( comment_object-value )
TABLES
object_content = object_content
EXCEPTIONS
OTHERS = 1.
et_decision_note = object_content.
* Or create a single string
* LOOP AT object_content INTO DATA(lv_soli).
* CONCATENATE text lv_soli-line INTO text.
* ENDLOOP.
This SOLI_TAB can be passed to a default mail step and will keep line breaks etc.

Update 02.06.2026: A shorter approach can be the following.
DATA(lo_workitem) = NEW /iwwrk/cl_wf_read_workitem( iv_wiid ).
lo_workitem->get_wi_appr_comments( IMPORTING et_wi_appr_comm = DATA(lt_wi_appr_comm)
ev_return_code = DATA(lv_return_code) ).
READ TABLE lt_wi_appr_comm INTO DATA(ls_decision) WITH KEY obj_name = 'COMMENT' obj_type = 'TXT'.
DATA(soli_tab) = cl_document_bcs=>string_to_soli( ls_decision-text ).
But string to soli_tab is always a bit risky when having a text with >255 characters (see here).
[ABAP] Include table fields in local type
Somehow I always forget the syntax for this….
TYPES: BEGIN OF ty_test.
INCLUDE TYPE z_table.
TYPES: my_new_field TYPE string,
END OF ty_test.
[ABAP] Read components of a dynamic structure
DATA(lo_structdescr) = CAST cl_abap_structdescr( cl_abap_structdescr=>describe_by_data( p_data = <dynamic_structure> ) ).
DATA(components) = lo_structdescr->get_components( ).
IF line_exists( components[ name = 'FIELD1' ] ).
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <dynamic_structure> TO FIELD-SYMBOL(<field1>).
"do stuff...
ENDIF.
[SAP] Namensraum öffnen für Änderungen
Namensraum anlegen
Tcode: SE03

Editierbarkeit von Objekten eines Namensraumes zulassen
Tcode: SE03

Ggf. muss in der SE80 noch der Modifikationsassistant ausgeschaltet werden.
SE80 -> Bearbeitten -> Modifikationsoperationen -> Assistant ausschalten
[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] Check if class exists and is activated
" Check if class exists and is activated
IF cl_esh_ca_check=>is_active_class( 'ZCL_MYCLASS' ) = abap_true.
WRITE: 'Class exists'.
ENDIF.
[ABAP] Find fullname for sy-uname
Via Infotype
TRY.
DATA(lo_employee_api) = cl_hcmfab_employee_api=>get_instance( ).
DATA(lv_pernr) = lo_employee_api->get_employeenumber_from_user( sy-uname ).
DATA(lv_ename) = lo_employee_api->get_name( lv_pernr ).
CATCH cx_hcmfab_common.
ENDTRY.
or via SU01
DATA(lv_ename) = NEW cl_hreic_appl_utilities( )->get_user_name( sy-uname ).
