Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Skipping input line in LSMW

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

5 REPLIES 5

former_member188685
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

former_member188685
Active Contributor
0 Kudos

For that Field You Need to Code in the Start-of-record event ....

regards

vijay

Former Member
0 Kudos

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

Former Member
0 Kudos

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