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 PROGRAM

Former Member
0 Kudos

HI BOSS,

I NEED MODEL BDC PROGRAM USING CALL TRANSACTION METHOD .

MAINLY TRANSACTION CODE USING MB1C...

pls sent to me....

with regards,

sankar

3 REPLIES 3

sailaja_vadlamudi
Contributor
0 Kudos

Hi

Check this link

/community [original link is broken]

Sail

Former Member
0 Kudos

report Z14049_BDC_SECOND

no standard page heading line-size 255.

data: bdcdata like bdcdata occurs 0 with header line.

data: messtab like bdcmsgcoll occurs 0 with header line.

DATA: BEGIN OF ITAB_BDC OCCURS 0,

MBRSH LIKE RMMG1-MBRSH,

MTART LIKE RMMG1-MTART,

WERKS LIKE RMMG1-WERKS,

VKORG LIKE RMMG1-VKORG,

VTWEG LIKE RMMG1-VTWEG,

MAKTX LIKE MAKT-MAKTX,

MEINS LIKE MARA-MEINS,

MTPOS_MARA LIKE MARA-MTPOS_MARA,

END OF ITAB_BDC.

DATA:I_FILETABLE TYPE FILETABLE,

W_RC TYPE I.

PARAMETER:P_FILE(4000) TYPE C.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM F4_HELP.

*include bdcrecx1.

start-of-selection.

PERFORM UPLOAD_DATA.

LOOP AT ITAB_BDC.

CLEAR: BDCDATA, BDCDATA[].

PERFORM BDC_POPULATION.

PERFORM CALL_TRAN.

ENDLOOP.

*perform open_group.

*obligatory

&----


*& Form UPLOAD_DATA

&----


form UPLOAD_DATA .

DATA: L_FILE TYPE STRING.

L_FILE = P_FILE.

call function 'GUI_UPLOAD'

exporting

filename = L_FILE

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE = VIRUS_SCAN_PROFILE

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

  • HEADER = HEADER

tables

data_tab = ITAB_BDC

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. " UPLOAD_DATA

&----


*& Form F4_HELP

&----


form F4_HELP .

call method cl_gui_frontend_services=>file_open_dialog

  • EXPORTING

  • WINDOW_TITLE =

  • DEFAULT_EXTENSION =

  • DEFAULT_FILENAME =

  • FILE_FILTER =

  • WITH_ENCODING =

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

changing

file_table = I_FILETABLE

rc = W_RC

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5

.

if sy-subrc = 0.

READ TABLE I_FILETABLE INDEX 1 INTO P_FILE.

endif.

endform. " F4_HELP

&----


*& Form BDC_POPULATION

&----


form BDC_POPULATION .

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-MBRSH'

ITAB_BDC-MBRSH.

perform bdc_field using 'RMMG1-MTART'

ITAB_BDC-MTART.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(04)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(02)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(03)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-VKORG'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

ITAB_BDC-WERKS.

perform bdc_field using 'RMMG1-VKORG'

ITAB_BDC-VKORG.

perform bdc_field using 'RMMG1-VTWEG'

ITAB_BDC-VTWEG.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=SP02'.

perform bdc_field using 'MAKT-MAKTX'

ITAB_BDC-MAKTX.

perform bdc_field using 'BDC_CURSOR'

'MARA-MEINS'.

perform bdc_field using 'MARA-MEINS'

ITAB_BDC-MEINS.

perform bdc_field using 'MARA-MTPOS_MARA'

ITAB_BDC-MTPOS_MARA.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=SP04'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

  • perform bdc_field using 'MAKT-MAKTX'

  • 'This is New Material'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP05'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

  • perform bdc_field using 'MAKT-MAKTX'

  • 'This is New Material'.

  • perform bdc_field using 'MARA-MEINS'

  • 'JH5'.

perform bdc_field using 'MVKE-SKTOF'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

  • perform bdc_field using 'MAKT-MAKTX'

  • 'This is New Material'.

  • perform bdc_field using 'MARA-MTPOS_MARA'

  • 'NORM'.

  • perform bdc_field using 'MVKE-MTPOS'

  • 'NORM'.

  • perform bdc_transaction using 'MM01'.

  • perform close_group.

endform. " BDC_POPULATION

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

  • if fval <> nodata.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata.

  • endif.

endform.

&----


*& Form CALL_TRAN

&----


form CALL_TRAN .

DATA: W_MODE TYPE C VALUE 'A'.

CALL TRANSACTION 'MM01' USING bdcdata MODE W_MODE MESSAGES INTO messtab.

endform. " CALL_TRAN

regards

Giridhar

Former Member
0 Kudos

Dear Sankar,

Kindly go through the following code.

*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.

Regards,

Abir

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

  • Don't forget to reward points *