Saturday, October 29, 2016

Valuation


Procurement process starts with creating purchase order and ends with invoice verification. In the whole process one of the important parts is material valuation. In procurement process while creating purchase orders material price is a mandatory field and it is automatically determined. This happens because material valuation is maintained in SAP system in material master. Material valuation represents integration between MM & FI (Financial Accounting) modules since it updates the general ledger accounts in financial accounting. The key points about material valuation are as follows.
  • Material valuation helps to determine the price of material and for which general ledger account it needs to be posted in financial accounting.
  • Material valuation can happen at company code level or plant level. (Valuation area /MBEW-BWKEY)
  • Material can be valuated based on different types of procurement and this is known as split valuation. Normally split valuation is used to valuate material in same valuation area (company or plant) differently. Split valuation is described in detail in below context.
Split Valuation
Split valuation enables you to valuate stocks of a material in the same valuation area (company or plant) differently. Some of the examples where split valuation is required are as follows.

Example 1:
You procure a material both from in-house production and from external vendors. You want to valuate the stocks from each source separately. In this case, you select Procurement type as the valuation category ( B ) and Internal and External as valuation types.

Example 2:
You procure a material from several countries. You want to valuate the stocks from each country separately. In this case, you select Origin as the valuation category ( H ). As valuation types, you define the relevant countries, for example, Italy and France .

Example 3:

You procure a material in different grades. You want to valuate the stocks of each class separately. In this case, you select Quality as the valuation category ( Q ). As valuation types, you could define A , B , C , and D .
Split Valuation needs to be activated before setting any other configuration. Split valuation can be activated by following the below steps.
Path to Activate Split Valuation:
IMG => Materials Management => Valuation and Account Assignment => Split Valuation => Activate Split Valuation
TCode: OMW0
On Display IMG screen select Activate Split Valuation execute icon by following the above path.
SAP Split Valuation
Select Split material valuation active tab. Click on save. Split valuation is now activated.
SAP Split Valuation Set
Some important terms under split valuation are as follows.
  • Valuation Area: Material may be valuated at plant level or at company code level. The level at which materials are valuated is known as valuation area.
  • Valuation Category: Valuation category is the criteria on which material is split valuated.
  • Valuation Type: Valuation type specifies the features of a valuation category.
Split valuation configurations like defining valuation category, valuation type are described in below context.
Split Valuation Configuration
Split valuation configurations like defining valuation category, valuation type can be done by following the below steps.
Path to Configure Split Valuation:
IMG => Materials Management => Valuation and Account Assignment => Split Valuation => Configure Split Valuation
TCode: OMWC
On Display IMG screen select Configure Split Valuation execute icon by following the above path.
SAP Split Valuation Configuration
Select Global Types tab to create valuation type.
SAP Split Valuation type path
Select Create icon.
SAP Split Valuation type create
Provide name of valuation type. Click on save. A new Valuation Type will be created.
SAP Split Valuation entry
Now go to same screen and select Global Categories tab to create valuation category.
SAP Split Valuation category
Select Create icon.
SAP Split Valuation Category create
Provide name of valuation category. Click on save. A new Valuation Category will be created.
SAP Split Valuation Category entry
Now go to same screen and select Local Definitions tab to map valuation type and valuation category.
SAP Split Valuation Map
Select Cats. -> OU tab.
SAP Split Valuation map select
Provide valuation type, valuation category and set status as active and then select Activate tab. Valuation category and valuation type are now mapped and both are activated.
SAP Split Valuation map entry
After maintaining valuation type and valuation category you can mention them in material master as shown below.
Go to mm02(Change screen for material master). Here you can maintain the valuation category and valuation class in accounting view. On this basis material will be valuated in a purchase order.
SAP Split Valuation material master

Tuesday, October 25, 2016

Files Upload/Download to application server/local

I. Upload File
1. OPEN DATASET
Open dataset statement is used to work with a file on application server.
OPEN DATASET dset
 FOR access
     IN mode [position]
                    [os_additions]
                    [error_handling]
     ENCODING ...

Access:
... INPUT
The addition FOR INPUT opens the file for reading. By default, the file pointer is set at the start of the file. If the file specified does not exist, sy-subrc is set to 8.

