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

Programming in LSMW

Former Member
0 Likes
919

Hello,

I have created an LSMW to post customers thorugh FD01 which works great. However, I would like to enter an IF statement somewhere to avoid duplicate postings. Does anyone know if this is possible and where I could enter the code?

Thanks for your help

Stephanie

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
762

Thanks for the reply. This would be Step number 5 correct? And I would like to base this off of the Customers Previous Account Number (ALTKN) Right now this is all it shows on the code:

1 ZCUSTPAY-ALTKN = ZAR_CUSTOMERS-ALTKN.

Is it here I need to add the IF statement?

Thanks again for your time and help

Stephanie

5 REPLIES 5
Read only

ThomasZloch
Active Contributor
0 Likes
762

You can add code to any particular field mapping. Here it would make sense to add code to the customer number conversion, checking if an entry in KNA1 already exists, then use "skip_transaction".

This is the simple scenario, it can get more complex if you have internal numbering or multiple company codes or sales areas per customer.

Thomas

Read only

Former Member
0 Likes
763

Thanks for the reply. This would be Step number 5 correct? And I would like to base this off of the Customers Previous Account Number (ALTKN) Right now this is all it shows on the code:

1 ZCUSTPAY-ALTKN = ZAR_CUSTOMERS-ALTKN.

Is it here I need to add the IF statement?

Thanks again for your time and help

Stephanie

Read only

0 Likes
762

Step 5, yes. You would add a SELECT on KNB1-ALTKN, and if entry found, use code line "skip_transaction". Please check with a local ABAPer, as this is very basic coding, and I might get smacked by a moderator if I'd give you the complete code

Also check LSMW documentation for "skip_transaction" and similar macros.

Thomas

Read only

0 Likes
762

Thanks Thomas

Read only

Former Member
0 Likes
762

I would say to write your code between begin of transaction event and end of transaction event on the field you want to check.You can even attch the errors in a internal table which can be displayed in the end.