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: 

i want in LSMW SAME CODING. THIS IS USING BDC CALL TRANSACTION

Former Member
0 Kudos

REPORT ZXX_BDC_PRA NO STANDARD PAGE HEADING LINE-COUNT 20

LINE-SIZE 150 .

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

  • Program Name :ZXX_BDC_PRA *

  • Object Id : *

  • Develper Name : praveen *

  • Start Date : 25.06.07 *

  • Description : uploading flat file to sap system *

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

*--structure for Data Uploading.

DATA: BEGIN OF IT_STR ,

VKORG LIKE RF02D-VKORG,

VTWEG LIKE RF02D-VTWEG,

SPART LIKE RF02D-SPART,

KTOKD LIKE RF02D-KTOKD,

NAME1 LIKE KNA1-NAME1,

SORTL LIKE KNA1-SORTL,

ORT01 LIKE KNA1-ORT01,

PSTLZ LIKE KNA1-PSTLZ,

LAND1 LIKE KNA1-LAND1,

SPRAS LIKE KNA1-SPRAS,

END OF IT_STR.

*--Internal Table for Data Uploading.

DATA: ITAB LIKE IT_STR OCCURS 0.

*--Internal Table to sucessfull Records.

DATA: ITAB1 LIKE IT_STR OCCURS 0.

*--Internal Table to Store Error Records.

DATA: ITAB2 LIKE STANDARD TABLE OF IT_STR WITH HEADER LINE.

*--Internal Table for Storing the BDC data.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

*--Internal Table for storing the messages.

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

DATA: COUNT TYPE I VALUE 1,

S VALUE 0, E VALUE 0.

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

  • Selection screen *

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

SELECTION-SCREEN BEGIN OF BLOCK b1

WITH FRAME TITLE TEXT-001.

PARAMETERS: P_FILE TYPE IBIPPARMS-PATH.

SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

*functionality to use drill down list

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

.

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

  • Start-of-selection *

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

START-OF-SELECTION.

DATA FILENAME TYPE STRING.

FILENAME = P_FILE.

*-- Form to upload flatfile data into the internal table.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

*--Generating the BDC table for the fields of the internal table.

LOOP AT ITAB INTO IT_STR.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0107'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF02D-KTOKD'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'RF02D-VKORG'

IT_STR-VKORG.

PERFORM BDC_FIELD USING 'RF02D-VTWEG'

IT_STR-VTWEG.

PERFORM BDC_FIELD USING 'RF02D-SPART'

IT_STR-SPART.

PERFORM BDC_FIELD USING 'RF02D-KTOKD'

IT_STR-KTOKD.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0110'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-SPRAS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'KNA1-NAME1'

IT_STR-NAME1.

PERFORM BDC_FIELD USING 'KNA1-SORTL'

IT_STR-SORTL.

PERFORM BDC_FIELD USING 'KNA1-ORT01'

IT_STR-ORT01.

PERFORM BDC_FIELD USING 'KNA1-PSTLZ'

IT_STR-PSTLZ.

PERFORM BDC_FIELD USING 'KNA1-LAND1'

IT_STR-LAND1.

PERFORM BDC_FIELD USING 'KNA1-SPRAS'

