Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

table control in bdc

Former Member
0 Likes
547

Hi all,

Can anyone tell me how to use table control functionality in BDC, Can any one pls give simple example with actual coding...

thanks in advance,

kumaran

1 ACCEPTED SOLUTION
Read only

Former Member
3 REPLIES 3
Read only

Former Member
Read only

Former Member
0 Likes
516

hi kumaran,

just try this code,

this is for customer master create,

report zbdc_cus_create_ctm no standard page heading message-id zsmep.

&----


*& Request ID: ECCK900136

*& Author : seshu

*& Date : 20/03/2007

*& This report Creates customer Master Details through BDC-Call transaction

*& method and download error files to the presentation server.

&----


data: begin of t_tab occurs 0,

kunnr type kun16,

bukrs type bukrs,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

ktokd type ktokd,

name1 type name1_gp,

sortl type sortl,

ort01 type ort01_gp,

land1 type land1_gp,

spras type spras,

pstlz type pstlz,

civve type civve,

akont type akont,

awahr type awahr,

waers type waers_v02d,

kzazu type kzazu_d,

antlf type string.

data: end of t_tab.

data: begin of t_tab1 occurs 0,

kunnr type kun16,

bukrs type bukrs,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

ktokd type ktokd,

name1 type name1_gp,

sortl type sortl,

ort01 type ort01_gp,

land1 type land1_gp,

spras type spras,

pstlz type pstlz,

civve type civve,

akont type akont,

awahr type awahr,

waers type waers_v02d,

kzazu type kzazu_d,

antlf type string.

data: end of t_tab1.

data: begin of g_tab_create occurs 0,

kunnr type kunnr,

messa type string.

data: end of g_tab_create.

data: begin of g_tab_error occurs 0,

kunnr type kunnr,

messa type string.

data: end of g_tab_error.

data: g_tab type table of string,

g_wa type string.

*DATA: g_tab TYPE TABLE OF t_tab,

  • g_wa LIKE LINE OF g_tab.

*

data: g_tab1 type table of string.

*itab for mapping...

data: begin of tab_map occurs 0.

include structure bdcdata.

data: end of tab_map.

*itab for error messages...

data: begin of tab_error occurs 0.

include structure bdcmsgcoll.

data: end of tab_error.

data: begin of l_tab occurs 0,

l_text type string.

data: end of l_tab.

*delcarations for blocked alv...

type-pools: slis.

data: l_tab_fieldcatlog type slis_t_fieldcat_alv,

l_tab_fieldcatlog1 type slis_t_fieldcat_alv,

l_layout type slis_layout_alv,

l_events type slis_t_event,

l_events1 type slis_t_event,

l_wa_events like line of l_events,

l_pos type i,

report type sy-repid,

path type string,

path1 type string.

      • End generated data section ***

selection-screen begin of block b1 with frame title text-001.

parameters: file type ibipparms-path obligatory.

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-002.

parameters: file1 type ibipparms-path.

selection-screen end of block b2.

at selection-screen on value-request for file.

call function 'F4_FILENAME'

importing

file_name = file.

move file to path.

at selection-screen on value-request for file1.

call function 'F4_FILENAME'

importing

file_name = file1.

move file1 to path1.

at selection-screen .

if file eq file1.

message e103(zsmep).

exit.

endif.

start-of-selection.

*call transaction method...

perform call_ctm.

*display the output in blocked alv...

perform disply_block_alv.

&----


*& Form call_ctm

&----


  • text

----


form call_ctm.

call function 'GUI_UPLOAD'

exporting

filename = path

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • 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 = g_tab

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.

data: text type table of string.

loop at g_tab into g_wa.

split g_wa at '|' into: t_tab-kunnr

t_tab-bukrs

t_tab-vkorg

t_tab-vtweg

t_tab-spart

t_tab-ktokd

t_tab-name1

t_tab-sortl

t_tab-ort01

t_tab-land1

t_tab-spras

