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: 

BDC upload

Former Member
0 Kudos

Hello friends,

In real time regarding BDC ...How to upload the data is it thru DATASET (i.e., thru Application server)

or thru gui_upload(i.e., thru presentation Server)

4 REPLIES 4

Former Member
0 Kudos

Hi sathya,

You can create a BDC recording using transaction-SHDB.

you can record all the events triggered for the transaction given.

As the BDC program needs all the fields names and events triggered, you can copy the recorded code into your Program.

Kindly check,

the procedure for recording in the following link

http://help.sap.com/saphelp_47x200/helpdata/en/b9/ec71180bfe11d2bd0b080009b4534c/frameset.htm

Download Step by Step: How to Create BDC Program

http://www.sap-img.com/sap-download/bdcrecording.zip

Some useful Links

http://www.sap-img.com/bdc.htm

http://www.sappoint.com/abap/bdcrec.pdf

Sample code

A sample program to upload data for transaction - MC76

REPORT ZBDC_MC76

NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE BDCRECX1.

      • Generated data section with specific formatting ***

DATA: BEGIN OF IT_RECORD OCCURS 0,

  • data element: PRGRP

PRGRP_001(018), " Product Group

  • data element: WERKS_D

WERKS_002(004), " Plant

  • data element: AWAHL

  • AWAHL_02_003(001), " Indicator for Selection

  • data element: FLGPR

  • FLGPR_004(001),

  • data element: FLGAB

  • FLGAB_005(001), " Disaggregate Sales Plan

  • data element: FLGLB

  • FLGLB_006(001),

  • data element:

FLD001_02_007(010), " Quantity

  • data element: AWAHL

  • AWAHL_04_008(001), " Indicator for Selection

END OF IT_RECORD.

      • End generated data section ***

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

PARAMETERS :

P_PATH LIKE IBIPPARMS-PATH. "File path and name

SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.

CTU = 'X'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

FIELD_NAME = 'PATH'

IMPORTING

FILE_NAME = P_PATH.

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_PATH

FILETYPE = 'DAT'

TABLES

DATA_TAB = IT_RECORD

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

NO_AUTHORITY = 10

OTHERS = 11.

IF SY-SUBRC 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*START-OF-SELECTION.

  • PERFORM OPEN_DATASET USING DATASET.

PERFORM OPEN_GROUP.

  • DO.

  • READ DATASET DATASET INTO IT_RECORD.

  • IF SY-SUBRC 0. EXIT. ENDIF.

LOOP AT IT_RECORD.

PERFORM BDC_DYNPRO USING 'SAPMMCP6' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMCP2-WERKS'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=IAKT'.

PERFORM BDC_FIELD USING 'RMCP2-PRGRP'

IT_RECORD-PRGRP_001.

PERFORM BDC_FIELD USING 'RMCP2-WERKS'

IT_RECORD-WERKS_002.

PERFORM BDC_DYNPRO USING 'SAPLMCP6' '0175'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMCP2-AWAHL(02)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=CONT'.

PERFORM BDC_FIELD USING 'RMCP2-AWAHL(02)' 'X'.

  • IT_RECORD-AWAHL_02_003.

PERFORM BDC_DYNPRO USING 'SAPMMCP6' '0620'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMCP2-FLGAB'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=CONT'.

  • PERFORM BDC_FIELD USING 'RMCP2-FLGPR'

  • IT_RECORD-FLGPR_004.

PERFORM BDC_FIELD USING 'RMCP2-FLGAB' 'X'.

  • IT_RECORD-FLGAB_005.

  • PERFORM BDC_FIELD USING 'RMCP2-FLGLB'

  • IT_RECORD-FLGLB_006.

PERFORM BDC_DYNPRO USING 'SAPLMCPA' '0807'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'*RMCP4-FLD001(02)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING '*RMCP4-FLD001(02)'

IT_RECORD-FLD001_02_007.

PERFORM BDC_DYNPRO USING 'SAPLMCPA' '0807'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'*RMCP4-FLD001(02)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=MAKR'.

PERFORM BDC_DYNPRO USING 'SAPMMCP6' '0140'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMCP2-AWAHL(04)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=CONT'.

PERFORM BDC_FIELD USING 'RMCP2-AWAHL(04)' 'X'.

  • IT_RECORD-AWAHL_04_008.

