Application Development and Automation 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: 
Read only

validating Input file in LSMW

Former Member
0 Likes
855

Hi All,

I am doing an initial stock upload using LSMW. I am

passing a file in .CSV format . How do i validate the

entries in CSV files in LSMW, so that incorrect entries

do not get processed at all.

Thanks

Nishant

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
700

Hi

You should insert the abap code you need in the MAPPING step.

There's a std MACRO to allow to skip the transaction: SKIP_TRANSACTION.

So for example:

SELECT SINGLE * FROM T001 WHERE BUKRS = FILE-COMPANY.

IF SY-SUBRC <> 0.

WRITE: / 'Company code is wrong'.

SKIP_TRANSACTION.

ENDIF.

In this way you can read a log after upolaading the file and the LSMW'll load only the correct record.

Max

Hi

You should insert the abap code you need in the MAPPING step.

There's a std MACRO to allow to skip the transaction: SKIP_TRANSACTION.

So for example:

SELECT SINGLE * FROM T001 WHERE BUKRS = FILE-COMPANY.

IF SY-SUBRC <> 0.

WRITE: / 'Company code is wrong'.

SKIP_TRANSACTION.

ENDIF.

In this way you can read a log after upolaading the file and the LSMW'll load only the correct record.

Max

4 REPLIES 4
Read only

Former Member
0 Likes
701

Hi

You should insert the abap code you need in the MAPPING step.

There's a std MACRO to allow to skip the transaction: SKIP_TRANSACTION.

So for example:

SELECT SINGLE * FROM T001 WHERE BUKRS = FILE-COMPANY.

IF SY-SUBRC <> 0.

WRITE: / 'Company code is wrong'.

SKIP_TRANSACTION.

ENDIF.

In this way you can read a log after upolaading the file and the LSMW'll load only the correct record.

Max

Read only

0 Likes
700

Hi Max,

I am new to LSMW and dont have much idea as to where this piece of coding should be done and how to read a log.Can you please elaborate on this.

Thanks in advance

Nishant

Read only

0 Likes
700

Hi

In the MAPPING step, you link the file fields to structures SAP fields.

After linking the fields, do a doubleclick on the field you need to check, now the system'll open and editor where you write your code.

So insert here your validation and write a log if it's wrong, use the global data G_SKIP_RECORD to skip the record (not SKIP_TRANSACTION).

All data you insert in this step, they'll be used in CONVERTION step by the system.

So:

IF ......

WRITE 'ERROR'.

G_SKIP_RECORD = 'X'.

ENDIF

Max

Read only

0 Likes
700

thanks MAx, that solved my problem...

i have given u full points for this....