‎2015 May 27 6:56 AM
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.
| MANDT | MANDT | CLNT | 3 | 0 | Client |
| INVOICE_TYPE | ZINVOICETYPE | CHAR | 20 | 0 | Invoice type |
| BELNR | BELNR_D | CHAR | 10 | 0 | Accounting Document Number |
| CUSTOMINVOICE | VBELN_VF | CHAR | 10 | 0 | Billing Document |
| KURST | KURST_CURR | CHAR | 4 | 0 | Exchange Rate Type |
| CUSTOMINVOICE1 | VBELN_VF | CHAR | 10 | 0 | Billing Document |
| CUSTOMINVOICE2 | VBELN_VF | CHAR | 10 | 0 | Billing Document |
| CUSTOMINVOICE3 | VBELN_VF | CHAR | 10 | 0 | Billing Document |
| CUSTOMINVOICE4 | VBELN_VF | CHAR | 10 | 0 | Billing Document |
| KURST1 | KURST_CURR | CHAR | 4 | 0 | Exchange Rate Type |
| KURST2 | KURST_CURR | CHAR | 4 | 0 | Exchange Rate Type |
| KURST3 | KURST_CURR | CHAR | 4 | 0 | Exchange Rate Type |
| KURST4 | KURST_CURR | CHAR | 4 | 0 | Exchange 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
‎2015 May 27 7:06 AM
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.
‎2015 May 27 7:22 AM
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.
‎2015 May 27 7:46 AM
Hi Dular,
I want to modify the records. Do not want to INSERT a new record.
Thanks,
Amit
‎2015 May 27 7:26 AM
Hi Amit ,
Have you checked internal table IT_INVTYPE have the modified entries or not ?
Use Commit work also
Regards
Yogendra Bhaskar
‎2015 May 27 9:06 AM
Hi,
Try,
MODIFY ZTYPE_INVOICES FROM TABLE IT_INVTYPE.
if sy-subrc = 0.
commit work.
endif.
Hope it helpful,
Regards,
Venkat.V