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
558

Hi Abapers,

Could you plz tell me how do we handle errors in lsmw..wat r diff ways in it..

Hi Abapers,

Could you plz tell me how do we handle errors in lsmw..wat r diff ways in it..

3 REPLIES 3
Read only

Former Member
0 Likes
532

Hi,

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.

Eg: 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.

Reward points if helpful.

Regards,

Dhana

Read only

Former Member
0 Likes
532

hi,

you can handle errors in LSMW automatically.

If you use session method we can check error log in sm35.

after each and every step it will give error message if that particular step contains error.

If you want to catch unprocessed records or if you want to display errors you can check dhan's posting

Read only

Former Member
0 Likes
532

Hi,

Still are you not clear in handling errors?

Regards,

Dhana