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

error in bdcmsgcol

Former Member
0 Likes
361

how to handle errors in bdcmsgcol, and where u write the error masages in bdcmsgcol give it with a real time scenario?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
312

hi,

report zsh_recording_fk01 .

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

  • T A B L E S *

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

tables : lfa1 . " Vendor Master.

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

  • I N T E R N A L T A B L E - D E C L A R A T I O N *

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

data : begin of it_tab occurs 0,

lifnr(16), "account number of vendor

ktokk(4), "Vendor Number

anred(15), "Account Group

name1(35), "Name

sortl(10), "Sort field

land1(3) , "Land

spras(1), "Language Key

kunnr(10), "customer number

banks(3), "Bank country key

bankl(15), "Bank Key

bankn(18), "Bank Account Number

koinh(60), "Account Holder Name

banka(60), "Name of bank

provz(3), "region

end of it_tab.

data : begin of it_tab1 occurs 0,

banks(3), "Bank country key

bankl(15), "Bank Key

bankn(18), "Bank Account Number

koinh(60), "Account Holder Name

banka(60), "Name of bank

provz(3), "region

end of it_tab1.

DATA:it_BDCtab LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • ERROR MESSAGE TABLE

DATA:it_MSGtab LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

data: program type BDCDATA-PROGRAM,

dynpro type BDCDATA-dynpro,

fnam type BDCDATA-fnam,

fval type BDCDATA-fval.

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

  • S E L E C T I O N - S C R E E N *

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

selection-screen : begin of block bl1 with frame.

parameter : p_file type rlgrap-filename default

'C:\Vendor.txt.txt' obligatory,

p_file1 type rlgrap-filename default

'C:\Vendor1.txt.txt' obligatory.

selection-screen : end of block bl1.

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

  • A T S E L E C T I O N - S C R E E N *

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

at selection-screen on value-request for p_file.

  • to get F4 help for p_file

perform f4_get_help using p_file.

  • to get F4 help for p_file

perform f4_get_help1 using p_file1.

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

  • S T A R T O F S E L E C T I O N *

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

start-of-selection.

  • Uploading data from flat file into it_tab

perform bdc_upload.

perform bdc_upload1.

perform populate_bdc.

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

  • E N D O F S E L E C T I O N *

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

end-of-selection.

  • displaying fields which r uploaded from flat file.

perform display_report.

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

  • T O P _ O F _ P A G E *

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

top-of-page.

  • to display header in the report

perform header.

&----


*& Form f4_get_help

&----


  • text

----


  • -->P_P_FILE text

----


form f4_get_help using p_p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

importing

file_name = p_p_file.

.

endform. " f4_get_help

&----


*& Form bdc_upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_upload .

data: v_file type string.

v_file = p_file.

call function 'GUI_UPLOAD'

exporting

filename = v_file

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_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.

endform. " bdc_upload

&----


*& Form display_report

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_report .

uline 1(86).

loop at it_tab .

format color 2.

write :/1 sy-vline,

2 it_tab-lifnr,

12 it_tab-ktokk ,

18 it_tab-anred ,

30 it_tab-name1 ,

55 it_tab-sortl ,

58 it_tab-land1 ,

72 it_tab-spras ,

76 it_tab-kunnr ,

88 it_tab-banks ,

94 it_tab-bankl ,

112 it_tab-bankn ,

132 it_tab-koinh ,

194 it_tab-banka ,

256 it_tab-provz ,

260 sy-vline.

.

endloop.

uline 1(86).

endform. " display_report

&----


*& Form header

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form header .

uline 1(86).

format color col_heading.

write :/1 sy-vline,

2 'VEN.NO',

12 'ACC' ,

18 'TITLE' ,

30 'NAME' ,

55 'ST',

58 'LAND' ,

72 'L' ,

76 'CUSTNO',

88 'CKI',

94 'BANKKEY',

112 'B.NO',

132 'ACC HOLDER NAME',

194 'BANK NAME',

256 'reg',

260 sy-vline.

endform. " header

&----


*& Form populate_bdc

&----


  • text

----


form populate_bdc .

loop at it_tab.

perform build_screen_details using 'SAPMF02K' '0105'.

*

perform build_fields using: 'BDC_OKCODE' '/00',

'RF02K-LIFNR' it_tab-lifnr,

'RF02K-KTOKK' it_tab-ktokk.

perform build_screen_details using 'SAPMF02K' '0110'.

perform build_fields using: 'BDC_OKCODE' '/00',

'LFA1-ANRED' it_tab-anred,

'LFA1-NAME1' it_tab-name1,

'LFA1-SORTL' it_tab-sortl,

'LFA1-LAND1' it_tab-land1,

'LFA1-SPRAS' it_tab-spras.

perform build_screen_details using 'SAPMF02K' '0120'.

perform build_fields using: 'BDC_OKCODE' '/00'.

perform build_screen_details using 'SAPMF02K' '0130'.

