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: 

how do we proceed to write a code in the lsmw

Former Member
0 Kudos

I have some object of IS-retail to be uploaded for which i need to do some changes in the LSMW, i know where we are writing the code for checking the fields that are getting uploaded but i am unable to find where to write the actual code,

in the 5th step we select the abap code where i had written a subroutine, but from where should i proceed in writing the ABAP code for this routine that i have created.

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

in the step of "maintain field mappings & conversion rules", we write the abap code for various purposes.

1. to validate each & every field,if requires

2. to track any error records

3. to download it to presentation/application server

to Validate a particular field, go in CHANGE Mode, & after assiging the field mappings(you can do so, by selecting menu option->auto field mapping) double click on the assignment line.

(i mean BGR00-MATNR = ZSOURCE_STRUC-MATNR double click on this line)which will take you to an abap editor. there write your logic for validating Material number

for example:

if ZSOURCE_STRUC-MATNR IS INITIAL.

*--ERROR RECORD.

SKIP_RECORD.

*--this SKIP_RECORD is an LSMW statement, used to skip the current record, as with out material number,there is no meaning in proceeding further..

ELSE.

BGR00-MATNR = ZSOURCE_STRUC-MATNR

ENDIF.

like this we validate the fields in LSMW.

to track all the error records, you can define an Internal table in the GLOBAL SECTION & use it in the validations.

for example:

if ZSOURCE_STRUC-MATNR IS INITIAL.

*--ERROR RECORD.

zerr_table-matnr = space

zerr_table-descr = 'material no is empty'.

append zerr_table.

SKIP_RECORD.

ELSE.

BGR00-MATNR = ZSOURCE_STRUC-MATNR

ENDIF.

revert, if you need any further clarifications on this.

regards

Srikanth

3 REPLIES 3

Former Member
0 Kudos

Hi Sushi,

welcome to sdn

ya 5th step

Step 5: Maintain field mapping and conversion rules

in this step after defining the souce fields, when u double click on that particular field u will get one more screen there u can write the conditions what ever u need

if u want to define and resuable routine u should go with step 6.

Step 6: Maintain fixed values, translations, user-defined routines

in this step u can define the reusable routines and function

if u need more info gimme ur mail id i will send u some lsmw material

Regards,

Naveen

Former Member
0 Kudos

in the step of "maintain field mappings & conversion rules", we write the abap code for various purposes.

1. to validate each & every field,if requires

2. to track any error records

3. to download it to presentation/application server

to Validate a particular field, go in CHANGE Mode, & after assiging the field mappings(you can do so, by selecting menu option->auto field mapping) double click on the assignment line.

(i mean BGR00-MATNR = ZSOURCE_STRUC-MATNR double click on this line)which will take you to an abap editor. there write your logic for validating Material number

for example:

if ZSOURCE_STRUC-MATNR IS INITIAL.

*--ERROR RECORD.

SKIP_RECORD.

*--this SKIP_RECORD is an LSMW statement, used to skip the current record, as with out material number,there is no meaning in proceeding further..

ELSE.

BGR00-MATNR = ZSOURCE_STRUC-MATNR

ENDIF.

like this we validate the fields in LSMW.

to track all the error records, you can define an Internal table in the GLOBAL SECTION & use it in the validations.

for example:

if ZSOURCE_STRUC-MATNR IS INITIAL.

*--ERROR RECORD.

zerr_table-matnr = space

zerr_table-descr = 'material no is empty'.

append zerr_table.

SKIP_RECORD.

ELSE.

BGR00-MATNR = ZSOURCE_STRUC-MATNR

ENDIF.

revert, if you need any further clarifications on this.

regards

Srikanth

ferry_lianto
Active Contributor
0 Kudos

Hi Sushi,

Please check this link for LSMW documentation and go to page 38 and 39. It should guide you to coding areas.

http://www.sapgenie.com/sapgenie/docs/LSMW180_HowTo_E.zip

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.