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: 

how many records are updated by update statement

Former Member
0 Kudos
1,461

Hi All ,

i am updating databese uisng update statment it is updating database table ,

after that i want to find how many records are updated i am using folloing coding but it is not working

very well

UPDATE lips SET brgew = itab-ausp1

WHERE vbeln = itab-vbeln AND

posnr = itab-posnr.

IF sy-subrc = 0.

itab-brgew = itab-ausp1.

MODIFY itab INDEX idx TRANSPORTING brgew.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

can anybody tell me how to do these

Thanks in advance

1 ACCEPTED SOLUTION

dev_parbutteea
Active Contributor
0 Kudos
284

Hi,

The statement UPDATE sets sy-dbcnt to the number of changed lines.

Just needed to do a F1 on UPDATE......

7 REPLIES 7

Former Member
0 Kudos
284

Hi Paresh,

Never update standard tables with MODIFY,UPDATE or INSERT.

try to use the BDC, BAPIS or FM's.

Regards,

Phani.

dev_parbutteea
Active Contributor
0 Kudos
285

Hi,

The statement UPDATE sets sy-dbcnt to the number of changed lines.

Just needed to do a F1 on UPDATE......

former_member222860
Active Contributor
0 Kudos
284

Hi,

Use Sy-dbcnt

check the code below:


Data: count type i.

UPDATE lips SET brgew = itab-ausp1
WHERE vbeln = itab-vbeln AND
posnr = itab-posnr.

IF sy-subrc = 0.
itab-brgew = itab-ausp1.
MODIFY itab INDEX idx TRANSPORTING brgew.
*count = sy-dbcnt.*

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.
write:/ count. 

thanks|

Mahesh

Former Member
0 Kudos
284

Hi

Good

The code you have mentioned below is to update the database table but no where you have mentioned the process you are following to know the number of record that has been updated through MODIFY statement.

If you want to see the records and you can use the select statement to select the brgew field, it will tell you the detail field updated using the modify method.

Thanks

nmrutyun^

former_member181995
Active Contributor
0 Kudos
284

If itu2019s not too late, I mean if your changes were not moved into PRD than stop your Work and post your requirement why you are tempting to Update DB manually?!?

Former Member
0 Kudos
284

Hi Paresh,

Its better to use a BDC insteat of UPDATE. Please refer the code given below:

send the data to be updated in BDC table & capture the meesage in message table as show below: then loop this message table to find which record have been updated & which are not updated.

* BDC table of call transaction
data:
  t_bdcdata type
   standard table
         of bdcdata,

  fs_bdcdata type bdcdata.             " Work area for bdcdata

* Messages of call transaction
data:
  t_messtab type
   standard table
         of bdcmsgcoll,

  fs_messtab type bdcmsgcoll.          " Work area for messtab

  call transaction 'PA30' using t_bdcdata
                           mode 'A'
                       messages into t_messtab.

    loop at t_messtab into fs_messtab.
      call function 'FORMAT_MESSAGE'
            exporting
              id        = fs_messtab-msgid
              lang      = sy-langu
              no        = fs_messtab-msgnr
              v1        = fs_messtab-msgv1
              v2        = fs_messtab-msgv2
              v3        = fs_messtab-msgv3
              v4        = fs_messtab-msgv4
            importing
              msg       = lw_string
            exceptions
              not_found = 1
              others    = 2.

      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.                           " IF sy-subrc <> 0

    endloop.                           " LOOP AT t_messtab into...

With luck,

Pritam.

Former Member
0 Kudos
284

thanks i got the answer

i used sy-dbcnt to find no of records updated