Snippets

Jimbo's picture

Produce a reconciliation report for material movement including financials

Reconciling inventory loads can be a daunting task involving complex table joins, custom queries and massive Excel spreadsheets. Accounting professionals will seldom turn down enriched data that saves them hours of mind-numbing number crunching and this snippet generates a report with almost all the information that they need.

Jimbo's picture

Export SAP tables to tab-delimited UTF-8 text file with header row

It never hurts to take a snapshot of high-profile tables in the production system before making changes. This task can be a manual task that is performed each day or broken down into object-specific tasks that automatically export pertinent tables as part of the Convert Data step.

Jimbo's picture

Find Finished Goods without Batch Classification

A recent requirement called for a report that listed all finished goods (material type: FERT) without a batch classification assignment. Normally this would be a five-minute task in SQ00 to create a query, but linking the MARA table to the INOB table in a meaningful way is forbidden by SAP if no join exists. By adding a few lines of code it is possible to produce the same report using LSMW.

Jimbo's picture

Ensure that user settings are aligned with source data

SAP expects date and number information to be formatted a certain way, but it varies based upon local standards and is configured for each client. When writing software and testing in a development system the software depends on the localized standards in the programmer's User Profile. The User Profile can be changed using transaction SU3 or by clicking through the menu with System → User Profile → Own Data.

Jimbo's picture

Determine Tax Jurisdictions for Customers During Conversion Step

Pre-validating source data during the conversion step in LSMW is a great way to provide meaningful reports to the resources who are extracting and transforming data from legacy systems. Finding errors in the source data and correcting them before attempting to load ensures a smoother ETL process.

Jimbo's picture

Display remaining time during long-running conversions

When performing pre-validations on data and comparing it against existing data the job tends to run a long time. LSMW by default will indicate the progress of the conversion step after every 500 records, but it doesn't indicate how much longer the task will run. While unnecessary, it is a fun way to plan for coffee breaks.

Percent complete SAPGUI 7.10 and earlier
Percent complete SAPGUI 7.20 and after

Jimbo's picture

Remove special characters from strings in ABAP.

Data sometimes comes with special characters that are expressly forbidden by SAP. Some fields are very specific and will except a very small character set. Having a tool to remove those special characters from free-text can save a lot of headaches, but removing those same forbidden characters from fields that are not free-text, can cause more headaches.

Jimbo's picture

Determine What Classification Materials Are Assigned To

When assigning classifications to materials it helps to check to see if the material is already assigned to a classification. In some cases materials can have just one type of classification assigned to it. For example, materials cannot have multiple batch classifications assigned to them.

Jimbo's picture

Predetermine the order of selectable views in MM02 transaction.

Making changes to materials using a recording can be difficult because of the Select Views screen that pops up providing a list of available views. SAP's method for determining the order of selectable views is difficult to understand even after hours spent examining all the tables involved. In the end, the simplest and therefore (according to Occam) best solution is to call SAP's functions for the purpose.

Jimbo's picture

Set a break point in LSMW to use SAP's debugger.

Sometimes problems in source code are too complicated to resolve without stepping through the code while it is executing. Adding a break point to the ABAP code in LSMW is easy and provides an invaluable way to debug complicated problems and is faster than invoking the debugger with /h.

Jimbo's picture

Add an index to reports generated in LSMW

The Convert Data step in LSMW is a great place to validate data with bits of ABAP and to produce a report that enables those responsible for cleansing to easily find problems with the source data. Catching errors at this point and excluding erroneous records from the load is always preferable to letting bad data pass through the conversion process and then allowing it to fail during the load only to then use the error log as a reporting tool.

Jimbo's picture

Add parameters to an LSMW object and describe them.

Often the behaviour of an LSMW object needs to change quickly to fit requirements as a project progresses. Modifying the source code in a development system and then transporting the LMSW object to a quality or production system takes time. Writing multiple LSMW objects for slightly different tasks is cumbersome and hard-to-manage and it duplicates effort.

Jimbo's picture

De-duplicate records in an Access table using VBA

Performing transformations on legacy data often entails removing duplicates from legacy data, especially when working with data from multiple legacy systems. The access feature Totals, often denoted by the Greek symbol Sigma (Σ), can be used for this, but there is a subtle difference between identifying (or counting) unique records and removing duplicates. Also, creating an Access query marries it to a single table with a fixed format; each table in need of de-duplication requires its own query.

