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

how to create error session in bdc call transaction method.

Former Member
0 Likes
603

hi all,

i have to update or create some table fields of a table depending upon the selection criteria.

now, if there is any error in updating or creating the record i have to generate an error session.

in the report output i have to display all the records which could not get updated or created.

i have to use bdc call transaction method.

thanks in advance.

shweta.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
543

hi,

after you write ur call transaction statment check for sy-subrc. coz CTU returns sy-subrc.

hence

if sy-subrc <> 0.

if p_flag = ' '.

bdc_open_group.

...

...

p_flag = 'X'.

endif.

bdc_insert.

....

...

...

..

endif.

endloop.

if p_flag = 'X'.

bdc_close_group.

endif.

p_flag is to make sure u create only one session.

santhosh

hi all,

i have to update or create some table fields of a table depending upon the selection criteria.

now, if there is any error in updating or creating the record i have to generate an error session.

in the report output i have to display all the records which could not get updated or created.

i have to use bdc call transaction method.

thanks in advance.

shweta.

3 REPLIES 3
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
543

Hi,

In call transaction you can see the error by using message_text_build function module.

DATA: W_TEXTOUT LIKE T100-TEXT.

DATA : T_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE. DATA: T_MESSTAB TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

CALL TRANSACTION "VA01' USING T_BDCDATA MODE 'N'

UPDATE 'S'

MESSAGES INTO T_MESSTAB.

if sy-subrc ne 0.

LOOP AT T_MESSTAB.

CLEAR T_ERROR.

IF T_MESSTAB-MSGTYP = 'E'.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

MSGID = T_MESSTAB-MSGID

MSGNR = T_MESSTAB-MSGNR

MSGV1 = T_MESSTAB-MSGV1

MSGV2 = T_MESSTAB-MSGV2

MSGV3 = T_MESSTAB-MSGV3

MSGV4 = T_MESSTAB-MSGV4

IMPORTING

MESSAGE_TEXT_OUTPUT = W_TEXTOUT.

IF SY-SUBRC = 0.

MOVE : T_MAIN-PERNR TO T_ERROR-PERNR,

T_MAIN-AMOUNT TO T_ERROR-AMOUNT,

T_MAIN-W_TYPE TO T_ERROR-W_TYPE,

W_TEXTOUT TO T_ERROR-ERROR.

APPEND T_ERROR.

CLEAR T_ERROR.

DELETE T_MAIN.

DELETE T_MESSTAB.

G_ERRCOUNT = G_ERRCOUNT + 1.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

endif.

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
543

Hi Shweta,

Go through this link and u can find enough info with specimen code for generating error report in BDC:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f562eb90-0201-0010-5ba8-ecdce4de...

Hope this helps

Sandeep

Read only

Former Member
0 Likes
544

hi,

after you write ur call transaction statment check for sy-subrc. coz CTU returns sy-subrc.

hence

if sy-subrc <> 0.

if p_flag = ' '.

bdc_open_group.

...

...

p_flag = 'X'.

endif.

bdc_insert.

....

...

...

..

endif.

endloop.

if p_flag = 'X'.

bdc_close_group.

endif.

p_flag is to make sure u create only one session.

santhosh