cancel
Showing results for 
Search instead for 
Did you mean: 

FUNC_LOCATION_UPDATE with change document

former_member204457
Active Participant
0 Kudos

hi gurus, I'm using FM FUNC_LOCATION_UPDATE to change 2 custom fields in functional location. I've activated the change documents in the fields and when I make the changes through IL02, change document is created. However, when I use the FM, no change document is generated and no update takes place in CDPOS and CDHDR, although the values do get changed in the record. Below is my code

function zqfloclatlong.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_TPLNR) LIKE IFLOT-TPLNR
*" REFERENCE(I_LAT) LIKE IFLOT-ZQLAT
*" REFERENCE(I_LONG) LIKE IFLOT-ZQLONG
*" TABLES
*" E_IFLOT STRUCTURE IFLOT
*"----------------------------------------------------------------------

data: n_iflo like iflo,
o_iflo like iflo,
lriupd_new type riupd,
lriupd_old type riupd,
change_doc type t370f-chdoc.


select single * from iflot into e_iflot where
tplnr = i_tplnr.
if sy-subrc = 0.
move-corresponding e_iflot to o_iflo.
endif.

move-corresponding e_iflot to n_iflo.
move i_lat to n_iflo-zqlat.
move i_long to n_iflo-zqlong.
clear lriupd_old.
lriupd_new-indupd = 'U'.
lriupd_new-indupd1 = 'U'.

lriupd_old-indupd = 'I'.
lriupd_old-indupd1 = 'I'.
change_doc = 'X'.


call function 'FUNC_LOCATION_UPDATE'
exporting
iflo_new = n_iflo
iflo_old = o_iflo
* INHB_COUNTER = 0
* INHB_DELETE = ' '
riupd_new = lriupd_new
riupd_old = lriupd_old
update_asynchron = space
WITH_CHANGE_DOCU = change_doc.
.

endfunction.

Accepted Solutions (1)

Accepted Solutions (1)

NTeunckens
Active Contributor

Could you check if the same behaviour occurs when using the BAPI "BAPI_FUNCLOC_CHANGE", which probably will be recommended by SAP? Provided SAP-KBA 2146575 is implemented, you could make use of this BAPI and it's "EXTENSION*"-Tables to enable the update of Custom Fields ...

If either the regular FM or BAPI produces strange results, you can always report to SAP via ONE Support Launchpad ...

Answers (4)

Answers (4)

peter_atkin
Active Contributor
0 Kudos

Cyrus,

Which table did you append on the FLoc?

PeteA

former_member204457
Active Participant
0 Kudos

I was doing a change to Flocs so I used the method IF_EX_BADI_EAM_ITOB_CUST_FIELD~EXTENSIONIN_FUNCLOC_CHANGE in the es ES_EAM_ITOB_BAPI_CUST_FIELDS this is the code that I used, basically changing the coordinates (latitude and longitude) which are custom fields in the table IFLOT

DATA: ls_extensionin TYPE bapiparex,
fs_extensionin TYPE bapiparex.DATA: lat_d_char TYPE iflot-lat_d,
lat_m_char TYPE iflot-lat_m,
lat_s_char TYPE iflot-lat_s,
lng_d_char TYPE iflot-lng_d,
lng_m_char TYPE iflot-lng_m,
lng_s_char TYPE iflot-lng_s,
lat_d_dec TYPE iflot-lat_no,
lng_d_dec TYPE iflot-lng_no.DATA: tmp_lat_dec TYPE iflot-lat_no,
tmp_lng_dec TYPE iflot-lng_no,
tmp_lat_deg TYPE iflot-lat_d,
tmp_lat_min TYPE iflot-lat_m,
tmp_lat_sec TYPE iflot-lat_s,
tmp_lng_deg TYPE iflot-lng_d,
tmp_lng_min TYPE iflot-lng_m,
tmp_lng_sec TYPE iflot-lng_s.
LOOP AT it_extensionin INTO fs_extensionin.CASE fs_extensionin-structure.WHEN 'LAT_NO'.
tmp_lat_dec = fs_extensionin-valuepart1(9).IF tmp_lat_dec IS NOT INITIAL.CALL METHOD me->convert_latdec_to_latdmsEXPORTING
i_lat_dec = tmp_lat_decCHANGING
o_lat_d = lat_d_char
o_lat_m = lat_m_char
o_lat_s = lat_s_char.ENDIF.WHEN 'LNG_NO'.
tmp_lng_dec = fs_extensionin-valuepart1+9(11).IF tmp_lng_dec IS NOT INITIAL.CALL METHOD me->convert_lngdec_to_lngdmsEXPORTING
i_lng_dec = tmp_lng_decCHANGING
o_lng_d = lng_d_char
o_lng_m = lng_m_char
o_lng_s = lng_s_char.ENDIF.WHEN 'LAT_D'.
tmp_lat_deg = fs_extensionin-valuepart1+20(4).WHEN 'LAT_M'.
tmp_lat_min = fs_extensionin-valuepart1+24(2).WHEN 'LAT_S'.
tmp_lat_sec = fs_extensionin-valuepart1+26(5).IF tmp_lat_deg IS NOT INITIAL AND tmp_lat_min IS NOT INITIAL AND tmp_lat_sec IS NOT INITIAL.CALL METHOD me->convert_latdms_to_latdecEXPORTING
iv_deg_char = tmp_lat_deg
iv_min_char = tmp_lat_min
iv_sec_char = tmp_lat_secCHANGING
cv_dec_char = lat_d_dec.ENDIF.WHEN 'LNG_D'.
tmp_lng_deg = fs_extensionin-valuepart1+31(4).WHEN 'LNG_M'.
tmp_lng_min = fs_extensionin-valuepart1+35(2).WHEN 'LNG_S'.
tmp_lng_sec = fs_extensionin-valuepart1+37(5).IF tmp_lng_deg IS NOT INITIAL AND tmp_lng_min IS NOT INITIAL AND tmp_lng_sec IS NOT INITIAL.CALL METHOD me->convert_lngdms_to_lngdecEXPORTING
iv_deg_char = tmp_lng_deg
iv_min_char = tmp_lng_min
iv_sec_char = tmp_lng_secCHANGING
cv_dec_char = lng_d_dec.ENDIF.ENDCASE.ENDLOOP.
LOOP AT it_extensionin INTO ls_extensionin.CASE ls_extensionin-structure.
WHEN 'LAT_NO'.IF ls_extensionin-valuepart1 IS NOT INITIAL.
cs_object-lat_no = ls_extensionin-valuepart1.
ELSE.
cs_object-lat_no = lat_d_dec.ENDIF.
WHEN 'LNG_NO'.IF ls_extensionin-valuepart1+9 IS NOT INITIAL.
cs_object-lng_no = ls_extensionin-valuepart1+9.ELSE.
cs_object-lng_no = lng_d_dec.
ENDIF.WHEN 'LAT_D'.IF ls_extensionin-valuepart1+20 IS NOT INITIAL.
cs_object-lat_d = ls_extensionin-valuepart1+20.
ELSE.
cs_object-lat_d = lat_d_char.
ENDIF.
WHEN 'LAT_M'.IF ls_extensionin-valuepart1+24 IS NOT INITIAL.
cs_object-lat_m = ls_extensionin-valuepart1+24.ELSE.
cs_object-lat_m = lat_m_char.ENDIF.
WHEN 'LAT_S'.IF ls_extensionin-valuepart1+26 IS NOT INITIAL.
cs_object-lat_s = ls_extensionin-valuepart1+26.
ELSE.
cs_object-lat_s = lat_s_char.ENDIF.
WHEN 'LNG_D'.IF ls_extensionin-valuepart1+31 IS NOT INITIAL.
cs_object-lng_d = ls_extensionin-valuepart1+31.ELSE.
cs_object-lng_d = lng_d_char.ENDIF.
WHEN 'LNG_M'.IF ls_extensionin-valuepart1+35 IS NOT INITIAL.
cs_object-lng_m = ls_extensionin-valuepart1+35.ELSE.
cs_object-lng_m = lng_m_char.ENDIF.
WHEN 'LNG_S'.IF ls_extensionin-valuepart1+37 IS NOT INITIAL.
cs_object-lng_s = ls_extensionin-valuepart1+37.ELSE.
cs_object-lng_s = lng_s_char.ENDIF.


ENDCASE.

former_member204457
Active Participant
0 Kudos

It was a bit painful 🙂 but was able to finally figure it out...thanks for the hints

NTeunckens
Active Contributor
0 Kudos

Great to see it worked out ...

Please mark your Question as Answered if that is the case ...


Kind regards

Nic T.

former_member204457
Active Participant
0 Kudos

any other suggestions?

former_member204457
Active Participant
0 Kudos

Thanks for that Nic, I've looked at the BAPI and note that you mentioned using the EXTENSIONIN and EXTENSIONOUT...unfortunately SAP hasn't provided an example on how this should be handled using ES_EAM_ITOB_BAPI_CUST_FIELDS and I can't wrap my head around it....have you used the BAPI in combination with the BADI to handle the custom fields? If so can you give me an example on how this can be done.

NTeunckens
Active Contributor

No specific sample code on THAT BAPI, but the EXTENSION-Tables are pretty much filled the same way for (all / most) BAPI's, so here are some samples : link / link / blog / ...