In a Unicode program, it is not possible to obtain write access to a file that is open for reading. In a non-Unicode program write access is also permitted.

... OUTPUT
The addition FOR OUTPUT opens the file for writing. If the specified file already exists, its content is deleted. If the file specified does not exist, it is created.

Data is read or written unchanged (as stored in the memory). (For details, see READ DATASET and TRANSFER.)

Mode:
TEXT MODE encoding [linefeed]
The addition IN TEXT MODE opens the file as a text file. Only the content of character-like data objects can be passed to text files and read from text files.

The addition ENCODING defines how the characters are represented in the text file. When writing to a text file, the content of a data object is converted to the representation entered after ENCODING, and passed to the file.

The end-of-line selection of the relevant platform is applied to the passed data by default. When reading from a text file, the content of the file is read until the next end-of-line selection, converted from the format specified after ENCODING into the current character format, and passed to a data object. The end-of-line selection used is controlled using the addition linefeed.
E.g.
open dataset lv_filename for output in text mode encoding utf-8 with byte-order mark with windows linefeed.

LEGACY TEXT MODE [endian] [CODE PAGE cp] [linefeed]
By specifying LEGACY, files can be written in the format that is expected by a non-Unicode system. The byte order (BOM) or the code page (look at TCP00A table) must be specified explicitly.

ENCODING
It defines the character representation in which the content of a text file is handled.
It is best to always write files in UTF-8 (if all readers can process this format). Otherwise, the code page can depend on the text environment and it is difficult to identify the code page from the file content.

TRANSFER LW_LINE TO P_EFILE.
Transfer a line to a file on application server.

This open dataset can be used to input, output text file, pdf file (smartform), ... to application server.

2. Upload File from PC to Server
CALL FUNCTION 'GUI_UPLOAD'
   EXPORTING
     FILENAME           = W_FNAME       "File path
     FILETYPE            = 'ASC'               " File type as ASCII
     HAS_FIELD_SEPARATOR = 'X'       "Fields are separated by tabs
   TABLES
     DATA_TAB            = TD_INFILE
   EXCEPTIONS
     OTHERS               = 0.

The module loads a file from the PC to the server.
Data can be transferred binarily or as text (file type = BIN/ASC/DAT).

The uploaded file is usually in text format with extension .txt and have tab seperator. In case of uploading a csv file, we can read each entire row to a string table (TABLE OF STRING), then use command SPLIT to get each field from the comma seperator.

For uploading an excel file, we can use the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE', ref upload-excel-to-sap

II. Download a file
1. Download File from Server to PC
This function module downloads a file from server to PC.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                                        = lw_fname
    FILETYPE                                         = 'ASC'
    WRITE_FIELD_SEPARATOR                = 'X'
    TRUNC_TRAILING_BLANKS                = 'X'
  TABLES
    DATA_TAB                                        = t_file
  .

Sunday, October 23, 2016

Unit of Measure

Purpose of document

This document is intended to serve as a guideline for creation of a new unit of measure and its related issues.

Introduction: Unit of Measure 

Definition - Unit of Measure is the criterion based on which you measure the quantity of the material. Unit of measure is a value for a physical size.
Examples:
  • Length dimension includes meter, centimeter and inch
  • Time dimension includes second, minute and hour
There are 4 different Unit of Measures used
  1. Base Unit of Measure: This is the unit of measure in which the stocks of a material are managed. The system converts all quantities entered in other units to the base unit of measure. All material postings will occur with respect to base unit of measure.
  2. Sales Unit of Measure: Allows a material to be sold in a unit differing from the base unit of measure. The sales unit is proposed automatically in the sales order, where it can be changed.
  3. (Purchase)Ordering Unit of Measure: Allows a material to be purchase in a unit differing from the base unit of measure. The purchase order unit is proposed automatically in a purchase order, where it can be changed.
  4. Unit of Issue: Unit of measure in which the material is issued from the warehouse. It allows consumption, stock transfers, transfer postings, and physical inventories to be recorded in a unit differing from the base unit of measure.
These UoM's are linked with each other for every material by conversation table which is explained below in section - IV-alternative unit of measure 

I. Creation of Unit of Measure

