0% found this document useful (0 votes)
203 views7 pages

BDC Programming: Excel Data Upload Guide

The document provides instructions for uploading data to SAP using BDC (Batch Data Communication) programming. It explains that a BDC program needs to be written to create sessions for uploading. It outlines the steps to record a transaction, create a program from the recording, and modify the program to loop through a file and upload the data by calling BDC fields and transactions. Examples of BDC commands for session handling and debugging are also provided.

Uploaded by

patel_sandeep123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
203 views7 pages

BDC Programming: Excel Data Upload Guide

The document provides instructions for uploading data to SAP using BDC (Batch Data Communication) programming. It explains that a BDC program needs to be written to create sessions for uploading. It outlines the steps to record a transaction, create a program from the recording, and modify the program to loop through a file and upload the data by calling BDC fields and transactions. Examples of BDC commands for session handling and debugging are also provided.

Uploaded by

patel_sandeep123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Learning BDC Programming

I want to learn how to upload data using BDC. If I have a excel data file how will
upload it using BDC. I don't know the full process of doing it, if someone help me
in this. I want it using BDC session process and processing that session. I was
trying to upload material master other day. But could not follow the process of
uploading using BDC though I know LSMW.  Please explain me the BDC
process in details with examples.

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

ABAP Tips by: Vijay K.

What is recording? 
As the word record implies, it mean recording the keystroke of the user input of a
SAP transaction screen.

Why it is used? 
It is normally used for mass update or uploading of data to the system.

What is its need? 


It help to save time for the users who need to mass change the system data.  For e.g.
tax rate change announce by the country government.

How it is related with bdc? 


It is related to bdc because bdc programming allows recording of user inputs.

BDC allows you to perform database updates in the background using standard SAP
transactions. The resultant entries will be as if the user had manually entered the data via
SAP. This means that you do not bypass any of the standard SAP consistency checks,
authorisations etc. There are two main methods of ABAP BDC, these are Call
Transaction and Batch Input. Other methods of update include Direct update, Idoc and
BAPI.Format date field for BDC screen entry 

REPORT Y730_BDC5 .
*HANDLING TABLE CONTROL IN BDC
DATA : BEGIN OF IT_DUMMY OCCURS 0,
       DUMMY(100) TYPE C,
       END OF IT_DUMMY.
DATA : BEGIN OF IT_XK01 OCCURS 0,
       LIFNR(10) TYPE C,
       BUKRS(4)  TYPE C,
       EKORG(4)  TYPE C,
       KTOKK(4)  TYPE C,
       NAME1(30) TYPE C,
       SORTL(10) TYPE C,
       LAND1(3)  TYPE C,
       SPRAS(2)  TYPE C,
       AKONT(6)  TYPE C,
       FDGRV(2)  TYPE C,
       WAERS(3)  TYPE C,
       END OF IT_XK01,
       BEGIN OF IT_BANK OCCURS 0,
       BANKS(3)  TYPE C,
       BANKL(10) TYPE C,
       BANKN(10) TYPE C,
       KOINH(30) TYPE C,
       LIFNR(10) TYPE C,
       END OF IT_BANK.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
       IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'


 EXPORTING
   FILENAME                      = 'C:\VENDOR.TXT'
   FILETYPE                      = 'ASC'
 TABLES
   DATA_TAB                      = IT_DUMMY.

LOOP AT IT_DUMMY.
  IF IT_DUMMY-DUMMY+0(2) = '11'.
    IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
    IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
    IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
    IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
    IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
    IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
    IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
    IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
    IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
    IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
    IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
    APPEND IT_XK01.
  ELSE.
    IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
    IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
    IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
    IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
    IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
    APPEND IT_BANK.
  ENDIF.
ENDLOOP.
LOOP AT IT_XK01.
REFRESH IT_BDCDATA.
perform bdc_dynpro      using 'SAPMF02K' '0100'.
perform bdc_field       using 'BDC_CURSOR'
                              'RF02K-REF_LIFNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'RF02K-LIFNR'
                              IT_XK01-LIFNR.
perform bdc_field       using 'RF02K-BUKRS'
                              IT_XK01-BUKRS.
perform bdc_field       using 'RF02K-EKORG'
                              IT_XK01-EKORG.
perform bdc_field       using 'RF02K-KTOKK'
                              IT_XK01-KTOKK.
perform bdc_dynpro      using 'SAPMF02K' '0110'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFA1-TELX1'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'LFA1-NAME1'
                              IT_XK01-NAME1.
perform bdc_field       using 'LFA1-SORTL'
                              IT_XK01-SORTL.
perform bdc_field       using 'LFA1-LAND1'
                              IT_XK01-LAND1.
perform bdc_field       using 'LFA1-SPRAS'
                              IT_XK01-SPRAS.
perform bdc_dynpro      using 'SAPMF02K' '0120'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFA1-KUNNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_dynpro      using 'SAPMF02K' '0130'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFBK-KOINH(02)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
DATA : FNAM(20) TYPE C,
       IDX      TYPE C.
  MOVE 1 TO IDX.
LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
  CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
  perform bdc_field       using FNAM
                                IT_BANK-BANKS.

  CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.


  perform bdc_field       using FNAM
                                IT_BANK-BANKL.

  CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.


  perform bdc_field       using FNAM
                                IT_BANK-BANKN.

  CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.


  perform bdc_field       using FNAM
                                IT_BANK-KOINH.
  IDX = IDX + 1.
ENDLOOP.

perform bdc_dynpro      using 'SAPMF02K' '0130'.


perform bdc_field       using 'BDC_CURSOR'
                              'LFBK-BANKS(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
perform bdc_dynpro      using 'SAPMF02K' '0210'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFB1-FDGRV'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'LFB1-AKONT'
                              IT_XK01-AKONT.
perform bdc_field       using 'LFB1-FDGRV'
                              IT_XK01-FDGRV.
perform bdc_dynpro      using 'SAPMF02K' '0215'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFB1-ZTERM'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_dynpro      using 'SAPMF02K' '0220'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFB5-MAHNA'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_dynpro      using 'SAPMF02K' '0310'.
perform bdc_field       using 'BDC_CURSOR'
                              'LFM1-WAERS'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'LFM1-WAERS'
                              IT_XK01-WAERS.
perform bdc_dynpro      using 'SAPMF02K' '0320'.
perform bdc_field       using 'BDC_CURSOR'
                              'WYT3-PARVW(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
perform bdc_dynpro      using 'SAPLSPO1' '0300'.
perform bdc_field       using 'BDC_OKCODE'
                              '=YES'.
CALL TRANSACTION 'XK01' USING IT_BDCDATA
                        MODE  'A'
                       UPDATE 'S'
                     MESSAGES INTO IT_BDCMSGCOLL.
ENDLOOP.

FORM BDC_DYNPRO USING PROG SCR.


  CLEAR IT_BDCDATA.
  IT_BDCDATA-PROGRAM = PROG.
  IT_BDCDATA-DYNPRO  = SCR.
  IT_BDCDATA-DYNBEGIN = 'X'.
  APPEND IT_BDCDATA.
ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.


  CLEAR IT_BDCDATA.
  IT_BDCDATA-FNAM = FNAM.
  IT_BDCDATA-FVAL  = FVAL.
  APPEND IT_BDCDATA.
ENDFORM.
Hope that would clear the matters for freshers.

Fast Links: 

You might also like