Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_OBJCL_CREATE and KEYDATE field

Former Member
0 Likes
3,121

All,

I am trying to use BAPI_OBJCL_CREATE to create object classification for equipment whereby the date of classification change is a date in the past. This is to meet a requirement for data migration.

See below for an example of the BAPI call.  What I expect is that the change will be tagged with the value passed to KEYDATE.  (Ideally that would get passed to CDHDR-UDATE). That is not happening.  Instead, the changes are getting marked with today's date which is what happens if no value is passed to the KEYDATE parameter.  Change logging for class type '002' has been turned on.   I've tried both passing and not passing a change master.  I've also tried passing a future date to see if I could find the irght combination of parameters and thus provide evidence that keydate matters (for create) only if a future date.  I've looked in fields such as AUSP-DATUV and INOB-DATUV to see if the KEYDATE is showing up there and it is not.

Any thoughts?  Am I misunderstanding the purpose of KEYDATE?   I've debugged and I see it connected to the valid-from date but I can't see where it is getting dropped. 

I have searched OSS with key words BAPI_OBJCL_CREATE and KEYDATE, reading the ~25 notes and come up with nothing good.  Please don't post the function module documentation.  I've read that as well.

Thanks,

Albert

CALL FUNCTION 'BAPI_OBJCL_CREATE'

   EXPORTING

     objectkeynew                = p_eq

     objecttablenew              = 'EQUI'

     classnumnew                 = 'EQU_CYLINDER'

     classtypenew                = '002'

*   STATUS                   = '1'

*   STANDARDCLASS            =

   CHANGENUMBER             = '000000100205'

    KEYDATE                  = p_chg_dt

*   NO_DEFAULT_VALUES        = ' '

* IMPORTING

*   CLASSIF_STATUS           =

   TABLES

     allocvaluesnum        = i_num_val

     allocvalueschar       = i_char_val

     allocvaluescurr      = i_curr_val

     RETURN                   = i_ret.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,399

Hi Albert.

importing parameter KEYDATE may be overwritten or not used.

If you already have SAP note 2038603 then it may be overwritten in BAPI_OBJCL_CREATE.

Then this parameter will be passed to importing parameter I_DATUV of function module CACL_OBJECT_VALIDATION_MAINT. There field AENR-DATUV sometimes will be filled from it. But this only happens, if some conditions are fulfilled.

See code lines after comment line

* set date

Regards,

Klaus

4 REPLIES 4
Read only

Former Member
0 Likes
2,400

Hi Albert.

importing parameter KEYDATE may be overwritten or not used.

If you already have SAP note 2038603 then it may be overwritten in BAPI_OBJCL_CREATE.

Then this parameter will be passed to importing parameter I_DATUV of function module CACL_OBJECT_VALIDATION_MAINT. There field AENR-DATUV sometimes will be filled from it. But this only happens, if some conditions are fulfilled.

See code lines after comment line

* set date

Regards,

Klaus

Read only

0 Likes
2,399

Klaus,

Thanks for the suggestion.  The note 2038603 is not in our system but I replicated the behavior of the note by ensuring KEYDATE was the same as the effectivity date on the change master and got the same result that I've been seeing. 

Was your response cut short or were you referring to the code lines after the comment in the OSS note?  I was hoping you might have laid out some of the conditions under which the date will be set so I could check my data and configuration against them. 

Regards,

Albert

Read only

0 Likes
2,399

Hi Albert,

I was referring to the code lines in function module CACL_OBJECT_VALIDATION_MAINT after the commet line

* set date

In complete I've ment this code lines:

* set date

  clear rumpf_mat.

  if change_no is initial.

    aenr-datuv = sy-datum.

  else.

    call function 'CLEF_EFFECTIVITY_USED'

         exporting

              i_aennr          = change_no

              i_classtype      = class_type

         importing

              e_effe_aennr     = g_effectivity_used

         exceptions

              klart_not_active = 1

              others           = 2.

    if g_effectivity_used is initial.

      select single datuv from aenr into aenr-datuv

                          where aennr eq change_no.

      if syst-subrc > 0.

        syst-subrc = 19.

        perform LOG_OBJECT using 'E' CLASS_TYPE               "  1302674

                                     OBJECT_TYPE OBJEKT.      "  1302674

        perform error_upd using syst-subrc change_no

                                class_type class.

        perform end_of_api using 'E'.

      endif.

    else.

      aenr-datuv = i_datuv.

    endif.

  endif.

Here you can see three different ways how field AENR-DATUV is filled.

Regards,

Klaus

Read only

0 Likes
2,399

Klaus,

Thanks.  This pointed me in the right direction.  I had to change some config on the class type to make it work, namely, checking the ECH box in the IMG for the class type and then classifying an object for the first time.  Once it had been initially classified with ECH on then the keydate when passed (and aligned to the change master) would date on/date off changes.  I could then look in the equipment and specify a date when navigating to the characteristics tab.

Ultimately, the functional/business folks decided they didn't like the overhead, but now I know. 

Albert