t_tab-pstlz

t_tab-civve

t_tab-akont

t_tab-awahr

t_tab-waers

t_tab-kzazu

t_tab-antlf,

table text.

append t_tab.

clear g_wa.

endloop.

loop at t_tab.

refresh tab_map.

perform sub using 'SAPMF02D' '0100'.

perform sub1 using 'BDC_CURSOR'

'RF02D-KTOKD'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub1 using 'RF02D-KUNNR'

t_tab-kunnr.

perform sub1 using 'RF02D-BUKRS'

t_tab-bukrs.

perform sub1 using 'RF02D-VKORG'

t_tab-vkorg.

perform sub1 using 'RF02D-VTWEG'

t_tab-vtweg.

perform sub1 using 'RF02D-SPART'

t_tab-spart.

perform sub1 using 'RF02D-KTOKD'

t_tab-ktokd.

perform sub using 'SAPMF02D' '0110'.

perform sub1 using 'BDC_CURSOR'

'KNA1-SPRAS'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub1 using 'KNA1-NAME1'

t_tab-name1.

perform sub1 using 'KNA1-SORTL'

t_tab-sortl.

perform sub1 using 'KNA1-ORT01'

t_tab-ort01.

perform sub1 using 'KNA1-LAND1'

t_tab-land1.

perform sub1 using 'KNA1-SPRAS'

t_tab-spras.

perform sub1 using 'KNA1-PSTLZ'

t_tab-pstlz.

perform sub using 'SAPMF02D' '0120'.

perform sub1 using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '0125'.

perform sub1 using 'BDC_CURSOR'

'KNA1-NIELS'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '0130'.

perform sub1 using 'BDC_CURSOR'

'KNBK-BANKS(01)'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

perform sub using 'SAPMF02D' '0340'.

perform sub1 using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

perform sub using 'SAPMF02D' '0370'.

perform sub1 using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

perform sub1 using 'KNA1-CIVVE'

t_tab-civve.

perform sub using 'SAPMF02D' '0360'.

perform sub1 using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

perform sub using 'SAPMF02D' '0210'.

perform sub1 using 'BDC_CURSOR'

'KNB1-AKONT'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub1 using 'KNB1-AKONT'

t_tab-akont.

perform sub using 'SAPMF02D' '0215'.

perform sub1 using 'BDC_CURSOR'

'KNB1-GUZTE'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '0220'.

perform sub1 using 'BDC_CURSOR'

'KNB5-KNRMA'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '0230'.

perform sub1 using 'BDC_CURSOR'

'KNB1-VRSNR'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '0310'.

perform sub1 using 'BDC_CURSOR'

'KNVV-BZIRK'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub1 using 'KNVV-AWAHR'

t_tab-awahr.

perform sub1 using 'KNVV-WAERS'

t_tab-waers.

perform sub using 'SAPMF02D' '0315'.

perform sub1 using 'BDC_CURSOR'

'KNVV-LPRIO'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub1 using 'KNVV-KZAZU'

t_tab-kzazu.

perform sub1 using 'KNVV-ANTLF'

t_tab-antlf.

perform sub using 'SAPMF02D' '0320'.

perform sub1 using 'BDC_CURSOR'

'KNVV-PERFK'.

perform sub1 using 'BDC_OKCODE'

'/00'.

perform sub using 'SAPMF02D' '1350'.

perform sub1 using 'BDC_CURSOR'

'RF02D-KUNNR'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

perform sub using 'SAPMF02D' '0324'.

perform sub1 using 'BDC_CURSOR'

'KNVP-PARVW(01)'.

perform sub1 using 'BDC_OKCODE'

'=ENTR'.

call transaction 'XD01' using tab_map

mode 'N'

update 'A'

messages into tab_error.

loop at tab_error.

data: l_message type string.

if tab_error-msgtyp = 'I' or tab_error-msgtyp = 'S'.

call function 'FORMAT_MESSAGE'