Jimbo's picture

Export directly to Excel from Access using VBA

Export to ExcelExcel has a lot of tendencies that make it a less-than-desirable tool for data conversion. Too often data is corrupted by Excel's tendency to convert numbers from one international standard to another, to convert long numeric values to scientific notation and to convert dates from one format to another. The insufferable habit of trimming off leading zeros makes Excel near worthless for handling many types of SAP data.

Where Excel shines is in it's ability to act as an easy-to-use reporting tool. Handing off reports for the purposes of validation and reconciliation is best done in Excel because few functional resources are equipped to handle raw text. Additionally, Excel is the industry standard for perusing table data and is installed on almost all work computers.

Jimbo's picture

Identify Malformed Postal Codes in LSMW

PostcodeStaring at a spreadsheet of ten thousand customers looking for invalid data is like looking for defective hay in a haystack. SAP can cut the time required for validation to a small fraction of what it would normally take by identifying problem records in the source data. The resource that is responsible for correcting invalid data (potentially the same person performing the ETL) will be grateful for the help.

Jimbo's picture

How to replace invalid, malformed postal codes with valid dummy values

Many legacy systems have little or no validation on the postal code and SAP has very strict, country-specific validation that cannot be circumvented. Validating the postal codes in LSMW as part of the Convert Data phase is always a good idea and is a great way to identify defects in the data and provide feedback to the client. Early in the implementation it is better to transport the master data with dummy postal codes to allow the processing of downstream transactional data.

Jimbo's picture

Import a text file as a table in MS Access using VBA

MS Access is easily the best-suited software tool for manipulating, cleansing and transforming extracts from legacy systems prior to loading into SAP. This function automatically determines the format of the text file and creates a table based on the structure of the text data. It can even import extracts created using the SE16 transaction in SAP without any additional steps.

Jimbo's picture

Pre-validate Vendor Masters before transporting dependent transactional data

So often a disconnect appears between the Vendor Masters that are transported to SAP and the transactional data that follows. Vendors are a dependency for documents like accounts payable and purchase orders. If vendors aren't present in the new system or, if they're configured incorrectly, then the documents cannot post and a conversion project can grind to a standstill.

Jimbo's picture

Extract an Entire Database from SQL Server into Access

Access LogoOften times Data Conversion projects migrate from Access to SQL Server in order to bypass the 2GB limit on the size of Access databases. Sometimes it goes the other way. When a young legacy system has yet to accumulate 2GB of data, it might be easier to work with in Access.

Working with an Access database on a local hard drive will almost always be faster than working on a SQL server in another country. Manipulating data over a network presents a great deal of overhead and latency even when the server is in the same room.

Jimbo's picture

Import a text file as a linked table using VBA

https://usercontent2.hubstatic.com/7521114_f260.jpg|https://usercontent2.hubstatic.com/7521087_f520.jpg|http://img.scoop.it/ZAUfhjn4fcSHYE1CZHHC2jl72eJkfbmt4t8yenImKBVvK0kTmF0xjctABnaLJIm9|https://s-media-cache-ak0.pinimg.com/564x/6e/da/4d/6eda4ded7de46ef76f40bc5c69f184c8.jpgAll versions of MS Access have a 2GB file-size limitation. Without warning or explanation, Access will simply stop working and the database is rendered useless until the size is reduced. Handling large text file extracts from legacy systems as linked tables is an easy workaround for this problem, but managing linked tables is cumbersome unless every single revision of the extract is in the exact same format.

Linking to the text file rather than importing it presents a non-negligible performance hit. With modern computers linking doesn't have a significant impact on overall processing time, especially if the text file is on a local hard drive instead of a network share.

Jimbo's picture

Export directly to UTF-8 from Access using VBA

Since the release of ECC 6.10 the SAP R/3 system supports Unicode, a system that uses multiple bytes to represent characters and allows symbols from non-ASCII alphabets to appear in the data. While ASCII can still be used for data from America and for simple financial data, the transport of data from one system to the next is almost always handled now using Unicode.

The flavors of Unicode

Pages