Application Development and Automation 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: 
Read only

Primary key combination

Former Member
0 Likes
910

Hi,

I am working on a module pool programming.

In which i have around 13 database table fields. Out of which first 3 fields are primary key.

MANDTMANDTCLNT30Client
INVOICE_TYPEZINVOICETYPECHAR200Invoice type
BELNRBELNR_DCHAR100Accounting Document Number
CUSTOMINVOICEVBELN_VFCHAR100Billing Document
KURSTKURST_CURRCHAR40Exchange Rate Type
CUSTOMINVOICE1VBELN_VFCHAR100Billing Document
CUSTOMINVOICE2VBELN_VFCHAR100Billing Document
CUSTOMINVOICE3VBELN_VFCHAR100Billing Document
CUSTOMINVOICE4VBELN_VFCHAR100Billing Document
KURST1KURST_CURRCHAR40Exchange Rate Type
KURST2KURST_CURRCHAR40Exchange Rate Type
KURST3KURST_CURRCHAR40Exchange Rate Type
KURST4KURST_CURRCHAR40Exchange Rate Type

1st part is : on screen user will make all the required entries an saves it. (That is working fine)

2nd part : when user put the BELNR and click on Display, all the fields are getting populated from table. (Working Fine)

3rd part : When makes some entries in fields, let say make any changes in the fields apart from key fields. it should get saved in database.

3rd part is not working.

i used below command for saving

APPEND WA_INVTYPE TO IT_INVTYPE " For updating internal table.

MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE. " for updating database table.

Thanks,

Amit Dwivedi

5 REPLIES 5
Read only

Former Member
0 Likes
821

Hi Amit,

Can you try in this way?

DATA: INV_TYPE2 TYPE ZTYPE_INVOICES.


LOOP AT IT_INVTYPE. INTO WA_INVTYPE.  

  MOVE-CORRESPONDING WA_INVTYPE TO WA_INVTYPE2.

MODIFY ZTYPE_INVOICES FROM WA_INVTYPE2.

ENDLOOP.

Read only

Former Member
0 Likes
821

Hi,

If this is the case you have to use Insert query because Modify statement works based on primary key,so If primary keys remain same and rest of the data got changed it will only modify record.

Else you can check sy-subrc for that particular input field if entry exist than insert into table.

Thank you.

Regards,

Dular Sharma.

Read only

0 Likes
821

Hi Dular,

I want to modify the records. Do not want to INSERT a new record.

Thanks,

Amit

Read only

yogendra_bhaskar
Contributor
0 Likes
821

Hi Amit ,

Have you checked internal table IT_INVTYPE have the modified entries or not ?


Use Commit work also

Regards

Yogendra Bhaskar

Read only

VenkatRamesh_V
Active Contributor
0 Likes
821

Hi,

Try,

MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE.

if sy-subrc = 0.

commit work.

endif.


Hope it helpful,


Regards,

Venkat.V