Transaction code SMW0 in SAP ABAP is the SAP Web Repository. Its primary purpose is to manage binary and text-based objects that are used by various applications within the SAP system, particularly those related to web-based technologies and user interfaces.
Explanation
The main types of objects you can manage with SMW0 are:
Binary Data for WebRFC Applications: This is the most common use case. It’s for uploading and storing binary files like images, logos, sound files, or other media. These objects can then be referenced and displayed in ABAP programs, SAP GUI screens, or used in forms like Smart Forms. HTML Templates for WebRFC Applications: This allows developers to store HTML files or templates. These templates can be used to generate dynamic web pages or for sending rich HTML emails from ABAP programs. XSLT Programs for Transformation: You can also store XSLT (eXtensible Stylesheet Language Transformations) files here, which are used to transform XML documents.
Common Use Cases for SMW0
Uploading Company Logos: This is a very frequent use of SMW0. Developers upload a company logo (e.g., in .BMP or .GIF format) as binary data to the repository. The logo is then configured to appear on the SAP Easy Access screen or on reports and forms. Displaying Images in ABAP Programs: You can use SMW0 to store images and then display them in your custom ABAP programs by referencing the stored object. This is typically done with ABAP GUI controls, such as CL_GUI_PICTURE. Creating Predefined Format Of Files: For eg. In the Excel file need to make few fields as char type in that case we will use the web repository.
Key Points for ABAP Developers
Object Naming: Objects in SMW0 have a unique name. It’s a best practice to use a customer namespace (starting with ‘Z’ or ‘Y’) to avoid conflicts with standard SAP objects. MIME Types: Before uploading a file, you must ensure that its MIME type (e.g., image/jpeg for a JPEG image) is maintained in the system settings within SMW0. Transportability: Objects created in SMW0 are transportable. You can assign them to a transport request to move them between development, quality assurance, and production systems.
Steps To add the File in Web repository.
Start the Transaction: Go to transaction code SMW0.
Select Binary Data: On the initial screen, select the radio button for “Binary data for WebRFC applications” and click the Execute button.
Define Mime types.
In the Settings->Define Mime Types
Click on create button.
Create a New Object: Click on the Create button (or press F5).
Define Object Details: A dialog box will appear where you’ll need to enter the following information:
OBJID: This is the unique identifier for your file, such as ZSO_UPLOAD_TEMPLATE.
Description: A short, descriptive text for the object .
Save the Entry: Save the object definition.
Import the File: With your newly created object selected, click the Import button.
Choose the File: A file selection dialog will pop up, allowing you to browse your local computer and choose the file you want to upload.
Save the Changes: After selecting the file, save your changes. The file content is now stored in the WWWDATA table and is linked to the OBJID you created.
The entries are added in wwwdata table.
Download the Filed from WWWDATA Table Using report Program.
DATA: lv_objid TYPE wwwdatatab-objid VALUE ‘ZN_UPLOAD_TEMPLATE’,
ls_objdata TYPE wwwdatatab,
lv_file TYPE string,
lv_msg TYPE string,
lv_file1 TYPE rlgrap-filename,
lv_subrc TYPE sy-subrc.
” Get desktop path
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = lv_file.
CONCATENATE lv_file ‘C:salesorder455.xlsx’ INTO lv_file1.
” Read object metadata
SELECT SINGLE relid objid INTO CORRESPONDING FIELDS OF ls_objdata
FROM wwwdata
WHERE srtf2 = 0 AND relid = ‘MI’ AND objid = lv_objid.
IF sy-subrc = 0.
” Download the file
CALL FUNCTION ‘DOWNLOAD_WEB_OBJECT’
EXPORTING
key = ls_objdata
destination = lv_file1
IMPORTING
rc = lv_subrc.
IF lv_subrc = 0.
lv_msg = ‘Template downloaded sucessfully’.
CONCATENATE lv_msg lv_file1 INTO lv_msg.
MESSAGE lv_msg TYPE ‘S’.
ELSE.
MESSAGE ‘Download failed.’ TYPE ‘E’.
ENDIF.
ELSE.
MESSAGE ‘Template not found in repository.’ TYPE ‘E’.
ENDIF.
Conclusion.
SMW0 is a specialized SAP transaction code for managing non-transactional files like images and HTML templates. Its primary use case is to store and make these files available for display and use across various SAP applications, particularly for branding and UI purposes.
Transaction code SMW0 in SAP ABAP is the SAP Web Repository. Its primary purpose is to manage binary and text-based objects that are used by various applications within the SAP system, particularly those related to web-based technologies and user interfaces. Explanation The main types of objects you can manage with SMW0 are: Binary Data for WebRFC Applications: This is the most common use case. It’s for uploading and storing binary files like images, logos, sound files, or other media. These objects can then be referenced and displayed in ABAP programs, SAP GUI screens, or used in forms like Smart Forms. HTML Templates for WebRFC Applications: This allows developers to store HTML files or templates. These templates can be used to generate dynamic web pages or for sending rich HTML emails from ABAP programs. XSLT Programs for Transformation: You can also store XSLT (eXtensible Stylesheet Language Transformations) files here, which are used to transform XML documents. Common Use Cases for SMW0 Uploading Company Logos: This is a very frequent use of SMW0. Developers upload a company logo (e.g., in .BMP or .GIF format) as binary data to the repository. The logo is then configured to appear on the SAP Easy Access screen or on reports and forms. Displaying Images in ABAP Programs: You can use SMW0 to store images and then display them in your custom ABAP programs by referencing the stored object. This is typically done with ABAP GUI controls, such as CL_GUI_PICTURE. Creating Predefined Format Of Files: For eg. In the Excel file need to make few fields as char type in that case we will use the web repository.Key Points for ABAP Developers Object Naming: Objects in SMW0 have a unique name. It’s a best practice to use a customer namespace (starting with ‘Z’ or ‘Y’) to avoid conflicts with standard SAP objects. MIME Types: Before uploading a file, you must ensure that its MIME type (e.g., image/jpeg for a JPEG image) is maintained in the system settings within SMW0. Transportability: Objects created in SMW0 are transportable. You can assign them to a transport request to move them between development, quality assurance, and production systems. Steps To add the File in Web repository.Start the Transaction: Go to transaction code SMW0. Select Binary Data: On the initial screen, select the radio button for “Binary data for WebRFC applications” and click the Execute button. Define Mime types.In the Settings->Define Mime Types Click on create button.Create a New Object: Click on the Create button (or press F5). Define Object Details: A dialog box will appear where you’ll need to enter the following information: OBJID: This is the unique identifier for your file, such as ZSO_UPLOAD_TEMPLATE. Description: A short, descriptive text for the object .Save the Entry: Save the object definition. Import the File: With your newly created object selected, click the Import button. Choose the File: A file selection dialog will pop up, allowing you to browse your local computer and choose the file you want to upload. Save the Changes: After selecting the file, save your changes. The file content is now stored in the WWWDATA table and is linked to the OBJID you created. The entries are added in wwwdata table.Download the Filed from WWWDATA Table Using report Program.DATA: lv_objid TYPE wwwdatatab-objid VALUE ‘ZN_UPLOAD_TEMPLATE’,
ls_objdata TYPE wwwdatatab,
lv_file TYPE string,
lv_msg TYPE string,
lv_file1 TYPE rlgrap-filename,
lv_subrc TYPE sy-subrc.
” Get desktop path
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = lv_file.
CONCATENATE lv_file ‘C:salesorder455.xlsx’ INTO lv_file1.
” Read object metadata
SELECT SINGLE relid objid INTO CORRESPONDING FIELDS OF ls_objdata
FROM wwwdata
WHERE srtf2 = 0 AND relid = ‘MI’ AND objid = lv_objid.
IF sy-subrc = 0.
” Download the file
CALL FUNCTION ‘DOWNLOAD_WEB_OBJECT’
EXPORTING
key = ls_objdata
destination = lv_file1
IMPORTING
rc = lv_subrc.
IF lv_subrc = 0.
lv_msg = ‘Template downloaded sucessfully’.
CONCATENATE lv_msg lv_file1 INTO lv_msg.
MESSAGE lv_msg TYPE ‘S’.
ELSE.
MESSAGE ‘Download failed.’ TYPE ‘E’.
ENDIF.
ELSE.
MESSAGE ‘Template not found in repository.’ TYPE ‘E’.
ENDIF. Conclusion.SMW0 is a specialized SAP transaction code for managing non-transactional files like images and HTML templates. Its primary use case is to store and make these files available for display and use across various SAP applications, particularly for branding and UI purposes. Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog