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

Accessing Object Application Tool from user exit

Former Member
0 Likes
426

There is an object application tool that shows on the sales order form that allows users to attachi files and create notes, among other things, to a sales order. The program associated with this tool is SAPLSGOSDS.

I need to use the CREATE NOTE portion of this tool to attach a note to my sales order from a user exit. I will know the title and note details at runtime and don't want the NOTE tool popping up on the screen waiting for the user to fill it out. I just want to access this tool from my user exit to create this note for a sales order behind the scenes.

What is the best way programmatically to do this? Is there a simple method or function call I can make to do this or do I need to somehow call the SAPLSGOSDS program with parameters to hide the input screens, or just include a few of its include files in my program so I can instantiate the object for that and call the appropriate instance methods?

Any samples would be much appreciated.

Thanks,

Scott

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
346

You can create the note by calling the FM SO_OBJECT_INSERT in the user-exit (e.g. USEREXIT_SAVE_DOC_PREPARE) of Sales Order. You need to remember that the functionality of GOS will only be available once Sales Order is created i.e. VA02 and VA03.


* note header data
L_OBJ_DATA-OBJLA = sy-langu..
L_OBJ_DATA-OBJDES = 'Testing from user-exit'.
L_OBJ_DATA-OBJSNS = 'O'.
L_OBJ_DATA-FILE_EXT = 'TXT'.

* note content
append 'note line 1' to lt_objcont.
append 'note line 2' to lt_objcont.

* Get folder
  call function 'SO_FOLDER_ROOT_ID_GET'
       exporting
            region    = 'B'
       importing
            folder_id = folder_id
       exceptions
            others    = 1.

  call function 'SO_OBJECT_INSERT'
       exporting
            folder_id             = folder_id
            object_type           = 'RAW'
            object_hd_change      = l_obj_data
       importing
            object_id             = l_obj_id
       tables
            objhead               = lt_objhead
            objcont               = lt_objcont
       exceptions
            active_user_not_exist =   35
            folder_not_exist      =    6
            object_type_not_exist =   17
            owner_not_exist       =   22
            parameter_error       =   23
            others                = 1000.

Regards,

Naimesh Patel

1 REPLY 1
Read only

naimesh_patel
Active Contributor
0 Likes
347

You can create the note by calling the FM SO_OBJECT_INSERT in the user-exit (e.g. USEREXIT_SAVE_DOC_PREPARE) of Sales Order. You need to remember that the functionality of GOS will only be available once Sales Order is created i.e. VA02 and VA03.


* note header data
L_OBJ_DATA-OBJLA = sy-langu..
L_OBJ_DATA-OBJDES = 'Testing from user-exit'.
L_OBJ_DATA-OBJSNS = 'O'.
L_OBJ_DATA-FILE_EXT = 'TXT'.

* note content
append 'note line 1' to lt_objcont.
append 'note line 2' to lt_objcont.

* Get folder
  call function 'SO_FOLDER_ROOT_ID_GET'
       exporting
            region    = 'B'
       importing
            folder_id = folder_id
       exceptions
            others    = 1.

  call function 'SO_OBJECT_INSERT'
       exporting
            folder_id             = folder_id
            object_type           = 'RAW'
            object_hd_change      = l_obj_data
       importing
            object_id             = l_obj_id
       tables
            objhead               = lt_objhead
            objcont               = lt_objcont
       exceptions
            active_user_not_exist =   35
            folder_not_exist      =    6
            object_type_not_exist =   17
            owner_not_exist       =   22
            parameter_error       =   23
            others                = 1000.

Regards,

Naimesh Patel