Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BDC messages

how to retrieve all the messages of a bdc which will be displayed in the status bar while running the bdc. after we run the program we should display all those messages on the screen in a report program.

Tags:
Former Member
Former Member replied

<b>THIS IS CALL TRANSACTION METHOD.

TCODE 'MK01' WITH DISPLAY ERROR MESSAGE .</b>

no standard page heading line-size 255.

data: begin of itab occurs 0,

lifnr like lfa1-lifnr,

ekorg like lfm1-ekorg,

ktokk like lfa1-ktokk,

name1 like lfa1-name1,

sortl like lfa1-sortl,

end of itab.

data: bdcdata like bdcdata occurs 0 with header line,

i_msg like bdcmsgcoll occurs 0 with header line.

*include bdcrecx1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:/ITAB.TXT'

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = ITAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

start-of-selection.

*perform open_group.

LOOP AT ITAB.

perform bdc_dynpro using 'SAPMF02K' '0107'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

  • 'Di001'.

ITAB-LIFNR.

perform bdc_field using 'RF02K-EKORG'

  • '1000'.

ITAB-EKORG.

perform bdc_field using 'RF02K-KTOKK'

  • '0001'.

ITAB-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-LAND1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

  • 'nehru'.

ITAB-NAME1.

perform bdc_field using 'LFA1-SORTL'

  • 'NE'.

ITAB-SORTL.

perform bdc_field using 'LFA1-LAND1'

'in'.

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

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

'inr'.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

*perform bdc_transaction using 'MK01'.

*perform close_group.

CALL TRANSACTION 'MK01' USING BDCDATA

UPDATE 'A'

MODE 'A'

MESSAGES INTO I_MSG.

IF SY-SUBRC <> 0 .

PERFORM ERROR.

ENDIF.

CLEAR BDCDATA.

REFRESH BDCDATA.

ENDLOOP.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

  • IF FVAL <> NODATA.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

  • ENDIF.

ENDFORM.

<b>form ERR .

DATA V_MSG(255) TYPE C.

READ TABLE I_MSG WITH KEY MSGTYP = 'E'.

IF SY-SUBRC = 0.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = I_MSG-MSGID

LANG = 'E'

NO = I_MSG-MSGNR

V1 = I_MSG-MSGV1

V2 = I_MSG-MSGV2

V3 = I_MSG-MSGV3

V4 = I_MSG-MSGV4

IMPORTING

MSG = V_MSG

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

WRITE V_MSG. " Error Message Displayed Here.

CLEAR V_MSG.

ENDIF.

endform. " ERR</b>

The above Blocked Part for Handling Message Using <b>BDCMSGCOLL</b> Structure.

Regards,

Vijay

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question