lsmw
Transcript of lsmw
S AP AG 1999
BasicsBasics
Structure DefinitionsStructure Definitions
Field Mapping and RulesField Mapping and Rules
Reading and Transferring Data to R/3Reading and Transferring Data to R/3
LSMW Basics
S AP AG 1999
Read data
Spreadsheet tables
Sequential files
Convert data
Import data
LSMW: Core Functions
Data transfer
Note:
• Using the LSMW, you can read data from presentation servers (PC) or application servers. To read these files, you must define the structure of the file (source structure).
• The file contents are then read into an internal LSMW format and stored as an LSMW file.
• The next step is to define structure relationships and field assignments. These specify the mapping of the source structure fields to the target structure fields.
• In addition, you must define a conversion rule for every source field that maps to a field in the target structure. To do this, you specify how the value of the source structure field is to be transferred to the field in the target structure.
• Using these definitions, the contents of the LSMW file are converted to the target structure and can then be transferred using the specified transfer method.
• The LSMW generates two executable ABAP programs from the structure definitions and conversion rules.
S AP AG 1999
Starting the LSMW
Transaction LSMW
Initial Screen:
LSMW organized by:
You must specify a name
and short description for
each of these.
Project
S ubproject
Object
Project
Subproject
Object
S AP AG 1999
Project Overview
All Objects
Overview of objects contained in system
My Objects
Overview of objects the user created
All Objects in a Project
Overview of objects in the current project
S AP AG 1999
Define object attributes
Define source structures and source fields
Define structure relationships
Define field mapping and convers ion rules
Read data
Convert data
Import data
The Main Steps
S AP AG 1999
SAPSAP Easy Easy Access Access
LSM Workbench E dit ... Extras ... Utilities S ystem
...
Personal Menü
LSMW - Substeps
Maintain source attributes
Personal Menu
Maintain source structures
Maintain source fields
Maintain structure relationships
F ixed values, maintain conversions and own routines
S pecfiy files
Generate import program
Display import program
Import data
Display imported data
Generate conversion program
Display conversion program
Convert data
Display converted data. . .
The available LSMW
substeps can be
activated via the
Personal Menu
S AP AG 1999
Attributes
Object
Owner
Data transfer
BC420_ D E xample
ROBE RTS J essica Robertsonce periodic
Object Attributes
Object ID
Owner
Property
Maintain Object Attributes
S AP AG 1999
Object Overview
Overview of Object Creation
LS MW
Object Overview...
Object information about:
Source structures
Source fields
Structure relationships
Target structures
Target fields
Field mapping
S AP AG 1999
E XCE L List
S TYPE Record type CHAR 1
TCODE Transaction code CHAR 20
KUNNR Customer number CHAR 10 a3ktn2 10 M
BUKRS Company code CHAR 4
Field Length Convers ion .........
SAP Fields
Field Description Type Length
Non-SAP Fields
Convers ion on Paper
S AP AG 1999
BasicsBasics
Structure DefinitionsStructure Definitions
Field Mapping and RulesField Mapping and Rules
Reading and Transferring Data to R/3Reading and Transferring Data to R/3
LSMW Structure Definitions
S AP AG 1999
File with flat structure:
Structure A
Field 1Field 2 Field 3
Definition contains :
Structure name
Field name
Flat Source Structure
S AP AG 1999
File with two structures :
Structure B
Structure C
Field 1 Field 2 Field 3 Field 4
Field 1 Field 2 Field 3
Definition contains :
Structure names
Field names
Source Structures Containing Two Structures
S AP AG 1999
File with header and positions : Field 2 Field 3 Field 4
Field 1
Position ID field
Field 2 Field 3
Header structure
Position structure
Field 1
Header ID field
Definition contains :
Structure names
Field names
ID field
Source Structures With Header and Positions
S AP AG 1999
Work S teps
Source Structures
HEAD
POSI
Document header
Document position
Maintain source structures
Name of the source structure
Description of the source structure
Maintain Source Structures
S AP AG 1999
Work S teps
Maintain Source Fields
Field name
Field ID
Field length
Field type
Source Fields
HEAD
SET1 C(001) Record ID
REF_NO C(009) Reference number
POSI
SET2 C(001) Record ID
DATE DDMY(010) Posting date
:
:
Maintain Source Fields
S AP AG 1999
Fields with alphanumeric contents (C field)
Fields with numeric contents (N field)
Date in date format (DDMY, DMDY, DYMD)
=> internal ABAP format YYYYMMDD
Amount fields (AMT1, AMT2, AMT3, AMT4)
=> internal ABAP format with period as decimal point
Fields with packed contents (PAC0 ......PAC5)
Field Types
S AP AG 1999
Source structures
A
B
CStructure relation
X
Y
Z
A
B
C
Available fieldsX
Y
Z
A
A ^ B
A ^ B ^ C
Hierarchical Display
S AP AG 1999
BasicsBasics
Structure DefinitionsStructure Definitions
Field Mapping and RulesField Mapping and Rules
Reading and Transferring Data to R/3Reading and Transferring Data to R/3
LSMW Field Mapping and Rules
S AP AG 1999
Work S teps
Field mapping and rules
BGR00
Fields
BBKPF
Fields
BLDAT Date
BUKRS Company code
Overview: Field Mapping
Field Information and convers ion rules
Documentation
Valid values
Navigation in the ABAP Dictionary
S AP AG 1999
Display Variant in the LSMW
Other parameters , such
as the LSMW
“Technical fields“ can
be displayed from the
display variant.
Form routines (ABAP subprograms)
Process ing times
Global data definitions
Code
Initial fields
Technical fields
Determine Display Variant
SAPSAP Easy Easy Access Access
F ield Mapping E dit ... Extras ... Utilities S ystem
...
Display variant
S AP AG 2001
Display Variant: Technical Fields
After selecting the
checkbox , the
technical fields of
s tructure BGR00
(sess ion header record)
are visible
Code
Initial fields
Technical fields
Determine Display Variant
BGR00
Fields
STYPE Record type for BI interface
GROUP Name of BI session
MANDT Client
Coding: BGR00-STYPE = ‘0‘.
Coding: BGR00-GROUP = g_groupname.
Coding: BGR00-MANDT = SY_MANDT.
USNAM Queue Userid / historically determined
Coding: BGR00-USNAM = g_userid.. . .
Field Mapping and Assignment
S AP AG 1999
Rule levels
Domain level
Data element level
Field (name) level
System proposal
Domain /
Data element/
Field name
Project
Reusability of Rules
S AP AG 1999
Sequence
1. Ass ignment of source field to target field
2. Definition of convers ion rule
1.
2.
Source Field Ass ignment
S AP AG 1999
Attribute
Target field filled with a constant value
0001Company code 0001
Rule: Constants
S AP AG 1999
Attribute
Target field filled with ABAP command MOVE
SMITH SMITH
E xceptions:
Packed fields
Date fields
Amount fields
Rule: Transfer
DDMMYYYY
MMDDYYYY
Internal format (YYYYMMDD)
As of LSMWVers ion 1.7
S AP AG 1999
Attribute
Target field ass igned a “variable”
BUKRS Company code (domain)
F ixed value
Attributes
Fixed Value
Name
Description
Attributes
Length
ABAP type
Lowercase
Value
0001
BUKRS
=
0001
Rule: Fixed Value
S AP AG 1999
Translation attributes
Source field / target field
Control
1:1 translation values
Interval translation values
BSCHL
=
? ? ?
perform lsmw_translate
using 'BSCHL'
POSI-POSTING_KEY
changing BBSEG-NEWBS.
Double-click
Rule: Changing Trans lation
S AP AG 1999
Translation attribute
Control
BSCHL
=
? ? ?
Variant F irst Second
Alternative Alternative
1:1 translation
Interval translation
Initial value
Constant
Transfer (MOVE )
User-defined routine
No action
Variants
Other
Add 1:1 translation values automatically
Translation Control Overview
S AP AG 1999
1:1 Values of conversion key
Old value
New valueBSCHL
=
? ? ?
Old Value
0004
0005
New Value
40
50
OK
1:1 Values of Convers ion Key
S AP AG 1999
Convers ion value interval
Old values from .... to
New value BSCHL
=
? ? ?
Old values from
0001
0005
Old values to
0004
0008
OKNew value
40
50
Convers ion Value Interval
S AP AG 1999
Rule: Prefix
CONCATENATE
'10' posi-acount
INTO bbseg-newko.
10Prefix 1104 10110410 +
10 + ...
=
00Suffix 1104 110400+ 00
... + 00
=
CONCATENATE
posi-account '00'
INTO bbseg-newko.
Attribute
String operation
S AP AG 1999
Attribute
String operation: Combine source fields
A_ 2311 Plant A_2311+ .....
... + ...
=
Plant +
Important: All source fields involved in the concatenation must be previously
ass igned to the same target field.
Rule: Concatenation
S AP AG 1999
Bbseg-sgtxt = posi-text.
SHIFT bbseg-sgtxt
LEFT DELETING LEADING SPACE.
E xample:
Attribute
String operation: Text transferred left-justified
Information
Information
Rule: Transfer Left-Justified
S AP AG 1999
Attribute
Insert your own ABAP code in the generated
program
221555
1234400
ABAP
Rule: ABAP Code
S AP AG 2001
GSBER Bus iness area (domain)
Attribute
Include subprograms
E xample:
PERFORM ur_gsber
CHANGING bbseg-gsber.
FORM ur_gsber ...
ENDFORM.
Rule: Own Routine
S AP AG 1999
Work S teps
Fixed values , conversion rules ....
Overview of reusable rules
Fixed values
Convers ions
User-defined routines
Reusable rules
BC420-TEST Training data transfer BC420
Fixed values
BLART
Conversions
BLART
BSCHL
User-defined routines
Field Mapping and Convers ion Rules
S AP AG 1999
BasicsBasics
Structure DefinitionsStructure Definitions
Field Mapping and RulesField Mapping and Rules
Reading and Transferring Data to R/3Reading and Transferring Data to R/3
LSMW Reading and Transferring Data to R/3
S AP AG 1999
Work S teps
Specify files
Specify paths and files
Convers ionon PC
Application
server
File name
File name File name
File name
Specifying Files
S AP AG 1999
Imported Data File
File BC420_46_ D_CT_ 01.lsmw.read
File name: <path><file name>.lsmw.read
Specify paths and file names
File name = project name
+ subproject name
+ object name
S AP AG 2001
Converted Data File
Depending on the selected object (e.g. batch input for
customers), you have the following options :
Determine path and file name for objects that only have a
physical path/file name.
Determine logical path and logical file.
File BC420_46_ D_CT_ 01.lsmw.conv
Logical path Z_ TEMP
Z_ BC420Logical file
File name: <path><file name>.lsmw.conv
S AP AG 1999
Us ing wildcards in file names
Value of wildcard
Description
data_1
Data record 1
doc_*.leg doc_*.lsmw.read doc_*.lsmw.conv
Wildcards in File Names
S AP AG 1999
Work S teps
Source structures and files
HEAD documents
source data BC420_DOC_HEAD_POS.LEG
POSI position
source data BC420_DOC_HEAD_POS.LEG
Object attributes
Specify which source structure is filled by which file
HEAD
POSI
Assigning Files
S AP AG 1999
Work S teps
Import data
Specify which data is to be imported
Amount fields
Amount fields are converted into the internal ABAP
format (with decimal point), if checkbox is selected
Date values
Date fields are converted into the internal ABAP format
(YYYYMMDD), if checkbox is selected
Importing Data
Amount fields -> 1234.56
Date values -> YYYYMMDD
S AP AG 1999
Work S teps
1 DOCUMENTS HBC100000119990730 07 31.07.199930.07.1999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 DOCUMENTS HBC100000219990730 07 31.07.199930.07.1999$
6 POSI P0004S100000 3420.50 3206.89 Info 1
7 POSI P0005H113100 3010.50 2830.77 Info 2
8 POSI P0005S110000 410 376.12 Info 3
1 HEAD HBC100000119990730 07 3107199930071999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 HEAD HBC100000219990730 07 3107199930071999$
6 POSI
7 POSI
8 POSI
Displaying Imported Data
Field name Field text Field value
SET1 Record indicator H
REF_NO Reference number BC1000001
DOC_DATE Doc. date 30071999
TYPE TYPE 07
CURR_KEY document currency DM
Display imported data
By record
By field
S AP AG 1999
Work S teps
1 DOCUMENTS HBC100000119990730 07 31.07.199930.07.1999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 DOCUMENTS HBC100000219990730 07 31.07.199930.07.1999$
6 POSI P0004S100000 3420.50 3206.89 Info 1
7 POSI P0005H113100 3010.50 2830.77 Info 2
8 POSI P0005S110000 410 376.12 Info 3
1 HEAD HBC100000119990730 07 3107199930071999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 HEAD HBC100000219990730 07 3107199930071999$
6 POSI
7 POSI
8 POSI
Displaying Imported Data
Field name Field text Field value
SET1 Record indicator H
REF_NO Reference number BC1000001
DOC_DATE Doc. date 30071999
TYPE TYPE 07
CURR_KEY document currency DM
Display imported data
By record
By field
S AP AG 1999
Work S teps
Generated
convers ion
program
Transactions read: 5
Records read: 20
Transactions written: 5
Records written: 21
Note:Amount fields (AMT1...) for standard
transfer programs are formatted
according to user-defined settings .
Date fields are NOT formatted in the
LSMW version < 1.7 they are always
displayed in format YYYYMMDD
Field assignment
Converting Data
Convert data
S AP AG 1999
Work S teps
1 BGR00 0KNA1_A 100ROBERTS /
2 BBKPF 1FB01 30071999SA0001/ / DEM
3 BBSEG 2BBSEG 40/ //
4 BBSEG 2BBSEG 50/ //
5 BBSEG 2BBSEG 50/ //
6 BBKPF 1FB01 30071999SA0001/ / USD
7 BBSEG 2BBSEG 40/ //
8 BBSEG 2BBSEG 50/ //
9 BBSEG 2BBSEG 50/ //
Displaying the converted data
By record
By field
Field Field text Field value
STYPE Record type 1
TCODE Transaction code FB01
BLDAT Date 30071999
BLART Document type SA
BUKRS Company code 0001
BUDAT Date /
WAERS Currency key DEM
Displaying Converted Data
S AP AG 1999
Project
Copy
Delete
Create documentation
Export
Import
Administrative Functions
E xport /
Import
S AP AG 1999
Profile
B_LSMW_ SHOW
B_LSMW_ E XE C
B_LSMW_ CHG
B_LSMW_ ALL
Authorization Level
Display
E xecute
Change
Administrate
Authorizations
S AP AG 1999
Course Overview Diagram
Datenübernahme
DX Workbench
LSM Workbench
Principles of Standard
Data TansferD
ire
ct
Inp
ut
BAPI
TA
Re
co
rde
r
Course Overview
Ba
tch
In
pu
t
Ca
ll T
ran
sac
tio
n
3
EDI
Basics7
5
8 106
11
14
13
12
11
12
1
2
99
11
4
10
Notes:
• An alternative to the batch input method is the direct input (DI) method. DI is more efficient than the other methods making it especially useful for transferring large datasets. Unlike batch input, no sessions are created -the data is updated directly. No screens are involved in this procedure. The data is entered directly into database tables by calling function modules that carry out the necessary checks.
• If case errors occur during the data transfer, direct input has a restart mechanism. To enable restart, direct input programs must be processed as background jobs run under the direct input monitor (program RBMVSHOW or transaction BMV0).
• If you are working with test data, you can start direct input in foreground. Make sure that neither error logs are created nor that the possibility of a restart exists in error situations.
• SAP strongly recommends that you use transaction BMV0 for the actual data transfer.
Notes:
• Direct input run:
• First create a variant for the transfer program.
• Define a job with this variant.
• Schedule the time of the job (start: immediately, date, time, by job, by event, etc).
• Analyze the job log after the job run.
• If the job is terminated, it can be reset.
• Note: The restart mechanism will not work if the file contains formal errors (i.e. if the records are not in the SAP Record Layout). Use the “check file” function to ensure that no formal errors exist before processing the file using direct input.
S AP AG 1999
Job Analys is
J ob administration Applications
Direct input :adminis tration
Job details Job log
Technical information
Program name
Variant name
Server
.....
Administration information
Number of errors
Number of restarts
.....
System messages are lis ted
chronologically
Long text can be displayed