TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = lt_output ).
CATCH cx_salv_msg INTO DATA(lx_salv).
WRITE: / lx_salv->get_text( ).
ENDTRY.
DATA(columns) = lo_alv->get_columns( ).
DATA(lt_cols) = columns->get( ).
LOOP AT lt_cols INTO DATA(ls_cols).
DATA(lo_column) = ls_cols-r_column.
CASE ls_cols-columnname.
WHEN 'MANDT'
lo_column->set_visible( abap_false ).
ENDCASE.
ENDLOOP.
Tag: SAP
[CAP] Fiori Elements – Add button in table toolbar to trigger action
A button for calling an action or function can be added to a table header with a single line in the annotations.cds file:
UI.LineItem : [
{ $Type: 'UI.DataFieldForAction', Action: 'myService.EntityContainer/myAction', Label: 'This is my button label' },
...
],
[CAP] Create value help with distinct values
using my.Model as db from '../db/data-model';
service myService @(requires: 'authenticated-user') {
@readonly
@cds.odata.valuelist
entity uniqueValues as select from db.Table distinct {
key field
};
}
[CAP] Update standalone approuter
You can simply update your standalone approuter using cf push
,
cd ~/projects/bookshop/app/approuter/
cf push bookshop-approuter # take your approuter name from the mta.yaml file
cd ~/projects/bookshop/
[SAP] Set default download path in SU01
SU01 -> Edit user -> Parameter -> Add Parameter GR8 and your preferred path -> Save
[SAP] Reset different SAP buffers
https://wiki.scn.sap.com/wiki/display/Basis/How+to+Reset+different+SAP+buffers
/$SYNC - Resets the buffers of the application server
/$CUA - Resets the CUA buffer of the application server
/$TAB - Resets the TABLE buffers of the application server
/$NAM - Resets the nametab buffer of the application server
/$DYN - Resets the screen buffer of the application server
/$ESM - Resets the Exp./ Imp. Shared Memory Buffer of the application server
/$PXA - Resets the Program (PXA) Buffer of the application server.
/$OBJ - Resets the Shared Buffer of the application server.
[ABAP] convert string to xstring and convert back
DATA(lv_string) = |My string I want to convert to xstring.|.
TRY.
DATA(lv_xstring) = cl_abap_codepage=>convert_to( lv_string ).
DATA(lv_string_decoded) = cl_abap_codepage=>convert_from( lv_xstring ).
WRITE: / lv_string,
/ lv_xstring,
/ lv_string_decoded.
CATCH cx_root INTO DATA(e).
WRITE: / e->get_text( ).
ENDTRY.
[ABAP] Filter table using VALUE FOR
DATA(lt_result) = VALUE z_type( FOR line IN lt_table
WHERE ( value IN lr_values )
( field = ls_line-value ) ).
[ABAP] Selection Screen Tabbed Block

SELECTION-SCREEN BEGIN OF BLOCK bl4 WITH FRAME TITLE TEXT-t01.
SELECTION-SCREEN BEGIN OF TABBED BLOCK tbl FOR 10 LINES.
SELECTION-SCREEN TAB (15) tbl_tab1 USER-COMMAND tab1 DEFAULT SCREEN 1001.
SELECTION-SCREEN TAB (15) tbl_tab2 USER-COMMAND tab2 DEFAULT SCREEN 1002.
SELECTION-SCREEN TAB (15) tbl_tab3 USER-COMMAND tab3 DEFAULT SCREEN 1003.
SELECTION-SCREEN END OF BLOCK tbl.
SELECTION-SCREEN END OF BLOCK bl4.
* Subscreen 1001 Tab1
SELECTION-SCREEN BEGIN OF SCREEN 1001 AS SUBSCREEN.
PARAMETERS p_bool1 TYPE abap_bool AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 1001.
* Subscreen 1002 Tab2
SELECTION-SCREEN BEGIN OF SCREEN 1002 AS SUBSCREEN.
PARAMETERS p_btp1 TYPE flag RADIOBUTTON GROUP rbg DEFAULT 'X'.
PARAMETERS p_btp2 TYPE flag RADIOBUTTON GROUP rbg.
PARAMETERS p_btp3 TYPE flag RADIOBUTTON GROUP rbg.
SELECTION-SCREEN END OF SCREEN 1002.
* Subscreen 1003 Tab3
SELECTION-SCREEN BEGIN OF SCREEN 1003 AS SUBSCREEN.
PARAMETERS p_bool2 TYPE flag AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 1003.
INITIALIZATION.
" provide tab names
tbl_tab1 = 'Tab1'.
tbl_tab2 = 'Tab2'.
tbl_tab3 = 'Tab3'.
" set active tab (activetab value must be in uppercase)
tbl-activetab = 'TAB2'.
tbl-dynnr = 1002.
tbl-prog = sy-repid.
AT SELECTION-SCREEN.
" click on tabstrip event
CASE sy-ucomm.
WHEN 'TAB1'.
MESSAGE 'TAB1' TYPE 'S'.
WHEN 'TAB2'.
MESSAGE 'TAB2' TYPE 'S'.
WHEN 'TAB3'.
MESSAGE 'TAB3' TYPE 'S'.
ENDCASE.
[ABAP] Replace unusual characters with ordinary characters in a String
DATA(unusual) = 'äöüáĂā'.
DATA(pretty) = /ui2/cl_serialize=>pretty_text( unusual ).
WRITE unusual.
WRITE pretty.