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 Need Navigation about BDC Upload

Former Member
0 Kudos

Need Navigation about BDC Upload

3 REPLIES 3

Former Member
0 Kudos

Hi

<b>the BDC program should be in this format</b>

Transaction Recorder (SHDB)

How to Upload Presentation Server Flat file to SAP R/3 system???

How to upload application server file to R/3 system?

Definition

<b>Example - Call Transaction Method</b>

<b>Transaction Recorder (SHDB)</b>

Before you work with the Batch Input methods, you should know the purpose of the tool

Transaction Recorder.

<b>Use:</b>

You can use the transaction recorder to record a series of transactions and their screens.

<b>Features:</b>

You can use the recording to create

Data transfer programs that use batch input or CALL TRANSACTION

Batch input sessions

Test data

Function modules.

Note: It doesn’t record F1, F4 and Scrollbar movements

<b>Upload Flat file from Presentation Server to SAP R/3</b>

CALL FUNCTION ‘GUI_UPLOAD'

EXPORTING

CODEPAGE = ‘IBM'

FILENAME = P_UFILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = INT_TAB

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10 .

IF SY-SUBRC NE 0.

MESSAGE E999(FR) WITH 'ERROR IN FILE UPLOAD'.

ENDIF.

<b>Upload file from application server to SAP R/3</b>

Open the the application server file

OPEN DATASET <dsn> FOR INPUT <mode>

Read the data from application server file

READ DATASET <dsn> INTO <wa>

And then close the application server file

CLOSE DATASET <dsn>

Definition- Declaring BDC Table

DATA: BDC_TAB LIKE STANDARD TABLE OF

BDCDATA INITIAL SIZE 6

WITH HEADER LINE .

The internal table used to collect the transaction’s information must be declared “LIKE BDCDATA”.

<b>Filling BDC Table – Method #1</b>

FORM FILL_BDC_TAB.

REFRESH BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-PROGRAM = ‘SAPMF02K’.

BDC_TAB-DYNPRO = ‘01016’.

BDC_TAB-DYNBEGIN = ‘X’.

APPEND BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-FNAM = ‘RF02K-LIFNR’.

BDC_TAB-FVAL = ‘TEST1’.

APPEND BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-FNAM = ‘RF02K-D0010’.

BDC_TAB-FVAL = ‘X’.

APPEND BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-PROGRAM = ‘SAPMF02K’.

BDC_TAB-DYNPRO = ‘0110’.

BDC_TAB-DYNBEGIN = ‘X’.

APPEND BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-FNAM = ‘LFA1-STRAS’.

BDC_TAB-FVAL = ‘123 Main St.’.

APPEND BDC_TAB.

CLEAR BDC_TAB.

BDC_TAB-FNAM = ‘BDC_OKCODE’.

BDC_TAB-FVAL = ‘/11’.

APPEND BDC_TAB.

ENDFORM.

<b>Filling BDC Table – Method #2</b>

FORM FILL_BDC_TAB.

REFRESH BDC_TAB.

PERFORM POPULATE_BDC_TAB

USING:

‘1’ ‘SAPMF02K’ ‘0106’,

‘ ‘ ‘RF02K-LIFNR’ ‘TEST1’,

‘ ‘ ‘RF02K-D0010’ ‘X’,

‘1’ ‘SAPMF02K’ ‘0110’,

‘ ‘ ‘LFA1-STRAS’, ‘123 Main St.’,

‘ ‘ ‘BDC_OKCODE’, ‘/11’.

ENDFORM.

FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.

CLEAR BDC_TAB.

IF FLAG = ‘1’.

BDC_TAB-PROGRAM = VAR1.

BDC_TAB-DYNPRO = VAR2..

BDC_TAB-DYNBEGIN = ‘X’.

ELSE.

BDC_TAB-FNAM = VAR1.

BDC_TAB-FVAL = VAR2.

ENDIF.

APPEND BDC_TAB.

ENDFORM.

This two subroutine method to fill the BDC table is preferable because the “POPULATE_BDC_TABLE” subroutine is reusable throughout all batch input programs.

Example #1 - Change Vendor (Call Transaction Method)

<b>Example #1- Declaration Section</b>

REPORT Y180DM10.

DATA: BDC_TAB LIKE STANDARD TABLE OF

BDCDATA INITIAL SIZE 6 WITH HEADER LINE.

INFILE(20) VALUE ‘/tmp/bc180_file4’.

DATA: BEGIN OF INREC.

VENDNUM LIKE LFA1-LIFNR.

STREET LIKE LFA1-STRAS.

END OF INREC.

PARAMETERS: DISPMODE DEFAULT ‘A’,

UPDAMODE DEFAULT ‘S’.

START-OF-SELECTION.

OPEN DATASET INFILE

FOR INPUT IN TEXT MODE.

DO.

READ DATASET INFILE INTO INREC.

IF SY-SUBRC < > 0. EXIT. ENDIF.

PERFORM FILL_BDC_TAB.

CALL TRANSACTION ‘FK02’

USING BDC_TAB

MODE DISPMODE

UPDATE UPDAMODE.

IF SY-SUBRC < > 0.

WRITE: /‘ERROR’.

ENDIF.

ENDDO.

CLOSE DATASET INFILE.

<b>synchronous updating</b>

DO.

………

PERFORM FILL_BDC_TAB.

CALL TRANSACTION ‘FK02’

USING BDC_TAB

MODE ‘N’

UPDATE ‘S’.

