Application Development and Automation 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: 
Read only

BDC

Former Member
0 Likes
533

hi frnds,

i want to do BDC for creation of dependencies (TCODE-CU01). can anyone help me out of this?

6 REPLIES 6
Read only

Former Member
0 Likes
496

Hi,

Step1:

Create a BDC Recording using transaction SHDB.

Step2:

Create a ZProgram from the Recording (from tcode SHDB).

Step3:

Upload the legacy data.. Use FM GUI_UPLOAD.

Step4:

Loop at the internal table (with legacy data)

Put the BDC code inside the loop and replace the values which you gave while recording with the internal table fields respectively.

Step5:

Activate the program and execute.

Regards,

K.Tharani.

Read only

Former Member
0 Likes
496

hi,

Simple step by step procedure,

BDC RECORDING METHOD:

________________________

This is a predefined tool to create BDC code and screens for data migration. BDC Recording method allows the user to record the keystrokes done during data migration. This method can use only existing screens, i.e. predefined screens.

MM01 - Create Material

XD01 - Create Customer

XK01 - Create Vendor

VA01 - Create Sales Order

SHDB is the Transaction code to call Recording Method.

Navigations to use Recording Method:

-


SHDB -> Opens an interface -> Click on New Recordings pushbutton from appn. toolbar -> Specify Recording Name -> Specify Tcode (MM01) -> Click on Continue -> Opens MM01 Screen -> Specify Sample Data -> Click on Select View pushbutton from appn. toolbar -> Opens an interface -> Select First view (Basic Data 1) -> Click on Continue -> Opens another interface -> Specify short description for the material -> Specify units of measurement -> Save -> Opens an interface with defined field and their values -> Save -> Come back -> Select Recording Object -> Click on Program pushbutton from appn. toolbar to autogenerate the BDC source code -> Opens an interface -> Specify Program Name -> Select Transfer From Recording radiobutton -> Click on Source Code pushbutton -> Opens SE38 Editor with autogenerated code -> Specify following code after include statement:

include bdcrecx1.

DATA : BEGIN OF ITAB OCCURS 0,

STR(255),

END OF ITAB.

DATA ITAB1 LIKE MARA OCCURS 0 WITH HEADER LINE.

Specify following code after start-of-selection statement:

start-of-selection.

CALL FUNCTION 'UPLOAD'

EXPORTING

FILENAME = 'C:\COUP.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = ITAB.

LOOP AT ITAB.

SPLIT ITAB-STR AT ',' INTO ITAB1-MATNR ITAB1-MBRSH ITAB1-MTART

ITAB1-MEINS.

APPEND ITAB1.

ENDLOOP.

Specify Loop-Endloop statement for the bdc-dynpro, bdc-field and bdc_transaction statements as follows:

perform open_group.

LOOP AT ITAB1.

.

.

.

ENDLOOP

perform close_group.

-> Save -> Activate -> Execute -> Choose Call Transaction or Session method to process the datas.

The advantage of Recording Method is finally after executing the program, we can choose either Session method or Call Transaction method to upload the datas using predefind Tcode (MM01, MK01, VA01, XD01, XK01).

Hope this helps u,

Regards,

Arunsri

Read only

Former Member
0 Likes
496

Hi Nitin,

Follow these Steps for creation of dependencies.I also attach sample code for creation of material master ok.Based on that u have to build ur logic ok.

Procedure:

1.Goto SHDB Transaction code and enter CU01 code and fill ur data.

2.Finally u have to save ur data.

3.Select the program button which is present in the application toolbar and that will take u se38 transaction code and follow the below logic.

i will attach FLAT FILE along with code at end check it once ok..

REPORT:

-


REPORT

-


&----


*& Report YBDC_UPLOAD_MM01_XLS *

*& *

&----


*& DEVELOPER : KIRAN KUMAR.G *

*& PURPOSE : MAKE CHANGES TO DOWNLOADED FILE AND UPLOAD THE FILE *

*& CREATION DT: 3/12/2007 *

*& REQUEST : ERPK900035 *

&----


REPORT YBDC_UPLOAD_MM01_XLS.

----


  • Tables

----


TABLES : mara. "General Material Data

----


  • Global BDCDATA Structure and MESSAGE Structure

----


DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

gt_msgtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

----


  • Global Variables

----


DATA: gv_infile TYPE string,

