Skip to Content
author's profile photo Former Member
Former Member

BDC CALL TRANSACTION

Hi experts,

can one post the example program for bdc session and call transaction method.

Thanks in advance,

Kishore

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 02:46 PM

    check these below links

    sample code for call transaction method

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

    chk this for BDC recording with screen shots

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

    BDC

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

    Table control in BDC

    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

    best typical example is BDC for MM01

    check the below links for the same

    bdc for MM01.

    mm01

    bdc-mm01

    ~~Guduri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 02:48 PM

    Call Transaction :

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

    • Report : ZMPPC014

    • Type : Data upload

    • Author : Seshu Maramreddy

    • Date : 05/23/2005

    • Transport : DV3K919897

    • Transaction: ??

    • Description: This ABAP/4 Program to Update Rate Routing for

    • SMI plants using CA22 Transaction.It accepts

    • tab-delimited spreadsheet input and creates BDC sessions.

    *

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

    report zmppc014 no standard page heading

    line-size 120

    line-count 55

    message-id zz.

    • Constants

    constants : c_x type c value 'X'," Dynbegin

    c_tcode type tstc-tcode value 'CA22'," Transaction Code

    c_r(1) type c value 'R'," Task List type

    c_O(1) type c value 'O',

    c_fh(2) type c value 'FH'.

    • Variables

    data : v_lines_in_xcel like sy-tabix,

    v_matnr(18) type c, " Material Number

    v_PLNNR like mapl-plnnr," Group

    V_DATE(8) type c," System date

    v_date1(4) type c,

    v_date2(2) type c,

    v_date3(2) type c,

    V_COUNT TYPE I." Count

    • Internal table

    data : begin of i_error occurs 0,

    matnr like mara-matnr,

    werks like marc-werks,

    vornr like plpo-vornr,

    plnnr like plpo-plnnr,

    text(90) type c,

    end of i_error.

    • Internal table for BDCDATA Structure

    data : begin of itab_bdc_tab occurs 0.

    include structure bdcdata.

    data : end of itab_bdc_tab.

    • Internal table for File

    data : begin of t_file occurs 0,

    matnr(18) type c, " Material Number

    werks(4) type c, " Plant

    plnal(2) type n, " Routing Group Counter

    vornr(4) type c, " Operation#

    equnr(18) type c, " Equipment/PRT #

    steuf(4) type c, " Control Key

    end of t_file.

    • Selection-screen

    *selection-screen: skip 3.

    selection-screen: begin of block id1 with frame.

    *

    parameters: p_name like rlgrap-filename

    default 'C:\My Documents\InputFile.txt'

    obligatory.

    selection-screen: end of block id1.

    at selection-screen on value-request for p_name.

    • F4 value for Input file

    perform filename_get.

    • main processing

    start-of-selection.

    • To get the data from file to Internal table

    perform getdata_fromfile.

    loop at t_file.

    • fill in bdc-data for prod.version maintenance screens

    perform bdc_build_script.

    • insert the bdc script as a BDC transaction

    perform bdc_submit_transaction.

    endloop.

    top-of-page.

    call function 'Z_HEADER'

    • EXPORTING

    • FLEX_TEXT1 =

    • FLEX_TEXT2 =

    • FLEX_TEXT3 =

    .

    skip 1.

    write:/2 'Material #',24 'Plant',32 'Group',44 'Op #',

    53 'Status Message'.

    skip 1.

    &----


    *& Form filename_get

    &----


    • F4 Value for Input File parameter

    ----


    FORM filename_get.

    CALL FUNCTION 'WS_FILENAME_GET'

    EXPORTING

    DEF_PATH = 'C:\Temp\ '

    MASK = ',.,..'

    MODE = 'O'

    TITLE = 'Select File '(007)

    IMPORTING

    FILENAME = p_name

    EXCEPTIONS

    INV_WINSYS = 1

    NO_BATCH = 2

    SELECTION_CANCEL = 3

    SELECTION_ERROR = 4

    OTHERS = 5.

    ENDFORM. " filename_get

    &----


    *& Form getdata_fromfile

    &----


    • Uploading the data from file to Internal table

    ----


    FORM getdata_fromfile.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = p_name

    FILETYPE = 'DAT'

    TABLES

    DATA_TAB = t_file

    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 eq 0.

    sort t_file by matnr werks plnal vornr .

    clear v_lines_in_xcel.

    describe table t_file lines v_lines_in_xcel.

    if v_lines_in_xcel is initial.

    write: / 'No data in input file'.

    stop.

    endif.

    else.

    write:/ 'Error reading input file'.

    stop.

    endif.

    ENDFORM. " getdata_fromfile

    &----


    *& Form bdc_build_script

    &----


    • BDC Script

    ----


    FORM bdc_build_script.

    • Get the material number from tables ZMSMI_FERR_RAW,

    • ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW

    perform get_matnr.

    • Screen 1010.

    perform bdc_screen using 'SAPLCPDI' '1010'.

    perform bdc_field using 'BDC_OKCODE' '=VOUE'.

    perform bdc_field using 'RC27M-MATNR' SPACE .

    perform bdc_field using 'RC27M-WERKS' SPACE.

    perform bdc_field using 'RC271-VBELN' SPACE.

    perform bdc_field using 'RC271-POSNR' SPACE.

    perform bdc_field using 'RC271-PSPNR' SPACE.

    Clear v_plnnr.

    • Get the Group from MAPL Table

    select single plnnr from mapl

    into v_plnnr

    where matnr = t_file-matnr

    and werks = t_file-werks

    and loekz = space

    and plnty = c_r

    and plnal = t_file-plnal.

    perform bdc_field using 'RC271-PLNNR' v_plnnr.

    • Current date

    • MOVE SY-DATUM TO V_DATE.

    perform get_date.

    perform bdc_field using 'RC271-STTAG' V_DATE.

    perform bdc_field using 'RC271-PLNAL' t_file-plnal.

    • Screen 5400

    perform bdc_screen using 'SAPLCPDI' '5400'.

    perform bdc_field using 'BDC_OKCODE' '=OSEA'.

    • Screen 1010

    perform bdc_screen using 'SAPLCP02' '1010'.

    perform bdc_field using 'BDC_OKCODE' '=ENT1'.

    perform bdc_field using 'RC27H-VORNR' T_FILE-VORNR.

    • Screen 5400

    perform bdc_screen using 'SAPLCPDI' '5400'.

    perform bdc_field using 'BDC_OKCODE' '=FHUE'.

    perform bdc_field using 'RC27X-FLG_SEL(01)' C_X.

    • Get the no of records from PLAS,PLPO and PLFH Tables

    perform get_count.

    • Screen 0200

    IF V_COUNT = 0.

    perform bdc_screen using 'SAPLCFDI' '0200'.

    ELSEif v_count > 0.

    • Screen 0100

    perform bdc_screen using 'SAPLCFDI' '0100'.

    ENDIF.

    perform bdc_field using 'BDC_OKCODE' '/EFIE'.

    • Screen 0230

    perform bdc_screen using 'SAPLCFDI' '0230'.

    perform bdc_field using 'BDC_OKCODE' '=BACK'.

    perform bdc_field using 'PLFHD-EQUNR' T_FILE-EQUNR.

    perform bdc_field using 'PLFHD-STEUF' T_FILE-STEUF.

    • Screen 0100

    perform bdc_screen using 'SAPLCFDI' '0100'.

    perform bdc_field using 'BDC_OKCODE' '=BU'.

    ENDFORM. " bdc_build_script

    &----


    *& Form bdc_submit_transaction

    &----


    • BDC_INSERT Function Module

    ----


    FORM bdc_submit_transaction.

    call transaction c_tcode using itab_bdc_tab

    mode 'N' update 'S'.

    refresh itab_bdc_tab.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = SY-MSGID

    LANG = '-E'

    NO = SY-MSGNO

    V1 = SY-MSGV1

    V2 = SY-MSGV2

    V3 = SY-MSGV3

    V4 = SY-MSGV4

    IMPORTING

    MSG = i_error-text

    EXCEPTIONS

    NOT_FOUND = 1

    OTHERS = 2

    .

    i_error-matnr = t_file-matnr.

    i_error-werks = t_file-werks.

    i_error-plnnr = v_plnnr.

    i_error-vornr = t_file-vornr.

    append i_error.

    clear i_error.

    clear t_file.

    ENDFORM. " bdc_submit_transaction

    &----


    *& Form bdc_screen

    &----


    • BDC Script for Screen fields

    ----


    • -->P_PROG Program name

    • -->P_SCRN Screen Number

    ----


    FORM bdc_screen USING p_prog

    p_scrn.

    clear itab_bdc_tab.

    itab_bdc_tab-program = p_prog.

    itab_bdc_tab-dynpro = p_scrn.

    itab_bdc_tab-dynbegin = c_x.

    append itab_bdc_tab.

    ENDFORM. " bdc_screen

    &----


    *& Form bdc_field

    &----


    • BDC Script for Screen fileds

    ----


    • -->P_NAM Field name

    • -->P_VAL Field value

    ----


    FORM bdc_field USING p_nam

    p_val.

    clear itab_bdc_tab.

    itab_bdc_tab-fnam = p_nam.

    itab_bdc_tab-fval = p_val.

    append itab_bdc_tab.

    ENDFORM. " bdc_field

    &----


    *& Form get_matnr

    &----


    • Get the material number from tables ZMSMI_FERR_RAW,

    • ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW

    ----


    FORM get_matnr.

    clear v_matnr.

    case t_file-werks.

    when '0101'.

    select single cmatnr from zmsmi_simp_raw

    into v_matnr where matnr = t_file-matnr.

    if not v_matnr is initial.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    when '0103'.

    select single cmatnr from zmsmi_ferr_raw

    into v_matnr where matnr = t_file-matnr.

    if not v_matnr is initial.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    when '0102' or '0110' or '0111' or '0112' or '0113'

    or '0114' or '0115' or '0116' or '0117'.

    select single cmatnr from zmsmi_snap_raw

    into v_matnr where matnr = t_file-matnr.

    if not v_matnr is initial.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    endcase.

    ENDFORM. " get_matnr

    &----


    *& Form get_date

    &----


    • Converted date as per CA22 Transaction

    ----


    FORM get_date.

    clear : v_date,

    v_date1,

    v_date2,

    v_date3.

    v_date1 = sy-datum+0(4).

    v_date2 = sy-datum+4(2).

    v_date3 = sy-datum+6(2).

    concatenate v_date2 v_date3 v_date1 into v_date.

    ENDFORM. " get_date

    &----


    *& Form get_count

    &----


    • Get the no of records from PLAS,PLPO and PLFH Tables

    ----


    FORM get_count.

    clear v_count.

    select count(*) into v_count

    from plas as a inner join plpo as b on aplnty = bplnty

    and aplnnr = bplnnr

    and aplnkn = bplnkn

    inner join plfh as c on cplnty = aplnty

    and cplnnr = aplnnr

    and cplnal = aplnal

    and cplnfl = aplnfl

    and cplnkn = bplnkn

    where a~plnty = c_r

    and a~plnnr = v_plnnr

    and a~plnal = t_file-plnal

    and c~objct = c_O

    and a~loekz = space

    and b~vornr = t_file-vornr

    and c~objty = c_fh

    and c~loekz = space.

    ENDFORM. " get_count

    end-of-selection.

    • Displaying Error Log

    loop at i_error.

    write:/2 i_error-matnr,24 i_error-werks,32 i_error-plnnr,

    44 i_error-vornr,50 '-', 53 i_error-text.

    endloop.

    Session :

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

    • Report : ZMPPC015

    • Type : Data upload

    • Author : Seshu Maramreddy

    • Date : 05/26/2005

    • Transport : DV3K920025

    • Transaction: ??

    • Description: This ABAP/4 Program to Create Planned Independent

    • Requirement for SMI plants using MD61 Transaction.

    • It accepts tab-delimited spreadsheet input and

    • creates BDC sessions.

    *

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

    report zmppc015 no standard page heading

    line-size 120

    line-count 55

    message-id zz.

    • Constants

    constants : c_x type c value 'X'," Dynbegin

    c_tcode type tstc-tcode value 'MD61'." Transaction Code

    • Variables

    data : v_lines_in_xcel like sy-tabix,

    l_tabix like sy-tabix,

    v_trans_in_ssn type i,

    v_ssnnr(4) type n," Counter

    v_ssnname like apqi-groupid,

    v_matnr(18) type c. " Material Number

    • Internal Tables

    • Internal table for file

    data : begin of t_file occurs 0,

    matnr(18) type c, " Material Number

    berid(10) type c, " MRP Area

    PLNMG01(17) type n, " Forecast Month -01

    PLNMG02(17) type n, " Forecast Month -02

    PLNMG03(17) type n, " Forecast Month -03

    PLNMG04(17) type n, " Forecast Month -04

    PLNMG05(17) type n, " Forecast Month -05

    PLNMG06(17) type n, " Forecast Month -06

    PLNMG07(17) type n, " Forecast Month -07

    PLNMG08(17) type n, " Forecast Month -08

    PLNMG09(17) type n, " Forecast Month -09

    PLNMG10(17) type n, " Forecast Month -10

    PLNMG11(17) type n, " Forecast Month -11

    PLNMG12(17) type n, " Forecast Month -12

    WERKS(4) TYPE C, " Plant

    end of t_file.

    • Internal table for BDCDATA Structure

    data : begin of itab_bdc_tab occurs 0.

    include structure bdcdata.

    data : end of itab_bdc_tab.

    • Selection-screen

    selection-screen: skip 3.

    selection-screen: begin of block id1 with frame.

    *

    parameters: p_name like rlgrap-filename

    default 'C:\My Documents\InputFile.txt'

    obligatory,

    • bdc session name prefix

    p_bdcpfx(6) default 'ZPIRCT'

    obligatory,

    • number for transction per BDC session

    p_trnssn type i

    default 2000 obligatory,

    • retain the BDC session after successfull execution

    p_keep like apqi-qerase

    default c_x,

    • user who will be executing BDC session

    p_uname like apqi-userid

    default sy-uname

    obligatory.

    selection-screen : skip 1.

    • Requirement type

    parameters : p_bedae like t459u-bedae,

    • From Date

    p_date like sy-datum default sy-datum obligatory.

    selection-screen: end of block id1.

    at selection-screen on value-request for p_name.

    • F4 value for Input file

    perform filename_get.

    • main processing

    start-of-selection.

    • To get the data from file to Internal table

    perform getdata_fromfile.

    loop at t_file.

    • hang on to xcel line num

    l_tabix = sy-tabix.

    • if num-of-trnas-in-session = 0, create new BDC session

    if v_trans_in_ssn is initial.

    perform bdc_session_open.

    endif.

    • begin new bdc script for rtg create trans

    • fill in bdc-data for prod.version maintenance screens

    perform bdc_build_script.

    • insert the bdc script as a BDC transaction

    perform bdc_submit_transaction.

    • keep track of how many BDC transactions were inserted in the BDC

    • session

    add 1 to v_trans_in_ssn.

    • if the user-specified num of trans in BDC session is reached OR

    • if end of input file is reached, close the BDC session

    if v_trans_in_ssn = p_trnssn or

    l_tabix = v_lines_in_xcel.

    perform bdc_session_close.

    clear v_trans_in_ssn.

    endif.

    clear t_file.

    endloop.

    top-of-page.

    call function 'Z_HEADER'

    • EXPORTING

    • FLEX_TEXT1 =

    • FLEX_TEXT2 =

    • FLEX_TEXT3 =

    .

    &----


    *& Form filename_get

    &----


    • F4 Value for input file

    ----


    FORM filename_get.

    CALL FUNCTION 'WS_FILENAME_GET'

    EXPORTING

    DEF_PATH = 'C:\Temp\ '

    MASK = ',.,..'

    MODE = 'O'

    TITLE = 'Select File '(007)

    IMPORTING

    FILENAME = p_name

    EXCEPTIONS

    INV_WINSYS = 1

    NO_BATCH = 2

    SELECTION_CANCEL = 3

    SELECTION_ERROR = 4

    OTHERS = 5.

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

    &----


    *& Form getdata_fromfile

    &----


    • Upload the data from file to Internal table

    ----


    FORM getdata_fromfile.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = p_name

    FILETYPE = 'DAT'

    TABLES

    DATA_TAB = t_file

    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 eq 0.

    sort t_file by matnr .

    delete t_file where matnr = ''.

    clear v_lines_in_xcel.

    describe table t_file lines v_lines_in_xcel.

    if v_lines_in_xcel is initial.

    write: / 'No data in input file'.

    stop.

    endif.

    else.

    write:/ 'Error reading input file'.

    stop.

    endif.

    ENDFORM. " getdata_fromfile

    &----


    *& Form bdc_session_open

    &----


    • BDC_OPEN_GROUP

    ----


    FORM bdc_session_open.

    • create bdc session name = prefix-from-selectn-screen + nnnn

    add 1 to v_ssnnr.

    concatenate p_bdcpfx v_ssnnr into v_ssnname.

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    CLIENT = SY-MANDT

    GROUP = v_ssnname

    KEEP = p_keep

    USER = p_uname

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

    &----


    *& Form bdc_build_script

    &----


    • BDC Script

    ----


    FORM bdc_build_script.

    • Local Variables

    DATA : l_frdat(8) type c, " From Date

    l_todat(8) type c, " To Date

    l_frdat1(4) type c, " Year

    l_frdat2(2) type c, " Month

    l_frdat3(2) type c, " Day

    l_tdate like sy-datum, " Subtract date(1)

    l_todat1(4) type c, " Year

    l_todat2(2) type c, " Month

    l_todat3(3) type c. " Day

    • Get the material number from tables ZMSMI_FERR_RAW,

    • ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW

    perform get_matnr.

    • Screen 0100.

    perform bdc_screen using 'SAPMM60X' '0100'.

    perform bdc_field using 'BDC_OKCODE' '/EBDPT'.

    perform bdc_field using 'AM60X-MATAW' 'X'.

    perform bdc_field using 'AM60X-MATNR' T_FILE-MATNR.

    perform bdc_field using 'AM60X-PRGRP' SPACE.

    perform bdc_field using 'AM60X-PBDNR' SPACE.

    perform bdc_field using 'RM60X-BERID' T_FILE-BERID.

    perform bdc_field using 'AM60X-WERKS' SPACE.

    perform bdc_field using 'RM60X-VERSB' '00'.

    • Converted the date as per MD61 Transaction.

    • From date

    l_frdat1 = p_date+0(4).

    l_frdat2 = p_date+4(2).

    l_frdat3 = p_date+6(2).

    concatenate l_frdat2 l_frdat3 l_frdat1 into l_frdat.

    • To Date

    l_tdate = p_date - 1.

    l_todat1 = l_tdate+0(4) + 1.

    l_todat2 = l_tdate+4(2).

    l_todat3 = l_tdate+6(2).

    concatenate l_todat2 l_todat3 l_todat1 into l_todat.

    perform bdc_field using 'RM60X-DATVE' l_frdat.

    perform bdc_field using 'RM60X-DATBE' l_todat.

    perform bdc_field using 'RM60X-ENTLU' 'M'.

    • Screen 0127

    perform bdc_screen using 'SAPMM60X' '0127'.

    perform bdc_field using 'BDC_OKCODE' '=WEIT'.

    if p_bedae is initial.

    perform bdc_field using 'T459U-BEDAE' space.

    else.

    perform bdc_field using 'T459U-BEDAE' P_BEDAE.

    endif.

    • Screen 0100.

    perform bdc_screen using 'SAPMM60X' '0100'.

    perform bdc_field using 'BDC_OKCODE' '/00'.

    perform bdc_field using 'AM60X-MATAW' 'X'.

    perform bdc_field using 'AM60X-MATNR' T_FILE-MATNR.

    perform bdc_field using 'AM60X-PRGRP' SPACE.

    perform bdc_field using 'AM60X-PBDNR' SPACE.

    perform bdc_field using 'RM60X-BERID' T_FILE-BERID.

    perform bdc_field using 'AM60X-WERKS' SPACE.

    perform bdc_field using 'RM60X-VERSB' '00'.

    perform bdc_field using 'RM60X-DATVE' l_frdat.

    perform bdc_field using 'RM60X-DATBE' l_todat.

    perform bdc_field using 'RM60X-ENTLU' 'M'.

    • Screen 0200

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG01.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG02.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG03.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG04.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG05.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG06.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG07.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG08.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG09.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG10.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=S+'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG11.

    perform bdc_screen using 'SAPLM60E' '0200'.

    perform bdc_field using 'BDC_OKCODE' '=SICH'.

    perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG12.

    ENDFORM. " bdc_build_script

    &----


    *& Form get_matnr

    &----


    • Get the material number from tables ZMSMI_FERR_RAW,

    • ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW

    ----


    FORM get_matnr.

    clear v_matnr.

    case t_file-werks.

    when '0101'.

    select single cmatnr from zmsmi_simp_raw

    into v_matnr where matnr = t_file-matnr.

    if sy-subrc eq 0.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    when '0103'.

    select single cmatnr from zmsmi_ferr_raw

    into v_matnr where matnr = t_file-matnr.

    if sy-subrc eq 0.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    when '0102' or '0110' or '0111' or '0112' or '0113'

    or '0114' or '0115' or '0116' or '0117'.

    select single cmatnr from zmsmi_snap_raw

    into v_matnr where matnr = t_file-matnr.

    if sy-subrc eq 0.

    clear t_file-matnr.

    t_file-matnr = v_matnr.

    endif.

    endcase.

    ENDFORM. " get_matnr

    &----


    *& Form bdc_screen

    &----


    • BDC Script for Screen fields

    ----


    • -->P_PROG Program name

    • -->P_SCRN Screen Number

    ----


    FORM bdc_screen USING p_prog

    p_scrn.

    clear itab_bdc_tab.

    itab_bdc_tab-program = p_prog.

    itab_bdc_tab-dynpro = p_scrn.

    itab_bdc_tab-dynbegin = c_x.

    append itab_bdc_tab.

    ENDFORM. " bdc_screen

    &----


    *& Form bdc_field

    &----


    • BDC Script for Screen fileds

    ----


    • -->P_NAM Field name

    • -->P_VAL Field value

    ----


    FORM bdc_field USING p_nam

    p_val.

    clear itab_bdc_tab.

    itab_bdc_tab-fnam = p_nam.

    itab_bdc_tab-fval = p_val.

    append itab_bdc_tab.

    ENDFORM. " bdc_screen

    &----


    *& Form bdc_submit_transaction

    &----


    • BDC_INSERT Function Module

    ----


    FORM bdc_submit_transaction.

    • Load BDC script as a trqansction in BDC session

    call function 'BDC_INSERT'

    EXPORTING

    tcode = c_tcode

    TABLES

    dynprotab = itab_bdc_tab

    EXCEPTIONS

    internal_error = 01

    not_open = 02

    queue_error = 03

    tcode_invalid = 04.

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    refresh itab_bdc_tab.

    ENDFORM. " bdc_submit_transaction

    &----


    *& Form bdc_session_close

    &----


    • text

    ----


    FORM bdc_session_close.

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    • EXCEPTIONS

    • NOT_OPEN = 1

    • QUEUE_ERROR = 2

    • OTHERS = 3

    .

    skip 2.

    if sy-subrc ne 0.

    write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.

    else.

    write : / 'Session created:', v_ssnname,

    50 '# of transactions:', v_trans_in_ssn.

    endif.

    ENDFORM. " bdc_session_close

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 03:19 PM

    Hi,

    Call Transaction:

    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.

    ...end of program...

    Session Method:

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

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

              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

              Regards,

              Bhaskar

              Add a comment
              10|10000 characters needed characters exceeded

            • author's profile photo Former Member
              Former Member
              Posted on Aug 01, 2008 at 12:36 PM

              Can Any body Give me a BDC program which includes both session and call transaction method for table bnka and transaction FI01 and FI02 ?

              The following are the data fields that will be extracted from the data source:

              u2022 Bank Key (Routing Number)

              u2022 Bank Name

              u2022 Bank Region (State)

              u2022 Bank Street (Address)

              u2022 Bank City

              u2022 Bank Zip Code

              The Bank Country will be entered in the selection screen depending on the data source.

              Selection Criteria:

              1. File Name

              2. Last change u2265 (Variable Date): CDHDR-UDATE (Object = BANK)

              3. Error Session (default).

              4. User (default)

              Loading Data

              1. The Accounts payable department reviews the data file download from the source repository. If additional data fields are provided, they will be removed before tab delimited text file is generated.

              2. Program reads the records in the file and updates the bank master accordingly.

              a. If the bank country and bank key combination exist in table BNKA, change bank master (Transaction FI02) is performed updating the appropriate fields.

              b. If the combination does not exist, create bank master (Transaction FI01) is performed.

              c.

              3. The data file name is entered and the program will try to post using transaction u2018FI01u2019 or u2018FI02u2019 as determined in previous step. If the first bank master record posts successfully, the next bank master record is processed. If the bank master record cannot be processed, then a BDC session is created so that the user can make any corrections and reprocess the bank master create and/or change.

              4. When a bank master change is necessary and a change record exists u2265 user-defined date, the bank master record will be written to a separate file and not uploaded into SAP. This will prevent recent changes to be overwritten. The controlling date will be defined on the selection criteria menu.

              5. If Bank Country (BNKA-BANKA) is u201CUSu201D, then the Routing number/bank key should be 9 digits. If the bank key is less than 9 digits, than a BDC session is created, so that the user can make any corrections and reprocess the bank master create and/or change.

              Bank master records excluded from the upload due to the last change u2265 Date entered on the selection menu will be written to a separate file for review.

              Report should list:

              1. Total number of bank master records

              2. Number of records read into SAP

              a. Bank Masters Created

              b. Bank Masters Changed

              3. Number of records excluded from upload

              4. Bank master records excluded from the upload should be listed in the report.

              Add a comment
              10|10000 characters needed characters exceeded

            Before answering

            You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
            You must be Logged in to submit an answer.

            Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.