12-01-2005 8:51 AM
Hi everybody!
I am migrating legacy data to SAP using LSMW. Now I want to skip an input line during transformation if a certain value is zero. How can I do that?
Regards, Joerg
12-01-2005 9:10 PM
Hi
First of all you should make sure you use a display variant enabling all possiblities for coding. Doing so you'll see it's possible to define GLOBAL_DATA, defining code in BEGIN_OF_TRASACTION etc.
Your conditions for skipping a record may be coded as part of the formatting of the target fields. I would rather suggest you code your conditions under BEGIN_OF_TRANSACTION.
Example:
BEGINOF_TRANSACTION_
g_skip_transaction = no.
IF <my conditions>.
SKIP_TRANSACTION.
ENDIF.
CHECK g_skip_transaction = no.
This will see to that you never process BEGIN_OF_RECORD if you want to skip. Debug your processing from Conversion step and you'll see this is exactly how the LSMW generated code is handing skiping transactions.
Initialize the variable g_skip_transaction som only transactions fulfilling your criterias are excluded. Doing a "CHECK g_skip_transaction = no" after every place you check conditions is a good practice. By doing so you may extend your conditions endlessly.
Good luck
Bjarne
12-01-2005 8:56 AM
Hi For that Line You need to Code something.
for that field where you mapped in usermapping there you can code and validate
reagrds
vijay
12-01-2005 8:57 AM
Not possible in LSMW to ignore skip a line if it is there in input file. Write another program to delete the line from file ( I mean create a new file ) before passing to LSMW.
Cheers.
Sanjay
12-01-2005 8:58 AM
For that Field You Need to Code in the Start-of-record event ....
regards
vijay
12-01-2005 9:10 PM
Hi
First of all you should make sure you use a display variant enabling all possiblities for coding. Doing so you'll see it's possible to define GLOBAL_DATA, defining code in BEGIN_OF_TRASACTION etc.
Your conditions for skipping a record may be coded as part of the formatting of the target fields. I would rather suggest you code your conditions under BEGIN_OF_TRANSACTION.
Example:
BEGINOF_TRANSACTION_
g_skip_transaction = no.
IF <my conditions>.
SKIP_TRANSACTION.
ENDIF.
CHECK g_skip_transaction = no.
This will see to that you never process BEGIN_OF_RECORD if you want to skip. Debug your processing from Conversion step and you'll see this is exactly how the LSMW generated code is handing skiping transactions.
Initialize the variable g_skip_transaction som only transactions fulfilling your criterias are excluded. Doing a "CHECK g_skip_transaction = no" after every place you check conditions is a good practice. By doing so you may extend your conditions endlessly.
Good luck
Bjarne
12-02-2005 3:56 AM
You don't have to write a seperate program to skip lines or to change the file in anyway. In your Mapping section, there will be several places where you can insert the code. For example, BEGINOF_TRANSACTION_ or BEGINOF_RECORD, ENDOF_TRANSACTION_, etc. or even in the field logic.
Let us say you want to skip the record if FIELD1 is blank. Do your mapping for this field and then in change mode, double click on this field. It will open up the editor for you with one line of code that says <TARGETFIELD> = <SOURCEFIELD>. Here you can insert the following code and it will work.
IF FIELD1 IS INITIAL.
skip_record.
ELSE.
<TARGETFIELD> = <SOURCEFIELD>.
ENDIF.
Writing a whole new program just to work on the file is not necessary.
Srinivas