Application Development 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: 

update Ztable report

Former Member
0 Kudos

Hi Experts,

I want to update some FI documents into my ztable report day wise as a background, So pls help me with some example reports how to update/append records into Ztable from main table like bseg or bkpf(for example) and how to modify the same table and append the existing records,if any user changes the same document for any fields after posted.

For ex: If an LC document get posted as new document, then my report will update the records into Ztable from BSEG. If the user agains going and changing the same document ,say for example amounts, then simultaneously it has to be updated into my same document number of my Ztable.

hope its very clear.

Pls post ur examples and advises.

thanks & regards

sankar.

4 REPLIES 4

Former Member
0 Kudos

Hi

In the report, u can retrieve data from BSEG based on Last adjusment date (LINFV), and then for each entry you can use modify ztable from work area (keep in mind Lock/unlock the ztable ).Thus updating the ztable.

0 Kudos

Hello Sir,

thanks for ur prompt reply.

Could u guide me more with some examples with some small statements while appending and modifying the Ztable (with lock/unlock mode)

regards

sankar.

Edited by: ABAP Learner SR on Sep 30, 2008 4:56 PM

0 Kudos

Try something similar to this:


DATA: it_ztable TYPE STANDARD TABLE OF ztable.
DATA: wa_ztable TYPE ztable.
DATA: it_bkpf TYPE STANDARD TABLE OF bkpf.
DATA: wa_bkpf TYPE bkpf.

SELECT * FROM bkpf INTO TABLE it_bkpf WHERE ... "some conditions

LOOP AT it_bkpf INTO wa_bkpf.
  CLEAR wa_ztable.
  SELECT SINGLE * FROM ztable INTO wa_ztable
   WHERE field1 = wa_bkpf-field1
     AND field2 = wa_bkpf-field2.
  IF sy-subrc EQ 0.
    UPDATE ztable SET field3 = wa_bkpf-field3
     WHERE field1 = wa_bkpf-field1
       AND field2 = wa_bkpf-field2.
  ELSE.
    MOVE-CORRESPONDING wa_bkpf TO wa_ztable.
    INSERT ztable FROM wa_ztable.
  ENDIF.
ENDIF.

Regards,

Valter Oliveira.

Former Member
0 Kudos

Example:

*Lock Table ZHPA_CON_INF

PERFORM sub_lock_db.

*Update the table with this work area having current date and time

MODIFY zhpa_con_inf FROM wa_zhpa_con_inf.

IF sy-subrc = 0.

COMMIT WORK.

ENDIF.

*Unloak Table ZHPA_CON_INF

PERFORM sub_unlock_db.

**************************************

&----


*& Form sub_lock_db

&----


  • Lock Database

----


  • No Parameters

----


FORM sub_lock_db.

  • Declare the local variable for varkey

DATA : l_varkey TYPE vim_enqkey. "Varkey

  • Move the value of client to local variable

CONCATENATE sy-mandt c_intid INTO l_varkey.

  • Lock the table before update

CALL FUNCTION 'ENQUEUE_E_TABLEE'

EXPORTING

tabname = c_tabname "ZHPA_CON_INF

varkey = l_varkey

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE i000 WITH 'Error while locking table:'(002) c_tabname.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " sub_lock_db

&----


*& Form sub_unlock_db

&----


  • Unlock Database

----


  • No Parameters

----


FORM sub_unlock_db .

  • Declare the local variable for varkey

DATA : l_varkey TYPE vim_enqkey. "Varkey

  • Move the value of client to local variable

CONCATENATE sy-mandt c_intid INTO l_varkey.

*Unlock the table

CALL FUNCTION 'DEQUEUE_E_TABLEE'

EXPORTING

tabname = c_tabname "ZHPA_CON_INF

varkey = l_varkey.

ENDFORM. " sub_unlock_db