2006 Nov 27 6:04 AM
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.
2006 Nov 27 9:09 AM
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
2006 Nov 27 6:11 AM
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.
2006 Nov 27 9:04 AM
Hi Shweta,
Go through this link and u can find enough info with specimen code for generating error report in BDC:
Hope this helps
Sandeep
2006 Nov 27 9:09 AM
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