perform build_fields using: 'BDC_OKCODE' '=BANK',

'LFBK-BANKS(01)' it_tab-banks,

'LFBK-BANKL(01)' it_tab-bankl,

'LFBK-BANKN(01)' it_tab-bankn,

'LFBK-KOINH(01)' it_tab-koinh.

perform build_screen_details using 'SAPLBANK' '0100'.

perform build_fields using: 'BDC_OKCODE' '=ENTR',

'BNKA-BANKA' it_tab-banka,

'BNKA-PROVZ' it_tab-provz.

perform build_screen_details using 'SAPMF02K' '0130'.

perform build_fields using: 'BDC_OKCODE' '=UPDA'.

endloop.

call transaction 'FK01' using it_bdctab mode 'A' update

'S' messages into it_msgtab.

clear it_bdctab.

refresh it_bdctab.

loop at it_msgtab.

perform format_message.

endloop.

endform. " populate_bdc

&----


*& Form build_screen_details

&----


  • text

----


form build_screen_details using p_program type BDCDATA-PROGRAM

p_dynpro type BDCDATA-dynpro.

it_BDCtab-PROGRAM = p_program. " Program Name

it_BDCtab-DYNPRO = p_dynpro. " Screen Number

it_BDCtab-DYNBEGIN = 'X'. " New screen

Append it_bdctab.

clear it_bdctab.

endform. " build_screen_details

&----


*& Form build_fields

&----


  • text

----


form build_fields using p_fnam

p_fval.

it_BDCtab-FNAM = p_fnam.

it_BDCtab-FVAL = p_fval.

Append it_bdctab.

clear it_bdctab.

endform. " build_fields

&----


*& Form format_message

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form format_message .

call function 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = sy-langu

NO = SY-MSGNO

V1 = SY-MSGV1

V2 = SY-MSGV2

V3 = SY-MSGV3

V4 = SY-MSGV4

IMPORTING

MSG = it_msgtab

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.

endform. " format_message

&----


*& Form bdc_upload1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_upload1 .

data : v_file1 type string.

v_file1 = p_file1.

call function 'GUI_UPLOAD'

exporting

filename = v_file1

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_tab1

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

if sy-subrc <> 0.

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

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

endif.

endform. " bdc_upload1

&----


*& Form f4_get_help1

&----


  • text

----


  • -->P_P_FILE1 text

----


form f4_get_help1 using p_p_file1.

call function 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = p_p_file1

.

endform. " f4_get_help1

Regards,

Laxmi.

1 REPLY 1
Read only

Former Member
0 Likes
313

hi,

report zsh_recording_fk01 .

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

  • T A B L E S *

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

tables : lfa1 . " Vendor Master.

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

  • I N T E R N A L T A B L E - D E C L A R A T I O N *

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

data : begin of it_tab occurs 0,

lifnr(16), "account number of vendor

ktokk(4), "Vendor Number

anred(15), "Account Group

name1(35), "Name

sortl(10), "Sort field

land1(3) , "Land

spras(1), "Language Key

kunnr(10), "customer number

banks(3), "Bank country key

bankl(15), "Bank Key

bankn(18), "Bank Account Number

koinh(60), "Account Holder Name

banka(60), "Name of bank

provz(3), "region

end of it_tab.

data : begin of it_tab1 occurs 0,

banks(3), "Bank country key

bankl(15), "Bank Key

bankn(18), "Bank Account Number

koinh(60), "Account Holder Name

banka(60), "Name of bank

provz(3), "region

end of it_tab1.

DATA:it_BDCtab LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • ERROR MESSAGE TABLE

DATA:it_MSGtab LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

data: program type BDCDATA-PROGRAM,

dynpro type BDCDATA-dynpro,

fnam type BDCDATA-fnam,

fval type BDCDATA-fval.

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

  • S E L E C T I O N - S C R E E N *

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

selection-screen : begin of block bl1 with frame.

parameter : p_file type rlgrap-filename default

'C:\Vendor.txt.txt' obligatory,

p_file1 type rlgrap-filename default

'C:\Vendor1.txt.txt' obligatory.

selection-screen : end of block bl1.

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

  • A T S E L E C T I O N - S C R E E N *

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

at selection-screen on value-request for p_file.

  • to get F4 help for p_file

perform f4_get_help using p_file.

  • to get F4 help for p_file

perform f4_get_help1 using p_file1.

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

  • S T A R T O F S E L E C T I O N *

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

start-of-selection.

  • Uploading data from flat file into it_tab

perform bdc_upload.

perform bdc_upload1.

perform populate_bdc.

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

  • E N D O F S E L E C T I O N *

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

end-of-selection.

  • displaying fields which r uploaded from flat file.

perform display_report.

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

  • T O P _ O F _ P A G E *

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

top-of-page.

  • to display header in the report

perform header.

&----


*& Form f4_get_help

&----


  • text