exporting

id = tab_error-msgid

lang = 'EN'

no = tab_error-msgnr

v1 = tab_error-msgv1

v2 = tab_error-msgv2

v3 = tab_error-msgv3

v4 = tab_error-msgv4

importing

msg = l_message

exceptions

not_found = 1

others = 2.

if sy-subrc <> 0.

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

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

endif.

move: t_tab-kunnr to g_tab_create-kunnr,

l_message to g_tab_create-messa.

append g_tab_create.

elseif

tab_error-msgtyp = 'E'.

move-corresponding t_tab to t_tab1.

append t_tab1.

data: text1 type string.

concatenate t_tab-kunnr

t_tab-bukrs

t_tab-vkorg

t_tab-vtweg

t_tab-spart

t_tab-ktokd

t_tab-name1

t_tab-sortl

t_tab-ort01

t_tab-land1

t_tab-spras

t_tab-pstlz

t_tab-civve

t_tab-akont

t_tab-awahr

t_tab-waers

t_tab-kzazu

t_tab-antlf

into text1 separated by '|'.

l_tab-l_text = text1 .

append l_tab.

*error records downlaod to pc...

perform gui_downlaod.

call function 'FORMAT_MESSAGE'

exporting

id = tab_error-msgid

lang = 'EN'

no = tab_error-msgnr

v1 = tab_error-msgv1

v2 = tab_error-msgv2

v3 = tab_error-msgv3

v4 = tab_error-msgv4

importing

msg = l_message

exceptions

not_found = 1

others = 2.

if sy-subrc <> 0.

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

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

endif.

move: t_tab-kunnr to g_tab_error-kunnr,

l_message to g_tab_error-messa.

append g_tab_error.

endif.

endloop.

refresh tab_error.

clear l_message.

endloop.

endform. "call_ctm

&----


*& Form sub

&----


  • text

----


  • -->A text

  • -->B text

----


form sub using a b.

clear tab_map.

tab_map-program = a.

tab_map-dynpro = b.

tab_map-dynbegin = 'X'.

append tab_map.

endform. "FORM

" sub

&----


*& Form sub1

&----


  • text

----


  • -->P_0579 text

  • -->P_0580 text

----


form sub1 using c d.

clear tab_map.

tab_map-fnam = c.

tab_map-fval = d.

append tab_map.

endform. " sub1

*END-OF-SELECTION.

&----


*& Form disply_block_alv

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form disply_block_alv .

perform fill_fieldcatlog.

perform fill_fieldcatlog1.

perform call_block_alv.

endform. " disply_block_alv

&----


*& Form fill_fieldcatlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_fieldcatlog .

perform build_catlog using l_pos 'G_TAB_CREATE' 'KUNNR' '16' text-004.

perform build_catlog using l_pos 'G_TAB_CREATE' 'MESSA' '90' text-005.

endform. " fill_fieldcatlog

&----


*& Form BUILD_CATLOG

&----


  • text

----


  • -->P_L_POS text

  • -->P_0844 text

  • -->P_0845 text

  • -->P_0846 text

  • -->P_TEXT_004 text

----


form build_catlog using u_pos type any

value(u_0844) type any

value(u_0845) type any

value(u_0846) type any

u_text type any.

data: l_wa_fieldcatlog type slis_fieldcat_alv.

add 1 to u_pos.

l_wa_fieldcatlog-col_pos = u_pos.

l_wa_fieldcatlog-tabname = u_0844.

l_wa_fieldcatlog-fieldname = u_0845.

l_wa_fieldcatlog-outputlen = u_0846.

l_wa_fieldcatlog-reptext_ddic = u_text.

append l_wa_fieldcatlog to l_tab_fieldcatlog.

endform. " BUILD_CATLOG

&----


*& Form fill_fieldcatlog1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_fieldcatlog1 .

perform build_catlog1 using l_pos 'G_TAB_ERROR' 'KUNNR' '16' text-004.