Unit of measure can be created using transaction CUNI (SPRO-> SAP Net Weaver-> General Settings ->Check units of measurement).
Units of measurement are held centrally in the SAP R/3 System for all applications. It's a onetime creation during the project phase and it used across all modules.
Creation/change of new unit of measure is a Global Impact change in the system.
Go to CUNI transaction


  1. Decide under which dimension unit has to be created:
There are seven base dimensions, to which all other dimensions can be traced: Length, weight, time, electrical current, temperature, molecular mass and brightness.
Whenever unit of measurement is to be created first decide to which dimension it belongs to or otherwise UOM is created under no dimensions. Dimension helps us to group the UOMs. System will allow to create business specific dimensions but always it is advisable to create UOM under the above 7 dimensions.
  
2Decide which ISO code should be assigned to the unit:
An ISO code can be assigned to several internal measurement units.
The ISO code is important for Electronic Data Interchange (EDI). It is used for converting the SAP-internal units of measurement into standard units of measurement. Converting the internal units of measurement into the ISO code is required for exchanging data using EDI. So it is always advised to assign ISO code to UOM. A list of the current international ISO codes for units of measurement is available on the Internet at:
Business specific ISO codes can be created in the system if not available in the system and assigned to UOM.


3.Select the particular dimension under which you want create the unit as shown below
Ex:TIME

4. Select TIME and then click on Units of measurement All other units under the dimension TIME is defined with respect to S (second).S is the SI unit in this dimension

5. Click on create button

6. Maintain the details like Measurement text, commercial name and technical name.
7. Maintain the conversion factor with respect to SI unit. For example here In H unit of measure, conversion is defined with respect to S second.
I.e. 1 H = 3600 sec
8. Maintain the decimal places (up to which decimal value should display) and decimal place rounding (up to which the value should be rounded off)
9. Maintain the tick for commercial unit check box if that unit is used commercially. It will make this unit get displayed in F4 help for unit of measure.
10. Maintain the tick for Value based check box if that unit will be derived based on value. If it is based on quantity, check box should not have a tick.
10. Select the ISO code for the unit and maintain Tick for primary code if that is primary unit for the ISO code.
If the same ISO code is used for more than one unit of measure, you can only flag one unit of measure as a primary unit for one ISO code. Rest of unit of measure will be the secondary unit for this ISO code.
11. Save.
12. Maintain UOM in different languages by logging to the system with different logon language 

Customizing of UOM in SAP is basically stored in two tables:
T006 - Language Independent attributes
T006A - language dépendent attributes + description 

II.     Change in the Unit of Measure:

 Changes in the unit of measure may be for
1.       Change in commercial name
2.       Change in Technical name
3.       Change in Measurement text
4.       Assignment of ISO code/changing ISO code
5.       Change in Decimal Place Rounding.
6.       UOM not maintained in other languages(create UOM in login language) 
As Unit of measurement is held centrally in the SAP R/3 System for all applications, any change will have impact in all modules.

III.  Deletion of Unit of Measure:

Deletion of unit of measure is not advisable as it used centrally in all applications.
Instead of deleting Unit of measure, In CUNI transaction Commercial measuring unit tick is removed so that it will not be displayed in F4 search help for UOM and also whenever it is used in any transaction it will give an Error as "unit is not defined as commercial unit"(SAP always go by commercial name)  
Example: "HR" unit with commercial measuring unit ticked in CUNI transaction






Go to MM02, in sales view check search help (F4) in sales unit field for HR with search criteria H*,you will find the Unit" HR"  

 Go to CUNI transaction and remove the tick of commercial measuring unit Go to MM02, in sales view check search help (F4) in sales unit field for HR with search criteria H* ,here you will not find the unit "HR"  .Try to maintain HR unit directly in Sales unit field ,system will throw the error.



    






IV.  Alternative Unit of Measure:

Individual departments may have their own units of measure. For example, Purchasing may use a different unit than Sales and production may issue a material which is different than the base unit of measure. All units of measure other than the base unit of measure are referred to as alternative units of measure.
Base unit of measure
It is defined in Basic data view in material master. All other units defined, conversion should be maintained with respect to unit of measure in Material master additional data.
Base unit of measure once defined and processed cannot be changed to other unit of measure.
Purchase Order unit
It is defined in purchasing view of material master.
Sales unit
It is defined in sales view of material master.

