2007 Sep 03 1:09 PM
any body send me the sample code for bdc using table control.
2007 Sep 03 1:12 PM
Following is a sample code of handling table control in BDC.
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.
Thanks
Seshu
2007 Sep 03 1:12 PM
Following is a sample code of handling table control in BDC.
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.
Thanks
Seshu
2007 Sep 03 1:28 PM
Hi Surya..
This is a useful program for that..
BDC program for Purchase Info Records
REPORT zmm0069 NO STANDARD PAGE HEADING
MESSAGE-ID z0
LINE-SIZE 132
LINE-COUNT 65(2).
----
Internal Tables *
----
*Internal table for the purchasing info records fields.
DATA: BEGIN OF i_inforecord OCCURS 0,
matnr(18),
lifnr(10),
uom(3),
ekgrp(3),
planned_time(3),
under_tol(3),
over_tol(3),
qty(10),
price_cat(5),
inco(3),
designation(28),
netpr(13),
scale_qty1(10),
scale_pr1(13),
scale_qty2(10),
scale_pr2(13),
scale_qty3(13),
scale_pr3(10),
scale_qty4(13),
scale_pr4(10),
scale_qty5(13),
scale_pr5(10),
scale_qty6(13),
scale_pr6(10),
scale_qty7(13),
scale_pr7(10),
scale_qty8(13),
scale_pr8(10),
scale_qty9(13),
scale_pr9(10),
scale_qty10(13),
scale_pr10(10),
END OF i_inforecord.
Internal table for Old and New Vendor number
DATA : BEGIN OF i_lfb1 OCCURS 1,
lifnr(10),
altkn(10),
END OF i_lfb1.
Declare internal table for Call Transaction and BDC Session
DATA: i_bdc_table LIKE bdcdata OCCURS 0 WITH HEADER LINE.
----
Global Variables *
----
DATA: g_counter(2) TYPE n,
g_field_name(18) TYPE c,
zc_yes TYPE syftype VALUE 'X'.
----
Selection Screen *
----
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_fname1 TYPE localfile .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_rloc1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
PARAMETERS p_group(12) OBLIGATORY DEFAULT 'ZPURCHINFO'.
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN END OF BLOCK a.
**WRITE the report header
TOP-OF-PAGE.
INCLUDE zheading.
----
Start of selection *
----
START-OF-SELECTION.
Load Input file
PERFORM f_load_input_file.
Create BDC records.
PERFORM create_bdc_records .
&----
*& Form Create_BDC_records
&----
Perform the BDC for the records in the internal table
----
FORM create_bdc_records .
IF NOT i_inforecord[] IS INITIAL.
Open BDC session
PERFORM open_bdc_session.
SELECT lifnr altkn FROM lfb1 INTO TABLE i_lfb1
FOR ALL ENTRIES IN i_inforecord
WHERE altkn = i_inforecord-lifnr.
Sorting the Internal table for better performance
SORT i_lfb1 BY altkn.
LOOP AT i_inforecord.
***Mapping Old Vendor number to the new Vendor number
READ TABLE i_lfb1 WITH KEY altkn = i_inforecord-lifnr BINARY
SEARCH.
IF sy-subrc EQ 0.
i_inforecord-lifnr = i_lfb1-lifnr.
ENDIF.
CLEAR i_bdc_table[].
PERFORM insert_screen_header.
call transaction 'ME11' using i_bdc_table
mode 'A'.
CLEAR i_bdc_table.
ENDLOOP.
CLEAR i_inforecord[].
PERFORM close_bdc_session.
Release the BDC sessions created
PERFORM release_bdc.
ENDIF.
ENDFORM. " open_group
&----
*& Form bdc_dynpro_start
&----
Start the screen for the transfer of fields
----
FORM bdc_dynpro_start USING p_g_program_1
p_g_screen.
CLEAR i_bdc_table.
i_bdc_table-program = p_g_program_1.
i_bdc_table-dynpro = p_g_screen.
i_bdc_table-dynbegin = 'X'.
APPEND i_bdc_table.
ENDFORM. " bdc_dynpro_start_start
&----
*& Form bdc_insert_field
&----
Insert field *
----
FORM bdc_insert_field USING f_name f_value.
IF f_value <> space.
CLEAR i_bdc_table.
i_bdc_table-fnam = f_name.
i_bdc_table-fval = f_value.
APPEND i_bdc_table.
ENDIF.
ENDFORM. "bdc_insert_field
&----
*& Form open_bdc_session
&----
Open a BDC session
----
FORM open_bdc_session .
Open BDC session and create and update records
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
DEST = FILLER8
group = p_group
HOLDDATE = FILLER8
keep = 'X'
user = sy-uname
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 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.
ENDFORM. " create_bdc_session
&----
*& Form insert_screen_header
&----
Screen flow for the transfer of fields
----
FORM insert_screen_header .
First Screen 100
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
PERFORM bdc_insert_field USING:'BDC_CURSOR' 'EINA-LIFNR',
'BDC_OKCODE' '/00',
'EINA-LIFNR' i_inforecord-lifnr,
'EINA-MATNR' i_inforecord-matnr,
'EINE-EKORG' '1000',
'RM06I-NORMB' zc_yes.
****----
Next Screen 101
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0101'.
PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINA-MAHN1',
'BDC_OKCODE' '/00',
'EINA-MEINS' i_inforecord-uom.
****----
*Next Screen 102
PERFORM bdc_dynpro_start USING 'SAPMM06I' '0102'.
PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINE-INCO2',
'EINE-APLFZ' i_inforecord-planned_time,
'EINE-EKGRP' i_inforecord-ekgrp,
'EINE-NORBM' i_inforecord-qty.
PERFORM bdc_insert USING 'EINE-UEBTK' ' '.
PERFORM bdc_insert_field USING:'EINE-PEINH' i_inforecord-scale_qty1,
'EINE-BPRME' i_inforecord-uom,
'EINE-UNTTO' '5',
'EINE-UEBTO' '25',
'EINE-MEPRF' i_inforecord-price_cat,
'EINE-NETPR' i_inforecord-netpr,
'EINE-INCO1' i_inforecord-inco,
'EINE-INCO2' i_inforecord-designation.
Checking for Scale quantities
IF i_inforecord-scale_qty2 = space.
PERFORM bdc_insert_field USING 'BDC_OKCODE' '=BU'.
PERFORM insert_bdc_new.
ELSE.
PERFORM bdc_insert_field USING 'BDC_OKCODE' '=KO'.
****----
Next Screen 201
PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'RV13A-DATAB',
'BDC_OKCODE' '=PSTF'.
****----
Next Screen 201
PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONP-KSCHL(01)',
'BDC_OKCODE' '=PSTF',
'RV130-SELKZ(01)' zc_yes.
****----
LAST SCREEN 303
PERFORM bdc_dynpro_start USING 'SAPMV13A' '0303'.
PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONM-KBETR(03)',
'BDC_OKCODE' '=SICH'.
<b>* Counter to Loop the Item level entry
g_counter = 0.
PERFORM scale_entry USING i_inforecord-scale_qty2
i_inforecord-scale_pr2.
PERFORM scale_entry USING i_inforecord-scale_qty3
i_inforecord-scale_pr3.
PERFORM scale_entry USING i_inforecord-scale_qty4
i_inforecord-scale_pr4.
PERFORM scale_entry USING i_inforecord-scale_qty5
i_inforecord-scale_pr5.
PERFORM scale_entry USING i_inforecord-scale_qty6
i_inforecord-scale_pr6.
PERFORM scale_entry USING i_inforecord-scale_qty7
i_inforecord-scale_pr7.
PERFORM scale_entry USING i_inforecord-scale_qty8
i_inforecord-scale_pr8.
PERFORM scale_entry USING i_inforecord-scale_qty9
i_inforecord-scale_pr9.
PERFORM scale_entry USING i_inforecord-scale_qty10
i_inforecord-scale_pr10.
PERFORM insert_bdc_new.
</b>
ENDIF.
ENDFORM. " insert_screen_header
&----
*& Form insert_bdc
&----
Insert BDC
----
FORM insert_bdc_new .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'ME11'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = i_bdc_table
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR i_bdc_table[].
ENDFORM. " insert_bdc
&----
*& Form close_bdc_session
&----
Close the BDC session
----
FORM close_bdc_session .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
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. " close_bdc_session
&----
*& Form f_load_input_file
&----
Upload the file
----
FORM f_load_input_file.
Check always Local file for upload
IF p_rloc1 = zc_yes.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_fname1
filetype = 'DAT'
TABLES
data_tab = i_inforecord
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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
STOP.
ENDIF.
ENDIF.
*
ENDFORM. " f_load_input_file
&----
*& Form release_bdc
&----
Release the session
----
FORM release_bdc.
SUBMIT rsbdcsub WITH mappe EQ p_group
WITH von EQ sy-datum
WITH bis EQ sy-datum
WITH fehler EQ '.'
EXPORTING LIST TO MEMORY
AND RETURN.
ENDFORM. " release_bdc
&----
*& Form scale_entry
&----
Populate the Scale quantities
----
-->P_SCALE_QTY
-->P_SCALE_PRICE
----
FORM scale_entry USING p_scale_qty
p_scale_price.
Increment the Counter
g_counter = g_counter + 1.
IF p_scale_qty <> space.
CONCATENATE 'KONM-KSTBM(' g_counter ')' INTO g_field_name.
PERFORM bdc_insert_field USING g_field_name p_scale_qty.
CONCATENATE 'KONM-KBETR(' g_counter ')' INTO g_field_name.
PERFORM bdc_insert_field USING g_field_name p_scale_price.
ENDIF.
ENDFORM.
&----
*& Form bdc_insert
&----
To uncheck the Unlimited (UEBTK)
----
FORM bdc_insert USING f_name f_value.
CLEAR i_bdc_table.
i_bdc_table-fnam = f_name.
i_bdc_table-fval = f_value.
APPEND i_bdc_table.
ENDFORM. " bdc_insert
<b>reward if Helpful</b>
2007 Sep 03 3:09 PM
hi surya, i suposed to be this code is very useful to you. this bdc program for the transaction <b>[ME01]</b> (source list information).Please make some changes i used with header internal table you change that to with out header internal table.
************************************************************************
*PARAMETERS Declarations
************************************************************************
PARAMETERS: file1 LIKE rlgrap-filename.
************************************************************************
*Internal Table Declarations
************************************************************************
DATA: BEGIN OF itab OCCURS 0,
matnr(18) TYPE c, "MaterialNumber
werks(4) TYPE c, "Plant
vdatu(10) TYPE c, "Valid From Date
bdatu(10) TYPE c, "Valid To Date
lifnr(10) TYPE c, "Vendor Number
ekorg(4) TYPE c, "Purchasing Organization
feskz TYPE c, "Fixed
autet TYPE c, "MRP Indicator
END OF itab.
DATA: bdcdata LIKE TABLE OF bdcdata WITH HEADER LINE.
************************************************************************
*VARIABLES Declarations
************************************************************************
DATA: wa1 LIKE LINE OF itab. "Workarea for ITAB
DATA: n TYPE i, "Check
count TYPE i.
DATA: cnt(2), "Counter
wa(15). "Workarea to hold concatenatedvalue
DATA v_msg(100).
DATA: flag.
DATA: file TYPE string.
************************************************************************
*Initialization event
************************************************************************
INITIALIZATION.
************************************************************************
*At-selection-screen event
************************************************************************
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file1.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = file1.
***********************************************************************
*START-OF-SELECTION EVENT
***********************************************************************
START-OF-SELECTION.
MOVE file1 TO file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab
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.
*To populate BDCDATA and start data transfer
LOOP AT itab .
* To validate Plant range
IF itab-werks = '1000' OR itab-werks = '2000'
OR itab-werks = '1008'.
AT NEW werks.
CLEAR: n.
cnt = 1.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EORD-MATNR'
itab-matnr.
PERFORM bdc_field USING 'EORD-WERKS'
itab-werks.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING 'BDC_CURSOR'
wa.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
ENDAT.
IF n = 12.
READ TABLE bdcdata WITH KEY fval = '=BU'.
bdcdata-fval = '=NS'.
MODIFY bdcdata INDEX sy-tabix TRANSPORTING fval.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-VDATU(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
cnt = 2.
n = 2.
ENDIF.
CONCATENATE 'EORD-VDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-vdatu.
CONCATENATE 'EORD-BDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-bdatu.
CONCATENATE 'EORD-LIFNR(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-lifnr.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-ekorg.
CONCATENATE 'RM06W-FESKZ(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-feskz.
CONCATENATE 'EORD-AUTET(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-autet.
IF n <> 12.
n = cnt.
ENDIF.
cnt = cnt + 1.
AT END OF werks.
CALL TRANSACTION 'ME01' USING bdcdata
UPDATE 'S'
MODE 'A'.
CLEAR:bdcdata,bdcdata[].
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = 'EN'
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = v_msg.
WRITE:/ v_msg.
CLEAR: bdcdata,bdcdata[],flag.
ENDAT.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* 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 values
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
IF NOT fval IS INITIAL.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
CLEAR wa.
ENDFORM.
<b>if helpful reward some points.</b>
2007 Sep 03 4:08 PM
the programs are useful but here no body used ctu parameters i need some information about ctu parameters and why we use ctu parameters.
2007 Sep 03 4:20 PM
Check the below code :
data: f_option type ctu_params,
f_option-updmode = 'S'.
f_option-defsize = 'X'.
f_option-dismode = 'N'.
call transaction 'VA01' using bdcdata options from f_option messages into bdcerror.
Normally we use above statement if screen is small from system to system then we use screen resolution.
Example :
suppose you are uploading the data into one transaction,there you can see table control total lines per each page 13 lines ,if you upload from other system ,then it may vary,if you use above command then system will keep exact table controls lines for all system.
Hope you got it.
Thanks
Seshu