Application Development 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: 

LSMW (complex line)

Former Member
0 Kudos

Hi,

I have to upload file through LSMW (BAPI method).

File has the following structure:

HEADER1 ITEM1 ITEM2 ITEM3

HEADER2 ITEM1 ITEM2 ITEM3

HEADER3 ITEM1 ITEM2 ITEM3

and so on

So, number of items is constatnt for every header object.

I should get the next hierarchy of created object:

HEADER

- ITEM1

- ITEM2

- ITEM3

But now I can only get

HEADER

- ITEM1

Is it possible to do this task via LSMW?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can insert ABAP Code in your LSMW, so you can apply your logic.

Regards.

6 REPLIES 6

Former Member
0 Kudos

Hi,

You can insert ABAP Code in your LSMW, so you can apply your logic.

Regards.

0 Kudos

Now I'm trying to do this, but still can't choose necessary event.

JL23
Active Contributor
0 Kudos

In general SAP reads only one line in the source, hence it creates only 1 item for the target.

better would be if you source structure would already be like this:

HEADER1

- ITEM1

- ITEM2

- ITEM3

HEADER2

- ITEM1

- ITEM2

- ITEM3

but it is even possible with the structure you have

at the __END_OF_RECORD__ section for your item

add a small coding to replace ITEM1 data with ITEM2 data

followed by TRANSFER_THIS_RECORD "..."

then replace ITEM2 data with ITEM3 data

and do again TRANSFER_THIS_RECORD "..."

Former Member
0 Kudos

Thank you for your answers.

I've made it slightly different.

Added some ABAP code at event __BEGIN_OF_TRANSACTION__ to fill some dummy substructure (that is not filled at reading file).

dhirendra_pandit
Active Participant
0 Kudos

Hi Ilya,

You can do it very easily, one simple method Add a field at first position and assign records identifier to that.

To do that go to your Maintain Source Fields and create first filed with identifier like HEAD for Header record and ITEM for your Item records.

After that it will look like as follows :

| ZHEADER Task List header

| IDENTIFIER_HD C(004) Record Identifier

| Identifing Field Content: HEAD

| STTAG_HD C(010) Key Date (MM/DD/YYYY)

| KTEXT_HD C(999) Text

|

|----


ZOPERATION Task List Operation

-


IDENTIFIER_OP C(004) Record Identifier

-


Identifing Field Content: OPER

-


STTAG_OP C(010) Key Date (MM/DD/YYYY)

-


KTEXT_OP C(999) Text

Now maintain the same field order in the file and while reading the file choose the file type as sequential (among tabular or sequential file option ) and maintain the date file like this

HEAD <head value>

ITEM <Item value>

ITEM <Item value>

ITEM <Item value>

If you have any doubt you can revert me with you file layout details i'll explain it in detail.

Regards

Dhirendra

0 Kudos

Hi dhirendra pandit,

Thanx for your detailed answer, but header data and item data are in one row and I can't change this requirement.