06-22-2022 2:52 PM
Settlement rule creation based on the condition on RAKEY for ZC02 type Default settlement rule for the order type is 90
i have requirement like based on RAKEY given by user or based on condition in user exit RAKEY will be determined for the RAKE ZSVOC only need to create the settlement profile ,
i have added the code in the WORKORDER_UPDATE BADI i have tried in AT_SAVE ( BUT here we are not getting the OBject number in the save temporary number for the order beacuse not able to give cobra-objnr and BEFORE_UPDATE here we are getting objnr and tried COBRA is creating success fully but COBRB entries are not populating automatically. i have tried with FM 1) K_SRULE_SAVE_UTASK 2) K_POSTING_RULE_INSERT these FM having option to pass 80E Aprof .
1) using K_SRULE_SAVE_UTASK
MOVE is_header_dialog-objnr TO l_str_cobra-objnr.
MOVE '80E' TO l_str_cobra-aprof.
MOVE 'RA' TO l_str_cobra-absch.
MOVE 'R1' TO l_str_cobra-ersch.
CALL FUNCTION 'K_SRULE_SAVE_UTASK'
TABLES
T_COBRA_INSERT = l_tab_cobra[]
t_cobrb_insert = l_tab_cobrb[]
EXCEPTIONS
srule_utask_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
2 ) with K_POSTING_RULE_INSERT
DATA: l_var_aprof TYPE aprof,
add_para TYPE cobr_info,
konty TYPE konty,
object_no TYPE j_objnr,
ls_e_cobrb TYPE cobrb,
it_dftab TYPE TABLE OF dftabelle.
l_var_aprof = l_str_valuescs066-fieldvalue. ""Aprof
MOVE-CORRESPONDING l_str_header TO add_para.
konty = 'EO'.
object_no = l_str_header-objnr.
CALL FUNCTION 'K_POSTING_RULE_INSERT'
EXPORTING
add_para = add_para
aprof = l_var_aprof
dfreg = 'BAP'
konty = konty
flg_objnr_check = ' '
objnr = object_no
TABLES
dftab = it_dftab
CHANGING
e_cobrb = ls_e_cobrb
EXCEPTIONS
error_message = 2
OTHERS = 1.
*.save settlement rule (no 'commit work' performed!)...................
CALL FUNCTION 'K_SETTLEMENT_RULE_SAVE'
EXPORTING
objnr = object_no
dialog = ' '
EXCEPTIONS
no_rule_for_objnr = 01.
IF sy-subrc <> 0.
* RAISE error_occurred.
ENDIF.
06-23-2022 6:45 AM
I have tried this way aslo to generate COBRB entry and populate COBRA-SORT and COBRB-REC_OBJ1 and
MOVE-CORRESPONDING l_str_header TO l_wa_item4.
APPEND l_wa_item4 TO lt_item4[].
CALL FUNCTION 'RKE_GET_ACCTNR'
EXPORTING
i_erkrs = '1000'
i_pa_type = '1'
i_vorgang = 'SM00'
i_ergbr = '3'
IMPORTING
e_delkey = e_delkey "" type i
TABLES
object_table = lt_item4[].
READ TABLE lt_item4[] INTO l_wa_item4 INDEX 1.
IF sy-subrc = 0.
* l_var_eo_obj = eo10000002953015
CONCATENATE 'EO1000' l_wa_item4-paobjnr INTO l_var_eo_obj .
CONCATENATE 'EO1000' paobjnr INTO l_var_eo_obj .
l_str_cobra-sort = l_var_eo_obj .""l_wa_item4
ENDIF.
APPEND l_str_cobra TO l_tab_cobra.
*******//First line cobrb
MOVE l_str_header-objnr TO l_str_cobrb-objnr.
MOVE '001' TO l_str_cobrb-lfdnr.
ADD 1 TO l_str_cobrb-lfdnr.
MOVE '000' TO l_str_cobrb-bureg.
CALL FUNCTION 'CONVERSION_EXIT_PERBZ_INPUT'
EXPORTING
input = 'FUL'
IMPORTING
output = l_str_cobrb-perbz.
MOVE 'FUL' TO l_str_cobrb-perbz.
MOVE 'PM1' TO l_str_cobrb-dfreg.
MOVE '100' TO l_str_cobrb-prozs.
MOVE 'EO' TO l_str_cobrb-konty.
l_str_cobrb-paobjnr = paobjnr ."" l_wa_item4-paobjnr.
l_str_cobrb-rec_objnr1 = l_var_eo_obj.
MOVE l_str_header-kokrs TO l_str_cobrb-kokrs.
MOVE l_str_header-bukrs TO l_str_cobrb-bukrs.
l_str_cobrb-pasubnr = '1'.
l_str_cobrb-extnr = '1'.
APPEND l_str_cobrb TO l_tab_cobrb.
CLEAR :l_str_cobrb .
****
********//Seccond line CoBRB
MOVE l_str_header-objnr TO l_str_cobrb-objnr.
MOVE '000' TO l_str_cobrb-bureg.
MOVE '002' TO l_str_cobrb-lfdnr.
CALL FUNCTION 'CONVERSION_EXIT_PERBZ_INPUT'
EXPORTING
input = 'PER'
IMPORTING
output = l_str_cobrb-perbz.
MOVE 'PER' TO l_str_cobrb-perbz.
MOVE 'PM2' TO l_str_cobrb-dfreg.
MOVE '100' TO l_str_cobrb-prozs.
MOVE 'EO' TO l_str_cobrb-konty.
l_str_cobrb-paobjnr = paobjnr."" l_wa_item4-paobjnr.
l_str_cobrb-rec_objnr1 = l_var_eo_obj.
MOVE l_str_header-kokrs TO l_str_cobrb-kokrs.
MOVE l_str_header-bukrs TO l_str_cobrb-bukrs.
l_str_cobrb-pasubnr = '1'.
l_str_cobrb-extnr = '2'.
APPEND l_str_cobrb TO l_tab_cobrb.
CLEAR :l_str_cobrb .
CALL FUNCTION 'K_SRULE_SAVE_UTASK'
TABLES
t_cobra_insert = l_tab_cobra[]
t_cobrb_insert = l_tab_cobrb[]
EXCEPTIONS
srule_utask_error = 1
OTHERS = 2.