PERFORM BDC_DYNPRO USING 'SAPLMCPA' '0807'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'*RMCP4-FLD001(02)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=SICH'.

PERFORM BDC_TRANSACTION USING 'MC76'.

REFRESH BDCDATA.

ENDLOOP.

*ENDDO.

PERFORM CLOSE_GROUP.

*PERFORM CLOSE_DATASET USING DATASET.

Kindly reward points for useful answers!

Best regards,

Vikram

Former Member
0 Kudos

Check these threads..U have sample programs.

Regards,

maha

jayakummar
Active Participant
0 Kudos

hi....

i real time we have transaction to upload and download file form application srv to prsentation srv and vice versa

t-code : cg3y, cg3z.

try this....

reward points is usefull..

regards ,

jai.m

former_member585865
Contributor
0 Kudos

Hi Satya,

Check this sample program it is for upload the vendor master data.

report ZBDC_UPLOAD_VENDORMASTER

no standard page heading line-size 255.

include bdcrecx1.

TYPE-POOLS : truxs.

DATA: it_raw TYPE truxs_t_text_data.

TABLES : LFA1.

DATA : BEGIN OF T_LIFNR OCCURS 0,

LIFNR LIKE RF02K-LIFNR, "Vendor Account Number

BUKRS LIKE RF02K-BUKRS, "Company Code

EKORG LIKE RF02K-EKORG, "Purchasing Organization

KTOKK LIKE RF02K-KTOKK, "Vendor account group

ANRED LIKE LFA1-ANRED, "Title

NAME1 LIKE LFA1-NAME1, "Name 1

SORTL LIKE LFA1-SORTL, "Sort field

STRAS LIKE LFA1-STRAS, "House number and street

ORT01 LIKE LFA1-ORT01, "City

PSTLZ LIKE LFA1-PSTLZ, "Postal Code

ORT02 LIKE LFA1-ORT02, "District

PFORT LIKE LFA1-PFORT, "PO Box city

LAND1 LIKE LFA1-LAND1, "Country Key

SPRAS LIKE LFA1-SPRAS, "Language Key

TELF1 LIKE LFA1-TELF1, "First telephone number

TELFX LIKE LFA1-TELFX, "Fax Number

AKONT LIKE LFB1-AKONT, "Reconciliation Account in General Ledger

ZUAWA LIKE LFB1-ZUAWA, "Key for sorting according to assignment numbers

ZTERM LIKE LFB1-ZTERM, "Terms of Payment Key

WAERS LIKE LFM1-WAERS, "Purchase order currency

END OF T_LIFNR.

DATA : BEGIN OF T_ERROR OCCURS 0,

INDEX TYPE I,

LIFNR(30) TYPE C,

NUM TYPE STRING,

END OF T_ERROR.

SELECTION-SCREEN BEGIN OF BLOCK BBB WITH FRAME TITLE VENDMAS.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\' OBLIGATORY.

SELECTION-SCREEN END OF BLOCK BBB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM 100_FILEGET.

start-of-selection.

PERFORM 200_UPLOAD_FILE.

PERFORM 250_VALIDATE_DATA.

PERFORM 300_BDC.

PERFORM 400_ERROR_DOWNLOAD.

&----


*& Form 100_FILEGET

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form 100_FILEGET .

CALL FUNCTION 'WS_FILENAME_GET'

IMPORTING

filename = p_file.

endform. " 100_FILEGET

&----


*& Form 200_UPLOAD_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form 200_UPLOAD_FILE .

DATA : wa(4) TYPE c,

wa1(30) TYPE c .

SPLIT p_file AT '.' INTO wa1 wa.

DATA: filename TYPE string.

filename = p_file.

IF wa EQ 'txt'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = filename

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = T_LIFNR.

ELSEIF wa EQ 'xls'.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_file

TABLES

i_tab_converted_data = T_LIFNR.

ENDIF.

endform. " 200_UPLOAD_FILE

&----


*& Form 300_BDC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form 300_BDC .

LOOP AT T_LIFNR.

perform open_group.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'RF02K-LIFNR' T_LIFNR-LIFNR.

perform bdc_field using 'RF02K-BUKRS' T_LIFNR-BUKRS.

