Skip to Content
0

Using BAPI_OBJCL_CHANGE

Oct 27, 2016 at 01:42 PM

871

avatar image

I've looked at a ton of entries in the questions but I probably don't know enough to undersrtand what i'm reading.

So here is the issue.

We have a program that updates batch characteristics based on some business process requirements. This works.

However, we will have some numeric characteristics that have no values, (i.e. null or in SAP parlence, not not-initial) when the program runs. When the program is done, the batch values now shows as 0.00 and not null for these characteristics. The developers solution for this was to go back and delete them. But this resutls in change records showing a value of 0.00 created and a value of 0.00 deleted in the batch change records. Not good and not accurate.

I know in the underlaying tables there is an indicator flag, (initial/not-initial), that tells the system whether the value stored (0.0000000000) is really a true zero, or null.

My developers are telling me that is how BABI_OBJCL_CHANGE works. I disagree. There must be a way to use BABI_OBCJL_CHANGE to only update the characteristics you want to and not have it "default" in 0.00 for numeric characteristics that the program shouldn't even touch or know about.

Any suggestions as to what I can suggest to my developers?

Thanks!

Craig

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Samuli Kaski Oct 28, 2016 at 01:37 PM
0

The BAPI has a parameter for not setting default values, that will allow you to add characteristic without setting a value. I'll look up the logic once I get to the office.

Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hi Samuli,

are you talking about NO_DEFAULT_VALUES import parameter?

1

keep_same_defaults = 'X' ? (see OSS Note 1930673 - BAPI_OBJCL_CHANGE: Interface enhancement)

2

Thanks Pablo: I just downloaded and installed it :)

1

I just checked. I'm using the flags NO_DEFAULT_VALUES and KEEP_SAME_DEFAULTS mentioned by Simone and Pablo in my program to avoid the mentioned issue. You have to explicitly set a non initial value for any characteristic for it to be set/changed.

1

Also just to be clear, I am specifcally referring to batch class 023. I think that class has some special nuances to it vs. say material class 001 or vendor class 010.

Craig

0

The behaviour should be the same.

Try to give your Abapers the OSS note from Pablo and link them this thread :)

1

Thank you so much for your help! That's exactly what I did! Hopefully they'll look at it and I'll hear something next week on it.

Craig

0
Pablo Casamayor Oct 28, 2016 at 08:06 AM
0

Hi,

maybe you could use fm 'BAPI_OBJCL_EXISTENCECHECK' as it is used in fm CKCVAL_COSTING_CHARVAL_SET.

check first and according to the result change or...whatever you decide

e.g.

CALL FUNCTION 'BAPI_OBJCL_EXISTENCECHECK'
    EXPORTING
      objectkey         = lf_class-objek
      objecttable       = lf_class-obtab
      classnum          = lf_class-class
      classtype         = lf_class-classtype
*     KEYDATE           = SY-DATUM
    tables
      return            = lt_return.
  LOOP AT LT_RETURN WHERE TYPE = 'S'.
    EXIT.
  ENDLOOP.
  if SY-SUBRC = 0.
* Change the characteristic valuation
    CALL FUNCTION 'BAPI_OBJCL_CHANGE'
      EXPORTING
        objectkey                = lf_class-objek
        objecttable              = lf_class-obtab
        classnum                 = lf_class-class
        classtype                = lf_class-classtype
*       STATUS                   = '1'
*       STANDARDCLASS            =
*       CHANGENUMBER             =
*       KEYDATE                  = SY-DATUM
      tables
        allocvaluesnumnew        = LT_VALUESNUM
        allocvaluescharnew       = LT_VALUESCHAR
        allocvaluescurrnew       = LT_VALUESCURR
        return                   = LT_RETURN.
  else.
* Create the characterisitc valuation
    refresh lt_return.
    CALL FUNCTION 'BAPI_OBJCL_CREATE'
      EXPORTING
        objectkeynew          = lf_class-objek
        objecttablenew        = lf_class-obtab
        classnumnew           = lf_class-class
        classtypenew          = lf_class-classtype
