‎2020 Dec 10 11:52 AM
Hello folks,
i have created a ALV Report to display Equipment data and a button in toolbar, with which you can jump off in transaction IE02 and change equipment master. After user Save in IE02 press and come back to report, i use BAPI to read Equiment Data again but i get old value instead of new value updated in IE02.
I have tried all options from CALL TRANSACTION with MODE and UPDATE, I also used the bapi BAPI_TRANSACTION_COMMIT after CALL TRANSACTION but still get the old value.
Only when i quit the current session and start the report again, so i get the correct data. By selecting data in DB, the updated data are saved in DB.
TRY.
CALL TRANSACTION 'IE02' WITH AUTHORITY-CHECK and SKIP FIRST SCREEN. "USING lt_bdc MODE 'A' UPDATE 'A' MESSAGES INTO lt_mess. "and SKIP FIRST SCREEN.
CATCH cx_sy_authorization_error.
RETURN.
ENDTRY.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
DATA:
lv_CUOBJ TYPE CUOBJ,
lt_kssk TYPE TABLE OF kssk,
lv_obj TYPE bapi1003_key-object,
lv_kssk_obj TYPE bapi1003_key-object,
lt_alloc TYPE TABLE OF bapi1003_alloc_list,
lt_return TYPE TABLE OF bapiret2.
lv_obj = <fs>. " <------ EQUNR
SELECT SINGLE CUOBJ FROM inob INTO lv_CUOBJ WHERE objek eq lv_obj and obtab eq 'EQUI' AND klart eq '002'.
SELECT * FROM kssk INTO CORRESPONDING FIELDS OF TABLE lt_kssk WHERE objek eq lv_CUOBJ.
CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
EXPORTING
objectkey_imp = lv_obj
objecttable_imp = 'EQUI'
classtype_imp = '002'
READ_VALUATIONS = 'X'
* keydate = sy-datum
* language = sy-langu
* OBJECTKEY_IMP_LONG =
TABLES
alloclist = lt_alloc
* ALLOCVALUESCHAR =
* ALLOCVALUESCURR =
* ALLOCVALUESNUM =
return = lt_return.
*
From Code above, table lt_kssk and table lt_alloc are always different. The data in table lt_kssk are always correct (select data directly from DB) and the data in lt_alloc not ( read data through BAPI).
By debugging i found out, that the data is buffered in Function Group of this BAPI somehow. My question is, is there any way to reset the buffer or how can i work around with this.
It happens with all BAPIs: BAPI_OBJCL_GETCLASSES, BAPI_EQUI_GETSTATUS etc..
I appreciate any help.
Thanks and regards,
Ton
‎2020 Dec 10 1:33 PM
Hello pis296
Now I understand you problem better. I must have overlooked the fact that you've already check UPDATE option of CALL TRANSACTION.
BAPI_OBJCL_GETCLASSES uses CLAP_DDB_* functions internally. They indeed use buffering. The function CLAP_DDB_INIT_CLASSIFICATION initializes all the buffers of the function group.
Also look at the note 438353 - ObjectClassification.GetClasses: Initialization that also refers to function CLAP_DDB_INIT_CLASSIFICATION.
Try calling CLAP_DDB_INIT_CLASSIFICATION before BAPI_OBJCL_GETCLASSES
HTH / BR
Dominik Tylczynski
‎2020 Dec 10 12:31 PM
Hello pis296
When you call a transaction using CALL TRANSACTION ... AND SKIP FIRST SCREEN you don't have a control on data update processing. Typically SAP updates the data asynchronously with update tasks. Therefore once you get out of the transaction and try to read the data, in fact the data is not changed in the database yet. BAPI_TRANSACTION_COMMIT won't help you here.
Instead you may want to call IE02 with CALL TRANSACTION ... USING ... MODE 'E' UPDATE 'S'. This way the data update is synchronous and once you are out of the transaction and back to your program all the changes are already written to the database. So you can read all the updated data.
Best regards
Dominik Tylczynski
‎2020 Dec 10 12:47 PM
Hello Dominik,
thank you for your quick response. As i mentioned above, i have tried all options of CALL TRANSACTION ( all combination of MODE and UPDATE), i still got the old value. After CALL TRANSACTION command i have tried to select data from Database and the updated value is saved (with 2 Select from code). Its somehow weird and im still searching for answer. Any idea?
Thanks and regards,
Ton
‎2020 Dec 10 1:33 PM
Hello pis296
Now I understand you problem better. I must have overlooked the fact that you've already check UPDATE option of CALL TRANSACTION.
BAPI_OBJCL_GETCLASSES uses CLAP_DDB_* functions internally. They indeed use buffering. The function CLAP_DDB_INIT_CLASSIFICATION initializes all the buffers of the function group.
Also look at the note 438353 - ObjectClassification.GetClasses: Initialization that also refers to function CLAP_DDB_INIT_CLASSIFICATION.
Try calling CLAP_DDB_INIT_CLASSIFICATION before BAPI_OBJCL_GETCLASSES
HTH / BR
Dominik Tylczynski
‎2021 Jan 30 8:31 PM
Hello Dominik,
this is a good hint, by resetting the buffer op the function group, i got the right value. Thank you very much for your response.
Best regard,
Ton
‎2021 Jan 31 9:45 AM
Isn't CLAP_DDB_INIT_CLASSIFICATION always called by BAPI_OBJCL_GETCLASSES since note 438353?
‎2021 Feb 01 9:46 AM