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
706

Hi!

Is any body having an idea how to use loop in lsmw and how to do data validation in lsmw

Hi!

Is any body having an idea how to use loop in lsmw and how to do data validation in lsmw

2 REPLIES 2
Read only

Former Member
0 Likes
631

Hi Preet,

Can you tell me a little bit more about the loop you want to use? is it for uploading the whole data set of your secuential file? if so you dont need to loop, LSMW will do it for you.. it will read the whole file until the end ... if is for something else please give me more detail.

For data validation in step 4 you'll find the Maintain field mapping and conversion rules, here you can add some validation selecting different options like concatenation, etc. or you can write your own code in an integrated editor that option has.

Hope it helps.

Read only

Former Member
0 Likes
631

Hello,

You can loop in LSMW any point in the step 'Maintain Field Mapping and Conversion Rules'. Remember, behind the scenes every LSMW object generates an ABAP program. If you check the box 'Display Conversion Program', you'll be able to see the ABAP program name.

Eg: Here I'm looping mulitiple fields of the same row to get Scale values for loading Purchase info records. The structure is BKONM.

***********************************************************************************

BKONM Conditions (Quantity Scale 1-Dimensional) for BTCI

5 Fields

__BEGIN_OF_RECORD__ Before Using Conversion Rules

Rule : Default Settings Modified

Code: Do 6 times.

BKONM = INIT_BKONM.

STYPE Batch Input Interface Record Type

Rule : Default Settings

Code: BKONM-STYPE = '2'.

TBNAM Table Name

Rule : Default Settings

Code: BKONM-TBNAM = 'KONM'.

KSCHL Condition type

Rule : Fixed Value (Reusable)

Code: BKONM-KSCHL = FV_CONDITION_PB00.

KSTBM Condition scale basis quantity

Source: INPUTFILE-KSTBW1 (Scale - 1)

Code: CASE SY-INDEX.

WHEN '1'.

BKONM-KSTBM = INPUTFILE-KSTBW1.

BKONM-KBETR = INPUTFILE-KBETR1.

WHEN '2'.

BKONM-KSTBM = INPUTFILE-KSTBW2.

BKONM-KBETR = INPUTFILE-KBETR2.

WHEN '3'.

BKONM-KSTBM = INPUTFILE-KSTBW3.

BKONM-KBETR = INPUTFILE-KBETR3.

KBETR Condition amount/percentage in non-scale case

Source: INPUTFILE-KBETR1 (Price - 1)

ENDCASE.

transfer_record.

Enddo.

__END_OF_RECORD__ After Using Conversion Rules

Rule : Default Settings Modified

Code: *transfer_record.

***********************************************************************************

Instead of transferring the record at the end of every line, I'm transferring the values for 3 different Price fields.

Refer the ABAP program generated by LSMW and you'll see the logic system provided and the user can pretty much do all the ABAP code it.

Hope this helps.

Good luck and Best Regards,

Gopakumar

Sr.SAP Tech.Consultant/Tech.Team Lead