cancel
Showing results for 
Search instead for 
Did you mean: 

Delete records in update routine

Former Member
0 Kudos

Hi Everyone,

I have a keyfigure called " <b>Quantity</b> " and I would like to not update the quantity if my Characteristic CS_ITEM has a value "HEADCO" and Characteristic CURTYPE has a value "10". Can you please suggest some abap code in either update rule or start routine to skip or not update records if these values are present mentioned above.

Thanks

Asad

Accepted Solutions (0)

Answers (4)

Answers (4)

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi:

THe COde should still work. Don't mix this COde with old COde. Write after the old COde is finished.

<i>data : itab like DATA_PACKAGE occurs 1 with header line.

itab[] = DATA_PACKAGE[]. "copy all records to itab"

loop at DATA_PACKAGE into itab.

itab-/BIC/ZBALANCE = itab-BALANCE.

itab-/BIC/ZCURRENCY = itab-CURRENCY.

itab-/BIC/ZCurtype = itab-curtype.

append itab. "Add additional records

endloop.

refresh DATA_PACKAGE.

DATA_PACKAGE[] = itab[].</i>

Code-1:

delete data_package where CS_ITEM = 'HEADCO' and

CURTYPE = '10'.

OR

Code-2:

delete data_package where CS_ITEM = 'HEADCO' and

ZCURTYPE = '10'.

Try both these and tell me.

NOTE: Don't write both the Codes. Try Code-1 first. If it doesn't work, try COde-2.

Ram C.

Message was edited by: Ram Chamarthy

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi:

Like bhanu asked, the COde will skip/delete records as you suggested.

If you only want to make Quantity = 0 and leave therest of the record as it is, then write this code in start routine.

loop at data_package where CS_ITEM = 'HEADCO' and

CURTYPE = '10'.

data_package-quantity = '0'.

modify data_package.

endloop.

Also, in my previos post, dont use " use singel quotes (')in ABAP Code as shown in this code.

Ram C.

Former Member
0 Kudos

Hi Guys,

Perhaps I should have told you that there's already a start routine there. It seems like records are being copied to another field and that includes Curtype field. I added a code in there but it didn't do anything.

data : itab like DATA_PACKAGE occurs 1 with header line.

itab[] = DATA_PACKAGE[]. "copy all records to itab"

loop at DATA_PACKAGE into itab.

itab-/BIC/ZBALANCE = itab-BALANCE.

itab-/BIC/ZCURRENCY = itab-CURRENCY.

itab-/BIC/ZCurtype = itab-curtype.

<b>if itab-/BIC/ZCurtype = '10' and itab-CS_ITEM = 'HEADCO'.

<b>delete DATA_PACKAGE.</b> Endif.</b>

append itab. "Add additional records

endloop.

refresh DATA_PACKAGE.

DATA_PACKAGE[] = itab[].

Can you please let me know if this routine is causing the problem? ( I mean when want to delete or not update Quantity where curtype is '10' and CS_ITEM = 'HEADCO', it's not allowing me. I am a novice in ABAP and your help is much appreciated. Thanks and looking forward for your response.

former_member188975
Active Contributor
0 Kudos

Hi Asad,

do you just have one KF or more of them, and do you want this condition only for the Quanitity KF or all of them...reason to ask is that if you code in the Start Routine, it will apply to all the KF.

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

Hi:

write in start routine. its better.

Its very easy.

delete data_package where CS_ITEM = 'HEADCO' and

CURTYPE = '10'.

Message was edited by: Ram Chamarthy