2022 Dec 13 12:02 PM
Hi
I just needed to know if it is possible to Insert a new record directly to a maintenance view through a work area or an internal table.
It would be great if someone can help me with this.
Thanks
Farhan
2022 Dec 13 1:00 PM
Could you be more specific in your question ? You would like to insert data with INSERT statement or using trans. like SM30 ... ?
2022 Dec 13 1:27 PM
Yes it's possible. Please explain the scenario when you want to insert a line.
2022 Dec 13 2:17 PM
Yes, it is possible to insert a new record directly to a maintenance view through a work area or an internal table in ABAP. To do this, you can use the CREATE statement to create a new record in the maintenance view, and then use the MODIFY statement to populate the fields of the record with the data from the work area or internal table.
For example, if you have a maintenance view called ZMAINT_VIEW and a work area called WA_DATA, you can insert a new record into the view as follows:
CREATE OBJECT wa_data FROM zmaint_view.
MODIFY zmaint_view FROM wa_data.
2022 Dec 13 5:55 PM
2022 Dec 14 4:31 AM
I don't want to use the transaction.
I have data some data in work area now I want to insert that data in a maintenance view directly instead of a db table.
2022 Dec 14 6:32 AM
Could you provide the maintenance view name and the structure of your work area ?
did you try to do it ?
2022 Dec 14 6:40 AM
Yes I have provided the name to maintenance view and the same name as type for work area
2022 Dec 14 8:48 AM
Is there a reason why you want to "insert that data in a maintenance view directly instead of a db table"?
Is it because it's a standard table?
To update directly, you may use VIEW_MAINTENANCE_LOW_LEVEL, but there's very little information/examples in the Web. You could use batch input instead.
NB: just to say, I don't think there's a big risk to update directly one very simple customizing table.
2022 Dec 14 9:09 AM
sandra.rossi could be a risk to create a line with not-existing referenced data. (could create a line for plant 1234 and this plant doesnt exist in the T001W table)
2022 Dec 14 9:10 AM
And, when you do like this, I am not sure SAP will ask for transport request. So you could create inconsistency between system in the customizing.
2022 Dec 14 9:27 AM
Just wanted to try this out of curiosity. If you have any simple solution for this (not bdc or tmg) then it'll be fine.
BTW thanks for the comments.
2022 Dec 19 4:26 PM
You can use FM VIEW_MAINTENANCE_SINGLE_ENTRY to create an entry in a maintenance view, and you will get the same data quality as with the SM30 transaction, so remember to deal with the errors raised.
CALL FUNCTION 'VIEW_MAINTENANCE_SINGLE_ENTRY'
EXPORTING
action = 'INS'
view_name = 'name of view'
insert_key_not_fixed = 'X'
no_transport = 'X' " or pass/receive a transport request
CHANGING
entry = work area
EXCEPTIONS
ENTRY_ALREADY_EXISTS = 1
ENTRY_NOT_FOUND = 2
CLIENT_REFERENCE = 3
FOREIGN_LOCK = 4
INVALID_ACTION = 5
NO_CLIENTINDEPENDENT_AUTH = 6
NO_DATABASE_FUNCTION = 7
NO_EDITOR_FUNCTION = 8
NO_SHOW_AUTH = 9
NO_TVDIR_ENTRY = 10
NO_UPD_AUTH = 11
SYSTEM_FAILURE = 12
UNKNOWN_FIELD_IN_DBA_SELLIST = 13
VIEW_NOT_FOUND = 14
OTHERS = 15.