Code: Alles auswählen.
SELECT-OPTIONS: so_cost FOR wa_zwerb-satzart NO-EXTENSION NO INTERVALS.
FORM get_kagru.
CLEAR flg_kagru.
CLEAR: wa_findstruk-kagru.
CLEAR: it_kstar, it_return.
REFRESH: it_kstar, it_return.
CALL FUNCTION 'BAPI_COSTELEM_GETLIST'
EXPORTING
coarea = con_kokrs
date = sy-datum
costelementgroup = con_cost_elem_kst
TABLES
costelementlist = it_kstar
return = it_return.
READ TABLE it_kstar WITH KEY cost_elem = wa_zwerb-satzart.
IF sy-subrc IS INITIAL AND it_return[] IS INITIAL.
wa_findstruk-kagru = con_cost_elem_kst.
ELSE.
CLEAR: it_kstar, it_return.
REFRESH: it_kstar, it_return.
CALL FUNCTION 'BAPI_COSTELEM_GETLIST'
EXPORTING
coarea = con_kokrs
date = sy-datum
costelementgroup = con_cost_elem_eo
TABLES
costelementlist = it_kstar
return = it_return.
READ TABLE it_kstar WITH KEY cost_elem = wa_zwerb-satzart.
IF sy-subrc IS INITIAL AND it_return[] IS INITIAL.
wa_findstruk-kagru = con_cost_elem_eo.
ELSE.
CLEAR: it_kstar, it_return.
REFRESH: it_kstar, it_return.
CALL FUNCTION 'BAPI_COSTELEM_GETLIST'
EXPORTING
coarea = con_kokrs
date = sy-datum
costelementgroup = con_cost_elem_crm
TABLES
costelementlist = it_kstar
return = it_return.
READ TABLE it_kstar WITH KEY cost_elem = wa_zwerb-satzart.
IF sy-subrc IS INITIAL AND it_return[] IS INITIAL.
wa_findstruk-kagru = con_cost_elem_crm.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " get_kagru
Code: Alles auswählen.
FORM get_kagru.
CLEAR flg_kagru.
CLEAR: wa_findstruk-kagru.
CLEAR: it_kstar, it_return.
REFRESH: it_kstar, it_return.
DO.
CALL FUNCTION 'BAPI_COSTELEM_GETLIST'
EXPORTING
coarea = con_kokrs
date = sy-datum
costelementgroup = so_cost
TABLES
costelementlist = it_kstar
return = it_return.
READ TABLE it_kstar WITH KEY cost_elem = wa_zwerb-satzart.
IF sy-subrc IS INITIAL AND it_return[] IS INITIAL.
wa_findstruk-kagru = so_cost.
ENDIF.
IF so_cost = wa_zwerb-satzart.
exit.
ENDIF.
ENDDO.
ENDFORM
Code: Alles auswählen.
FORM get_kagru.
CLEAR flg_kagru.
CLEAR: wa_findstruk-kagru.
CLEAR: it_kstar, it_return.
REFRESH: it_kstar, it_return.
data: wa_cost type kagru.
loop at so_cost into wa_cost.
CALL FUNCTION 'BAPI_COSTELEM_GETLIST'
EXPORTING
coarea = con_kokrs
date = sy-datum
costelementgroup = wa_cost
TABLES
costelementlist = it_kstar
return = it_return.
READ TABLE it_kstar WITH KEY cost_elem = wa_zwerb-satzart.
IF sy-subrc IS INITIAL AND it_return[] IS INITIAL.
wa_findstruk-kagru = wa_cost.
ENDIF.
IF wa_cost = wa_zwerb-satzart.
exit.
ENDIF.
endloop.
* KOSTL
PERFORM findsingle USING 'KOSTL'
''.
wa_zwerbsap-kostl = p_fval.
IF wa_findstruk-kagru IS INITIAL.
wa_zwerbsap-kostl = 'F003'.
ENDIF.