2018年6月13日星期三

Solution to solve call bapi without wait. (Especialy BAPI_PS_PRECOMMIT)

When you use bapi to update the data of sap standard table, when you use BAPI_TRANSACTION_COMMIT function and set wait = ‘X’, but some times it doesn't work.

MAYBE  LIKE  THIS

LOOP.
  CALL function 'BAPI_XXXXX'

  CALL function 'BAPI_TRANSACTION_COMMIT'
   exporting
   wait 'X'.

 
endloop.


The reason is there are many functions called in update task in the bapi.

when the commit command is executed,the functions registered in update task

begin to execute.

You can get the data from vbdata vbmod table and execute them before commit command. when all functions where executed you can delete the data from vbmod
and vbkey table.




 






abap GET VBKEY of CALL FUNCTION IN UPDATE TASK

When we call a function in update task, it stores the data in vbmod, vbhrd and vbdata table.
How to get the vbkey of the current  transaction.

DATA:TH_OPCODE(1)         TYPE X.                "#EC *


CONSTANTSSTART_VB       LIKE TH_OPCODE VALUE 1,"#EC *
           GET_VB_KEY     LIKE TH_OPCODE VALUE 2.


TYPESbegin of %_vbkey,
         head(2),
         vbkey type vbdata-vbkey,
       end of %_vbkey.


DATA:   l_enqkey   type eqeusrvb,
        l_vbkey    type %_vbkey,
        l_enqdone  type length 1.


DATAlt_psguid_ins TYPE TABLE OF psguid WITH HEADER LINE.
DATAls_psguid_ins LIKE psguid.
DATAlt_psguid_upd TYPE TABLE OF psguid WITH HEADER LINE.
DATAls_psguid_upd LIKE psguid.


CALL FUNCTION 'PS_GUID_POST' in update task
       TABLES
            PSGUID_INS lt_psguid_ins
            PSGUID_UPD lt_psguid_upd.



CALL 'ThVBCall'    id 'OPCODE' field get_vb_key

                   id 'VBKEY'   field l_vbkey-vbkey            "#EC *
                   id 'ENQKEY'  field l_enqkey
                   id 'ENQDONE' field l_enqdone.




ThvbCALL will retrieve vbkey value and stored it in variant get_vb_key.
You can use vbkey to get data from vbdata vbmod vbhrd table.











 

Customer Characteristic

  Characteristic Descriptions are stored in the table - CABNT - Language - SPRAS - Characteristic description - ATBEZ Characteristic Values ...