‎2011 Mar 14 10:30 PM
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
‎2011 Mar 15 1:49 PM
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
‎2011 Mar 15 1:49 PM
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