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

how to use table control in bdc briefly?

how to use table control in bdc briefly in description manner ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Posted on Jan 29, 2008 at 08:06 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:16 AM

    Hai

    check this.

    How to deal with table control / step loop in BDC

    Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen? Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')

    Now with the help of Poonam on sapfans.com developement forum, I find a method with which we can determine the number of visible lines on Transaction Screen from our Calling BDC program. Maybe it is useless to you, but I think it will give your some idea.

    Demo ABAP code has two purposes:

    1. how to determine number of visible lines and how to calculte page number;

    (the 'calpage' routine has been modify to meet general purpose usage)

    2. using field symbol in BDC program, please pay special attention to the difference in Static ASSIGN and Dynamic ASSIGN.

    Now I begin to describe the step to implement my method:

    (I use transaction 'ME21', screen 121 for sample,

    the method using is Call Transation Using..)

    Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop. Then have a look at steploop itselp, one entry of it will occupy two lines.

    (Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)

    Now we have : FixedLine = 9

    LoopLine = 2(for table control, LoopLine is always equal to 1)

    Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.

    Now we have: FirstLine = 0

    or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)

    Step3: write a subroutine calcalculating number of pages

    (here, the name of actual parameter is the same as formal parameter)

    global data: FixedLine type i, " number of fixed line on a certain screen

    LoopLine type i, " the number of lines occupied by one steploop item

    FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1

    Dataline type i, " number of items you will use in BDC, using DESCRIBE to get

    pageno type i, " you need to scroll screen how many times.

    line type i, " number of lines appears on the screen.

    index(2) type N, " the screen index for certain item

    begin type i, " from parameter of loop

    end type i. " to parameter of loop

    *in code sample, the DataTable-linindex stands for the table index number of this line

    form calpage using FixedLine type i (see step 1)

    LoopLine type i (see step 1)

    FirstLine type i (see step 2)

    DataLine type i ( this is the item number you will enter in transaction)

    changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)

    changing line type i.(visible lines one the screen)

    data: midd type i,

    vline type i, "visible lines

    if DataLine eq 0.

    Message eXXX.

    endif.

    vline = ( sy-srows - FixedLine ) div LoopLine.

    *for table control, you should compare vline with maximum line of

    *table control, then take the small one that is min(vline, maximum)

    *here only illustrate step loop

    if FirstLine eq 0.

    pageno = DataLine div vline.

    if pageno eq 0.

    pageno = pageno + 1.

    endif.

    elseif FirstLine eq 1.

    pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.

    midd = ( DataLine - 1 ) mod ( vline - 1).

    if midd = 0 and DataLine gt 1.

    pageno = pageno - 1.

    endif.

    endif.

    line = vline.

    endform.

    Step4 write a subroutine to calculate the line index for each item.

    form calindex using Line type i (visible lines on the screen)

    FirstLine type i(see step 2)

    LineIndex type i(item index)

    changing Index type n. (index on the screen)

    if FirstLine = 0.

    index = LineIndex mod Line.

    if index = '00'.

    index = Line.

    endif.

    elseif FirstLine = 1.

    index = LineIndex mod ( Line - 1 ).

    if ( index between 1 and 0 ) and LineIndex gt 1.

    index = index + Line - 1.

    endif.

    if Line = 2.

    index = index + Line - 1.

    endif.

    endif.

    endform.

    Step5 write a subroutine to calculate the loop range.

    form calrange using Line type i ( visible lines on the screen)

    DataLine type i

    FirstLine type i

    loopindex like sy-index

    changing begin type i

    end type i.

    If FirstLine = 0.

    if loopindex = 1.

    begin = 1.

    if DataLine <= Line.

    end = DataLine.

    else.

    end = Line.

    endif.

    elseif loopindex gt 1.

    begin = Line * ( loopindex - 1 ) + 1.

    end = Line * loopindex.

    if end gt DataLine.

    end = DataLine.

    endif.

    endif.

    elseif FirstLine = 1.

    if loopindex = 1.

    begin = 1.

    if DataLine <= Line.

    end = DataLine.

    else.

    end = Line.

    endif.

    elseif loop index gt 1.

    begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.

    end = ( Line - 1 ) * ( loopindex - 1 ) + Line.

    if end gt DataLine.

    end = DataLine.

    endif.

    endif.

    endif.

    endform.

    Step6 using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control

    form creat_bdc.

    field-symbols: <material>, <quan>, <indicator>.

    data: name1(14) value 'EKPO-EMATN(XX)',

    name2(14) value 'EKPO-MENGE(XX)',

    name3(15) value 'RM06E-SELKZ(XX)'.

    assign: name1 to <material>,

    name2 to <quan>,

    name3 to <indicator>.

    .

    do pageno times.

    if sy-index gt 1

    *insert scroll page ok_code"

    endif.

    .

    .

    perform calrange using Line DataLine FirstLine sy-index

    changing begin end.

    .

    .

    loop at DataTable from begin to end.

    perform calindex using Line FirstLine DataTable-LineIndex changing Index.

    name1+11(2) = Index.

    name2+11(2) = Index.

    name3+12(2) = Index.

    .

    .

    perform bdcfield using <material> DataTable-matnr.

    perform bdcfield using <quan> DataTable-menge.

    perform bdcfield using <indicator> DataTable-indicator.

    .

    .

    .

    endloop.

    enddo.

    regards.

    sowjanya.b.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:54 AM

    hi

    here iam sending detailed code...hope this will be useful.

    reward points if this is helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:55 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:56 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 10:05 AM

    Hi friend,

    here i am giving exm. code of table control.see if help full to u.

    REPORT zxk_01

    NO STANDARD PAGE HEADING LINE-SIZE 255.

    • include bdcrecx1.

    TYPES : BEGIN OF ty_data,

    line(100) TYPE c,

    END OF ty_data.

    PARAMETERS: p_pcfile LIKE ibipparms-path DEFAULT 'D:\NKS.TXT'.

    DATA : g_filename TYPE string.

    TYPES : BEGIN OF ty_file,

    lifnr(16) TYPE c, " vendor

    bukrs(4) TYPE c, "company code

    ktokk(4) TYPE c, " Acc grp

    anred(15) TYPE c, " Title

    name1(35) TYPE c, " name

    sortl(10) TYPE c, " search term

    stras(35) TYPE c, " street

    ort01(35) TYPE c, " city

    ort02(35) TYPE c, " district

    land1(3) TYPE c, " country

    pfach(10) TYPE c, " PO BOx

    spras(2) TYPE c, " language

    kunnr(10) TYPE c, " Customer

    vbund(6) TYPE c, " trading partner

    banks(3) TYPE c, " BANK COUNTRY

    bankl(15) TYPE c, " BANK KEY

    bankn(18) TYPE c, " BANK ACC

    koinh(60) TYPE c, " ACC HOLDER

    bkont(2) TYPE c, " CK

    bvtyp(4) TYPE c, " BNKT

    bkref(20) TYPE c, " REFERENCE DETAILS

    namev(35) TYPE c, " first NAME

    name2(35) TYPE c, " NAME

    telf1(16) TYPE c, " TELEPHONE

    abtnr(4) TYPE c, " DEPTT

    pafkt(2) TYPE c, " FUNCTION

    akont(10) TYPE c, " REC ACCOUNT

    zuawa(3) TYPE c, " SORT KEY

    lnrze(10) TYPE c, "HEAD OFFICE

    fdgrv(10) TYPE c, " CASH MGMT GRP,

    frgrp(4) TYPE c, " RELEASE GRP

    zterm(4) TYPE c, " PAY TERMS

    togru(4) TYPE c, " TOLERENCE GRP,

    reprf, "CHECK DOUBLE INV

    zwels(10) TYPE c, " PAYMENTS METHODS

    zahls, " PAYMENTS BLOCK

    hbkid(5) TYPE c, " house bank

    zgrup(2) TYPE c, " grouping key

    mahna(4) TYPE c, " dunn procedure

    mansp, " DUNNING BLOCK'

    gmvdt(10) TYPE c, " LEGAL DONE PROCEDURE

    lfrma(10) TYPE c, " DUNN RECEPIENT

    madat(10) TYPE c, " LAST DUNNED

    mahns(1) TYPE c, " dunning level

    mgrup(2) TYPE c, " grouping key

    busab(2) TYPE c, "dunning clerk

    END OF ty_file.

    DATA : BEGIN OF it_xk01 OCCURS 0,

    lifnr(16) TYPE c, " vendor

    bukrs(4) TYPE c, "company code

    ktokk(4) TYPE c, " Acc grp

    anred(15) TYPE c, " Title

    name1(35) TYPE c, " name

    sortl(10) TYPE c, " search term

    stras(35) TYPE c, " street

    ort01(35) TYPE c, " city

    ort02(35) TYPE c, " district

    land1(3) TYPE c, " country

    pfach(10) TYPE c, " PO BOx

    spras(2) TYPE c, " language

    kunnr(10) TYPE c, " Customer

    vbund(6) TYPE c, " trading partner

    akont(10) TYPE c, " REC ACCOUNT

    zuawa(3) TYPE c, " SORT KEY

    lnrze(10) TYPE c, "HEAD OFFICE

    fdgrv(10) TYPE c, " CASH MGMT GRP,

    frgrp(4) TYPE c, " RELEASE GRP

    zterm(4) TYPE c, " PAY TERMS

    togru(4) TYPE c, " TOLERENCE GRP,

    reprf, "CHECK DOUBLE INV

    zwels(10) TYPE c, " PAYMENTS METHODS

    zahls, " PAYMENTS BLOCK

    hbkid(5) TYPE c, " house bank

    zgrup(2) TYPE c, " grouping key

    mahna(4) TYPE c, " dunn procedure

    mansp, " DUNNING BLOCK'

    gmvdt(10) TYPE c, " LEGAL DONE PROCEDURE

    lfrma(10) TYPE c, " DUNN RECEPIENT

    madat(10) TYPE c, " LAST DUNNED

    mahns(1) TYPE c, " dunning level

    mgrup(2) TYPE c, " grouping key

    busab(2) TYPE c, "dunning clerk

    END OF it_xk01.

    • internal table for bank detaiils

    DATA : BEGIN OF it_bank OCCURS 0,

    banks(3) TYPE c, " BANK COUNTRY

    bankl(15) TYPE c, " BANK KEY

    bankn(18) TYPE c, " BANK ACC

    koinh(60) TYPE c, " ACC HOLDER

    bkont(2) TYPE c, " CK

    bvtyp(4) TYPE c, " BNKT

    bkref(20) TYPE c, " REFERENCE DETAILS

    lifnr(16) TYPE c, " vendor

    • xezer, " CHECK

    END OF it_bank.

    • INTERNAL TABLE FOR CONTACT PERSON

    TYPES : BEGIN OF ty_cust,

    lifnr(16) TYPE c,

    namev(35) TYPE c, " first NAME

    name1(35) TYPE c, " NAME

    telf1(16) TYPE c, " TELEPHONE

    abtnr(4) TYPE c, " DEPTT

    pafkt(2) TYPE c, " FUNCTION

    END OF ty_cust.

    • INTERNAL TABLES DECLARATION

    DATA : it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

    it_bdcmsgcoll LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

    it_file TYPE TABLE OF ty_file,

    it_data TYPE TABLE OF ty_data,

    it_cust TYPE TABLE OF ty_cust.

    • WORK AREAS FOR TYPES

    DATA : wa_xk01 LIKE it_xk01,

    wa_data TYPE ty_data,

    wa_file TYPE ty_file,

    wa_bank LIKE it_bank,

    wa_cust TYPE ty_cust.

    *CALL METHOD cl_gui_frontend_services=>gui_upload

    • EXPORTING

    • filename = lt_file

    • filetype = 'ASC'

    • CHANGING

    • data_tab = iT_DATA.

    • IF sy-subrc <> 0.

    • ENDIF.

    g_filename = p_pcfile.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = g_filename "'D:\TESTDATA1_XK01.txt'

    • filetype = 'TXT'

    has_field_separator = 'X'

    • HEADER_LENGTH = 0

    • read_by_line = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    replacement = ' '

    • CHECK_BOM = ' '

    • VIRUS_SCAN_PROFILE =

    • NO_AUTH_CHECK = ' '

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    TABLES

    data_tab = it_file

    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.

    LOOP AT it_file INTO wa_file .

    ON CHANGE OF WA_FILE-LIFNR.

    wa_xk01-lifnr = wa_file-lifnr.

    wa_xk01-bukrs = wa_file-bukrs.

    wa_xk01-ktokk = wa_file-ktokk.

    wa_xk01-anred = wa_file-anred.

    wa_xk01-name1 = wa_file-name1.

    wa_xk01-sortl = wa_file-sortl.

    wa_xk01-stras = wa_file-stras.

    wa_xk01-ort01 = wa_file-ort01.

    wa_xk01-ort02 = wa_file-ort02.

    wa_xk01-land1 = wa_file-land1.

    wa_xk01-pfach = wa_file-pfach.

    wa_xk01-spras = wa_file-spras.

    wa_xk01-kunnr = wa_file-kunnr.

    wa_xk01-vbund = wa_file-vbund.

    wa_xk01-akont = wa_file-akont.

    wa_xk01-zuawa = wa_file-zuawa.

    wa_xk01-lnrze = wa_file-lnrze.

    wa_xk01-fdgrv = wa_file-fdgrv.

    wa_xk01-frgrp = wa_file-frgrp.

    wa_xk01-zterm = wa_file-zterm.

    wa_xk01-togru = wa_file-togru.

    wa_xk01-reprf = wa_file-reprf.

    wa_xk01-zwels = wa_file-zwels.

    wa_xk01-zahls = wa_file-zahls.

    wa_xk01-hbkid = wa_file-hbkid.

    wa_xk01-zgrup = wa_file-zgrup.

    wa_xk01-mahna = wa_file-mahna.

    wa_xk01-mansp = wa_file-mansp.

    wa_xk01-gmvdt = wa_file-gmvdt.

    wa_xk01-lfrma = wa_file-lfrma.

    wa_xk01-madat = wa_file-madat.

    wa_xk01-mahns = wa_file-mahns.

    wa_xk01-mgrup = wa_file-mgrup.

    wa_xk01-busab = wa_file-busab.

    APPEND wa_xk01 TO it_xk01.

    CLEAR : WA_XK01.

    • CONTINUE.

    ENDON.

    • IF WA_FILE-BANKS NE ''.

    wa_bank-lifnr = wa_file-lifnr.

    wa_bank-banks = wa_file-banks.

    wa_bank-bankl = wa_file-bankl.

    wa_bank-bankn = wa_file-bankn.

    wa_bank-koinh = wa_file-koinh.

    wa_bank-bkont = wa_file-bkont.

    wa_bank-bvtyp = wa_file-bvtyp.

    wa_bank-bkref = wa_file-bkref.

    wa_cust-lifnr = wa_file-lifnr.

    wa_cust-namev = wa_file-namev.

    wa_cust-name1 = wa_file-name2.

    wa_cust-telf1 = wa_file-telf1.

    wa_cust-abtnr = wa_file-abtnr.

    wa_cust-pafkt = wa_file-pafkt.

    APPEND wa_bank TO it_bank.

    APPEND wa_cust TO it_cust.

    • APPEND wa_xk01 TO it_xk01.

    CLEAR : wa_bank , wa_cust.

    • ENDIF.

    ENDLOOP.

    START-OF-SELECTION.

    LOOP AT it_xk01 INTO wa_xk01.

    REFRESH it_bdcdata.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02K-KTOKK'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'RF02K-LIFNR'

    wa_xk01-lifnr. " vendor

    PERFORM bdc_field USING 'RF02K-BUKRS'

    wa_xk01-bukrs. " company cpode

    PERFORM bdc_field USING 'RF02K-KTOKK'

    wa_xk01-ktokk. " Acc group

    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFA1-SPRAS'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'LFA1-ANRED'

    wa_xk01-anred. " title

    PERFORM bdc_field USING 'LFA1-NAME1'

    wa_xk01-name1. " name

    PERFORM bdc_field USING 'LFA1-SORTL'

    wa_xk01-sortl. " ' search term'

    PERFORM bdc_field USING 'LFA1-STRAS'

    wa_xk01-stras. "street'

    PERFORM bdc_field USING 'LFA1-PFACH'

    wa_xk01-pfach. " po box

    PERFORM bdc_field USING 'LFA1-ORT01'

    wa_xk01-ort01. " city

    PERFORM bdc_field USING 'LFA1-ORT02'

    wa_xk01-ort02. " district

    PERFORM bdc_field USING 'LFA1-LAND1'

    wa_xk01-land1. " country

    PERFORM bdc_field USING 'LFA1-SPRAS'

    wa_xk01-spras. " language

    PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFA1-VBUND'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'LFA1-KUNNR' " customer

    wa_xk01-kunnr.

    PERFORM bdc_field USING 'LFA1-VBUND'

    wa_xk01-vbund. " trading partner

    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFBK-BKREF(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    DATA : fnam(20) TYPE c,

    int TYPE c.

    MOVE 1 TO int.

    CLEAR wa_bank.

    LOOP AT it_bank INTO wa_bank WHERE lifnr = wa_xk01-lifnr.

    CONCATENATE 'LFBK-BANKS(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-banks. " city

    CONCATENATE 'LFBK-BANKL(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-bankl.

    CONCATENATE 'LFBK-BANKN(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-bankn.

    CONCATENATE 'LFBK-KOINH(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-koinh.

    CONCATENATE 'LFBK-BKONT(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-bkont.

    CONCATENATE 'LFBK-BVTYP(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-bvtyp.

    CONCATENATE 'LFBK-BKREF(' int ')' INTO fnam.

    PERFORM bdc_field USING fnam

    wa_bank-bkref.

    int = int + 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' '0380'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNVK-PAFKT(05)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    DATA : fnam1(20) TYPE c,

    cnt.

    cnt = 1.

    CLEAR : wa_cust.

    LOOP AT it_cust INTO wa_cust WHERE lifnr = wa_xk01-lifnr.

    CONCATENATE 'KNVK-NAMEV(' cnt ')' INTO fnam1.

    PERFORM bdc_field USING fnam1

    wa_cust-namev.

    CONCATENATE 'KNVK-NAME1(' cnt ')' INTO fnam1.

    PERFORM bdc_field USING fnam1

    wa_cust-name1.

    CONCATENATE 'KNVK-TELF1(' cnt ')' INTO fnam1.

    PERFORM bdc_field USING fnam1

    wa_cust-telf1.

    CONCATENATE 'KNVK-ABTNR(' cnt ')' INTO fnam1.

    PERFORM bdc_field USING fnam1

    wa_cust-abtnr.

    CONCATENATE 'KNVK-PAFKT(' cnt ')' INTO fnam1.

    PERFORM bdc_field USING fnam1

    wa_cust-pafkt.

    cnt = cnt + 1.

    ENDLOOP.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0380'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNVK-NAMEV(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB1-FRGRP'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'LFB1-AKONT'

    wa_xk01-akont. " REC aCC

    PERFORM bdc_field USING 'LFB1-ZUAWA'

    wa_xk01-zuawa. " SORT KEY

    PERFORM bdc_field USING 'LFB1-LNRZE'

    wa_xk01-lnrze. " HEAD OFFICE

    PERFORM bdc_field USING 'LFB1-FDGRV'

    wa_xk01-fdgrv. " CASH MGMT GRP

    PERFORM bdc_field USING 'LFB1-FRGRP'

    wa_xk01-frgrp. " RELEASE GRP

    PERFORM bdc_field USING 'LFB1-CERDT'

    ''.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB1-ZGRUP'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'LFB1-ZTERM'

    wa_xk01-zterm. " PAYMENT TERMS'

    PERFORM bdc_field USING 'LFB1-TOGRU'

    wa_xk01-togru. " TOLERENCE GRP

    PERFORM bdc_field USING 'LFB1-REPRF'

    wa_xk01-reprf. " CHECK DOUBLE INV

    PERFORM bdc_field USING 'LFB1-ZWELS'

    wa_xk01-zwels. " PAYMENT METHOD

    PERFORM bdc_field USING 'LFB1-ZAHLS'

    wa_xk01-zahls. " PAYMENT BLOCK

    PERFORM bdc_field USING 'LFB1-HBKID'

    wa_xk01-hbkid. " HOUSE BANK

    PERFORM bdc_field USING 'LFB1-ZGRUP'

    wa_xk01-zgrup. " GROUPING KEY

    PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB5-BUSAB'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'LFB5-MAHNA'

    wa_xk01-mahna. " DUNN PROCEDURE

    PERFORM bdc_field USING 'LFB5-MANSP'

    wa_xk01-mansp. " DUNNING BLOCK

    PERFORM bdc_field USING 'LFB5-LFRMA'

    wa_xk01-lfrma. " Dunn representative

    PERFORM bdc_field USING 'LFB5-GMVDT'

    wa_xk01-gmvdt. " legal dunn proc

    PERFORM bdc_field USING 'LFB5-MADAT'

    wa_xk01-madat. " last dunned

    PERFORM bdc_field USING 'LFB5-MAHNS'

    wa_xk01-mahns. " dunn level

    PERFORM bdc_field USING 'LFB5-BUSAB'

    wa_xk01-busab. " dunning clerk

    PERFORM bdc_field USING 'LFB1-MGRUP'

    wa_xk01-mgrup. " grouping key

    CALL TRANSACTION 'XK01' USING it_bdcdata

    MODE 'A'.

    ENDLOOP.

    ----


    • Start new screen *

    ----


    FORM bdc_dynpro USING program dynpro.

    CLEAR it_bdcdata.

    it_bdcdata-program = program.

    it_bdcdata-dynpro = dynpro.

    it_bdcdata-dynbegin = 'X'.

    APPEND it_bdcdata.

    ENDFORM. "BDC_DYNPRO

    *----


    *

    • Insert field

    *

    *----


    *

    FORM bdc_field USING fnam fval TYPE any.

    CLEAR it_bdcdata.

    it_bdcdata-fnam = fnam.

    it_bdcdata-fval = fval.

    APPEND it_bdcdata.

    ENDFORM. "bdc_field

    *perform close_group.

    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.