‎2019 Oct 17 7:03 AM
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.
‎2019 Oct 17 7:10 AM
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
‎2019 Oct 17 7:26 AM
‎2019 Oct 17 8:38 AM
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!
‎2019 Oct 17 11:17 AM
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?".
‎2019 Oct 17 7:46 AM
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.
‎2019 Oct 17 8:50 AM
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
‎2019 Oct 17 3:53 PM
Thank you all for your explanations. I understood the consequences. I will go and talk to the functional people about it.