PM Partner Update Fonksiyon
evcut muhataplar PM_PARTNER_GET fonksiyonu ile alınır,
Değiştiirlmek istenen muhatap türü daha önceden var ise güncellenir, yok ise eklenir.
Hazırlanan muhatap listesi PM_PARTNER_UPDATE fonksiyonuna verilir.
Commit ŞART....
Dikkat edilmesi gereken hususlar :
- PARVW Conversion, AŞ=>AG
- counter = ls_ihpa_FULL-counter + 1 ya da 1(yeni muhatap)
function zps_partner_update.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_OBJNR) TYPE J_OBJNR
*" REFERENCE(I_PARVW) TYPE PARVW
*" REFERENCE(I_PARNR) TYPE I_PARNR
*" EXPORTING
*" VALUE(E_SUCCESS) TYPE ZPS_E_SUCCESS
*"----------------------------------------------------------------------
DATA: updkz_old(1) VALUE ` `, "Keine Veraenderung
updkz_new(1) VALUE `I`, "Neue Position
updkz_update(1) VALUE `U`, "Geaenderte Position
updkz_delete(1) VALUE `D`, "Löschen
updkz_inher(1) VALUE `E`, "Vererbt
updkz_delphy(1) VALUE `L`. "Physisch löschen
data: lt_ihpa_time type eam_t_ihpa_time.
data: lt_ihpa_tab type standard table of ihpavb.
data: lt_ihpa_full type standard table of ihpavb.
data: ls_ihpa_tab type ihpavb.
data: ls_ihpa_full type ihpavb.
data: ls_xihpa type ihpavb.
data: lt_xihpa type standard table of ihpavb.
call function `PM_PARTNER_GET`
exporting
objnr = i_objnr
i_from_db = `X`
importing
* DIADR_WA =
et_ihpa_time = lt_ihpa_time
tables
ihpa_tab = lt_ihpa_tab
* IHPA_TAB_BEFORE =
.
lt_ihpa_full[] = lt_ihpa_tab[].
delete lt_ihpa_tab where kzloesch = `X`.
sort lt_ihpa_tab by parvw.
sort lt_ihpa_full by parvw counter.
read table lt_ihpa_tab into ls_ihpa_tab with key parvw = `AG` binary search.
if sy-subrc eq 0."Kayıt var Update olacak
ls_xihpa = ls_ihpa_tab.
ls_xihpa-updkz = updkz_update.
ls_xihpa-counter = ls_ihpa_tab-counter.
else."Kayıt yoh, Insert olacak
ls_xihpa-updkz = updkz_new.
read table lt_ihpa_full into ls_ihpa_full with key parvw = `AG` binary search.
if sy-subrc eq 0.
ls_xihpa-counter = ls_ihpa_full-counter + 1.
else.
ls_xihpa-counter = 1.
endif.
endif.
ls_xihpa-mandt = sy-mandt.
ls_xihpa-objnr = i_objnr.
ls_xihpa-erdat = sy-datum.
ls_xihpa-erzeit = sy-uzeit.
ls_xihpa-ernam = sy-uname.
ls_xihpa-aedat = sy-datum.
ls_xihpa-aezeit = sy-uzeit.
ls_xihpa-aenam = sy-uname.
call function `CONVERSION_EXIT_ALPHA_INPUT`
exporting
input = i_parnr
importing
output = ls_xihpa-parnr.
call function `CONVERSION_EXIT_PARVW_INPUT`
exporting
input = i_parvw
importing
output = ls_xihpa-parvw.
append ls_xihpa to lt_xihpa.
if not lt_xihpa[] is initial.
call function `PM_PARTNER_UPDATE`
tables
fxihpa = lt_xihpa.
case sy-subrc.
when 0.
e_success = `X`.
when others.
e_success = space.
endcase.
endif.
endfunction.