IF SY-SUBRC < > 0.

WRITE: /‘ERROR’.

ENDIF.

ENDDO.

With synchronous updating, we can check SY-SUBRC to determine the success of the transaction and the actual update to the database.

<b>asynchronous updating</b>

DO.

………

PERFORM FILL_BDC_TAB.

CALL TRANSACTION ‘FK02’

USING BDC_TAB

MODE ‘N’

UPDATE ‘A’.

IF SY-SUBRC < > 0.

WRITE: /‘ERROR’.

ENDIF.

ENDDO.

With asynchronous updating, we can check SY-SUBRC to determine the success of the transaction only, not the actual update to the database.

<b>Error Handling</b>

Write an error report.

Send the record(s) in error to an error file.

Create a batch input session with the record(s) in error.

To store error messages ( CALL TRANSACTION )

data: begin of Tab_Mess occurs 0.

include structure bdcmsgcoll.

data : end of Tab_Mess,

CALL TRANSACTION ‘FK02’ USING BDC_TAB MODE ‘N’ UPDATE ‘S’

MESSAGES INTO TAB_MESS.

IF SY-SUBRC NE 0.

WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,

Tab_MESS-MSGID.

ENDIF.

<b>i am giving you example for Change Vendor you practice for ur tcode</b>

For our example, we will use the “Change Vendor” transaction (“FK02”) to add a street address to an already existing vendor.

<b>Step #1</b>

Use “System&#61664;Status” menu path to determine online program name (SAPMF02K), screen number (0110)

<b>Step #2</b>

Use “F1” key and “Technical Info” pushbutton in each screen field to be filled to determine the field name.

<b>Step #3</b>

Determine how to proceed in the transaction

(save the record by clicking on the ‘Save’ pushbutton or pressing the ‘F11’ key).

<b>BDC Table Contents</b>

After researching the transaction we can determine the contents of the BDC table.

PROGRAM DYNPRO DYNBEGIN FNAM FVAL

SAMPF02K 0106 X

RF02K-LIFNR TEST1

RF02K-D0110 X

SAMPF02K 0110 X

LFA1-STRAS 123 Main St.

BDC_OKCODE /11

<b>Batch Input Methods</b>

“CALL TRANSACTION USING”

STATEMENT

<b>Call transaction - for data transfer</b>Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended data transfer methods. In this method, legacy data is processed inline in your data transfer program.

Syntax:

CALL TRANSACTION <tcode>

USING <bdc_tab>

MODE <mode>

UPDATE <update>

A Display all

E Display errors only

N No display

S Synchronous

A Asynchronous

L Local update

<b>The process flow of CALL TRANSACTION</b>

A program that uses CALL TRANSACTION USING to process legacy data should execute thefollowing steps:

Prepare a BDCDATA structure for the transaction that you wish to run.

Prepare a internal table to store error messages Tab_Mess like structure of BDCMSGCOLL.

With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA structure. For example:

CALL TRANSACTION ‘MM01' USING BDCDATA MODE 'A' UPDATE 'S'. MESSAGES INTO TAB_MESS.

IF SY-SUBRC <> 0.

<Error_handling>.

ENDIF.

<b>Overview of Batch Input Session</b>

The first batch input method is to create a batch input session. It is the processing of this batch input session that updates the database, not the execution of the batch input program.

<b>Reward if usefull</b>

Former Member
0 Kudos

Use the transaction SHDB and record the session.

A BDC program is generated.

A sample program for uploading pricing condition records for materials.

http://www.sap-img.com/abap/upload-the-pricing-condtion-records-for-materials.htm

Learning BDC Programming:

http://www.sap-img.com/abap/learning-bdc-programming.htm

Hope this helps you.

Regards,

Anjali

Former Member
0 Kudos

hi,

For a BDC upload you need to write a program which created BDC sessions.

Steps:

1. Work out the transaction you would use to create the data manually.

2. Use transaction SHDB to record the creation of one material master data.

Click the New recording button or the Menu - Recording - Create

3. Save the recording, and then go back a screen and go to the overview.

4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.

5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:

5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated).

5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data.

5.3. After perform bdc_transaction, add the endloop.

Execute the program. It will have options to create a batch session or to process directly.

These are all my finds . Might be it will be useful to you.

Direct call of transactions, session handling:

/nxxxx This terminates the current transaction, and starts transaction xxxx

/n This terminates the transaction. This generally corresponds to pressing F15 to go back.

/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).

/nex This terminates all separate sessions and logs off immediately (without any warning!).

/oxxxx This opens a new session and starts transaction xxxx in This session.

/o This lists existing sessions and allows deletion or opening of a new session.

/i This terminates the current session (corresponds to System End

/i1, /i2,... This terminates the session with the number given.

.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon and is provided more for emergencies (such as a defective mouse).

Batch

The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only') when processing a batch input session:

/n This terminates the current batch input transaction and characterizes it as

/bdel This deletes the current batch input transaction.

/bend This terminates batch input processing and sets the session to Failed

/bda This switches from Display errors only to Process in foreground

/bde This switches from Process in foreground to Display errors only

ABAP/4

/h This switches into debugging mode.

/hs This switches into debugging mode and activates the debugging of system functions.

Buffer

WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.

It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.

/$SYNC This resets all buffers of the application server

/$CUA This resets the CUA buffer of the application server

/$TAB This resets the TABLE buffers of the application server

/$NAM This resets the nametab buffer of the application server

/$DYNP This resets the screen buffer of the application server