IT_STR-SPRAS.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0120'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-TXJCD'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0125'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNA1-NIELS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0360'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0310'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNVV-BEGRU'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_DYNPRO USING 'SAPMF02D' '0324'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KNVP-PARVW(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

*--Calling the transaction 'Vd01'.

CALL TRANSACTION 'VD01' USING BDCDATA MODE 'N' UPDATE 'S'

MESSAGES INTO MESSTAB.

PERFORM MESSAGES.

REFRESH : BDCDATA, MESSTAB.

ENDLOOP.

END-OF-SELECTION.

*--Populating the Success records internal table.

IF ITAB1[] IS NOT INITIAL.

format color 5.

WRITE: /'SUCCESSFUL RECORDS'.

format color off.

LOOP AT ITAB1 INTO IT_STR.

WRITE:/ IT_STR-VKORG,IT_STR-VTWEG,

IT_STR-SPART,IT_STR-KTOKD,

IT_STR-NAME1,IT_STR-SORTL,

IT_STR-ORT01,

IT_STR-PSTLZ,

IT_STR-LAND1,

IT_STR-SPRAS.

S = S + 1.

ENDLOOP.

REFRESH : ITAB1.

WRITE:/ 'TOTAL RECORDS',S.

ENDIF.

*--Populating the error records internal table.

IF ITAB2[] IS NOT INITIAL.

FORMAT COLOR 3.

WRITE 😕 'ERRORS RECORDS ARE'.

FORMAT COLOR OFF.

LOOP AT ITAB2.

WRITE:/ ITAB2-VKORG,

ITAB2-VTWEG,

ITAB2-SPART,ITAB2-KTOKD,

ITAB2-NAME1,ITAB2-SORTL,

ITAB2-ORT01,

ITAB2-PSTLZ,

ITAB2-LAND1,

ITAB2-SPRAS.

E = E + 1.

ENDLOOP.

REFRESH : ITAB2.

WRITE: / 'TOTAL RECORDS',E.

REFRESH : ITAB2.

ENDIF.

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

  • End of Selection *

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

END-OF-SELECTION.

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

  • TOP-OF-PAGE *

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

TOP-OF-PAGE.

WRITE:/ SY-ULINE.

WRITE:/10 'REPORT ID',21 SY-REPID,35 'USERNAME',46 SY-UNAME,

60 'SYSTEM DATE',70 SY-DATUM,80 'SYSTEM TIME',90 SY-UZEIT,

100 'PAGE NO',108 SY-PAGNO.

WRITE:/ SY-ULINE.

&----


  • FOrm to Populate the BDC table.

----


----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM. "BDC_FIELD

&----


*& Form messages

&----


FORM MESSAGES .

LOOP AT MESSTAB.

IF MESSTAB-MSGTYP = 'I'.

  • WRITE : / MESSTAB-MSGV1.

ELSEIF

MESSTAB-MSGTYP = 'S'.

INSERT LINES OF ITAB FROM COUNT TO COUNT INTO TABLE ITAB1 .

COUNT = COUNT + 1.

  • WRITE : / MESSTAB-MSGV1.

ELSEIF

MESSTAB-MSGTYP = 'E'.

INSERT LINES OF ITAB FROM COUNT TO COUNT INTO TABLE ITAB2.

COUNT = COUNT + 1.

  • WRITE : / MESSTAB-MSGV1.

ENDIF.

ENDLOOP.

ENDFORM. " messages

3 REPLIES 3

Former Member
0 Kudos

Hi

Go through the doc and do the same using LSMW

BDC is the way to transfer data by writing a batch input program which can use either session or call transaction method.

LSMW used to transfer data without/less code.

What type of data we transfer using LSMW?

LSMW is best suited for transferring master data.

Actually BDC and LSMW are not comparable at all.

for example LSMW itself can use BDC as a way of mass data transfer.

BDC is a mass data transfer technique via screen logic of existing SAP Data entry transactions. It behaves as if you are manually making thousand of entires into sap system as a background job. And that is probably the reason why BAPI's are preffered over BDC's.

On the other hand LSMW is a tool to facilitate DATA migration from other legacy systems ... It contains step by step procedure for data migration.

Like Managing Data Migration Projects , Creating Source Structures , Mapping Source structures wid Target structures , etc etc

LSMW internally might well be using the following techniqes for data transfer..

1. IDOX

2. Direct Input / BDC

4. BAPI's

LSMW is an encapsulated data transfer tool. It can provide the same functionality as BDC infact much more but when coming to techinical perspective most the parameters are encapulated. To listout some of the differences :

LSMW is basicaly designed for a fuctional consultant who do not do much coding but need to explore the fuctionality while BDC is designed for a technical consultant.

LSMW offers different techinque for migrating data: Direct input ,BAPI,Idoc,Batch input recording. While bdc basically uses recording.

LSMW mapping is done by SAP while in BDC we have to do it explicitly .

LSMW is basically for standard SAP application while bdc basically for customized application.

Coding can be done flexibly in BDC when compared to LSMW

1. Maintain Attributes:

Here you have to choose the second option and you can do the recording how this should work. Then assign the same to the Batch Input Recording name.

2. Maintain Source structure:

Create a structure name

3. Maintain Source field:

In this you have to create a structure same as that of the input file

eg: name

age

sex

4. Maintain structure relations:

This will link the structure to the input file.

5. Maintain field mapping and conversion rules:

Here is the place where you can do coding, depending upon the code you have written or assignment you have done the values will get picked up from the file and get processed.

6. Maintain field mapping and conversion rules:

If you have any fixed values you can define here.

7. Specify files:

Specify the input file path and type.

8. Assign files:

This will assign ur file to the Input file

9. Read Data:

This will read ur data from teh file.

10. Dispaly Read Data:

You can see the uploaded data

11. Convert Data

This will convert the data to the corresponding format for processing

12. Display Converted data:

13. Create batch input session

Here this will create a batch input session for processing

14. Run Batch Input session:

By clicking on the session and process the same you can do teh needfu.

http://www.sapbrain.com/TOOLS/LSMW/SAP_LSMW_steps_introduction.html

http://esnips.com/doc/8e732760-5548-44cc-a0bb-5982c9424f17/lsmw_sp.ppt

http://esnips.com/doc/f55fef40-fb82-4e89-9000-88316699c323/Data-Transfer-Using-LSMW.zip

http://esnips.com/doc/1cd73c19-4263-42a4-9d6f-ac5487b0ebcb/LSMW-with-Idocs.ppt

http://esnips.com/doc/ef04c89f-f3a2-473c-beee-6db5bb3dbb0e/LSMW-with-BAPI.ppt

http://esnips.com/doc/7582d072-6663-4388-803b-4b2b94d7f85e/LSMW.pdf

for Long texts Upload

Please take a look at this..

http://help.sap.com/saphelp_erp2005/helpdata/en/e1/c6d30210e6cf4eac7b054a73f8fb1d/frameset.htm

Reward points for useful Answers

Regards

Anji

0 Kudos

how do error handling in LSMW AND how to view out put.

Former Member
0 Kudos

hi,

We use Lsmw to upload large amount of data.Almost 60% logic will be provided by system and error handling is also very easy.

LSMW supports Session method and Direct Input only.<b>It doesn't support all Transaction method.u can use recording with batch input</b>We can use BAPI's and IDoc's also.

We need to follow some steps.In case of session method

The steps are:

1.Maintain Object Attributes : here we can specify which mehod we are using

.select and execute it.

It contains 4 options

*Standard Batch/Direct Input : we can you predified objects provided by sap

*Batch Input Recording : we can record a particular transaction: give name ->select overview->provide recording name->give the tcode XK01->do the recording->select default all->save->f3

*BAPI

*Idoc->save -> back

2.Maintain Source Structures-we have to maintain a structure nothing but Internal table->save -> back

3.Maintain Source Fields : we have to maintain fields we can create and we can copy from repository->save -> back[create fields that u have in flat file

VKORG

VTWEG

SPART

KTOKD

NAME1

SORTL

ORT01

PSTLZ

LAND1

SPRAS ]

4.Maintain Structure Relations: here our structure is assigned to Our recording if we use recording->save -> back

5.Maintain Field Mapping and Conversion Rules : here fields are mapped;just go to EXTRAS->auto field mapping,for checking unassigned fields->EXTRAS->un assigned fields->save -> back

6.Maintain Fixed Values, Translations, User-Defined Routines: here we can specify fixed values and user defined sub routines->save -> back

7.Specify Files : we have to give the path of file and name and delimitor details->save -> back

8.Assign Files : we have to assign our file,it will be automatically assigned -> save -> back

9.Read Data->execute->records will be read

10.Display Read Data->displays the no.of records read

11.Convert Data->execute ->f3(writes records)

12.Display Converted Data->execute->f3

13.Create Batch Input Session->creates session->execute->f3

14.Run Batch Input Session->controls leads to sm35->process->check i log if it contains errors.

also go through the links:

steps for LSMW: detail documnets: http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc

http://sapabap.iespana.es/sapabap/manuales/pdf/lsmw.pdf

http://www.sap-img.com/sap-data-migration.htm

https://websmp207.sap-ag.de/lsmw

http://www.sapbrain.com/TOOLS/LSMW/SAP_LSMW_steps_introduction.html

http://esnips.com/doc/8e732760-5548-44cc-a0bb-5982c9424f17/lsmw_sp.ppt

http://esnips.com/doc/f55fef40-fb82-4e89-9000-88316699c323/Data-Transfer-Using-LSMW.zip

http://esnips.com/doc/1cd73c19-4263-42a4-9d6f-ac5487b0ebcb/LSMW-with-Idocs.ppt

http://esnips.com/doc/ef04c89f-f3a2-473c-beee-6db5bb3dbb0e/LSMW-with-BAPI.ppt

http://esnips.com/doc/7582d072-6663-4388-803b-4b2b94d7f85e/LSMW.pdf

REFER.