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 Multiple Files

Former Member
0 Likes
1,240

Hi All,

I have the records in the following pattern.

Key Record

REC_KEY1 CLASS1 CHAR1 CHAR_VALUE1

CHAR2 CHAR_VALUE2

CLASS2 CHAR3 CHAR_VALUE1

CHAR4 CHAR_VALUE4

REC_KEY2 CLASS3 CHAR1 CHAR_VALUE1

CLASS4 CHAR1 CHAR_VALUE1

REC_KEY3 SPACE SPACE

All these records are in a Single file. I have LSMW Structure as

KEY

--- CLASS

___ CHAR

is there any way i can split the Above file and keep KEY VAlUE in Both the files and populate the LSMW Recorrs ? I know the way to use record identifier. Trying to use the way with Multiple fiels, One for Header with Key Value and 2nd with CLASS and CAHR Values. Please Help !!

Thanks In Advace

Kalso

1 ACCEPTED SOLUTION
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,061

Hello,

If I understood your requirement correctly this is the solution.

Follow these steps for processing multiple records in lsmw.

I presume that you have one header line and multiple line items in the file and has a unique identifier. Let us say you have two nodes in lsmw called VBAK and VBAP.

Normally lsmw process one line of the file at a time. When lsmw reads the header line, process the VBAK node and use the 'transfer_record' command (this must be already there). When the second record is processed and if the unique identifier is same as the header then write a command called 'skip_record' in the '__BEGIN_OF_RECORD__' session of VBAK. If you do like this we will have one header and multiple line items.

Thanks

Vinod

Hi All,

I have the records in the following pattern.

Key Record

REC_KEY1 CLASS1 CHAR1 CHAR_VALUE1

CHAR2 CHAR_VALUE2

CLASS2 CHAR3 CHAR_VALUE1

CHAR4 CHAR_VALUE4

REC_KEY2 CLASS3 CHAR1 CHAR_VALUE1

CLASS4 CHAR1 CHAR_VALUE1

REC_KEY3 SPACE SPACE

All these records are in a Single file. I have LSMW Structure as

KEY

--- CLASS

___ CHAR

is there any way i can split the Above file and keep KEY VAlUE in Both the files and populate the LSMW Recorrs ? I know the way to use record identifier. Trying to use the way with Multiple fiels, One for Header with Key Value and 2nd with CLASS and CAHR Values. Please Help !!

Thanks In Advace

Kalso

6 REPLIES 6
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,062

Hello,

If I understood your requirement correctly this is the solution.

Follow these steps for processing multiple records in lsmw.

I presume that you have one header line and multiple line items in the file and has a unique identifier. Let us say you have two nodes in lsmw called VBAK and VBAP.

Normally lsmw process one line of the file at a time. When lsmw reads the header line, process the VBAK node and use the 'transfer_record' command (this must be already there). When the second record is processed and if the unique identifier is same as the header then write a command called 'skip_record' in the '__BEGIN_OF_RECORD__' session of VBAK. If you do like this we will have one header and multiple line items.

Thanks

Vinod

Read only

0 Likes
1,061

Thanks for Quick reply Vinod.

I have header record in One file and Item records in another file, with Key same ( Sales Order #) .

Do i have to still use identifier ? Do i have to write any code for this kind too ?

Read only

0 Likes
1,061

As far as I know you cannot have two source files at the same time. I think you need to merge both the files items after header, then use my logic.

Kindly assign points if the answers were helpful.

Read only

0 Likes
1,061

Hi!

You can define two files in 'specify files'. In next step 'assign files' you can assign file1 to header structure and file2 to positions structure(s).

With your common key a 'loop where' should work.

Regards,

Christian

Read only

0 Likes
1,061

Thanks Christian, You are right, the loop works automatically. I Figured out a way for the file structure. thanks for the help.

The first file is in the following format

KEY1 XXXX XXXXXXXXXX

KEY2 XXXX XXXXXXXXXXX

Second file

KEY1 CLASS1 CHAR1 CHAR_VALUE1

KEY1 CLASS2 CHAR2 CHAR_VALUE2

KEY2 CLASS3 CHAR1 CHAR_VALUE1

KEY2 CLASS2 CHAR2 CHAR_VALUE2

KEY3 CLASS3 CHAR1 CHAR_VALUE1

KEY4 CLASS2 CHAR2 CHAR_VALUE2

LSMW Looped Internally

Read only

0 Likes
1,061

What version of SAP you have used ? Its not allowing me to use multiple files in ECC 6.0. If there is any other setting to be done, please do let me know.

Thanks

Ramgopal