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 using BAPI method for ME21N

Former Member
0 Likes
893

Hi to all,

I am using LSMW BAPI method for the transaction ME21N Iam able to post a PO document successfully, But in my flat file I have a header and followed by item in the same line, while I was posting with same header for different line items its posting different PO's for different line items but suppose it has to post one document with multiple items.

My flat file fields are like this : (where as ABCD my header and rest are line items) I am using only one structure 'podata' in LSMW and I am not using any identifier.

header--Line items

A B C D S P Q W E X

A B C D 1 D 3 F K L

Business Object - BUS2012

Method - CREATEFROMDATA1

Message Type - PORDCR1

Basic Type - PORDCR101

As per my requirement if I have multiple line items for the same header then only one PO should be posted.

Could you suggest me, How can I achieve this.

Thanks,

Lahari

4 REPLIES 4
Read only

SharathYaralkattimath
Contributor
0 Likes
691

Hi Lahari,

You may need to write code in LSMW in "Maintain Field Mapping and Conversion Rules" Step.

Like transferring the records line by line & then transferring all the records with the same header i.e transferring the transaction at the last header record, You can use the technique

 At END OF... 

as used in ABAP here.

Read only

JL23
Active Contributor
0 Likes
691

you can look into [Modifications for Experienced Users|http://help.sap.com/saphelp_nw70/helpdata/en/b0/d268c7206911d2b430006094b944c8/content.htm]

However,

more easy to use is to create a second table from your source file which you manipulate in a way that it only has one record per PO. just remove the lines that represent multiple items.

then define a source structure that has a header structure and a subnordinate item structure.

The file with the single records becomes your header file, the file with all records the item file.

SAP internally joins those 2 files in the READ step based on common fields (e.g. your PO number).

so you get one header with multiple item lines.

Read only

Former Member
0 Likes
691

Hi Jurgen,

Thanks for your reply.

As poer your suggestion, I passed my flat file data into a single file and in the begin of transaction, I divided the data into 2 structures as Header & Item.

Still I am unable to achieve the desired results, can you please elaborate more on how SAP internally joins the structures again.

To be more clear my flat file data look like this :

217836 NB 1826162667 0127 00 1 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 60.00 1 EA

217836 NB 1826162667 0127 00 2 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 860.00 1 EA

217836 NB 1826162668 0127 00 1 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 160.00 1 EA

217836 NB 1826162668 0127 00 2 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 560.00 1 EA

The bold ones being header and the remaining Items, the underlined field is PO number.

In normal process this file is considered to have 4 records, and tries to create 4 PO's.But my requirement is to create only 2 PO's with 2 items each.

Thanks.

Lahari

Read only

JL23
Active Contributor
0 Likes
691

you missed what I said.

I said you should create 2 files.

one file looks like:

217836 NB 1826162667 0127 00

217836 NB 1826162668 0127 00

and the other is like your original file was:

217836 NB 1826162667 0127 00 1 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 60.00 1 EA

217836 NB 1826162667 0127 00 2 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 860.00 1 EA

217836 NB 1826162668 0127 00 1 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 160.00 1 EA

217836 NB 1826162668 0127 00 2 LEAN SIX SIGMA PRIMER MRO Z 4.00 EA 560.00 1 EA

the structure of the source files is to be setup like that:

-header

-


item