SAP MM is the materials management module of the SAP ERP software package from SAP AG that is used for Procurement Handling and Inventory Management. Materials management is integrated with other modules such as SD, PP and QM. Materials management is used for procurement and inventory management.
The module has two important master data - material and vendor. Broadly, the various levels that can be defined for a SAP MM implementation are: Client, Company Code, Plant, Storage Location and Purchase Organization.
SAP Materials management covers all tasks within the supply chain, including consumption-based planning, planning, vendor evaluation and invoice verification. It also includes inventory and warehouse management to manage stock until usage dictates the cycle should begin again. Electronic Kanban/Just-in-Time delivery is supported.
It can be divided into five major components. There are: materials management, plant maintenance, quality management, production planning and control, and a project management system. Each is divided into number of subcomponents.
SAP MM is all about managing the materials i.e the resources of an organization. These resources include man, manpower and materials. The main functionality within MM includes purchasing, Inventory management, valuation and assignment, batch management and classification
SAP MM Module :
SAP MM is the materials management module of the SAP ERP software package from SAP AG that is used for Procurement Handling and Inventory Management. Materials management is integrated with other modules such as SD, PP and QM. Materials management is used for procurement and inventory management.
The module has two important master data - material and vendor. Broadly, the various levels that can be defined for a SAP MM implementation are: Client, Company Code, Plant, Storage Location and Purchase Organization.
SAP Materials management covers all tasks within the supply chain, including consumption-based planning, planning, vendor evaluation and invoice verification. It also includes inventory and warehouse management to manage stock until usage dictates the cycle should begin again. Electronic Kanban/Just-in-Time delivery is supported.
It can be divided into five major components. There are: materials management, plant maintenance, quality management, production planning and control, and a project management system. Each is divided into number of subcomponents.
SAP MM is all about managing the materials i.e the resources of an organization. These resources include man, manpower and materials. The main functionality within MM includes purchasing, Inventory management, valuation and assignment, batch management and classification
Wednesday, July 27, 2011
MM Process Flow
MM - Process Flow
Determination of Requirements
The user department responsible is manually passing a requirement for materials to the purchasing department via Purchase Requisition. Purchase requests are generated when business runs the MRP and Request are also generated based in Consumption based planning (CBP) for Production and Engg.Stores.
Determination of Source of Supply
The purchasing component helps the buyer determine the sources of supply. User use the determination of the source of supply to create Requests for quotation (RFQs) and then to enter quotations. User is accessing the existing Purchase Orders and Conditions in the System.
Vendor Selection and Comparison of Quotations
The System is capable of simulating pricing scenarios and simplifies the selection of vendors by making price comparisons between the various quotations.
Purchase Order Processing
The purchasing system adopts information from purchase requisition and the quotation to help to create Purchase Orders. They are also creating manual purchase order directly for stock, non-stock items, services etc.
Purchase Order Monitoring
The buyer monitor the processing status of the purchase order online at any time and determine whether goods or an invoice have been received for the relevant purchase order item.
Goods Receipt and Inventory Management
The Goods receiving requester confirms the receipt of the materials by simply entering the Purchase Order Number. The system compares the goods receipt quantity with the purchase order quantity. By specifying permissible tolerances, buyers can limit over deliveries and under deliveries of ordered materials.
PURCHASING
Purchasing Functionality is integrated with Inventory Management and Invoice Verification within MM.
Determination of Requirements
The user department responsible is manually passing a requirement for materials to the purchasing department via Purchase Requisition. Purchase requests are generated when business runs the MRP and Request are also generated based in Consumption based planning (CBP) for Production and Engg.Stores.
Determination of Source of Supply
The purchasing component helps the buyer determine the sources of supply. User use the determination of the source of supply to create Requests for quotation (RFQs) and then to enter quotations. User is accessing the existing Purchase Orders and Conditions in the System.
Vendor Selection and Comparison of Quotations
The System is capable of simulating pricing scenarios and simplifies the selection of vendors by making price comparisons between the various quotations.
Purchase Order Processing
The purchasing system adopts information from purchase requisition and the quotation to help to create Purchase Orders. They are also creating manual purchase order directly for stock, non-stock items, services etc.
Purchase Order Monitoring
The buyer monitor the processing status of the purchase order online at any time and determine whether goods or an invoice have been received for the relevant purchase order item.
Goods Receipt and Inventory Management
The Goods receiving requester confirms the receipt of the materials by simply entering the Purchase Order Number. The system compares the goods receipt quantity with the purchase order quantity. By specifying permissible tolerances, buyers can limit over deliveries and under deliveries of ordered materials.
PURCHASING
Purchasing Functionality is integrated with Inventory Management and Invoice Verification within MM.
Standard Reports in MM during Implementation & support projects
List of Standard Reports in MM
MB51 Material Doc. List
MB5L List of Stock Values: Balances MBBS Display valuated special stock MC$G PURCHIS: Material PurchVal SelectionMC$I PURCHIS: Material PurchQty SelectionMC.1 INVCO: Plant Anal. Selection: Stock MC.2 INVCO: Plant Anal.Selection, Rec/IssMC.5 INVCO: SLoc Anal. Selection, Stock MC.9 INVCO: Material Anal.Selection,StockMC.A INVCO: Mat.Anal.Selection, Rec/Iss MC.L INVCO: Mat.Group Analysis Sel. StockMC48 INVCO: Anal. of Current Stock ValuesMC50 INVCO: Analysis of Dead Stock MCBA INVCO: Plant Analysis Selection MCBC INVCO: Stor. Loc. Analysis SelectionMCBE INVCO: Material Analysis Selection MCBK INVCO: MatGrp Analysis Selection MCBR INVCO: Batch Analysis Selection MCE1 PURCHIS: PurchGrp Analysis SelectionMCE3 PURCHIS: Vendor Analysis Selection MCE5 PURCHIS: MatGrp Analysis Selection MCE7 PURCHIS: Material Analysis SelectionMCW3 PURCHIS: Evaluate VBD Header MCW4 PURCHIS: Evaluate VBD Item ME2L Purchase Orders by Vendor ME2M Purchase
MB51 Material Doc. List
MB5L List of Stock Values: Balances MBBS Display valuated special stock MC$G PURCHIS: Material PurchVal SelectionMC$I PURCHIS: Material PurchQty SelectionMC.1 INVCO: Plant Anal. Selection: Stock MC.2 INVCO: Plant Anal.Selection, Rec/IssMC.5 INVCO: SLoc Anal. Selection, Stock MC.9 INVCO: Material Anal.Selection,StockMC.A INVCO: Mat.Anal.Selection, Rec/Iss MC.L INVCO: Mat.Group Analysis Sel. StockMC48 INVCO: Anal. of Current Stock ValuesMC50 INVCO: Analysis of Dead Stock MCBA INVCO: Plant Analysis Selection MCBC INVCO: Stor. Loc. Analysis SelectionMCBE INVCO: Material Analysis Selection MCBK INVCO: MatGrp Analysis Selection MCBR INVCO: Batch Analysis Selection MCE1 PURCHIS: PurchGrp Analysis SelectionMCE3 PURCHIS: Vendor Analysis Selection MCE5 PURCHIS: MatGrp Analysis Selection MCE7 PURCHIS: Material Analysis SelectionMCW3 PURCHIS: Evaluate VBD Header MCW4 PURCHIS: Evaluate VBD Item ME2L Purchase Orders by Vendor ME2M Purchase
SAP MM Important tables and important fields
131 T165K Copying Options: Header Texts
132 T165P Copying Options, Item texts
133 T166A Supplement Text in Purchasing Document Printouts
134 T166C Print-Relevant Purchasing Document Changes
135 T166K Header Texts in Purchasing Document Printouts
136 T166P Item Texts in Purchasing Document Printouts
137 T166T Change Texts in Purchasing Document Printouts
138 T166U Headings in Purchasing Document Printout
139 T167 Number Range Management for Purchasing Master Data
140 T167T Transaction Description
141 T168 Screen Control, Purchasing
142 T168F Function Codes, Purchasing
143 T168T Screen Titles
144 T16FB Release Indicators: Purchasing Document
145 T16FC Release Codes
146 T16FD Description of Release Codes
147 T16FE Descriptions of Release Indicators: Purchasing Documents
148 T16FG Release Groups
149 T16FH Descriptions of Release Groups
150 T16FK Release Statuses
151 T16FS Release Strategies
152 T16FT Descriptions of Release Strategies
153 T16FV Release Prerequisites
154 T16FW Assignment of Role to Release Code
155 T16LA Texts on Status of Requisition Processing
156 T16LB Scope of List: Purchase Requisitions
157 T16LC Description of Scope of List: Purchase Requisitions
158 T16LD Routines for Structure of Requisition Lists
159 T16LE Texts for Routines for Structure of Requisition Lists
160 T16LF Routines for Data Retrieval in Requisition Lists
161 T16LG Texts for Routines for Data Retrieval in Requisition Lists
162 T16LH Default List Scope for Requisitions in Transactions
163 T16LI Data Retrieval for List Scope: Purchase Requisitions
164 T16LL Routines for List Scope: Purchase Requisitions
165 T170 Copying Control: Texts in Purchasing
166 T460Q Special Procurement Types per Procurement Type
167
132 T165P Copying Options, Item texts
133 T166A Supplement Text in Purchasing Document Printouts
134 T166C Print-Relevant Purchasing Document Changes
135 T166K Header Texts in Purchasing Document Printouts
136 T166P Item Texts in Purchasing Document Printouts
137 T166T Change Texts in Purchasing Document Printouts
138 T166U Headings in Purchasing Document Printout
139 T167 Number Range Management for Purchasing Master Data
140 T167T Transaction Description
141 T168 Screen Control, Purchasing
142 T168F Function Codes, Purchasing
143 T168T Screen Titles
144 T16FB Release Indicators: Purchasing Document
145 T16FC Release Codes
146 T16FD Description of Release Codes
147 T16FE Descriptions of Release Indicators: Purchasing Documents
148 T16FG Release Groups
149 T16FH Descriptions of Release Groups
150 T16FK Release Statuses
151 T16FS Release Strategies
152 T16FT Descriptions of Release Strategies
153 T16FV Release Prerequisites
154 T16FW Assignment of Role to Release Code
155 T16LA Texts on Status of Requisition Processing
156 T16LB Scope of List: Purchase Requisitions
157 T16LC Description of Scope of List: Purchase Requisitions
158 T16LD Routines for Structure of Requisition Lists
159 T16LE Texts for Routines for Structure of Requisition Lists
160 T16LF Routines for Data Retrieval in Requisition Lists
161 T16LG Texts for Routines for Data Retrieval in Requisition Lists
162 T16LH Default List Scope for Requisitions in Transactions
163 T16LI Data Retrieval for List Scope: Purchase Requisitions
164 T16LL Routines for List Scope: Purchase Requisitions
165 T170 Copying Control: Texts in Purchasing
166 T460Q Special Procurement Types per Procurement Type
167
SAP Implementation Roadmap and Project Plan
SAP Implementation Phases i.e ASAP methodology
ASAP methodology (AcceleratedSAP) : A comprehensive solution for the introduction of the R/3 System in your enterprise. ASAP and most of its tools can be used independently of an R/3 installation. The tools available for ASAP are:
1. Project Estimator, an internal SAP tool which enables SAP consultants to accurately gauge the required resources, the costs and the time frame of implementation. The Project Estimator takes into account the project scope and several project and risk factors.
2. Concept Check Tool, a tool enabling you to carry out quality checks on the project preparation, technical infrastructure and R/3 configuration settings. This is done mainly during the first two implementation phases of the R/3 project. In this way you are alerted to potential data volume and configuration conflicts that could lead to performance issues if not addressed.
3.Implementation Assistant: The ASAP navigation tool that accompanies you through the five phases of implementation down to the task level. It includes a description and a detailed "how-to" for each task in the Roadmap. Along with that, many tools, templates and documents are hyperlinked to the task. The Implementation Assistant contains the following elements:
Generally ASAP incorporates standard design templates and accelerators covering every functional area within the system, as well as supporting all implementation processes. SAP Project Implementation is one of the components of Project Management and required a great degree of project related Knowledge such as Project Management, Change Management, Risk Analysis and Review Programs.
ASAP Implementation Roadmap and Project Plan. The Roadmap contains the five phases namely,
1.Project Preparation Phase – First Phase of SAP Implementation. In this phase, following are discussed and documented ,
• Project Planning & Procedures
• Project Team Members & their Training
• Project Kickoff /Start off /Sign on
• Technical Requirements
2.Business Blueprint Phase - In this phase, all the details of the projects are set, The project manager from implementers side and from client side, then the whole team is selected of both sides, sometimes there are interviews of consultants as well from the client and sign up of the project is done and also each modules consultants will sign up if the project start has big difference in dates. This AS-IS process (existing), the MM consultant and power users from client sit down and jot down all the current settings of the client ,and decides and researched how their current system is configured, and active settings for client process in SAP are framed i.e.Org. Str. like no.of plants, purchase organizations, pur.groups, material groups, material types,no.range for master record, document types ,document types for PR,PO,contract, Framework order(Blanket P.O), Source Lists, MRP type, subcontract, consignment process etc.
Once you get all the data in AS-IS, you create blueprint based on this information which will contain every info, i.e. how many plants will be created, what numbers, how many storage locations with names and numbers for each plant, how many purchase organization with details, purchase groups, document types of prs, pos, with number ranges, release strategy, and total process flow in this documentation and what can and what cant be configured in SAP, thus the TO BE pre-stage to finalized document for client business Process) . Here client views your document and if there are any reservations they are pointed out, if any deletion addition is needed to the document they are notified to the consultants, necessary changes are made to the blueprint and this up/down in changes keeps on going, until the blueprint is signed (Finalized document of the project)detailed study of business processes and business requirements are undertaken by the Project Team members. This is the phase where Project Team Members (SAP Consultants along with Project Manager) interact with respective Core Team Members (Non SAP Consultant) or Process Owners. The whole requirements are gathered in this phase and following are discussed and documented,
• Project Management
• Organizational Change Management
• Training
• Develop System Environment
• Organizational Structure Definition
• Business Process Analysis
• Business Process Definition
3.Realization Phase - In this phase, all the business and process requirements are implemented as documented in Business Blueprint. SAP R/3 system is configured step by step in two work packages, Baseline and Final configuration. How these configurations will be done and how it will be tested.
• Baseline Configuration and Confirmation
• System Management
• Final Configuration and Confirmation
• Development of external Programs & Interfaces
• Unit Testing & Documentation
• Final Integration Test
• Business Scenarios & Process Documentation
• End User Training & Documentation
• Quality Check
4.Final Preparation Phase - During this phase, following activities are discussed, completed and documented, successful completion of these activities leads to transition of all configurations settings to live R/3 System
• System Management
• Stress & Volume Tests
• Cutover Strategies & Plans
• End User Training
• Quality Check
5.Go Live and Support Phase – This is phase where all configurations/customizations are transported to live production operation and business starts all its activities in the SAP R/3.
During this phase, all the problems/issues related to hardware, network, operating system, database, training, and application system are addressed by the project team members and they help the end users in achieving their day to day task/assignments. This phase is further divided as:
• Application Production Support and Maintenance
• Project Implementation End
5.Continuous Improvement Phase – Towards continuous improvement and to overcome the organizational, business & technology changes the followings are covered under this phase:
• Post go-Live Support
• Improve System performance
ASAP methodology (AcceleratedSAP) : A comprehensive solution for the introduction of the R/3 System in your enterprise. ASAP and most of its tools can be used independently of an R/3 installation. The tools available for ASAP are:
1. Project Estimator, an internal SAP tool which enables SAP consultants to accurately gauge the required resources, the costs and the time frame of implementation. The Project Estimator takes into account the project scope and several project and risk factors.
2. Concept Check Tool, a tool enabling you to carry out quality checks on the project preparation, technical infrastructure and R/3 configuration settings. This is done mainly during the first two implementation phases of the R/3 project. In this way you are alerted to potential data volume and configuration conflicts that could lead to performance issues if not addressed.
3.Implementation Assistant: The ASAP navigation tool that accompanies you through the five phases of implementation down to the task level. It includes a description and a detailed "how-to" for each task in the Roadmap. Along with that, many tools, templates and documents are hyperlinked to the task. The Implementation Assistant contains the following elements:
Generally ASAP incorporates standard design templates and accelerators covering every functional area within the system, as well as supporting all implementation processes. SAP Project Implementation is one of the components of Project Management and required a great degree of project related Knowledge such as Project Management, Change Management, Risk Analysis and Review Programs.
ASAP Implementation Roadmap and Project Plan. The Roadmap contains the five phases namely,
1.Project Preparation Phase – First Phase of SAP Implementation. In this phase, following are discussed and documented ,
• Project Planning & Procedures
• Project Team Members & their Training
• Project Kickoff /Start off /Sign on
• Technical Requirements
2.Business Blueprint Phase - In this phase, all the details of the projects are set, The project manager from implementers side and from client side, then the whole team is selected of both sides, sometimes there are interviews of consultants as well from the client and sign up of the project is done and also each modules consultants will sign up if the project start has big difference in dates. This AS-IS process (existing), the MM consultant and power users from client sit down and jot down all the current settings of the client ,and decides and researched how their current system is configured, and active settings for client process in SAP are framed i.e.Org. Str. like no.of plants, purchase organizations, pur.groups, material groups, material types,no.range for master record, document types ,document types for PR,PO,contract, Framework order(Blanket P.O), Source Lists, MRP type, subcontract, consignment process etc.
Once you get all the data in AS-IS, you create blueprint based on this information which will contain every info, i.e. how many plants will be created, what numbers, how many storage locations with names and numbers for each plant, how many purchase organization with details, purchase groups, document types of prs, pos, with number ranges, release strategy, and total process flow in this documentation and what can and what cant be configured in SAP, thus the TO BE pre-stage to finalized document for client business Process) . Here client views your document and if there are any reservations they are pointed out, if any deletion addition is needed to the document they are notified to the consultants, necessary changes are made to the blueprint and this up/down in changes keeps on going, until the blueprint is signed (Finalized document of the project)detailed study of business processes and business requirements are undertaken by the Project Team members. This is the phase where Project Team Members (SAP Consultants along with Project Manager) interact with respective Core Team Members (Non SAP Consultant) or Process Owners. The whole requirements are gathered in this phase and following are discussed and documented,
• Project Management
• Organizational Change Management
• Training
• Develop System Environment
• Organizational Structure Definition
• Business Process Analysis
• Business Process Definition
3.Realization Phase - In this phase, all the business and process requirements are implemented as documented in Business Blueprint. SAP R/3 system is configured step by step in two work packages, Baseline and Final configuration. How these configurations will be done and how it will be tested.
• Baseline Configuration and Confirmation
• System Management
• Final Configuration and Confirmation
• Development of external Programs & Interfaces
• Unit Testing & Documentation
• Final Integration Test
• Business Scenarios & Process Documentation
• End User Training & Documentation
• Quality Check
4.Final Preparation Phase - During this phase, following activities are discussed, completed and documented, successful completion of these activities leads to transition of all configurations settings to live R/3 System
• System Management
• Stress & Volume Tests
• Cutover Strategies & Plans
• End User Training
• Quality Check
5.Go Live and Support Phase – This is phase where all configurations/customizations are transported to live production operation and business starts all its activities in the SAP R/3.
During this phase, all the problems/issues related to hardware, network, operating system, database, training, and application system are addressed by the project team members and they help the end users in achieving their day to day task/assignments. This phase is further divided as:
• Application Production Support and Maintenance
• Project Implementation End
5.Continuous Improvement Phase – Towards continuous improvement and to overcome the organizational, business & technology changes the followings are covered under this phase:
• Post go-Live Support
• Improve System performance
Friday, July 1, 2011
Simple way of defining Select-options in Module Pool Programming
Simple way of defining Select-options in Module Pool Programming
Defining select-options in selection-screen is easy task but in module pool it is slightly tricky.
Selection-screen can be defined as subscreen and can be applied in the subscreen area of module pool program.
Create report with following code.
REPORT zselectoptions.
TABLES : vbrk , vbrp .
SELECTION-SCREEN BEGIN OF SCREEN 400 AS SUBSCREEN.
PARAMETERS : p_vkorg TYPE vbrk-vkorg OBLIGATORY DEFAULT '1000'.
SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln,
s_posnr FOR vbrp-posnr.
SELECTION-SCREEN END OF SCREEN 400 .
START-OF-SELECTION .
CALL SCREEN 100 .
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
ENDMODULE. " USER_COMMAND_0100 INPUT
Define screen 100 with subcreen area SEL as shown in below .
Define PF status and title bar with any names. This is not shown in screen shot.
Put code in PBO and PAI of screen as shown in below screen shot.
Call subscreen sel including sy-repid ‘400’.
Activate all objects and execute the report you should get following module pool screen with select-options.
Defining select-options in selection-screen is easy task but in module pool it is slightly tricky.
Selection-screen can be defined as subscreen and can be applied in the subscreen area of module pool program.
Create report with following code.
REPORT zselectoptions.
TABLES : vbrk , vbrp .
SELECTION-SCREEN BEGIN OF SCREEN 400 AS SUBSCREEN.
PARAMETERS : p_vkorg TYPE vbrk-vkorg OBLIGATORY DEFAULT '1000'.
SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln,
s_posnr FOR vbrp-posnr.
SELECTION-SCREEN END OF SCREEN 400 .
START-OF-SELECTION .
CALL SCREEN 100 .
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
ENDMODULE. " USER_COMMAND_0100 INPUT
Define screen 100 with subcreen area SEL as shown in below .
Define PF status and title bar with any names. This is not shown in screen shot.
Put code in PBO and PAI of screen as shown in below screen shot.
Call subscreen sel including sy-repid ‘400’.
Activate all objects and execute the report you should get following module pool screen with select-options.
Display Logo on Screen
You can display logo(s) on your screen using the custom control function. A custom control is an area on the screen, created using the screen painter. Custom controls are used to embed controls. Container controls are instances of special global classes from the SAP Control Framework. The global class for custom controls is called CL_GUI_CUSTOM_CONTAINER. To link a custom control to a container control, pass the custom control name to the CONTAINER_NAME parameter of the container control constructor when you instantiate it. The following is a sample program to demonstrate the logo display using the custom control. This program was written in SAP4.6C. Design a screen with the custom control, by name PICTURE_CONTAINER. It has the following flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
The GUI status SCREEN100 has the functions BACK, EXIT, and CANCEL (all with type E).
Code
REPORT ZSURESH_TEST .
* Type declarations.....................
TYPES pict_line(256) TYPE c.
* data declarations......................
DATA :init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
picture TYPE REF TO cl_gui_picture,
pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
CALL SCREEN 100.
* Dialog modules......................................
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN100'.
IF init is initial.
init = 'X'.
CREATE OBJECT:
container EXPORTING container_name = 'PICTURE_CONTAINER',
picture EXPORTING parent = container.
ENDIF.
IMPORT pict_tab = pict_tab FROM DATABASE abtree(pi) ID 'ENJOY'.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'GIF'
TABLES
data = pict_tab
CHANGING
url = url.
CALL METHOD picture->load_picture_from_url EXPORTING url = url.
CALL METHOD picture->set_display_mode
EXPORTING display_mode = picture->display_mode_fit_center.
ENDMODULE.
MODULE cancel INPUT.
LEAVE TO SCREEN 0.
ENDMODULE.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
The GUI status SCREEN100 has the functions BACK, EXIT, and CANCEL (all with type E).
Code
REPORT ZSURESH_TEST .
* Type declarations.....................
TYPES pict_line(256) TYPE c.
* data declarations......................
DATA :init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
picture TYPE REF TO cl_gui_picture,
pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
CALL SCREEN 100.
* Dialog modules......................................
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN100'.
IF init is initial.
init = 'X'.
CREATE OBJECT:
container EXPORTING container_name = 'PICTURE_CONTAINER',
picture EXPORTING parent = container.
ENDIF.
IMPORT pict_tab = pict_tab FROM DATABASE abtree(pi) ID 'ENJOY'.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'GIF'
TABLES
data = pict_tab
CHANGING
url = url.
CALL METHOD picture->load_picture_from_url EXPORTING url = url.
CALL METHOD picture->set_display_mode
EXPORTING display_mode = picture->display_mode_fit_center.
ENDMODULE.
MODULE cancel INPUT.
LEAVE TO SCREEN 0.
ENDMODULE.
Step-by-Step guide to develop Outbound ABAP Proxy from SAP with PDF attachment
In order to develop a ABAP Proxy first we need to have a Proxy Configured in the transaction SPROXY, this is to be done by PI or XI consultant, as a ABAPer you are not concerned with this.
The Proxy configured in SPROXY will look like.
By Clicking on the structure we can also see the structure of the Proxy, which is in tree structure.
In this case, proxy have 4 structured to be filled with data and then trigger the proxy to PI.
In order to create the proxy from the namespace given, we need to do following
1.Right click on the Message interface(outbound) and click on create
2.After clicking on create it will ask for Transport Request no, prefix, proxy class and other details, that we need to give in order to create the proxy and then activate.
3.We need to create a simple report program using SE38 .
4.We need to create a structure that will refer to the proxy structure. We need to populate this in order to send our data.
g_t_header TYPE zintercompany_data _send .
5.Various data declalarions required for Proxy sending and PDF attachment sending are.
attch_protocol TYPE REF TO if_wsprotocol_attachments,
g_attachment TYPE REF TO if_ai_attachment,
g_attachments TYPE prx_attach, "Internal table for attachment
g_attach_xstring TYPE xstring, "variable of xstring type.
g_spool_id TYPE tsp01-rqident,
g_pripar TYPE pri_params,
g_arcpar TYPE arc_params,
g_pdfspoolid TYPE tsp01-rqident, "SPOOL ID
g_jobname TYPE tbtcjob-jobname, "Jobname parameter for SPOOL
g_jobcount TYPE tbtcjob-jobcount, "Jobcount Paramater for SPOOL
g_string TYPE string, "To convert 132 character data into 255 character data.
*Reference variables exception class
lo_sys_exception TYPE REF TO cx_ai_system_fault,
*Object declaration for Proxy Class
obj_invoice1 TYPE REF TO “Proxy class name”.
* creating proxy object
CREATE OBJECT obj_invoice1.
6.If some amount field is involved, we can use FM CONVERSION_EXIT_CUNIT_OUTPUT to put –ve sign on the left side.
7.Update the main structure with the data required, if some substructures are there, then also finally we need to fill the main structure we only, that will be passed while triggering the proxy.
g_t_header-invoice_details-invoice_line_item[] = g_t_tab_det[].
g_t_header-invoice_properties = wa_inv_pro.
8.Get all the data required for PDF into a internal table.
9.In order to send the PDF into the proxy we need to get all the data in a “Xstring” type variable. To do so first we need to create a SPOOL of the data in our internal table.
10.Use FM 'GET_PRINT_PARAMETERS', if some special format is required. Start the TRY-CATCH Block. To create SPOOL :
NEW-PAGE PRINT ON
PARAMETERS g_pripar
ARCHIVE PARAMETERS g_arcpar
NO DIALOG.
“Write your data that need to be printed , with the format required for PDF. Whatever written here will be converted into SPOOL.
g_spool_id = sy-spono.
NEW-PAGE PRINT OFF.
11.We need to convert this SPOOL into PDF format using FM 'CONVERT_ABAPSPOOLJOB_2_PDF'
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = g_spool_id " SPOOL ID
no_dialog = ' '
IMPORTING
pdf_bytecount = g_size_bytes
pdf_spoolid = g_pdfspoolid
btc_jobname = g_jobname
btc_jobcount = g_jobcount
TABLES
pdf = g_table " All the data will be in this Data table
12.Converting the 132 character data to 255 character data
CLEAR g_string.
LOOP AT g_table INTO wa_table.
TRANSLATE wa_table USING ' |'.
CONCATENATE g_string wa_table INTO g_string.
ENDLOOP.
TRANSLATE g_string USING '| '.
DO.
wa_buf = g_string.
APPEND wa_buf TO g_t_buf.
SHIFT g_string BY 255 PLACES.
IF g_string IS INITIAL.
EXIT.
ENDIF.
ENDDO.
13.Appending 255 character data in one variable.
IF g_t_buf[] IS NOT INITIAL.
LOOP AT g_t_buf INTO wa_buf.
CONCATENATE
g_output
wa_buf
INTO g_output.
ENDLOOP.
14.Convert the Binary String to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = g_output
IMPORTING
buffer = g_outputx
15.Concatenating attach_xstring with the data field.We need to send this field to Proxy.
CONCATENATE g_attach_xstring g_outputx INTO g_attach_xstring IN BYTE MODE.
16.Below is the code required to send the proxy.
TRY-CATCH
* Get attachment protocol
TRY.
attch_protocol ?= obj_invoice1->get_protocol( if_wsprotocol=>attachments ).
g_attachment = attch_protocol->get_attachment_from_binary(
data = g_attach_xstring
type = if_ai_attachment=>c_mimetype_pdf
name = 'PDF Attachment' ). " Name of PDF to be uploaded
APPEND g_attachment TO g_attachments.
attch_protocol->set_attachments( g_attachments ).
*Sending Proxy fields to XI through EXECUTE ASYNCHRONOUS Method.
CALL METHOD obj_invoice1->execute_asynchronous
EXPORTING
output = g_t_header.
CATCH cx_ai_system_fault INTO lo_sys_exception.
COMMIT WORK.
ENDTRY.
CATCH cx_ai_system_fault INTO lo_sys_exception.
ENDTRY.
17.Other Exception Handling can be done as per the requirement. Using the “SXMB_MONI” TCode we can check whether the proxy has been sent successfully or not.
The Proxy configured in SPROXY will look like.
By Clicking on the structure we can also see the structure of the Proxy, which is in tree structure.
In this case, proxy have 4 structured to be filled with data and then trigger the proxy to PI.
In order to create the proxy from the namespace given, we need to do following
1.Right click on the Message interface(outbound) and click on create
2.After clicking on create it will ask for Transport Request no, prefix, proxy class and other details, that we need to give in order to create the proxy and then activate.
3.We need to create a simple report program using SE38 .
4.We need to create a structure that will refer to the proxy structure. We need to populate this in order to send our data.
g_t_header TYPE zintercompany_data _send .
5.Various data declalarions required for Proxy sending and PDF attachment sending are.
attch_protocol TYPE REF TO if_wsprotocol_attachments,
g_attachment TYPE REF TO if_ai_attachment,
g_attachments TYPE prx_attach, "Internal table for attachment
g_attach_xstring TYPE xstring, "variable of xstring type.
g_spool_id TYPE tsp01-rqident,
g_pripar TYPE pri_params,
g_arcpar TYPE arc_params,
g_pdfspoolid TYPE tsp01-rqident, "SPOOL ID
g_jobname TYPE tbtcjob-jobname, "Jobname parameter for SPOOL
g_jobcount TYPE tbtcjob-jobcount, "Jobcount Paramater for SPOOL
g_string TYPE string, "To convert 132 character data into 255 character data.
*Reference variables exception class
lo_sys_exception TYPE REF TO cx_ai_system_fault,
*Object declaration for Proxy Class
obj_invoice1 TYPE REF TO “Proxy class name”.
* creating proxy object
CREATE OBJECT obj_invoice1.
6.If some amount field is involved, we can use FM CONVERSION_EXIT_CUNIT_OUTPUT to put –ve sign on the left side.
7.Update the main structure with the data required, if some substructures are there, then also finally we need to fill the main structure we only, that will be passed while triggering the proxy.
g_t_header-invoice_details-invoice_line_item[] = g_t_tab_det[].
g_t_header-invoice_properties = wa_inv_pro.
8.Get all the data required for PDF into a internal table.
9.In order to send the PDF into the proxy we need to get all the data in a “Xstring” type variable. To do so first we need to create a SPOOL of the data in our internal table.
10.Use FM 'GET_PRINT_PARAMETERS', if some special format is required. Start the TRY-CATCH Block. To create SPOOL :
NEW-PAGE PRINT ON
PARAMETERS g_pripar
ARCHIVE PARAMETERS g_arcpar
NO DIALOG.
“Write your data that need to be printed , with the format required for PDF. Whatever written here will be converted into SPOOL.
g_spool_id = sy-spono.
NEW-PAGE PRINT OFF.
11.We need to convert this SPOOL into PDF format using FM 'CONVERT_ABAPSPOOLJOB_2_PDF'
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = g_spool_id " SPOOL ID
no_dialog = ' '
IMPORTING
pdf_bytecount = g_size_bytes
pdf_spoolid = g_pdfspoolid
btc_jobname = g_jobname
btc_jobcount = g_jobcount
TABLES
pdf = g_table " All the data will be in this Data table
12.Converting the 132 character data to 255 character data
CLEAR g_string.
LOOP AT g_table INTO wa_table.
TRANSLATE wa_table USING ' |'.
CONCATENATE g_string wa_table INTO g_string.
ENDLOOP.
TRANSLATE g_string USING '| '.
DO.
wa_buf = g_string.
APPEND wa_buf TO g_t_buf.
SHIFT g_string BY 255 PLACES.
IF g_string IS INITIAL.
EXIT.
ENDIF.
ENDDO.
13.Appending 255 character data in one variable.
IF g_t_buf[] IS NOT INITIAL.
LOOP AT g_t_buf INTO wa_buf.
CONCATENATE
g_output
wa_buf
INTO g_output.
ENDLOOP.
14.Convert the Binary String to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = g_output
IMPORTING
buffer = g_outputx
15.Concatenating attach_xstring with the data field.We need to send this field to Proxy.
CONCATENATE g_attach_xstring g_outputx INTO g_attach_xstring IN BYTE MODE.
16.Below is the code required to send the proxy.
TRY-CATCH
* Get attachment protocol
TRY.
attch_protocol ?= obj_invoice1->get_protocol( if_wsprotocol=>attachments ).
g_attachment = attch_protocol->get_attachment_from_binary(
data = g_attach_xstring
type = if_ai_attachment=>c_mimetype_pdf
name = 'PDF Attachment' ). " Name of PDF to be uploaded
APPEND g_attachment TO g_attachments.
attch_protocol->set_attachments( g_attachments ).
*Sending Proxy fields to XI through EXECUTE ASYNCHRONOUS Method.
CALL METHOD obj_invoice1->execute_asynchronous
EXPORTING
output = g_t_header.
CATCH cx_ai_system_fault INTO lo_sys_exception.
COMMIT WORK.
ENDTRY.
CATCH cx_ai_system_fault INTO lo_sys_exception.
ENDTRY.
17.Other Exception Handling can be done as per the requirement. Using the “SXMB_MONI” TCode we can check whether the proxy has been sent successfully or not.
Subscribe to:
Posts (Atom)