Skip to Content
avatar image
Former Member

FUNC_LOCATION_UPDATE with change document

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    May 03, 2017 at 10:50 PM

    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 ...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 04, 2017 at 01:37 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 07, 2017 at 02:13 AM

    any other suggestions?

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 28, 2017 at 06:40 AM

    Cyrus,

    Which table did you append on the FLoc?

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • avatar image
    Former Member
    Jul 26, 2017 at 09:45 PM

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

    Add comment
    10|10000 characters needed characters exceeded