cancel
Showing results for 
Search instead for 
Did you mean: 

Modify Z* Db table not working

ricky_shaw
Contributor
424

Hi,
I have a Zinvoice table with 'INVNO' as the ONLY key field.

Its type is XBLNR_KK which holds 16 chars.

I am updating this Z* table via reading big volume of data from flat file.

Sometimes i get same value for 'INVNO' field in different rows.
I use modify statement as below in the program.

modify zinvoice from wa_invoice.

Issues:
1)This statement is giving sy-subrc = 0 even when same 'INVNO' field is seen.
2) Also its NOT updating for different INVNO. What could be the reason?
3) Do i need to prefill 0's if INVNO is filled with 9 or 10 chars?

 

Can any one suggest pls.

Sandra_Rossi
Active Contributor
0 Kudos
Of course, no doubt that Modify Z* Db table works. You have a bug in your values either in the internal table or in the database table (or both).
ricky_shaw
Contributor
0 Kudos
What exactly is the bug? Do i mandatorily need to use Alpha Conv for the INVNO?
Sandra_Rossi
Active Contributor
0 Kudos
Only you can see and compare the values you have in the internal table and in the database table (any difficulty?) Now if it's about the very basic concept of internal and external values, then apply the conversion exit to convert external values into internal values.
View Entire Topic
raymond_giuseppi
Active Contributor
0 Kudos

The Data/Element  (Domain) XBLNR_KK uses the ALPHA conversion exit. So you MUST convert data to a correct internal forma (e.g. use FM CONVERSION_EXIT_ALPHA_INPUT) 

  1. Else you can get different internal values that share same exernal value (so apparent duplicates and headaches)
  2. Also consider adding the MANDT as the first primary key of the table

 

ricky_shaw
Contributor
0 Kudos
Hi Raymond, No Luck..I tried using Alpha Conv & also MANDT field is already in the Z*table..I think i need to change it to insert..
Sandra_Rossi
Active Contributor
0 Kudos
@ricky_shaw You're still missing the exact problem. MODIFY = UPSERT (INSERT if new key, UPDATE if existing key). I never saw a bug reported about that and I doubt there's one.
ricky_shaw
Contributor
0 Kudos
Then why Sy-subrc = 0 always.?.
Sandra_Rossi
Active Contributor
0 Kudos
@ricky_shaw It's sy-subrc = 0 because the insertion or the modification succeeded (anyway, it's very exceptional that sy-subrc <> 0). The only problem is that you're not able to diagnose what happened after (rollbacked, deleted, key updated, or looking at it at the wrong moment, etc.) There are many ways to diagnose.
ricky_shaw
Contributor
0 Kudos
Sandra, I ran the same upload file for 5 recs (same OPBEL) for testing. It did NOT insert or update which is good. But i see sy-subrc = 0 . Isn't it like the sy-subrc should be = 4?
Sandra_Rossi
Active Contributor
@ricky_shaw You think that it didn't insert or modify because you don't see it, but it did it because sy-subrc = 0. So, you must check if there was a rollback, a commit, a database trigger, a wrong data selection, etc. It can be anything.
raymond_giuseppi
Active Contributor
0 Kudos

INVNO is part of the primary key so

  • If already in the table, you update with this same value, do you change other fields (try to add a changed on/by field) else nothing to see
  • If it's not in the table it will insert a new record (also if there are already wrong records in the database table, especially wrong format of key fields)

NB: Basically, only an unique secondary index can trigger a sy-subrc <> 0 for statement MODIFY dbtab (LOB doesn't seem relevant here)

Do you use an explicit DB commit or are you relying on an explicit DB commit ?

ricky_shaw
Contributor
0 Kudos

Hi Raymond, I am using 'Commit work' if there is at least one update. Even if i don't use commit, its updating 1000's of recs.

What is LOB here?

Sandra_Rossi
Active Contributor
0 Kudos

@ricky_shawJust click the links? Or ask GPT.

Sandra_Rossi_0-1718693577971.png