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

Modify Database table

Former Member
0 Likes
732

Hi,

I need to modify the DB. I have an internal table without header line. I checked with the threads posted though informatory but not useful for this scenario.

Scenario.

DB : 25 fields

Internal table 4 fields

tried with the checking the F1 syntax didnt work out.

Please provide your valuable inputs.

Thanks

Mohinder Singh Chauhan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

Hi Mohinder,

When modifying or performing any operation on DB table using an internal table, the structure of the internal table should be EXACTLY the same as the DB table.

Hence here, you would need to declare another internal table with the 25 fields in DB table and then move contents from source internal table into new internal table and modify DB table from new internal table.

Cheers,

Aditya

5 REPLIES 5
Read only

Former Member
0 Likes
708

Hi

You can use update using Set

or modify statement

but it wont modify the primary key fields

Regards

Shiva

Read only

Former Member
0 Likes
709

Hi Mohinder,

When modifying or performing any operation on DB table using an internal table, the structure of the internal table should be EXACTLY the same as the DB table.

Hence here, you would need to declare another internal table with the 25 fields in DB table and then move contents from source internal table into new internal table and modify DB table from new internal table.

Cheers,

Aditya

Read only

former_member188829
Active Contributor
0 Likes
708

Hi,

Check this simple program

TABLES:MARA.

DATA:ITAB LIKE MARA OCCURS 0 .

DATA:WA LIKE MARA.

START-OF-SELECTION.

WA-MATNR = '123ABCDAB'. .

WA-MBRSH = 'C'.

WA-MTART = 'FERT' .

WA-MEINS = 'KG' .

APPEND WA TO ITAB.

WA-MATNR = '123ABCDBB'. .

WA-MBRSH = 'C'.

WA-MTART = 'FERT' .

WA-MEINS = 'KG' .

APPEND WA TO ITAB.

LOOP AT ITAB INTO WA.

INSERT MARA FROM WA.

MODIFY MARA .

ENDLOOP.

Read only

Former Member
0 Likes
708

Hi Mohinder,

Would suggest not to use Modify or Update statement directly on the DB table. Find a BAPI instead.

IF still using always have to pass the Primary key and use Transporting. In othercase if you donot pass all the fields then the remaining fields will be modified and left empty.

-- Pass all the key fields to avoid data redundancy and loss,

Jayant Sahu.

Read only

Former Member
0 Likes
708

Hi Thanks for the reply

Thanks

Mohinder Singh Chauhan