Você está na página 1de 6

98011546.

doc

BASIC LSMW EXERCISE


PHASE I Mapping and Definition

EXAMINE THE TRANSACTION


Create a Financial Document using transaction FB01 DOCUMENT HEADER Document Date:today Document Type:SA Company Code: UKCC Currency: GBP FIRST DOCUMENT ITEM (input on the same screen) Posting key: 50 Account: 24100 Press Enter Amount: 12

SECOND DOCUMENT ITEM (input on the next screen) Posting key: 40 Account: 33300 Press Enter Amount: Press Save 12

LSMW Set up
Start the LSMW (Transaction LSMW) Create Project LSMW-xx - Description LSMW Demo Create SubProject SUBxx - Description First Subproject Create Object CTxx - Description FI Documents Call Transaction Maintain Object Attributes Standard Batch / Direct Input Object 100 Financial Documents Maintain Source Structures Create the structures GLHEADER and GLITEMS (below GLHEADER) Maintain Source Fields GLHEADER Name Description Length Type ID Record Type 1 C REF Reference Number 9 C DATE Document Date 10 DDMY TYPE Document Type 4 C CUR Currency Code 2 C

Value H

98011546.doc

GLITEMS Name Description ID Record Type KEY Posting Key ACCOUNT G/L Account Number AMOUNT Amount in Document Currency TEXT Item Text

Length 1 4 10 15 6

Type C C C AMT1 C

Value P

MAPPING
There are a large number of fields in the object definition! To save time, the following is the list of fields for which we need data. DOCUMENT HEADER Field Meaning Length BLART Document Type 2 BUKRS Company Code 4 BLDAT Document Date 8 WAERS Currency Code 5 BKTXT Document Text 25 DOCUMENT ITEM Field Meaning NEWBS Posting Key WRBTR Amount NEWKO G/L Account SGTXT Document Text Length 2 16 17 50

QUESTIONS What values did we use in the manual data of the transaction for these fields? Which source fields map to which target fields? Look at the source data which fields will need translating? What field(s) are not supplied in the source?

98011546.doc PHASE II Reading, Conversion and Processing

Structure Relations
Assign BGR00 and BBKPF to the Document Header Assign BBSEG to the Document Item

FIELD MAPPING
TARGET STRUCTURE BBKPF BBKPF BBKPF BBKPF BBKPF BBSEG BBSEG BBSEG BBSEG TARGET FIELD BLDAT BLART BUKRS WAERS BKTXT NEWBS WRBTR NEWKO SGTXT SOURCE STRUCTURE GLHEADER GLHEADER GLHEADER GLHEADER GLITEMS GLITEMS GLITEMS GLITEMS SOURCE FIELD DATE TYPE CUR REF KEY AMOUNT ACCOUNT TEXT REMARKS Assign the field as DDMMYYYY Translation needed Constant Value UKCC Translation needed

Translation needed

MAINTAIN FIXED VALUES, TRANSLATION RULES


Set up translation rules for the data, note that if you miss any entries, the system will fill in the source value entries when the conversion program runs for the first time.

SPECIFY & ASSIGN FILES


Select Legacy data on the PC. Then: File: C:\TEMP\LSMW Data.txt Description: (Your choice) Check Data for several source structures Assign the files to the source structures.

READ THE DATA


Display the data to confirm the successful data formatting

CONVERT THE DATA


Display the data to confirm the successful data conversion

START DIRECT INPUT PROGRAM


Use option Program RFBIBL00, then Data Transfer Type C. Note down the document numbers created. Note that if the program finds any errors, then it will create a batch input session with the name of the LSMW Object. Use SM35 to investigate this. In case of errors, rerun the appropriate steps. Look the documents you created via transaction FB03

98011546.doc

LSMW EXERCISE ERROR HANDLING


COPY & TEST
Copy the object CTxx created above to CTERRxx, then work with the new object. Change the file being read to C:\TEMP\LSMW Data errors.txt Rerun the read and convert processes. Look at the convert file can you find any of the errors?

