Application Development 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: 

Inserting Record in Maintenance View through a work area

far_sid2103
Explorer
0 Kudos
1,181

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

12 REPLIES 12

FredericGirod
Active Contributor
0 Kudos
915

Could you be more specific in your question ? You would like to insert data with INSERT statement or using trans. like SM30 ... ?

Sandra_Rossi
Active Contributor
0 Kudos
915

Yes it's possible. Please explain the scenario when you want to insert a line.

harishankar714
Participant
0 Kudos
915

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.

0 Kudos
915

It doesn't compile.

far_sid2103
Explorer
0 Kudos
915

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.

FredericGirod
Active Contributor
0 Kudos
915

Could you provide the maintenance view name and the structure of your work area ?

did you try to do it ?

far_sid2103
Explorer
0 Kudos
915

Yes I have provided the name to maintenance view and the same name as type for work area

Sandra_Rossi
Active Contributor
0 Kudos
915

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.

FredericGirod
Active Contributor
0 Kudos
915

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)

FredericGirod
Active Contributor
0 Kudos
915

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.

far_sid2103
Explorer
0 Kudos
915

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.

raymond_giuseppi
Active Contributor
915

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.