Unit of issue
It is defined in work scheduling view of the material master.
Alternate unit of measure conversion is maintained with respect to base unit of measure in additional data of material master
All these conversion can be obtained from the table MARM

Monday, October 10, 2016

ABAP Work Process and its Types


A work process executes the individual dialog steps of user requests. In other words, all the execution and processing of user requests is done by work  process and once a request is allotted to the work process, it executes only a single dialog step and then frees itself for handling other requests.
A Dialog step is referred to as the change of screen. A jump from one screen to another is a dialog step.

Components of a Work Process

There could be ‘N’ number of work processes in an Application server.  Each Work Process has 3 different components which it uses to process the request.

In ABAP application programming, there is a difference between user interaction and processing logic. The user interactions are handled by Screen processor whereas the processing logic which might require DB interactions etc is performed by ABAP Processor.
The Screen Processor executes the Screen Flow Logic which consists of large part of user interactions. The screen processor also handles the communication between work process and SAP GUI and it also handles the field transfer from screens to flow logic.
The ABAP Processor executes the processing logic of the application program and also establishes connection between the work process and DB by communicating with the DB interface. The screen processor informs the ABAP processor about the Screen modules to be processed.

The DB Interface
The DB interface is responsible for connecting and disconnecting the work process and the database. It also provides services like access to database tables, repository information etc.

Types of Work Processes

There are 5 types of Work Processes. Please note that the structure of each work process remains same irrespective of its type. The various types of work processes are helpful in optimizing the use of resources of Application server. The dispatcher allots the requests to work process based on its type.


Work Process Type
Request Type
Dialog
D
Dialog Requests
Update
V
Update Requests to Update Database Records
Background
B
Requests which runs in background
Spool
S
Spool Printing requests
Enqueue
E
Logical Lock Requests


Dialog Work Process (D)

Every user request to execute dialog step is processed by Dialog Work Process. By default the response time of a Dialog Work Process is 300sec, after that it gets terminated. Every SAP instance should have a minimum of 2 Dialog Work Processes and can be increased to more as per business requirement. Services with long running Dialog steps (which require more time for processing) should not be loaded to Dialog work processes as it will affect the system performance as a single work process will be allotted to a single a single service and thus other work process would have to handle multiple user requests.. Services with dialog processing time more than 300 sec should be run in background.

Background Work Process (B):

All long running batch jobs and reports where user interaction is not required are executed by Background Work Process. Every instance should have a minimum of 1 Background Work Processes and can be increased to more as per requirement. Background work processes are designed for periodic tasks such as reorganization or the automatic transfer of data from an external system to the R/3 System.

Update Work Process (V)

All the database update related requests are taken care by Update Work process. This is of two types, Synchronous updates (V1) and Asynchronous updates (V2). Every instance should have a minimum of 1 Update Work Processes and can be increased to more as per requirement.

Enqueue Work Process (E):

Enqueue work process implements lock mechanism. When two users are trying to update same data in a table then Enqueue work process locks that table for other user and releases it when first user saves an commits it. It administers the lock table in shared memory which contains the logical databases lock. Only 1 Enqueue Work Process in Application server is sufficient enough to do this job. In order to execute lock requests we must first define a lock object. A lock object is defined in ABAP dictionary which consists of table entries which are to be locked. As per the standard all the user defined lock mechanisms must begin with the name  'EY' or 'EZ'. When we activate a lock object system automatically generates Enqueue and Dequeue function modules which we can use in our ABAP programs to use lock mechanism functionality.


Spool Work Process (S):

Spooling refers to the buffered transfer of data to output devices such as printers, fax devices, and so
on. All printing related requests are handled by Spool Work process. Every ABAP Application server can have only 1 Spool Work Processes and it can’t be increased to more. Spool requests are generated in dialog mode or during background processing and are then set in the spool database with details about the printer and the print format. The data itself is stored in the TemSe (TEMporary SEquential object) database.


In addition to the above work processes the R/3 application server also has two additional services for communication within R/3 system and between Non-SAP  or other SAP systems. They are:-

Message Server (MS or M):

The message server (MS or M) communicates between the distributed dispatchers within the
R/3 System and is therefore the prerequisite for scalability using several parallel-processing
application servers.

Gateway Server (GW or G)

 The gateway server (GW or G) allows communication between R/3, R/2 and external