----


  • -->P_P_FILE text

----


form f4_get_help using p_p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

importing

file_name = p_p_file.

.

endform. " f4_get_help

&----


*& Form bdc_upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_upload .

data: v_file type string.

v_file = p_file.

call function 'GUI_UPLOAD'

exporting

filename = v_file

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_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.

endform. " bdc_upload

&----


*& Form display_report

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_report .

uline 1(86).

loop at it_tab .

format color 2.

write :/1 sy-vline,

2 it_tab-lifnr,

12 it_tab-ktokk ,

18 it_tab-anred ,

30 it_tab-name1 ,

55 it_tab-sortl ,

58 it_tab-land1 ,

72 it_tab-spras ,

76 it_tab-kunnr ,

88 it_tab-banks ,

94 it_tab-bankl ,

112 it_tab-bankn ,

132 it_tab-koinh ,

194 it_tab-banka ,

256 it_tab-provz ,

260 sy-vline.

.

endloop.

uline 1(86).

endform. " display_report

&----


*& Form header

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form header .

uline 1(86).

format color col_heading.

write :/1 sy-vline,

2 'VEN.NO',

12 'ACC' ,

18 'TITLE' ,

30 'NAME' ,

55 'ST',

58 'LAND' ,

72 'L' ,

76 'CUSTNO',

88 'CKI',

94 'BANKKEY',

112 'B.NO',

132 'ACC HOLDER NAME',

194 'BANK NAME',

256 'reg',

260 sy-vline.

endform. " header

&----


*& Form populate_bdc

&----


  • text

----


form populate_bdc .

loop at it_tab.

perform build_screen_details using 'SAPMF02K' '0105'.

*

perform build_fields using: 'BDC_OKCODE' '/00',

'RF02K-LIFNR' it_tab-lifnr,

'RF02K-KTOKK' it_tab-ktokk.

perform build_screen_details using 'SAPMF02K' '0110'.

perform build_fields using: 'BDC_OKCODE' '/00',

'LFA1-ANRED' it_tab-anred,

'LFA1-NAME1' it_tab-name1,

'LFA1-SORTL' it_tab-sortl,

'LFA1-LAND1' it_tab-land1,

'LFA1-SPRAS' it_tab-spras.

perform build_screen_details using 'SAPMF02K' '0120'.

perform build_fields using: 'BDC_OKCODE' '/00'.

perform build_screen_details using 'SAPMF02K' '0130'.

perform build_fields using: 'BDC_OKCODE' '=BANK',

'LFBK-BANKS(01)' it_tab-banks,

'LFBK-BANKL(01)' it_tab-bankl,

'LFBK-BANKN(01)' it_tab-bankn,

'LFBK-KOINH(01)' it_tab-koinh.

perform build_screen_details using 'SAPLBANK' '0100'.

perform build_fields using: 'BDC_OKCODE' '=ENTR',

'BNKA-BANKA' it_tab-banka,

'BNKA-PROVZ' it_tab-provz.

perform build_screen_details using 'SAPMF02K' '0130'.

perform build_fields using: 'BDC_OKCODE' '=UPDA'.

endloop.

call transaction 'FK01' using it_bdctab mode 'A' update

'S' messages into it_msgtab.

clear it_bdctab.

refresh it_bdctab.

loop at it_msgtab.

perform format_message.

endloop.

endform. " populate_bdc

&----


*& Form build_screen_details

&----


  • text

----


form build_screen_details using p_program type BDCDATA-PROGRAM

p_dynpro type BDCDATA-dynpro.

it_BDCtab-PROGRAM = p_program. " Program Name

it_BDCtab-DYNPRO = p_dynpro. " Screen Number

it_BDCtab-DYNBEGIN = 'X'. " New screen

Append it_bdctab.

clear it_bdctab.

endform. " build_screen_details

&----


*& Form build_fields

&----


  • text

----


form build_fields using p_fnam

p_fval.

it_BDCtab-FNAM = p_fnam.

it_BDCtab-FVAL = p_fval.

Append it_bdctab.

clear it_bdctab.

endform. " build_fields

&----


*& Form format_message

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form format_message .

call function 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = sy-langu

NO = SY-MSGNO

V1 = SY-MSGV1

V2 = SY-MSGV2

V3 = SY-MSGV3

V4 = SY-MSGV4

IMPORTING

MSG = it_msgtab

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.

endform. " format_message

&----


*& Form bdc_upload1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_upload1 .

data : v_file1 type string.

v_file1 = p_file1.

call function 'GUI_UPLOAD'

exporting

filename = v_file1

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_tab1

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

if sy-subrc <> 0.

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

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

endif.

endform. " bdc_upload1

&----


*& Form f4_get_help1

&----


  • text

----


  • -->P_P_FILE1 text

----


form f4_get_help1 using p_p_file1.

call function 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = p_p_file1

.

endform. " f4_get_help1

Regards,

Laxmi.