perform build_catlog1 using l_pos 'G_TAB_ERROR' 'MESSA' '90' text-005.

endform. " fill_fieldcatlog1

&----


*& Form build_catlog1

&----


  • text

----


  • -->P_L_POS text

  • -->P_0913 text

  • -->P_0914 text

  • -->P_0915 text

  • -->P_TEXT_004 text

----


form build_catlog1 using u_pos type any

value(u_0913) type any

value(u_0914) type any

value(u_0915) type any

u_text type any.

data: l_wa_fieldcatlog1 type slis_fieldcat_alv.

add 1 to u_pos.

l_wa_fieldcatlog1-col_pos = u_pos.

l_wa_fieldcatlog1-tabname = u_0913.

l_wa_fieldcatlog1-fieldname = u_0914.

l_wa_fieldcatlog1-outputlen = u_0915.

l_wa_fieldcatlog1-reptext_ddic = u_text.

append l_wa_fieldcatlog1 to l_tab_fieldcatlog1.

endform. " build_catlog1

&----


*& Form CALL_BLOCK_ALV

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form call_block_alv .

report = sy-repid.

clear l_events.

l_wa_events-name = slis_ev_top_of_page.

l_wa_events-form = 'TOP_OF_PAGE'.

append l_wa_events to l_events.

clear l_wa_events.

l_wa_events-name = slis_ev_top_of_page.

l_wa_events-form = 'ETOP_OF_PAGE'.

append l_wa_events to l_events1.

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = report

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IT_EXCLUDING =

.

if g_tab_create[] is initial.

message s101(zsmep).

  • EXIT.

else.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = l_layout

it_fieldcat = l_tab_fieldcatlog

i_tabname = 'G_TAB_CREATE'

it_events = l_events

  • IT_SORT =

  • I_TEXT = ' '

tables

t_outtab = g_tab_create

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

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

endif.

if g_tab_error[] is initial.

message s102(zsmep).

else.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = l_layout

it_fieldcat = l_tab_fieldcatlog1

i_tabname = 'G_TAB_ERROR'

it_events = l_events1

  • IT_SORT =

  • I_TEXT = ' '

tables

t_outtab = g_tab_error

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

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

endif.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • IS_PRINT =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

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

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

endif.

endform. " CALL_BLOCK_ALV

&----


*& Form top_of_page

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form top_of_page .

write: 'Created Records'.

endform. " top_of_page

&----


*& Form ETOP_OF_PAGE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form etop_of_page .

write: 'Error Records'.

endform. " ETOP_OF_PAGE

&----


*& Form gui_downlaod

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form gui_downlaod .

move file1 to path1.

call function 'GUI_DOWNLOAD'

exporting

  • BIN_FILESIZE =

filename = path1

filetype = 'ASC'

  • APPEND = ' '

write_field_separator = '|'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

  • IMPORTING

  • FILELENGTH =

tables

data_tab = l_tab

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_WRITE_ERROR = 1

  • NO_BATCH = 2

  • GUI_REFUSE_FILETRANSFER = 3

  • INVALID_TYPE = 4

  • NO_AUTHORITY = 5

  • UNKNOWN_ERROR = 6

  • HEADER_NOT_ALLOWED = 7

  • SEPARATOR_NOT_ALLOWED = 8

  • FILESIZE_NOT_ALLOWED = 9

  • HEADER_TOO_LONG = 10

  • DP_ERROR_CREATE = 11

  • DP_ERROR_SEND = 12

  • DP_ERROR_WRITE = 13

  • UNKNOWN_DP_ERROR = 14

  • ACCESS_DENIED = 15

  • DP_OUT_OF_MEMORY = 16

  • DISK_FULL = 17

  • DP_TIMEOUT = 18

  • FILE_NOT_FOUND = 19

  • DATAPROVIDER_EXCEPTION = 20

  • CONTROL_FLUSH_ERROR = 21

  • OTHERS = 22

