INITIALIZATION.
DATA: ls_restrictions TYPE sscr_restrict.
APPEND VALUE #( name = 'CP' options-cp = abap_true ) TO ls_restrictions-opt_list_tab.
APPEND VALUE #( kind = 'S' name = 'S_GRUND' sg_main = 'I'
sg_addy = ' ' op_main = 'CP' op_addy = 'CP' ) TO ls_restrictions-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
restriction = ls_restrictions.
Category: Functionmodule
[FI] CALCULATE_TAX_FROM_GROSSAMOUNT
DATA lt_mwdat TYPE TABLE OF RTAX1U15.
CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
EXPORTING
i_bukrs = lv_bukrs
i_mwskz = lv_mwskz
* I_TXJCD = ' '
i_waers = lv_waers
i_wrbtr = lv_wrbtr
* IMPORTING
* E_FWNAV =
* E_FWNVV =
* E_FWSTE =
* E_FWAST =
TABLES
t_mwdat = lt_mwdat
EXCEPTIONS
bukrs_not_found = 1
country_not_found = 2
mwskz_not_defined = 3
mwskz_not_valid = 4
account_not_found = 5
different_discount_base = 6
different_tax_base = 7
txjcd_not_valid = 8
not_found = 9
ktosl_not_found = 10
kalsm_not_found = 11
parameter_error = 12
knumh_not_found = 13
kschl_not_found = 14
unknown_error = 15
OTHERS = 16.
IF sy-subrc <> 0 OR lt_mwdat IS INITIAL.
RAISE EXCEPTION TYPE zcx_xxx
EXPORTING
textid = zcx_xxx=>zcx_xxx
msgv1 = SWITCH #( sy-subrc
WHEN 1 THEN 'BUKRS_NOT_FOUND '
WHEN 2 THEN 'COUNTRY_NOT_FOUND'
WHEN 3 THEN 'MWSKZ_NOT_DEFINED'
WHEN 4 THEN 'MWSKZ_NOT_VALID'
WHEN 5 THEN 'ACCOUNT_NOT_FOUND'
WHEN 6 THEN 'DIFFERENT_DISCOUNT_BASE'
WHEN 7 THEN 'DIFFERENT_TAX_BASE'
WHEN 8 THEN 'TXJCD_NOT_VALID'
WHEN 9 THEN 'NOT_FOUND'
WHEN 10 THEN 'KTOSL_NOT_FOUND'
WHEN 11 THEN 'KALSM_NOT_FOUND'
WHEN 12 THEN 'PARAMETER_ERROR'
WHEN 13 THEN 'KNUMH_NOT_FOUND'
WHEN 14 THEN 'KSCHL_NOT_FOUND'
WHEN 15 THEN 'UNKNOWN_ERROR' )
mtype = 'E'.
ENDIF.
[ABAP] Modify Infotype
METHOD operate_it.
DATA ls_return TYPE bapireturn1.
DATA key TYPE bapipakey.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = is_2002-pernr
IMPORTING
return = ls_return.
IF ls_return IS NOT INITIAL.
RAISE EXCEPTION TYPE zcx_xxx MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number.
ENDIF.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '2002'
number = is_2002-pernr
subtype = is_2002-subty
objectid = is_2002-objps
lockindicator = is_2002-sprps
validityend = is_2002-endda
validitybegin = is_2002-begda
recordnumber = is_2002-seqnr
record = is_2002_chg
operation = iv_actio "MOD,INS,DEL
tclas = 'A'
dialog_mode = '0'
IMPORTING
return = ls_return
key = key.
IF ls_return IS NOT INITIAL.
RAISE EXCEPTION TYPE zcx_xxx MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = is_2002-pernr.
ENDMETHOD.
[ABAP] Read infotype records
* Read multiple infotype records
DATA: ls_p0001 TYPE p0001,
lt_p0001 TYPE TABLE OF p0001.
* Initialise Infotyp reader
cl_hrpa_read_infotype=>get_instance( IMPORTING infotype_reader = DATA(lr_infotype_reader) ).
* Read Infotyp 1
lr_infotype_reader->read( EXPORTING tclas = 'A'
pernr = 6
infty = '0001'
begda = '01011900'
endda = '31129999'
no_auth_check = abap_true
IMPORTING infotype_tab = DATA(lt_infotype)
data_exists = DATA(lv_data_exists) ).
LOOP AT lt_infotype INTO DATA(ls_infotype).
cl_hr_pnnnn_type_cast=>prelp_to_pnnnn( EXPORTING prelp = ls_infotype
IMPORTING pnnnn = ls_p0001 ).
APPEND ls_p0001 TO lt_p0001.
ENDLOOP.
cl_demo_output=>display( lt_p0001 ).