ERROR HANDLING
There are at least 3 errors. A missing currency code in the translation table. A document with financial postings out of balance. JPY data being incorrectly formatted. These will all be fixed by setting up ABAP code in the Mapping Step Make the Processing Points and Global Data Definitions visible by choosing the menu option Extras > Display Variant and pick the correct options. MISSING CURRENCY CODE Following the translation of the currency code, test whether this has been successful by testing the value of the converted code. If this is still set to the No Data value (BGR00-NODATA usually /), then it has failed. Use skip_transaction to omit this data and write out a message. DOCUMENT OUT OF BALANCE Define a variable LIKE g_amount in _GLOBAL_DATA to be the net total of the document. For each document item, maintain the running net total from the amount. Test the converted posting key , if it is 50, then increment, otherwise decrement. At the processing point _END_OF_TRANSACTION, test the net total. If is not zero, use skip_transaction to omit this data and write out a message. This processing must be put before transfer_transaction. Dont forget to reset the net value for the next record! Note: SAVE the object following any global data definitions, otherwise the code blocks you write may not syntax check. CURRENCY FORMATTING Look at the code created to fill BBSEG-WRBTR. It will not work for currency codes such as JPY which have no decimal places. Can you think of a way to make this processing work for any (valid) currency code? Hint use the WRITE TO format with an addition. Having implemented and checked the code, rerun the LSMW from the convert step and confirm that the documents all post successfully.

98011546.doc

LSMW EXERCISE RECORDING


Strategy First understand the Transaction
Start up the customer maintenance transaction XD02 using customer number ., you do not need to supply any other details. Press the Contact Persons tab, you will see the contacts set up for this customer. To select details of a particular contact either: Move your cursor to the contact of interest and press F2. Then change the telephone number, Save ignore any warning messages. OR Type the surname of the contact in the List Search Name box and press enter what happens to the list? Then proceed as before. We shall be using the second technique as we do not know which position in the list our contact of interest is.

LSMW Stage 1 Record the transaction


Start transaction LSMW Object REC01xx

Then GO TO > RECORDINGS Create a recording name PHONE01 You will be recording transaction XD02 PLEASE NOTE THAT THE TRANSACTION LOOKS DIFFERENT THAN WHEN YOU RAN IT DIRECTLY THIS IS QUITE A COMMON FEATURE. Enter the customer number as above and check the Contact Persons Box Enter the surname of a contact in the Name box and press Enter, then select the top line, which will be your contact, press Partner Details to process the data, change the phone number and Save. You will have created the script of all the screens and fields that this transaction needs. The next stage is to assign field names to fields where you will be supplying data. Do this by positioning the cursor on the field and double clicking Field Suggested Name RF02D-KUNNR KUNNR Customer Number *KNVK-NAME1 SURNAME Surname KNVK-TELF1 PHONE New phone number Do not assign a field name to RF02D-D0360 this is the Customer Contact Check Box and will be the same for all records.

LSMW Stage 2 Build up the LSMW


The assumption we are making is that the data on Customer Number and Contact Name has been extracted from SAP, so will be valid . Compared with an LSMW data load, the mapping is extremely simple. Step 1 Maintain Object Attributes Object Type and Import Technique choose Batch Input Recording, using the name of the recording created above.

98011546.doc Step 2 Maintain Source Structures Create a structure suggested name PHONE_DATA Step 3 Maintain Source Fields Set up the structure all fields type C Field Length KUNNR 10 CUSTNAME 35 Customer Name this is for reference PARTNR 10 Partner Number this is for reference FIRST_NAME 35 Partner First Name this is for reference SUR_NAME 35 PHONE 16 Step 4 Maintain Structure Relations This is done for you, but SAVE. Step 5 Maintain Field Mapping and Conversion Rules Make the necessary mappings source to target. Step 6 Maintain Fixed Values Not necessary in this case because of the simplicity of the mapping Step 7 Specify Files Legacy Data On the PC Name : C:\TEMP\PHONES.TXT Tab delimited. Step 8 Assign Files This is done for you, but SAVE. Then work through the remaining steps, verifying the layout and mapping, process the batch input session.

Você também pode gostar