Skip to Content
author's profile photo Former Member
Former Member

BAPI_ALM_ORDER_MAINTAIN Service Line Price not changed

Hello,

I will correct the Price in a Service line. Anyway in same cases ist works, in same cases not. Don't know why.

METHOD correct_service_line_4_order.DATA: lv_objectkey TYPE objidext.DATA: lt_methods TYPE bapi_alm_order_method_t.FIELD-SYMBOLS: <fs_method> TYPE bapi_alm_order_method.DATA: ls_header TYPE bapi_alm_order_headers_i,
lt_header TYPE STANDARD TABLE OF bapi_alm_order_headers_i,
ls_header_up TYPE bapi_alm_order_headers_up,
lt_header_up TYPE STANDARD TABLE OF bapi_alm_order_headers_up.DATA: ls_operation TYPE bapi_alm_order_operation,
lt_operation TYPE STANDARD TABLE OF bapi_alm_order_operation,
ls_operation_up TYPE bapi_alm_order_operation_up,
lt_operation_up TYPE STANDARD TABLE OF bapi_alm_order_operation_up.FIELD-SYMBOLS: <fs_operations> TYPE bapi_alm_order_operation_e,
<fs_ml_esll> TYPE ml_esll.DATA: ls_srvoutline TYPE bapi_alm_srv_outline,
lt_srvoutline TYPE STANDARD TABLE OF bapi_alm_srv_outline,
ls_srvoutline_up TYPE bapi_alm_srv_outline_up,
lt_srvoutline_up TYPE STANDARD TABLE OF bapi_alm_srv_outline_up.DATA: ls_service_line TYPE bapi_alm_srv_service_line,
lt_service_line TYPE STANDARD TABLE OF bapi_alm_srv_service_line,
ls_service_line_up TYPE bapi_alm_srv_service_line_up,
lt_service_line_up TYPE STANDARD TABLE OF bapi_alm_srv_service_line_up.FIELD-SYMBOLS: <fs_service_line_old> TYPE bapi_alm_srv_service_line.DATA: ls_bapiret TYPE bapiret2,
lt_bapiret TYPE bapiret2_t.FIELD-SYMBOLS: <fs_bapiret> TYPE bapiret2.DATA: lt_numbers TYPE bapi_alm_numbers_t.DATA: BEGIN OF ls_cnt,
refnumber TYPE ifrefnum,END OF ls_cnt.DATA: BEGIN OF lf,
srv_line TYPE kennzx,END OF lf.
" Inhalte zurücksetzenCLEAR: ls_cnt, lf, lv_objectkey,
lt_methods[],
ls_header, lt_header[], ls_header_up, lt_header_up[],
ls_operation, lt_operation[], ls_operation_up, lt_operation_up[],
ls_srvoutline, lt_srvoutline[], ls_srvoutline_up, lt_srvoutline_up[],
ls_service_line, lt_service_line[], lt_service_line_up[],
lt_bapiret.
" Konvertierung der bestehenden Strukturen und Tabellen" AuftragskopfMOVE-CORRESPONDING is_header TO ls_header.APPEND ls_header TO lt_header.MOVE ls_header-orderid TO ls_header_up-orderid.APPEND ls_header_up TO lt_header_up.
" Prüfen und aktualisieren der LeistungenIF lines( it_service_line ) = lines( gs_data_in-t_ml_esll )AND gs_data_in-ebeln IS NOT INITIALAND lines( gs_data_in-t_ml_esll ) > 0.* Header hinzufügen - ÄnderungAPPEND INITIAL LINE TO lt_methods ASSIGNING <fs_method>.
ls_cnt-refnumber = ls_cnt-refnumber + 1.
<fs_method>-refnumber = ls_cnt-refnumber.
<fs_method>-objecttype = 'HEADER'.
<fs_method>-method = 'CALCULATE'.
<fs_method>-objectkey = ls_header-orderid.
* Leistungen einstellen -> direkt aus dem Kontrakt
lv_objectkey = ls_header-orderid." Services an die Vorgänge hängenLOOP AT it_operations ASSIGNING <fs_operations>.* ls_cnt-refnumber = ls_cnt-refnumber + 1.MOVE-CORRESPONDING <fs_operations> TO ls_operation." Vorgangsdaten Kontrakt einfügen
ls_operation-agreement = gs_data_in-ebeln. " Kontrakt
ls_operation-agmt_item = gs_data_in-ebelp. " KontraktpositionAPPEND ls_operation TO lt_operation." Methode für Operations einstellen
ls_operation_up-agreement = 'X'. " Kontrakt
ls_operation_up-agmt_item = 'X'. " KontraktpositionAPPEND ls_operation_up TO lt_operation_up." Methode für Operations einstellenAPPEND INITIAL LINE TO lt_methods ASSIGNING <fs_method>.
<fs_method>-refnumber = ls_cnt-refnumber.
<fs_method>-objecttype = 'OPERATION'.
<fs_method>-method = 'CHANGE'.CONCATENATE ls_header-orderid ls_operation-activity INTO <fs_method>-objectkey.CONDENSE <fs_method>-objectkey NO-GAPS.
LOOP AT it_service_line ASSIGNING <fs_service_line_old>.CLEAR: lf-srv_line.READ TABLE gs_data_in-t_ml_esll ASSIGNING <fs_ml_esll>WITH KEY srvpos = <fs_service_line_old>-service
del = abap_false.IF sy-subrc = 0." Leistungspreis aus Kontrakt übernehmen* ls_service_line-service = <fs_service_line_old>-service.IF <fs_service_line_old>-short_text <> <fs_ml_esll>-ktext1.
ls_service_line-short_text = <fs_ml_esll>-ktext1.
ls_service_line_up-short_text = 'X'.
ls_srvoutline-short_text = ls_service_line-short_text.
lf-srv_line = abap_true.ELSE.
ls_srvoutline-short_text = <fs_service_line_old>-short_text.ENDIF.IF <fs_service_line_old>-quantity <> <fs_ml_esll>-peinh.
ls_service_line-quantity = <fs_ml_esll>-peinh.
ls_service_line_up-quantity = 'X'.
lf-srv_line = abap_true.ENDIF.* ls_service_line-uom = <fs_service_line_old>-uom.* ls_service_line-uom_iso = <fs_service_line_old>-uom_iso.IF <fs_service_line_old>-gross_price <> <fs_ml_esll>-tbtwr.
ls_service_line-gross_price = <fs_ml_esll>-tbtwr.
ls_service_line_up-gross_price = 'X'.
lf-srv_line = abap_true.ENDIF.IF <fs_service_line_old>-net_price <> <fs_ml_esll>-tbtwr.
ls_service_line-net_price = <fs_ml_esll>-tbtwr.
ls_service_line_up-net_price = 'X'.
lf-srv_line = abap_true.ENDIF.IF <fs_service_line_old>-currency <> <fs_ml_esll>-waers.
ls_service_line-currency = <fs_ml_esll>-waers.
ls_service_line_up-currency = 'X'.
lf-srv_line = abap_true.ENDIF.IF <fs_service_line_old>-price_unit <> <fs_ml_esll>-peinh.
ls_service_line-price_unit = <fs_ml_esll>-peinh.
ls_service_line_up-price_unit = 'X'.
lf-srv_line = abap_true.ENDIF.IF <fs_service_line_old>-matl_group <> <fs_ml_esll>-matkl.
ls_service_line-matl_group = <fs_ml_esll>-matkl.
ls_service_line_up-matl_group = 'X'.
lf-srv_line = abap_true.ENDIF.IF lf-srv_line EQ abap_true." SRVOUTLINE
ls_srvoutline-activity = <fs_service_line_old>-activity.
ls_srvoutline-outline = <fs_service_line_old>-outline.* ls_srvoutline-short_text = ls_service_line-short_text.APPEND ls_srvoutline TO lt_srvoutline.
ls_srvoutline_up-activity = <fs_service_line_old>-activity.
ls_srvoutline_up-outline = <fs_service_line_old>-outline.
ls_srvoutline_up-short_text = 'X'.APPEND ls_srvoutline_up TO lt_srvoutline_up." SERVICE_LINE
ls_service_line-activity = <fs_service_line_old>-activity.
ls_service_line-outline = <fs_service_line_old>-outline.
ls_service_line-srv_line = <fs_service_line_old>-srv_line.APPEND ls_service_line TO lt_service_line.
ls_service_line_up-activity = <fs_service_line_old>-activity.
ls_service_line_up-outline = <fs_service_line_old>-outline.
ls_service_line_up-srv_line = <fs_service_line_old>-srv_line.APPEND ls_service_line_up TO lt_service_line_up.
" Methode für Service_Outline einstellenCONCATENATE ls_header-orderid ls_srvoutline-activity INTO lv_objectkey.CONDENSE lv_objectkey NO-GAPS.APPEND INITIAL LINE TO lt_methods ASSIGNING <fs_method>.
<fs_method>-refnumber = ls_cnt-refnumber.
<fs_method>-objecttype = 'SERVICEOUTLINE'.
<fs_method>-method = 'CHANGE'.CONCATENATE ls_header-orderid ls_srvoutline-activity INTO <fs_method>-objectkey .CONDENSE <fs_method>-objectkey NO-GAPS." Methode für Service_Line einstellenAPPEND INITIAL LINE TO lt_methods ASSIGNING <fs_method>.
<fs_method>-refnumber = ls_cnt-refnumber.
<fs_method>-objecttype = 'SERVICELINE'.
<fs_method>-method = 'CHANGE'.CONCATENATE ls_header-orderid ls_service_line-activity INTO <fs_method>-objectkey .CONDENSE <fs_method>-objectkey NO-GAPS.ENDIF.ENDIF.
ls_cnt-refnumber = ls_cnt-refnumber + 1.ENDLOOP.ENDLOOP.
* Funktion SpeichernIF lf-srv_line EQ abap_true.* ls_cnt-refnumber = ls_cnt-refnumber + 1.APPEND INITIAL LINE TO lt_methods ASSIGNING <fs_method>.
<fs_method>-refnumber = ls_cnt-refnumber - 1.
<fs_method>-objecttype = ''.
<fs_method>-method = 'SAVE'.
<fs_method>-objectkey = ls_header-orderid.
* Auftrag freigebenCALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
it_operation = lt_operation
it_operation_up = lt_operation_up
it_serviceoutline = lt_srvoutline
it_serviceoutline_up = lt_srvoutline_up
it_servicelines = lt_service_line
it_servicelines_up = lt_service_line_upreturn = lt_bapiret.* et_numbers = lt_numbers.
* Löschen Success oder InformationsmeldungenLOOP AT lt_bapiret ASSIGNING <fs_bapiret>.
delete_msgty_i_or_s( CHANGING cs_bapiret = <fs_bapiret> ).ENDLOOP.* Meldungen hinzufügen.
add_message_multi( lt_bapiret ).
IF check_error_exist_local( lt_bapiret ) = abap_false.* Verbuchung durchfürhren.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = 'X'IMPORTINGreturn = ls_bapiret.* Löschen Success oder Informationsmeldungen
delete_msgty_i_or_s( CHANGING cs_bapiret = ls_bapiret ).* Meldung hinzufügen -> falls aufgetreten.
add_message( ls_bapiret ).
cv_rc = cv_rc + 0.ELSE.* Verbuchung zurückdrehen.CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
cv_rc = cv_rc + 4.ENDIF.
* Systemvariablen zurücksetzenCALL FUNCTION 'PERMIT_INIT_AFTER_POST'.CALL FUNCTION 'CO_DB_DATA_RESET'.CALL FUNCTION 'CO_BH_DATA_RESET'.CALL FUNCTION 'CO_BR_DATA_RESET'.CALL FUNCTION 'CO_PD_DATA_RESET'.CALL FUNCTION 'CO_SF_DATA_RESET'.CALL FUNCTION 'CO_SD_DATA_RESET'.CALL FUNCTION 'CO_ZV_DATA_RESET'.CALL FUNCTION 'CO_OCM_BT_DATA_RESET'.CALL FUNCTION 'CO_FW_DATA_RESET'.* Nochmals prüfen, ob Fehler vorhanden.IF check_error_exist_local( lt_bapiret ) = abap_false.* Erfolgsmeldung wegschreiben" In den Auftrag &1 wurde die Leistungen zugefügt.IF 2 = 3. MESSAGE ID 'ZIPM_FTTH' TYPE 'S' NUMBER '025'. ENDIF.MESSAGE ID zi_if_ftth_constants=>gc_msgid TYPE zi_cl_msg=>c_type_success NUMBER 025WITH ls_header-orderidINTO gv_dummy_message.
add_message( ).ELSE." In den Auftrag &1 wurde die Leitungen nicht zugefügt.IF 2 = 3. MESSAGE ID 'ZIPM_FTTH' TYPE 'E' NUMBER '026'. ENDIF.MESSAGE ID zi_if_ftth_constants=>gc_msgid TYPE zi_cl_msg=>c_type_error NUMBER 038WITH ls_header-orderidINTO gv_dummy_message.
add_message( ).
zcx_ih_exception=>raise( ).ENDIF.ELSE.TRY.IF 2 = 3. MESSAGE ID 'ZIPM_FTTH' TYPE 'E' NUMBER '024'. ENDIF.MESSAGE ID zi_if_ftth_constants=>gc_msgid TYPE zi_cl_msg=>c_type_error NUMBER 024WITH ls_header-orderidINTO gv_dummy_message.
add_message( ).
zcx_ih_exception=>raise( ).ENDTRY.ENDIF.ENDIF.
ENDMETHOD.

Have anybody an idea why?

Best regards

Christian

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.