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: 

BDC

Former Member
0 Kudos
109

Hi Experts,

Is there any system variable which is returned after BDC is performed. For example for below code

perform bdc_dynpro using 'SAPMP50A' '1000'.

perform bdc_field using 'BDC_OKCODE' '=INS'.

perform bdc_field using 'RP50G-PERNR' it-pernr.

perform bdc_field using 'RP50G-TIMR6' 'X'.

perform bdc_field using 'RP50G-BEGDA' it-begda.

perform bdc_field using 'RP50G-ENDDA' it-endda.

perform bdc_field using 'RP50G-CHOIC' '2006'.

perform bdc_field using 'RP50G-SUBTY' it-ktart.

perform bdc_dynpro using 'MP200000' '2250'.

perform bdc_field using 'BDC_OKCODE' '=UPD'.

perform bdc_field using 'P2006-BEGDA' it-begda.

perform bdc_field using 'P2006-ENDDA' it-endda.

perform bdc_field using 'P2006-KTART' it-ktart.

perform bdc_field using 'P2006-DESTA' it-begda.

perform bdc_field using 'P2006-DEEND' it-endda.

perform bdc_transaction using 'PA30'.

What is the possible variable i should use to see if BDC was successfull else generate log file for errors. As we use sy-subrc for select.

Thank you.

Regards,

Admir.

Points will be rewarded.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
56

Hello,

If u r using the call transaction method then sy-subrc will be returned.

Else u can capture the message into the message table.


Addition 2d 
... MESSAGES INTO itab 


Effect 
Any messages that occur during CALL TRANSACTION USING ... are collected in the specified internal table. The internal table must have the structure BDCMSGCOLL. 



Example
DATA: BDCDATA TYPE TABLE OF BDCDATA. 

DATA: ITAB TYPE TABLE OF BDCMSGCOLL. 

DATA: PROGRAM LIKE SY-REPID, 

      WA_BDCDATA TYPE BDCDATA. 

WA_BDCDATA-PROGRAM  = 'SAPMS38M'. 
WA_BDCDATA-DYNPRO   = '0100'. 
WA_BDCDATA-DYNBEGIN = 'X'. 
APPEND WA_BDCDATA TO BDCDATA. 
CLEAR WA_BDCDATA. 
WA_BDCDATA-FNAM     = 'RS38M-PROGRAMM'. 
WA_BDCDATA-FVAL     = PROGRAM. 
APPEND WA_BDCDATA TO BDCDATA. 
... 
CALL TRANSACTION 'SE38'  USING BDCDATA  MODE 'N' 
                         MESSAGES INTO ITAB. 


REgards,

VAsanth

3 REPLIES 3

Former Member
0 Kudos
56

use BDCMSGCOLL Strcure

call transaction tcode using bdcdata mode 'A/E/N'

messages into i_bdcmsg.

here i_bdcmsg is bdcmsgcoll ,you will get log records

Former Member
0 Kudos
57

Hello,

If u r using the call transaction method then sy-subrc will be returned.

Else u can capture the message into the message table.


Addition 2d 
... MESSAGES INTO itab 


Effect 
Any messages that occur during CALL TRANSACTION USING ... are collected in the specified internal table. The internal table must have the structure BDCMSGCOLL. 



Example
DATA: BDCDATA TYPE TABLE OF BDCDATA. 

DATA: ITAB TYPE TABLE OF BDCMSGCOLL. 

DATA: PROGRAM LIKE SY-REPID, 

      WA_BDCDATA TYPE BDCDATA. 

WA_BDCDATA-PROGRAM  = 'SAPMS38M'. 
WA_BDCDATA-DYNPRO   = '0100'. 
WA_BDCDATA-DYNBEGIN = 'X'. 
APPEND WA_BDCDATA TO BDCDATA. 
CLEAR WA_BDCDATA. 
WA_BDCDATA-FNAM     = 'RS38M-PROGRAMM'. 
WA_BDCDATA-FVAL     = PROGRAM. 
APPEND WA_BDCDATA TO BDCDATA. 
... 
CALL TRANSACTION 'SE38'  USING BDCDATA  MODE 'N' 
                         MESSAGES INTO ITAB. 


REgards,

VAsanth

manubhutani
Active Contributor
0 Kudos
56

Hi.. See this code

FORM bdc_transaction tables return USING tcode p_rule.

*DATA : T_BDCMSGCOLL LIKE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE.

CLEAR w_ctu_params.

w_ctu_params-dismode = 'N'.

w_ctu_params-updmode = 'S'.

w_ctu_params-cattmode = ' '.

w_ctu_params-defsize = ' '.

w_ctu_params-racommit = ' '.

w_ctu_params-nobinpt = 'X'.

w_ctu_params-nobiend = ' '.

CALL TRANSACTION tcode USING t_bdcdata OPTIONS FROM w_ctu_params

MESSAGES INTO t_bdcmsgcoll.

IF sy-subrc = 0.

IF p_rule = 'P'.

  • Add 1 to successful PWS creation

new_pws = new_pws + 1.

  • Add 1 to successful WSR creation

ELSEIF p_rule = 'W'.

new_wsr = new_wsr + 1.

ENDIF.

  • On successful WSR creation, create selection table for submit to

  • RPTSHF00 (to generate WSR)

IF new_wsr > 0.

PERFORM create_sel_tab.

ENDIF.

REFRESH t_bdcdata.

ELSE.

loop at t_bdcmsgcoll.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = t_bdcmsgcoll-msgid

LANG = SY-LANGU

NO = t_bdcmsgcoll-msgnr

V1 = t_bdcmsgcoll-MSGV1

V2 = t_bdcmsgcoll-MSGV2

V3 = t_bdcmsgcoll-MSGV3

V4 = t_bdcmsgcoll-MSGV4

IMPORTING

MSG = err_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.

move err_msg to w_return-message.

append w_return to return.

endloop.

errors can be displayed like this..

Please reward points if helpful