.

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

regards...

seshu.

Message was edited by:

maddipatla Seshu chowdary

Read only

Former Member
0 Likes
516

hi,

check this example

&----


*& Report ZSR_BDC_TBCTRL

*&

&----


*&

*&

&----


REPORT ZSR_BDC_TBCTRL

NO STANDARD PAGE HEADING LINE-SIZE 255.

TABLES : RF02K,LFA1,LFBK.

DATA : BEGIN OF IT_VEN OCCURS 0,

LIFNR LIKE RF02K-LIFNR,

KTOKK LIKE RF02K-KTOKK,

NAME1 LIKE LFA1-NAME1,

SORTL LIKE LFA1-SORTL,

LAND1 LIKE LFA1-LAND1,

SPRAS LIKE LFA1-SPRAS,

BANKS(6) TYPE C,

BANKL(17) TYPE C,

BANKN(19) TYPE C,

END OF IT_VEN.

DATA : BEGIN OF BANKS OCCURS 0,

BANKS LIKE LFBK-BANKS,

END OF BANKS,

BEGIN OF BANKL OCCURS 0,

BANKL LIKE LFBK-BANKL,

END OF BANKL,

BEGIN OF BANKN OCCURS 0,

BANKN LIKE LFBK-BANKN,

END OF BANKN.

DATA : FLD(20) TYPE C,

CNT(2) TYPE N.

DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

INCLUDE BDCRECX1.

START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'Z:\sr.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_VEN

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

PERFORM OPEN_GROUP.

LOOP AT IT_VEN.

REFRESH BDCDATA.

REFRESH : BANKS,BANKL,BANKN..

SPLIT IT_VEN-BANKS AT ',' INTO TABLE BANKS.

SPLIT IT_VEN-BANKL AT ',' INTO TABLE BANKL.

SPLIT IT_VEN-BANKN AT ',' INTO TABLE BANKN.

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'

IT_VEN-LIFNR.

PERFORM BDC_FIELD USING 'RF02K-KTOKK'

IT_VEN-KTOKK.

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

IT_VEN-NAME1.

PERFORM BDC_FIELD USING 'LFA1-SORTL'

IT_VEN-SORTL.

PERFORM BDC_FIELD USING 'LFA1-LAND1'

IT_VEN-LAND1.

PERFORM BDC_FIELD USING 'LFA1-SPRAS'

IT_VEN-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-BANKN(02)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

*perform bdc_field using 'LFBK-BANKS(01)'

  • 'DE'.

*perform bdc_field using 'LFBK-BANKS(02)'

  • 'DE'.

*perform bdc_field using 'LFBK-BANKL(01)'

  • '10020030'.

*perform bdc_field using 'LFBK-BANKL(02)'

  • '67270003'.

*perform bdc_field using 'LFBK-BANKN(01)'

  • '12345'.

*perform bdc_field using 'LFBK-BANKN(02)'

  • '66666'.

MOVE 1 TO CNT.

LOOP AT BANKS.

CONCATENATE 'LFBK-BANKS(' CNT ') ' INTO FLD.

PERFORM BDC_FIELD USING FLD BANKS-BANKS.

CNT = CNT + 1.

ENDLOOP.

MOVE 1 TO CNT.

LOOP AT BANKL.

CONCATENATE 'LFBK-BANKL(' CNT ') ' INTO FLD.

PERFORM BDC_FIELD USING FLD BANKL-BANKL.

CNT = CNT + 1.

ENDLOOP.

MOVE 1 TO CNT.

LOOP AT BANKN.

CONCATENATE 'LFBK-BANKN(' CNT ') ' INTO FLD.

PERFORM BDC_FIELD USING FLD BANKN-BANKN.

CNT = CNT + 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 'SAPLSPO1' '0300'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=YES'.

PERFORM BDC_TRANSACTION USING 'XK01'.

ENDLOOP.

PERFORM CLOSE_GROUP.