perform bdc_field using 'RF02K-EKORG' T_LIFNR-EKORG.

perform bdc_field using 'RF02K-KTOKK' T_LIFNR-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-TELFX'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_field using 'LFA1-ANRED' T_LIFNR-ANRED.

perform bdc_field using 'LFA1-NAME1' T_LIFNR-NAME1.

perform bdc_field using 'LFA1-SORTL' T_LIFNR-SORTL.

perform bdc_field using 'LFA1-STRAS' T_LIFNR-STRAS.

perform bdc_field using 'LFA1-ORT01' T_LIFNR-ORT01.

perform bdc_field using 'LFA1-PSTLZ' T_LIFNR-PSTLZ.

perform bdc_field using 'LFA1-ORT02' T_LIFNR-ORT02.

perform bdc_field using 'LFA1-PFORT' T_LIFNR-PFORT.

perform bdc_field using 'LFA1-LAND1' T_LIFNR-LAND1.

perform bdc_field using 'LFA1-SPRAS' T_LIFNR-SPRAS.

perform bdc_field using 'LFA1-TELF1' T_LIFNR-TELF1.

perform bdc_field using 'LFA1-TELFX' T_LIFNR-TELFX.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR' 'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_dynpro using 'SAPMF02K' '0380'.

perform bdc_field using 'BDC_CURSOR' 'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_dynpro using 'SAPMF02K' '0210'.

perform bdc_field using 'BDC_CURSOR' 'LFB1-ZUAWA'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_field using 'LFB1-AKONT' T_LIFNR-AKONT.

perform bdc_field using 'LFB1-ZUAWA' T_LIFNR-ZUAWA.

perform bdc_dynpro using 'SAPMF02K' '0215'.

perform bdc_field using 'BDC_CURSOR' 'LFB1-ZTERM'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_field using 'LFB1-ZTERM' T_LIFNR-ZTERM.

perform bdc_dynpro using 'SAPMF02K' '0220'.

perform bdc_field using 'BDC_CURSOR' 'LFB5-MAHNA'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR' 'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_field using 'LFM1-WAERS' T_LIFNR-WAERS.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE' '=VW'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE' '=YES'.

perform bdc_transaction using 'XK01'.

ENDLOOP.

READ TABLE MESSTAB INDEX '2'.

IF MESSTAB-MSGTYP = 'E'.

T_ERROR-LIFNR = T_LIFNR-LIFNR.

concatenate 'Check' messtab-msgv1 'Values' into T_ERROR-NUM SEPARATED BY SPACE.

APPEND T_ERROR.

ENDIF.

perform close_group.

endform. " 300_BDC

&----


*& Form 250_VALIDATE_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form 250_VALIDATE_DATA .

LOOP AT T_LIFNR.

*IF T_LIFNR-LIFNR CO '0123456789 '.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = T_LIFNR-LIFNR

IMPORTING

OUTPUT = T_LIFNR-LIFNR.

*ENDIF.

MODIFY T_LIFNR.

SELECT SINGLE * FROM LFA1 WHERE LIFNR EQ T_LIFNR-LIFNR.

IF SY-SUBRC NE 0.

T_ERROR-INDEX = '9'.

T_ERROR-LIFNR = T_LIFNR-LIFNR.

CONCATENATE 'VENDOR' T_LIFNR-LIFNR ' ALREADY EXIST IN THE SAP SYSTEM' INTO T_ERROR-NUM SEPARATED BY SPACE.

APPEND T_ERROR.

DELETE T_LIFNR.

CONTINUE.

ENDIF.

ENDLOOP.

endform. " 250_VALIDATE_DATA

&----


*& Form 400_ERROR_DOWNLOAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form 400_ERROR_DOWNLOAD .

IF T_ERROR-LIFNR = ''.

T_ERROR-NUM = 'NO ERRORS FOUND'.

ELSE.

T_ERROR-INDEX = '1'.

CONCATENATE 'PROGRAM NAME : ' SY-REPID INTO T_ERROR-LIFNR SEPARATED BY SPACE.

T_ERROR-NUM = ''.

APPEND T_ERROR .

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'D:\ERR.XLS'

tables

data_tab = T_ERROR.

endform. " 400_ERROR_DOWNLOAD