BAPI – Business Application Programming Interface
LSMW using BAPI method
The minimum knowledge required for this process is
The Business Object
BAPI
Message Types
IDoc Types.
In this method we will upload a Purchase order using LSWM-BAPI method.
This method is the same as LSMW method except that we need to maintain some IDOC settings.
LIST OF BAPI – BAPI
Transaction Code is BAPI itself.
In this screen we can see the different modules.
Drill-down to see the list of BAPI.
Enter Tcode - LSMW. Enter
PROJECT
SUB-PROJECT
OBJECT
In the menu ba,r select SETTINGS and IDOC Inbound processing.
In the below screen we need to maintain some settings for the IDOCs to function properly.
We will do these settings here.
1. Maintain File port by clicking on Maintain Ports.
2. Maintain Partner. Type by clicking on Maintain Partner Types
3. Maintain Partner No. by clicking on Maintain Partner Numbers
4. Activate IDoc Inbound Processing
Maintain File port
Click on FILE and select SUBSYSTEM.
Copy the SUBSYSTEM and create the name under which we want to create the port.
LSMW in our case.
Don’t forget to tick-mark Unicode Format.
SAVE your entries.
Maintain Partner. Type
Click on MAINTAIN PARTNER TYPES to maintain the Partner types settings.
Select the Partner Type “US”.
Maintain Partner No
Click on Maintain Partner Numbers.
Select PARTNER TYPE US
Under the PARTNER TYPE US we have a number. Copy and rename as your SAP USERNAME as shown.
SAVE your entries.
The final entries should look as shown below.
Now that we have set-up the IDOCs, we should move ahead and do the LSMW process.
Click on EXECUTE
The below shown screen is the same as LSMW screen only a few extra fields for IDOCs.
Now, let us begin the process sequentially.
STEP 1 – Maintain Object Attributes
In this screen we must select the BUSINESS OBJECT METHOD.
Enter BUS2012 in the Business Object as shown below.
In METHOD choose “CREATE FORMDATA” for PO.
SAVE your entries
STEP 2 – MAINTAIN SOURCE STRUCTURES
Create a Source Structure by clicking the
Select the Source Structure and click on the CREATE button for creating the PO ITEM data.
Select Lower level here.
Now, select POHEADER and click on CHANGE/DISPLAY button.
Select TABLE MAINTENANCE button.
We should maintain the PO HEADER level details here.
We should have the EXCEL sheet ready with all the header level details.
Enter the above details in the SAP screen
SAVE and hit BACK button.
Now, select POHEADER and click on the button and maintain the details as “IDENTIFIER” and “H” as
shown in below diagram.
E
Press ENTER and we can see the IDENTIFIE FIELD CONTENT “H” is created under the PO HEADER ITEM.
SAVE the entries.
Now click on POITEM and click on the button and maintain the excel entries in SAP system as
shown in the below diagram.
SAVE and hit the BACK button.
We can see the “ID” automatically displayed for IDENTIFIER.
Now double-click on IDENTIFIER and enter “H” in IDENTIFYING CELL CONTENT as shown below.
Press Enter.
Now we can see the IDENTIFIER H in both the HEADER and ITEM level details.
SAVE and BACK.
STEP 3 – MAINTAIN STRUCTURE RELATIONS
Double-click/Execute on Maintain Structure relations
Click on CHANGE/DISPLAY button.
Select HEADER SEGMENT and click on the button.
Select POHEADER – we can see PO HEADER DATA is assigned to the HEADER SEGMENT.
Likewise, maintain relations for PO ITEM LEVEL by select the line items and selecting
button.
The system will assign the relationship on the right-side of the screen.
Now we have assigned all the relationship to HEADER and ITEM LEVEL.
SAVE and hit BACK.
STEP 5 – MAINTAIN FIELD MAPPING AND CONVERSION RULES
Double-click on MAINTAIN FIELD MAPPING AND CONVERSION RULES or hit the EXECUTE button.
Click on CHANGE/DISPLAY button.
Select the DOC_TYPE and click on the button.
Choose CONSTANT and click on OK.
Enter the DOCUMENT TYPE from the list.
Choose “NB”.
We can see the DOCUMENT TYPE “NB” is attached as shown below.
Likewise, Click on CO_CODE and select and select from the HEADER ITEM or ITEM
LEVEL.
The relation is displayed on the right-side of the screen as shown below.
Maintain for PUR ORG, PUR GRP, VENDOR.
SAVE your entries and maintain entries for ITEM LEVEL.
SAVE and hit BACK
STEP 6 – MAINTAIN FIXED VALUES, TRANSLATIONS, USER-DEFINED ROUTIENS
We can skip this step.
STEP 7 – SPECIFY FILES
In the Excel file, finally make entries as shown below
Finally the Excel format should look like the below.
Since Purchase groug is a Number, we should select the COLUMN D and in FORMAT cells options change
to 000 in CUSTOMIZE option.
SAVE the file as a “POHEADER.txt” file.
Likewise do the same for the POITEM file.
Maintain a EXCEL sheet as shown below.
SAVE as POITEM.txt file.
STEP 8 – SPECIFY FILES
Select LEGACY DATA and click on CHANGE/DISPLAY button.
Now, click on button to select the path of the files.
SAVE and BACK.
STEP 9 – ASSIGN FILES
Double-click on ASSIGN FILES.
Click on button.
Click on POHEADER and click on
Likewise, select POITEM and click on ASSIGNMENT BUTTON.
Now, both POHEADER and POITEM have been assigned to the Legacy data.
SAVE and hit BACK button.
STEP 10 – READ DATA
Double-click on READ DATA.
STEP 11 – DISPLAY DATA
Hit OK.
Click on the first line item POHEADER to check if the entries are correct.
Likewise, click on the second line-item to see if the entries are correct.
STEP 12 – CONVERT DATA
Double-click on CONVERT DATA
Hit EXECUTE button.
STEP 13 – DISPLAY CONVERTED DATA
Double-click on DISPLAY CONVERTED DATA.
SAVE and hit BACK button.
STEP 14 – START IDOC GENERATION
Double-click on STAR IDOC generation.
Click on EXECUTE.
STEP 15 – START IDOC PROCESSING
Double-click on START IDOC PROCESSING
EXECUTE.
There is a mistake in IDOC posting.
Else the GREEN symbol will be ON and message as “Application Document Posted”.
STEP 16 – IDOC OVERVIEW
Enter the IDOC number and press EXECUTE.
ra
In the STATUS RECORD a PO number will be generated.
CHECK IN ME23N for the correctness of the data.
So, this is how the LSMW – BAPI method work using IDOCs.