gv_msg TYPE string,

gv_update VALUE 'A'.

----


  • Internal Table

*----


DATA: BEGIN OF gt_data OCCURS 0,

matnr(20), "Material Number

mbrsh(20), "Account Group

mtart(20), "Material Type

meins(20), "Base Unit Of Measure

maktx(20), "Material Description

END OF gt_data.

----


  • Selection-screen

----


SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE rlgrap-filename,

p_mode.

SELECTION-SCREEN : END OF BLOCK b1.

----


  • Select the File

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM fetch_file.

START-OF-SELECTION.

----


  • Fetch Data From XLS File

----


PERFORM fetch_data.

----


  • Fetch Data From XLS File

----


PERFORM delete_headerinfo.

----


  • Fetch Data From XLS File

----


PERFORM place_data.

&----


*& Form fetch_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_file .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

IMPORTING

file_name = p_file.

gv_infile = p_file.

ENDFORM. " fetch_file

&----


*& Form fetch_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_data .

refresh : gt_data. "Clear Body Of the Internal Table

clear : gt_data. "Clear Header Line

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_infile

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = gt_data

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

.

IF sy-subrc <> 0.

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

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

endif.

ENDFORM. " fetch_data

&----


*& Form place_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM place_data .

LOOP AT gt_data.

PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMMG1-MATNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=AUSW'.

PERFORM bdc_field USING 'RMMG1-MATNR'

gt_data-matnr.

PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.

PERFORM bdc_field USING 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'

'X'.

PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field USING 'BDC_CURSOR'

'MAKT-MAKTX'.

PERFORM bdc_field USING 'MAKT-MAKTX'

gt_data-maktx.

PERFORM bdc_field USING 'MARA-MTPOS_MARA'

'NORM'.

CALL TRANSACTION 'MM02' USING gt_bdcdata MODE p_mode

UPDATE gv_update

MESSAGES INTO gt_msgtab.

*For Error Messages Handling.

LOOP AT gt_msgtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = sy-msgid

lang = sy-langu

no = sy-msgno

v1 = sy-msgv1

v2 = sy-msgv2

v3 = sy-msgv3

v4 = sy-msgv4

IMPORTING

msg = gv_msg

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

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

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

ENDIF.

IF sy-tabix = 1.

WRITE: / 'Process Log' COLOR 3.

ENDIF.

WRITE:/ gv_msg.

ENDLOOP.

REFRESH gt_msgtab.

REFRESH gt_bdcdata.

ENDLOOP.

ENDFORM. " place_data

----


  • Start new screen *

----


FORM bdc_dynpro USING program dynpro.

CLEAR gt_bdcdata.

gt_bdcdata-program = program.

gt_bdcdata-dynpro = dynpro.

gt_bdcdata-dynbegin = 'X'.

APPEND gt_bdcdata.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM bdc_field USING fnam fval.

CLEAR gt_bdcdata.

gt_bdcdata-fnam = fnam.

gt_bdcdata-fval = fval.

APPEND gt_bdcdata.

ENDFORM. "BDC_FIELD

&----


*& Form delete_headerinfo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM delete_headerinfo .

DELETE gt_data INDEX 1.

ENDFORM. " delete_headerinfo

----


  • FLAT FILE

----


*MATERIAL NUMBER INDUSTRY SECTOR MATERIAL TYPE BASE UNIT OF

*MEASURE MATERIAL DESCRIPTION

*806 M FERT CM IRON

*807 M HALB KG STEEL

*808 M HAWA KG IRON

----


Reward Points if helpful

Kiran Kumar.G.A

Edited by: KIRAN KUMAR on Feb 29, 2008 5:30 AM

Read only

mahaboob_pathan
Contributor
0 Likes
496

hi,

first do BDC Recording using transaction SHDB.

then

Create a ZProgram from the se38.

then

copy the perform part of recorded program.

Upload the file which ever by using FM: GUI_UPLOAD.

Loop at the internal table.

Put the BDC code inside the loop and replace the values which you gave while recording with the internal table fields respectively.

Activate the program and execute.

Read only

Former Member
0 Likes
496

Hi,

http://www.sapdevelopment.co.uk/bdc/bdchome.htm

http://www.sapbrainsonline.com/

Hope the above links would help.

Regards,

Lakshmanan

Read only

Former Member
0 Likes
496

BDC