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: 

Need help in transferring data from flatfiles to SAP R/3 tables

Former Member
0 Kudos

Hi,

I need to *transfer data in the flatfiles (NON SAP SYSTEM) to SAP R/3 tables*. Can we do it with a help of program ?

Please help me out

Thanks and regards,

Shiva shekar k

4 REPLIES 4

Former Member
0 Kudos

Hi Shiva

Try considering below methods basing on the nature, volume and usage of the data you need to Upload to R/3 system.


1. BAPI's
2. LSMW
3. Data Transfer Tools(Tran: SXDB)
4. BDC
5. IDoc's

Kind Regards

Eswar

Former Member
0 Kudos

You can use BDC, LSMW for the transfer of data from non SAP to SAP systems.

The BDC Methods are:

CALL TRANSACTION:

Single transaction can be processed always.

Synchronous Processing - means Transfers data for a single transaction.

Asynchronous and Synchronous Database Update is possible.

No Session Log is created

Faster as it Asynchronous Update is possible.

Returns the SY-SUBRC value.

SESSION METHOD:

Multiple Transactions can be Processed through the same session.

Asynchronous processing - means Transfers data for multiple transactions.

Synchronous updates only possible - means no transaction is started until the previous transaction has been written to the database.

Session log is created.

Slower as it is Synchronous Update only.

Doesn't return the SY-SUBRC value.

LSMW

Legacy System Migration Workbench(LSMW) is a tool for Uploading the Data into SAP.

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

IDocs

Idocs are Intermediate document created when we transfre data from(legacy system ) to SAP system or within several clients .

ALE (application link enabling) is the medium through which idocs are passed through . Customer distribution model is distributed

BAPI

BAPI stands for Business API(Application Program Interface).

A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..

You can make your function module remotely enabled in attributes of Function module but

A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).

Reward points if useful.

megha_h
Participant
0 Kudos

Hi Shiva,

If you are a functional consultant and have to do the transfer without any ABAP help then you can do it using LSMW or SCATT.

Else if you have an ABAP Consultant to help you then you can go for BDC or BAPIs.

Between these 2, BDC is easier.Just do the recording of the transaction using SHDB and ask the ABAPer to create a Report for you.

With BDC method, you are in better position to validate/change the data before posting.

Reward points if you found this answer useful.

Regards

Megha

Former Member
0 Kudos

Hi Shiva,

This code will be helpful to you.

*Code used to create BDC

&----


*& Report ZBDC *

*& *

&----


*& Example BDC program, which updates net price of item 00010 of a *

*& particular Purchase order(EBELN). *

*& *

&----


REPORT ZBDC NO STANDARD PAGE HEADING

LINE-SIZE 132.

*----


  • Data declaration

TABLES: ekko, ekpo.

TYPES: BEGIN OF t_ekko,

ebeln TYPE ekko-ebeln,

waers TYPE ekko-waers,

netpr TYPE ekpo-netpr,

err_msg(73) TYPE c,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko,

it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_error TYPE t_ekko,

it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_success TYPE t_ekko.

DATA: w_textout LIKE t100-text.

DATA: gd_update TYPE i,

gd_lines TYPE i.

*Used to store BDC data

DATA: BEGIN OF bdc_tab OCCURS 0.

INCLUDE STRUCTURE bdcdata.

DATA: END OF bdc_tab.

*Used to stores error information from CALL TRANSACTION Function Module

DATA: BEGIN OF messtab OCCURS 0.

INCLUDE STRUCTURE bdcmsgcoll.

DATA: END OF messtab.

*----


*Screen declaration

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME

TITLE text-001. "Purchase order Num

SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.

SELECTION-SCREEN END OF BLOCK block1.

SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME

TITLE text-002. "New NETPR value

PARAMETERS: p_newpr(14) TYPE c obligatory. "LIKE ekpo-netpr.

SELECTION-SCREEN END OF BLOCK block2.

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

*START-OF-SELECTION

START-OF-SELECTION.

  • Retrieve data from Purchase order table(EKKO)

SELECT ekkoebeln ekkowaers ekpo~netpr

INTO TABLE it_ekko

FROM ekko AS ekko INNER JOIN ekpo AS ekpo

ON ekpoebeln EQ ekkoebeln

WHERE ekko~ebeln IN so_ebeln AND

ekpo~ebelp EQ '10'.

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

*END-OF-SELECTION

END-OF-SELECTION.

  • Check data has been retrieved ready for processing

DESCRIBE TABLE it_ekko LINES gd_lines.

IF gd_lines LE 0.

  • Display message if no data has been retrieved

MESSAGE i003(zp) WITH 'No Records Found'(001).

LEAVE TO SCREEN 0.

ELSE.

  • Update Customer master data (instalment text)

LOOP AT it_ekko INTO wa_ekko.

PERFORM bdc_update.

ENDLOOP.

  • Display message confirming number of records updated

IF gd_update GT 1.

MESSAGE i003(zp) WITH gd_update 'Records updated'(002).

ELSE.

MESSAGE i003(zp) WITH gd_update 'Record updated'(003).

