Vous êtes sur la page 1sur 4

To Create an executable transaction (T-Code) for a specific LSMW program we will follow the following

steps:

1. Create a normal LSMW program.


2. Use the parodic data transfer instead of (Once-Only).
3. Create a T-Code for the LSME Program:
3.1. Using ABAP
3.2. Without Using ABAP

So let’s Start 

1. Create an LSMW Program (Create a material master with the basic data only).
a. Here is the program steps which I will follow in the next screenshots.
2. Maintain Object Attributes: in this step we must select the data transfer type to be Periodic not
as usual (Once-Only) to let the LSMW tool add an extra step to the steps list (Frame Program for
periodic data transfer).

This the only deference which is a must to continue our progress so complete the program steps as
usual and as recommended to create a sample of data in order to test the program and confirm that it’s
results is accepted, then you will find a step you will not use .. the last step .. it’s “Frame program for
periodic data transfer”, in the next steps we will discuss it clearly.
3. Create a T-Code for LSMW Program:
a. Using ABAP: The last step in this LSMW program Use a standard program to run .. which
means that if we tried to open “SE38” and use program
(/SAPDMC/SAP_LSMW_INTERFACE) this program use the LSMW (Project – Subproject –
Object) and run it using it’s internal configuration so we will finish all the LSMW steps
and use this program which will start running from step (Read Data to step Run Batch
Input).
So, we will open SE38 write program name – execute the program – then write the
project & subproject & Object and modify any extra required modification and press
save to save a variant for this selection for example we will save it using name
(ZMM_Material1).
then Open SE38 again and create a new program and use the below code and test
(Don’t forget to change the variant name)

*&---------------------------------------------------------------------*
*& Report ZLSMW3
*&---------------------------------------------------------------------*
*& this program created to call a program using the submit procedure plus running
*& function module in the next code block to run the program with the "hard Coded" Variant
name.
*&---------------------------------------------------------------------*

REPORT ZLSMW3. "Default ABAP Program Name

SUBMIT /SAPDMC/SAP_LSMW_INTERFACE using SELECTION-SCREEN '1000'.


" Use (Submit) to call a standard ABAP Program and specify the screen number

***** We used the below function module to open the program with a specifc Variant*****
*****CALL DEFAULT VARIANT FOR A REPORT*****
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
"this FM used to call a variant + program so we used it here with the above program
EXPORTING
REPORT = '/SAPDMC/SAP_LSMW_INTERFACE' "Program Name
VARIANT = 'ZMM_MATERIAL1'. "Variant Name

** The Above Part is mandatory to use but the next part is optional to use the error
handling

IF SY-SUBRC <> 0.
" Use SY-SUBRC to analyis the return Code ( 3lshan lw fe moshkla fel runtime)
* Implement suitable error handling here
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
EXPORTING
REPORT = '/SAPDMC/SAP_LSMW_INTERFACE'
"Program Name (esm el program bta3 el LSMW el 5atwa el a5era)
VARIANT = 'ZMM_MATERIAL1'
"Variant Name (esm el variant elly 3ayz andah 3aleh)
EXCEPTIONS
" Exception Handler (Error Handler) -- 3shan lw darabet
VARIANT_NOT_EXISTENT = 1
" In Case of Missing Variant Retrive value 1 to SY-SUBRC (Return Code)
VARIANT_OBSOLETE = 2.
ENDIF.
b. Without ABAP: Use the above step until you saved a variant for your selection then
open SE93 to create a new T-Code (Write the new T-Code name) and then press Create
choose the second radio button (Program and Selection Screen – Report transaction)
and then fill the following data.

The conclusion of the variant and why we will use it .. we will maintain the program name and sub
project and the object in the variant and use a separate t-code for each variant with the same program
and please notice too that any change to the LSMW program will reflect on the Z Tcode .. because by
the end of the day the program used In the t-code call the LSMW program and use it as is.

I prefer to use the ABAP steps to restrict the user to change the variant which means that he/she can
use another program otherwise try to find a way to authorize the variant itself to restrict the user from
accessing any other program.

Vous aimerez peut-être aussi