Showing posts with label LSMW. Show all posts
Showing posts with label LSMW. Show all posts

Friday, October 23, 2009

Error handling in LSMW

Joyjit Ghosh, Kolkata.


To do error handling in LSMW object we can write validation logic in step “5 Maintain Field Mapping and Conversion Rule”. All custom codes written in this section will be part of the conversion program once we generate it.

Following steps are required for error handling:

  1. Define an internal table to store all error messages
  2. Write logic to validate the data and populate the error table when validation fails
  3. Display error messages as part of conversion program output

All these steps should be performed under step “5 Maintain Field Mapping and Conversion Rule” from transaction LSMW.

Step 1: Define an internal table to store all error messages

In __GLOBAL_DATA__ section define the internal table that will store the error messages.

Step 2: Write logic to validate the data and populate the error table when validation fails

Now write validation logic for the fields those we want to validate. If validation fails then populate the error table and after that call the macro “SKIP_TRANSACTION” so that this error record can be skipped and control will go to next record in the file.


Step 3: Display error messages as part of conversion program output

Now at __END_OF_PROCESSING__ section write logic to display the error table.

After writing the above steps, check the syntax of the custom code by clicking the appropriate button () on application toolbar. It will display a pop-up screen where we need to press ‘Yes’ button.

If everything is OK then it will display message that conversion program is regenerated successfully.

After this follow the LSMW steps like “7 Specify Files”, “8 Assign Files”, “9 Read Data”, “10 Display Read Data”. And lastly perform the step “11 Convert Data” where SAP actually executes the validation logic (written in step “5 Maintain Field Mapping and Conversion Rule”) as part of conversion program. And display the error messages those are generated due to error handling.

Output:

Monday, July 21, 2008

Maintain LSMW object from its own transaction

By Joyjit Ghosh,
Kolkata, India.

Step: 1

Create a report and insert the code block given below.

* Type pools

TYPE-POOLS: tumls. " LSM Workbench: Type-Pool

* Data declaration

DATA: project TYPE tumls_project, " Project

subproj TYPE tumls_subproj, " Subproject

object TYPE tumls_objectnew. " Object

START-OF-SELECTION.

* Store project

project = 'TPISP - DC'.

* Store subproject

subproj = 'VARIANT_MAT'.

* Store object

object = '6GSC022_TS3'.

* Call the function module to display object (LSMW) maintenance screen

CALL FUNCTION '/SAPDMC/LSM_OBJ_STARTER'

EXPORTING

project = project

subproj = subproj

object = object

EXCEPTIONS

no_such_object = 1

OTHERS = 2.

Basically from LSMW’s initial screen whenever you press enter or continue button it calls the FM /SAPDMC/LSM_OBJ_STARTER and there is no authorisation check prior to do this, only LSMW checks for authorisation when you press Administration from GOTO menu using the FM /SAPDMC/LSM_AUTHORIZATN_CHECK. That means any body can access any object and can do any unwanted change. And it is really hard to track the changes as LSMW does not have any inbuilt version management. So to avoid this before calling the FM we can do the authorisation check based on certain conditions (not necessary to do authority check, but can be achieved by maintaining parameter ID in the user profile or through maintaining custom table) and by this way we can restrict unwanted user access.

Step: 2

Create a transaction for the report from SE93.

Now execute the program or the transaction. It will show you the maintenance screen of the LSMW object.