application systems.

Display and Control Work Processes 

Use

Work processes do the majority of the processing of the SAP System. They execute dialog steps in user transactions, updates, lock administration, etc.
You can also find the term Work Process in the glossary.
You can display a snapshot of the status of the work processes on the application server where you are logged on. (Choosing Administration  System Administration  Monitor ® System Monitoring  Process Overview or transaction SM50). You must refresh the display to get updated information. The information on this screen is described in the following section.
The process overview is intended primarily for information-gathering. For example, you can monitor processes to determine if the number of work processes in your system is adequate, to assess if the instance is working to full capacity, to gather information for trouble-shooting, or for tuning.

Integration

By choosing System monitoring  Servers, this displays the Overview of the SAP Application Server. Here, you can further display the work process overview for a particular server in the SAP System by clicking on the desired server name.
Note
If system load is low, you may notice while using the Process Overview that your requests appear to execute in only a single work process. The dispatcher is trying to use one work process for as many dialog steps for one user as possible. This avoids having to reload the roll area for the user.

Features

The Process Overview displays the following information:
·  No: The internal ID number of a process. Used to identify messages that belong to a work process in the system log
·  Type: Work process types:
¡  DIA work process for executing dialog steps in user transactions
¡  UPD: Update process for making U1 (time-critical) database changes
¡  UP2: Update process for executing U2 (not time-critical) database changes
¡  ENQ for setting and releasing locks on SAP lock objects
¡  BTC for executing background jobs
¡  SPO for spool formatting processes
·  PID:  Process ID of the work process (on the operating system)
·  Status: Current status of the work process Possible statuses are:
¡  Running (executing a request).
¡  Waiting (idle and waiting for a request)
¡  Hold (held for one user) is not an abnormal state, but a work process can only serve a single user.
If too many processes are in Hold, then system performance suffers. You can then use the Reason field to identify holds that perhaps can be released.
¡  Stopped (aborted; Restart set to No).
·  Reason: If a work process is in Hold status, the reason is displayed. Typical reasons are: Debugging, CPIC activity, locks, updates, GUI (system waits for response from the SAPGUI front-end program, for example, for a remote function call (RFC)). For an overview of the possible parameters, refer to the F1 help.
You may also see PRIV (PRIVate use) as a reason for holding a work process. PRIV indicates that a work process is reserved for a single user for memory management use. The work process has exceeded the limit of the SAP memory that is used by other processes. The process is held as long as the current user requires local memory. For more information, see Private Memory in the documentation on SAP Memory Management.
If more than a certain percentage of work processes are in PRIV hold state, then PRIV transactions are automatically terminated if the user is not active in the transaction for a set period of time. You can set this time span in the SAP system profile.
·  Start:Indicates whether the process should be automatically restarted if a process ends prematurely. You can change the restart status of a process by choosing Process  Restart after error  Yes/No. Normally, leave Restart set to Yes.
If a work process aborts during its startup, the system automatically sets Restart to No. This measure protects against endless attempts to restart a process if a database system is not available, or another serious problem is affecting the system. After correcting the problem, you can change Restart to Yes so that the system starts the work processes.
·  Err: Indicates how many times a work process has aborted
·  Sem:Indicates the number of the semaphore for which a work process is waiting.
Normally, this field should be empty. If one or more semaphore numbers frequently appears, evaluate the performance of your system using the Performance Monitor.
·  CPU:Cumulative CPU time since the start of a work process. The time units are seconds and hundredths of seconds.
Note
Calculating CPU time is onerous. Therefore, you must request this information using the CPU function.
·  Time:Indicates the elapsed time used by a work process for the dialog step that it is currently processing
·  Report: ABAP program or report that is currently being executed
·  Cl.: Client for the session that is currently being executed
·  User: User whose request is currently being processed
·  Action: Action that is being executed by the current program. The actions that are displayed are those that are recorded by the SAP performance monitor. The Performance Monitor must be active (SAP profile parameterstat/level = 1 (default)) for actions or database table accesses to be displayed.
·  Table: If the database is being accessed, this column shows the name of the table being accessed.
The menu offers the following functions:
·  Goto: Here you can display User Info to the user who is currently occupying the work process or Backtakes you to the last screen (same as the green arrow does).

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...