LSMW to Upload Journal Entries

Preview:

DESCRIPTION

Use LSMW (Legacy System Migration Workbench) to upload Excel-based journal entries into SAP.

Citation preview

LSMW for Uploading Journal Entries

This method uses several nice features:

1. Positives or negatives can be within the upload file. The program will determine debit or credit

2. Can be used for Cost Center Postings, Order Postings or balance sheet Profit Center postings within same file

3. Header text and line item text can be used4. Compund entries are accepted rather than one debit and an offsetting credit being

required

Create Project, Subproject and Object

First step is to assign the program or recording. We will use a program this time.

Use the FB01 Program-

Create a header and detail (line items) section

Create all lines as the above example

Final Result-

Result-

This section is long and tedious but be careful and go slowly to avoid mistakes

Examples below is to use a source field for document date. However, the document type will be hard coded as SA. This simply reflects two styles to be used to make the user entry easier.

Final Header section-

Detailed Line Items Section:

In order to interpret positives as posting key 40 and negatives as posting key 50, use this logic in the Posting Key field:

* Target Field: BBSEG-NEWBS Posting Key for the Next Line Item

data wrk_amt type f.

wrk_amt = DOC_LINE_ITEMS-AMOUNT.

if wrk_amt > 0.

BBSEG-NEWBS = '40'.

else. BBSEG-NEWBS = '50'.

endif.

Now, the system knows when to apply debit or credit based on whether the value is positive or negative. We will need to convert the values now from the text file from negatives to positives. All values must end up as positives. Therefore, the next code will simply use the values designated as 40 (positives), and reverse the others (negatives).

if BBSEG-NEWBS = '40'.

BBSEG-WRBTR = DOC_LINE_ITEMS -AMOUNT.

else. BBSEG-WRBTR = DOC_LINE_ITEMS -AMOUNT * -1.

endif.

In our case, we wish to have cost center populated sometimes, order number sometimes and in the case of balance sheet accounts, neither one, here we only want profit center. Profit center will be derived for the cost center and order fields. This means we must have code that allows each of these elements to be populated or not, based on what the text file includes.

Code for Cost Center-

if DOC_LINE_ITEMS -COSTCTR NE ''.

BBSEG-KOSTL = DOC_LINE_ITEMS -COSTCTR.

endif.

Code for Order number-

if DOC_LINE_ITEMS -ORDERNO NE ''.

BBSEG-AUFNR = DOC_LINE_ITEMS -ORDERNO.

endif.

Code for Profit Center-

if DOC_LINE_ITEMS -PRCTR NE ''.

BBSEG-PRCTR = DOC_LINE_ITEMS -PRCTR.

endif.

Add Line item text-

Finally, Account number-

Record ID is only needed to link the Header and Detail together. No mapping is required here.

Add detail now-

Pull in 2 useful User menu items the first time to generate the program-

Make sure to create 2 text files (for the Header and Line Items) as the examples below-

Generation is only required the first time. Uncheck for other users (User Menu) after success.

After generating the program and reading the data, the result should look like this-

Display Read Data-

Above import looks like an extra line exists in the header file. Open file, delete extra lines and read again.

Converson Program also required only the first time.

Result in FB03-