*       STATUS                = '1'
*       STANDARDCLASS         =
*       CHANGENUMBER          =
*       KEYDATE               = SY-DATUM
      tables
        ALLOCVALUESNUM        = LT_VALUESNUM
        ALLOCVALUESCHAR       = LT_VALUESCHAR
        ALLOCVALUESCURR       = LT_VALUESCURR
        return                = lt_return.
  endif.
<br>

Best regards,

Pablo

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks for your suggestion Pablo.

Isn't this check just telling me however that classification has occurred? It's not going to tell me for any one specific numeric characteristic of the value of 0.00 is actually a null value or a real value of 0.00? (see my comment on next answer)

0

Hi,

check BAPI_OBJCL_GETDETAIL and within that bapi have a look at fm CTMS_DDB_HAS_VALUES_INTERNAL that returns internal table lit_valtab.

Regards,

Pablo

1
Simone Milesi Oct 28, 2016 at 08:23 AM
0
There must be a way to use BABI_OBCJL_CHANGE to only update the characteristics you want to and not have it "default" in 0.00 for numeric characteristics that the program shouldn't even touch or know about.

In the BAPI's documentation

The information transferred by this BAPI replaces all old information. An empty field means "delete entry!", not "no change".

If you do not pass a characteristic, it looks like a deletion and avoid the enter 0 and then delete (or not create!) the characteristic you want to keep null.

Sadly, there is no option in the characteristics' tables of this bapi to set that flag.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

So are you saying that for those where we want the value to remain as null, we must delete the characteristic from the structure that is passed back? My understanding is that when the characteristics are obtained, the value shows a 0.00 (format based on charac.).

From what I understand, if I have an existing value, and fail to pass that same value back, it will be deleted.

So first I get all the characteristics via the module. When SAP provides them to me, the numeric value will show as 0.00. I'm really only talking about those characteristics in the ALLOCVALUESNUM structure.

I then have to update the ones I want to update. If I want to have a null value, I have to delete the entire characterisitc from the structure being passed back. Do I have that part right?

So the question would be, if SAP passes me 0.00 for all null characteristics when ALLOCVALUESNUM is imported, how am I to determine if that is a valid 0.00 or a null?

The FM Pablo suggested only appears to determine if classification has happened. It's not telling me about any one particular characteristic value.

Am I understanding this right?

0
avatar image
Former Member Nov 18, 2016 at 11:45 AM
0

Sorry, I could not solve my problem with"KEEP_SAME_DEFAULTS= 'X'".

we have several numeric characteritics in our classification (class 023) which appear as blank

when not filled with value.

When I want to change only some of them viaCALL FUNCTION 'BAPI_OBJCL_CHANGE'

those ones not updated appear as 0,0afterwards.Of course thats not good because 0 could

be a real value…

Hope to get good advice, here's part of my coding:

______________________________________________

* Zurückschreiben der Chargenmerkmale

*

CLEAR: it_put_return.

CALL FUNCTION 'BAPI_OBJCL_CHANGE'

EXPORTING

OBJECTKEY= put_objectkey

OBJECTTABLE= put_objecttable

CLASSNUM= put_classnum

CLASSTYPE= put_classtype

*STATUS= put_status

*STANDARDCLASS= put_standardclass

*CHANGENUMBER= put_changenumber

*KEYDATE= put_keydate

*NO_DEFAULT_VALUES= put_nodefvalues

KEEP_SAME_DEFAULTS= 'X'

*CLASSIF_STATUS= put_class_status

TABLES

ALLOCVALUESNUMnew= it_put_valnum

ALLOCVALUESCHARnew= it_put_valchar

ALLOCVALUESCURRnew= it_put_valcurr

RETURN= it_put_return.

* WICHTIG: Transaction Commit

COMMIT WORK.

CALL FUNCTION 'BUFFER_REFRESH_ALL'.

____________________________________________

THANK YOU !

Share
10 |10000 characters needed characters left characters exceeded