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

ABAP - update table vbap

Former Member
0 Likes
4,236

Hi,

I have the following code to update the table VBAP based on gt_record1 entries, which I got from file upload. Gt_record1 has ordnum, item, plant, item category data. I have to update table VBAP with plant and item cat for provided ordnum and item.

I am doing something wrong with my loops. Can you please help.

Form get_data.

If gt_record1 is not initial.

sort gt_record1.

select * from vbap into table @data(lt_vbap)

for all entries in @gt_record1

where vbeln = @gt_record1-ordnum

and posnr = @gt_record1-item.

Loop at gt_record1 assigning field-symbol(<fs_record1>).

If sy-subrc = 0.

Loop at lt_vbap assigning field-symbol(<fs_vbap>).

<fs_vbap>-werks = <fs_record1>-plant.

<fs_vbap>-pstyv = <fs_record1>-itemcat.

ENDLOOP.

MODIFY vbap FROM TABLE lt_vbap.

If sy-subrc = 0.

COMMIT WORK.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM.

7 REPLIES 7
Read only

FredericGirod
Active Contributor
3,071

The solution is very simple

YOU MUST NEVER MODIFY THE STANDARD TABLE CONTENT

or you will loose SAP support

so please, do not ask forbidden solution in an official SAP forum

Read only

Former Member
0 Likes
3,071

Thank you for your reply but that is my requirement.

Read only

0 Likes
3,071

Neela Veni,

No, this cant be your requirement. We should never perform such modification to standard table.

Liaise with your functional consultant and ask him what is the standard procedure to update these entries through transactions.

Then probably you can write a LSMW or BDC recording for the same or the most efficient process of using a BAPI.

Regards!

Read only

0 Likes
3,071

You can choose: be a crappy developer doing things without thinking about the consequences nor offering an alternative OR be a valuable resource, documenting your choices and explaining why something is wrong and should be done that way.

I bet your request is "update those 2 fields": now you have to ask yourself "what does SAP say on updating standard tables?".

Read only

VeselinaPeykova
Active Contributor
3,071

I agree completely with frdric.girod you should not do this, the person who requested this probably has no idea what can be the consequences of such approach. I am a SD consultant and please, believe me when I say that this can easily mess up your whole order-to-cash process.

As a developer you also have a say in the solution development.

What is more - there is no need for a custom program to update the [plant and the item category of sales order items; this can be done via transaction MASS and even with LSMW. If you really need to update sales orders via a custom program then at least you can use safer ways - like BAPI_SALESORDER_CHANGE.

Read only

Former Member
0 Likes
3,071

This is NOT your requirement.

Your requirement is to update sales orders. If you don't use Bapi's or even bdc to fulfill that requirement then SAP has no commitment to support your client in case something goes wrong with direct table updates.

Think of corrupt data, incorrect information which leads to failing audits, etc

If the functional/business requirement details the specific direct manipulation of SAP tables then it is your responsibility to reject that requirement.

Kind regards, Rob Dielemans

Read only

Former Member
0 Likes
3,071

Thank you all for your explanations. I understood the consequences. I will go and talk to the functional people about it.