It's a little awkward that this article is not about S/4 Hana, not about BTP even not about business partners. Still, it's wrapup related to traditional vendor master, not
fashionable enough, just works as a memory archive
😄
1. Standard functionality to create attachment at Vendor master
When a user needs to attach some files to a specific vendor, SAP already provides generic object services (GOS) Toolbar which fulfills the functionality to create attachments, notes, external documents (URL), etc. It's a very powerful&complex tool, here just has a very restricted view on attachment at vendor master. (Please check more at
this wonderful blog about GOS, also more
explanations from Janos,
blogs from Tushar.)
Where attachment been stored
- Table SRGBTBREL (Relationships in GOS Environment) stores the links between the business objects type and its GOS objects. Below is an example of which business objects type is 'LFM1' with purchase organization level, for service order which is 'BUS2088', sales order with 'BUS2032' and FSCM case with 'SCASE', etc.
- Table SOOD (SAPoffice: Object definition) stores the attributes of attached documents like document name&file extension mapping to the attachment list.
How to manipulate attachment at the program
There are many different ways to manipulate attachments like create/delete/copy. Wrap up some of them as below:
- BDS_BUSINESSDOCUMENT_CREATEF to create attachment ( example)
- BDS_BUSINESSDOCUMENT_CREA_TAB to create attachment ( example)
- BDS_GOS_CONNECTIONS_GET to get a list of attachment
- CL_BDS_DOCUMENT_SET provided various methods like copy_linked_objects ( example)
- Enhanced customized Class based on CL_FITV_GOS (detailed blog from Tushar)
- CL_GOS_API: Access to External GOS Attachment List (example)
For switch between change mode and display mode
A user could go to display mode and change into change mode by menu, so can't determine current screen is change mode or display mode by Transaction code. VENDOR_ADD_DATA already provides the field 'I_ACTIVITY' Activity category in SAP transactions. Change mode will be 'V' and display mode is 'A'. Using this field to decide screen fields are editable or not at PBO and whether allow saving at SAVE event.
2. Screen enhancement to create attachment at Vendor master
As the standard approach only provides attach files per vendor level (maybe along with company code or purchase organization), so have to use a customized tab to achieve more detail control. Here is one requirement which needs to attach files per registration number/certification number/ certification type, etc.
It involves various steps for configuration settings, screen design, PAI/PBO inside function group, etc. which have been discussed many times.
- Adding Customer Fields In Vendor Master from Malathesha
- Step by step guide to enhance/update Vendor Master and generate Idocs from Vivek
- Custom Screen in Vendor Master from Sanil
- SAP S/4HANA BP screen enhancement with custom tab from Badrinath for Hana 😄
I'll skip those basic steps and just list some points need to pay attention to.
Data exchange at BADI: VENDOR_ADD_DATA and VENDOR_ADD_DATA_CS
- Create a Z function group and define all global data at the TOP include along with all the screens and function modules, PAI/PBO, Status, etc. Create/change/delete activities at the various screens will be collected into global data separately (can using one SET function module to populate data);
- Create one GET function module at same function group to get all final data at BADI implementation method VENDOR_ADD_DATA~SAVE_DATA;
- whether display vendor at company code level or purchase org. level or general level control by E_HEADERSCREEN_LAYOUT at VENDOR_ADD_DATA_CS~GET_TAXI_SCREEN.
Validate message display
Create one global message table and append screen validation result inside, display those messages at BADI implementation method VENDOR_ADD_DATA~CHECK_ALL_DATA; remember to refresh at SAVE event of the main screen (FCODE:'
UPDA' at the standard screen).
e_msgid = ls_cqm_msg-msgid. "customized msg ID.
e_msgno = ls_cqm_msg-msgno. "customized msg no.
e_scrgr = 'ZV'. "your new added TAB name
e_dynnr = '4000'. "here fixed as 4000 for vendor master
e_fcode = 'Z_GSP'. "your new created Function Code
Generate attachment with DMS
(Some linkage for DMS introduction,
SAP help, and
this one from Lokeswara)
- Popup window to let the user choose a file from the local PC as an attachment by FM WS_FILENAME_GET;
- populate fields for document creation
CONSTANTS: c_dokar TYPE dokar VALUE 'ZSU', "Document Type
c_dokvr TYPE dokvr VALUE '01', "Document Version
c_doktl TYPE doktl_d VALUE '000'. "Document Part
*Allocate document data
l_wf_file_name2 = l_wf_file_name.
lw_doc-documenttype = c_dokar.
lw_doc-documentversion = c_dokvr.
lw_doc-documentpart = c_doktl.
lw_doc-description = im_ctf-zbus_scope.
l_desc = lw_doc-description.
lw_doc-statusextern = '80'.
lw_doc-statusintern = '80'.
lw_doc-createdate = sy-datum.
lw_doc-username = sy-uname.
* Determine the type of file
l_wf_length = strlen( l_wf_file_name ).
FIND ALL OCCURRENCES OF '.'
IN l_wf_file_name MATCH OFFSET l_wf_offset.
l_wf_position = l_wf_offset + 1.
l_wf_type = l_wf_length - l_wf_offset.
l_wf_file_type = l_wf_file_name+l_wf_position(l_wf_type).
* Description in english
CLEAR lw_drat.
REFRESH lt_drat.
lw_drat-language = 'EN'.
lw_drat-description = l_desc.
APPEND lw_drat TO lt_drat.
* Check original 1 into the SAP data base at the same time
CLEAR lw_files.
REFRESH lt_files.
lw_files-datacarrier = 'ZQM_DOCS'.
lw_files-originaltype = '1'.
lw_files-wsapplication = lw_doc-wsapplication1.
lw_files-docfile = l_wf_file_name2.
APPEND lw_files TO lt_files.
- check whether upload file extension is supported by the system
IF gt_tdwp[] IS INITIAL. "get all supported file extension
SELECT * INTO TABLE gt_tdwp FROM tdwp.
SET LOCALE LANGUAGE 'E'.
TRANSLATE l_wf_file_type TO LOWER CASE.
READ TABLE gt_tdwp INTO lw_tdwp
WITH KEY appsfx = l_wf_file_type
BINARY SEARCH.
lw_doc-wsapplication1 = lw_tdwp-dappl.
*make sure we have a workstation application and create the document.
IF lw_doc-wsapplication1 IS INITIAL. "extension not supported!
MESSAGE e010(zcn). "
ENDIF.
- Call BAPI to create the DMS document by 'BAPI_DOCUMENT_CREATE2'. Please refer to this one by Ali Akbar or this from Bruno.