Application Development 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: 

How to know if a Call Transaction was successful?

Former Member
0 Kudos

Hello

I want to know how can I validate if a Call Transaction finished successfully.

I know that a Call Transaction returns a message table with different type of messages (W, S, E, etc.).

My Call Transaction at the end is returning some S messages but it is not finishing successfully, so it is not the way I can validate this situation...

3 REPLIES 3

Former Member
0 Kudos

message s-> sucess.

error record .

loop at ii_bdcmsgcaoll into wa where msg = e.

call fuction format_message.

concatenate msgv1 msg2 into lt_error.

write'wite error record'.

endloop.

CALL TRANSACTION 'VD51' USING IT_BDC MODE 'A' UPDATE 'S'

MESSAGES INTO IT_MESSAGES.

IF NOT IT_MESSAGES[] IS INITIAL.

PERFORM FORMAT_MESSAGE.

ENDIF.

FORM FORMAT_MESSAGE.

DATA: L_MSG(100).

LOOP AT IT_MESSAGES.

READ TABLE IT_CUSTOMER INDEX L_INDEX.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = IT_MESSAGES-MSGID

LANG = SY-LANGU

NO = IT_MESSAGES-MSGNR

V1 = IT_MESSAGES-MSGV1

V2 = IT_MESSAGES-MSGV2

V3 = IT_MESSAGES-MSGV3

V4 = IT_MESSAGES-MSGV4

IMPORTING

MSG = L_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:/ l_msg.

ENDLOOP.

ENDFORM. " FORMAT_MESSAGE

Message was edited by:

Karthikeyan Pandurangan

naimesh_patel
Active Contributor
0 Kudos

Each call transaction gives you the message back in the message table. Due to you call transaction, some document has been created or changed.

Try to search for the message with type 'S' and has the same message number which is getting triggered when you have created the document.

Let's say you are creating a Sales order then your message table must have the message which says that "Order 1111 has been created". Find out the number of this message .. say V0 .. 011. Try to read your message table with this message number.

READ TABLE MESS_TAB WITH KEY MSGID = 'V0'
MSGNR = '011'.
IF SY-SUBRC = 0.
*   processed successful
else.
* error handling
endif.

Regards,

Naimesh Patel

Former Member
0 Kudos

hi,

this is full bdc call transaction method here i have used error msg also.

report Z_SN_BDC

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:\Documents and Settings\nehru\Desktop\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.

&----


*& Form ERROR

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form ERROR .

DATA: V_ER(250) TYPE C .

READ TABLE I_MSG WITH KEY MSGTYP = 'E'.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = '-D'

NO = SY-MSGNO

V1 = SY-MSGV1

V2 = SY-MSGV2

V3 = SY-MSGV3

V4 = SY-MSGV4

IMPORTING

MSG = V_ER

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:/ 'ERROR MSG', V_ER.

CLEAR:I_MSG, BDCDATA.

REFRESH: I_MSG , BDCDATA.

endform. " ERROR

if it usfull give reward.

thanks.