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

LSMW

Former Member
0 Likes
594

What is the necessity of coding in LSMW ?

Where to do coding ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
572

Hi,

Refer to this link, you will get nice documentation.

http://www.saptechnical.com/Tutorials/LSMW/LSMWMainPage.htm

Thanks,

Anitha

What is the necessity of coding in LSMW ?

Where to do coding ?

4 REPLIES 4
Read only

Former Member
0 Likes
572

hi,

to provide validations and error handlling techinques i.e to trnasfer unprocessed records to file or to provide error messgaes we use coding.

You can handle errors in field mapping or in the custom program of LSMW. In field mapping, you can check for the existence of the field in a standard table.. If its not there, then you can append that row to an error table and can display it at the end of processing.. This error message will be displayed after converting the data.

This should be done in Field Mapping.

ex:

This lsmw object contains 2 fields.. I have handled errors in Field Mapping..

In Global Data:

CONSTANTS: c_message(30) TYPE c VALUE 'Invalid Material & Plant'

c_message1(20) TYPE c VALUE 'Invalid Plant',

c_sermat(6) TYPE c VALUE 'SERMAT',

c_werks(5) TYPE c VALUE 'WERKS',

c_comment(8) TYPE c VALUE 'COMMENT',

c_error_records(20) TYPE c VALUE 'Error Records',

c_comment1(45) TYPE c VALUE

'The following record(s) will not be updated'.

TYPES: BEGIN OF tp_error,

sermat(18) TYPE c,

werks(5) TYPE c,

comment(30) TYPE c,

END OF tp_error.

  • Variables Declaration

DATA: w_matnr(18) TYPE c.

  • Internal Table and Work Area Declaration

DATA: t_error TYPE STANDARD TABLE OF tp_error,

wa_error TYPE tp_error.

In Beginof_Processing_:

CLEAR wa_error.

REFRESH t_error.

wa_error-sermat = c_sermat.

wa_error-werks = c_werks.

wa_error-comment = c_comment.

APPEND wa_error TO t_error.

Clear wa_error.

In BEGINOF_RECORD_:

WERKS Field:

IF NOT zafs_autoproject-werks IS INITIAL.

CLEAR w_matnr.

w_matnr = zafs_autoproject-sermat.

SELECT COUNT( * ) FROM t001w WHERE werks = zafs_autoproject-werks.

IF sy-subrc EQ 0.

yafs_autoproject-werks = zafs_autoproject-werks.

ELSE.

CLEAR wa_error.

wa_error-werks = zafs_autoproject-werks.

wa_error-sermat = w_matnr.

wa_error-comment = c_message1.

APPEND wa_error TO t_error.

CLEAR wa_error.

skip_transaction.

ENDIF.

ENDIF.

SERMAT Field:

IF NOT zafs_autoproject-sermat IS INITIAL.

CLEAR w_matnr.

w_matnr = zafs_autoproject-sermat.

CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'

EXPORTING

input = zafs_autoproject-sermat

IMPORTING

output = zafs_autoproject-sermat.

IF sy-subrc EQ 0.

SELECT COUNT( * ) FROM marc WHERE matnr = zafs_autoproject-sermat

AND werks = zafs_autoproject-wwerks.

IF sy-subrc EQ 0.

yafs_autoproject-sermat = zafs_autoproject-sermat.

ELSE.

CLEAR wa_error.

wa_error-werks = zafs_autoproject-werks.

wa_error-sermat = w_matnr.

wa_error-comment = c_message.

APPEND wa_error TO t_error.

CLEAR wa_error.

skip_transaction.

ENDIF.

ENDIF.

ENDIF.

In __END_OF_PROCESSING__:

WRITE:/ c_error_records,c_comment1.

ULINE.

LOOP AT t_error INTO wa_error.

WRITE :/2 wa_error-sermat,

20 wa_error-werks,

27 wa_error-comment.

CLEAR wa_error.

ENDLOOP.

Maintain Fixed Values, Translations, User-Defined Routines: here we can specify fixed values and user defined sub routines.

Read only

Former Member
0 Likes
573

Hi,

Refer to this link, you will get nice documentation.

http://www.saptechnical.com/Tutorials/LSMW/LSMWMainPage.htm

Thanks,

Anitha

Read only

Former Member
0 Likes
572

Hi Swapna

There is no need to write ABAP code for LSMW.

There is one possiblity to write ABAP Code. like In RULE m we need to write ABAP Code. This is used for Field mappings for source to target.

Regards

Ravi

Read only

Former Member
0 Likes
572

Swapna,

Coding in lsmw... If you want to write some piece of code repeatedly then u will write the coding in some routines ... like if you want some filed structure to be changed or if you want to do some calculations and submit that value to one of the fileds in the mapped structure ..... so based upon the requirement you have to write the coding....

so you have to do this coding in the 6th step... when u can write the function modules, subroutines and all....