ENDIF.

  • Display Success Report

  • **********************

  • Check Success table

DESCRIBE TABLE it_success LINES gd_lines.

IF gd_lines GT 0.

  • Display result report column headings

PERFORM display_column_headings.

  • Display result report

PERFORM display_report.

ENDIF.

  • Display Error Report

  • ********************

  • Check errors table

DESCRIBE TABLE it_error LINES gd_lines.

  • If errors exist then display errors report

IF gd_lines GT 0.

  • Display errors report

PERFORM display_error_headings.

PERFORM display_error_report.

ENDIF.

ENDIF.

&----


*& Form DISPLAY_COLUMN_HEADINGS

&----


  • Display column headings

----


FORM display_column_headings.

WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.

SKIP.

WRITE:2 'The following records updated successfully:'(013).

WRITE:/ sy-uline(42).

FORMAT COLOR COL_HEADING.

WRITE:/ sy-vline,

(10) 'Purchase Order'(004), sy-vline,

(11) 'Old Netpr'(005), sy-vline,

(11) 'New Netpr'(006), sy-vline.

WRITE:/ sy-uline(42).

ENDFORM. " DISPLAY_COLUMN_HEADINGS

&----


*& Form BDC_UPDATE

&----


  • Populate BDC table and call transaction ME22

----


FORM bdc_update.

PERFORM dynpro USING:

'X' 'SAPMM06E' '0105',

' ' 'BDC_CURSOR' 'RM06E-BSTNR',

' ' 'RM06E-BSTNR' wa_ekko-ebeln,

' ' 'BDC_OKCODE' '/00', "OK code

'X' 'SAPMM06E' '0120',

' ' 'BDC_CURSOR' 'EKPO-NETPR(01)',

' ' 'EKPO-NETPR(01)' p_newpr,

' ' 'BDC_OKCODE' '=BU'. "OK code

  • Call transaction to update customer instalment text

CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'

MESSAGES INTO messtab.

  • Check if update was succesful

IF sy-subrc EQ 0.

ADD 1 TO gd_update.

APPEND wa_ekko TO it_success.

ELSE.

  • Retrieve error messages displayed during BDC update

LOOP AT messtab WHERE msgtyp = 'E'.

  • Builds actual message based on info returned from Call transaction

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

msgid = messtab-msgid

msgnr = messtab-msgnr

msgv1 = messtab-msgv1

msgv2 = messtab-msgv2

msgv3 = messtab-msgv3

msgv4 = messtab-msgv4

IMPORTING

message_text_output = w_textout.

ENDLOOP.

  • Build error table ready for output

wa_error = wa_ekko.

wa_error-err_msg = w_textout.

APPEND wa_error TO it_error.

CLEAR: wa_error.

ENDIF.

  • Clear bdc date table

CLEAR: bdc_tab.

REFRESH: bdc_tab.

ENDFORM. " BDC_UPDATE

----


  • FORM DYNPRO *

----


  • stores values to bdc table *

----


  • --> DYNBEGIN *

  • --> NAME *

  • --> VALUE *

----


FORM dynpro USING dynbegin name value.

IF dynbegin = 'X'.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-program,

value TO bdc_tab-dynpro,

'X' TO bdc_tab-dynbegin.

APPEND bdc_tab.

ELSE.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-fnam,

value TO bdc_tab-fval.

APPEND bdc_tab.

ENDIF.

ENDFORM. " DYNPRO

&----


*& Form DISPLAY_REPORT

&----


  • Display Report

----


FORM display_report.

FORMAT COLOR COL_NORMAL.

  • Loop at data table

LOOP AT it_success INTO wa_success.

WRITE:/ sy-vline,

(10) wa_success-ebeln, sy-vline,

(11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,

(11) p_newpr, sy-vline.

CLEAR: wa_success.

ENDLOOP.

WRITE:/ sy-uline(42).

REFRESH: it_success.

FORMAT COLOR COL_BACKGROUND.

ENDFORM. " DISPLAY_REPORT

&----


*& Form DISPLAY_ERROR_REPORT

&----


  • Display error report data

----


FORM display_error_report.

LOOP AT it_error INTO wa_error.

WRITE:/ sy-vline,

(10) wa_error-ebeln, sy-vline,

(11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,

(73) wa_error-err_msg, sy-vline.

ENDLOOP.

WRITE:/ sy-uline(104).

REFRESH: it_error.

ENDFORM. " DISPLAY_ERROR_REPORT

&----


*& Form DISPLAY_ERROR_HEADINGS

&----


  • Display error report headings

----


FORM display_error_headings.

SKIP.

WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.

SKIP.

WRITE:2 'The following records failed during update:'(008).

WRITE:/ sy-uline(104).

FORMAT COLOR COL_HEADING.

WRITE:/ sy-vline,

(10) 'Purchase Order'(009), sy-vline,

(11) 'Netpr'(010), sy-vline,

(73) 'Error Message'(012), sy-vline.

WRITE:/ sy-uline(104).

FORMAT COLOR COL_NORMAL.

ENDFORM. " DISPLAY_ERROR_HEADINGS