‎2007 Oct 17 10:39 AM
Hi all ,
Suppose in doin BDC CALL TARANSACTION PROGRAM I<b> am passing a wrong data from input file ,</b> may be for that data the table cannt be updated n that is the 2nd data in input file 1st is ok and 3rd n 4th data are also fine , but only <b>2nd data is creatin problem ,</b> now hw to handle the situation ?So that my program runs well in back groungd with out user intervension ...
Plz help
‎2007 Oct 17 10:47 AM
In such a case better to use LSMW and run ,
it will update the non error records.
in BDC try to run in call transaction Mode 'N".
it may help you.
reward if useful.
Amit Singla
‎2007 Oct 17 10:42 AM
You can validate the data before the call transaction. If the validation fails then do not do the call.
If this solves your query pl mark this question answered else give more details so that we can understand better.
Regards.
‎2007 Oct 17 10:44 AM
Ok before transaction i can verify , btfor hundreads of data i cant do , and even i may not know which no data is not valid . In that case what to do ?
‎2007 Oct 17 10:50 AM
Use this code for reference... call transaction done for CO11n
______________________________________________________
CALL TRANSACTION 'CO11N' USING it_bdcdata
MODE 'n'
UPDATE c_update
MESSAGES INTO it_messtab.
If CO11n (confirmation) is a SUCCESS
IF NOT it_messtab[] IS INITIAL.
READ TABLE it_messtab INTO wa_messtab WITH KEY msgtyp = 'S'.
IF sy-subrc EQ 0.
Palletization process
PERFORM palletization.
ELSE.
READ TABLE it_messtab INTO wa_messtab WITH KEY msgtyp = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = wa_messtab-msgid
lang = sy-langu
no = wa_messtab-msgnr
v1 = wa_messtab-msgv1
v2 = wa_messtab-msgv2
v3 = wa_messtab-msgv3
v4 = wa_messtab-msgv4
IMPORTING
msg = wa_msg.
wa_prodord_conf-errortext = wa_msg.
MODIFY it_prodord_conf FROM wa_prodord_conf.
ENDIF. "IF sy-subrc EQ 0
ENDIF. " IF sy-subrc EQ 0
ENDIF. "IF NOT it_messtab[] IS INITIAL
_________________________________________________________________
This shud help u.
PS: Reward if helpful.
‎2007 Oct 17 10:43 AM
only for the 2nd record u get sy-subrc <> 0 for call transaction.
then u handle it by creating a session or use format_message and dispaly the error as output in ur report program......as u said it is background program!!!!!
for rest of the cases u will get sy-subrc = 0 for the call transaction statement.....so no problem!!!
Regards
Vasu
‎2007 Oct 17 10:47 AM
In such a case better to use LSMW and run ,
it will update the non error records.
in BDC try to run in call transaction Mode 'N".
it may help you.
reward if useful.
Amit Singla
‎2007 Oct 17 10:48 AM
Hi
the error handling will be done like this
Error Handling
Write an error report.
Send the record(s) in error to an error file.
Create a batch input session with the record(s) in error.
To store error messages ( CALL TRANSACTION )
data: begin of Tab_Mess occurs 0.
include structure bdcmsgcoll.
data : end of Tab_Mess,
CALL TRANSACTION FK02 USING BDC_TAB MODE N UPDATE S
MESSAGES INTO TAB_MESS.
IF SY-SUBRC NE 0.
WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,
Tab_MESS-MSGID.
ENDIF.
reward if usefull
‎2007 Oct 17 10:48 AM
Hi ,
There is nothing to worry about the particular error in the record.
If you run the BDC (either call transaction or Session ) in background, all the correct records will get updated in database and all the error records will not be updated irrespective of the position of the records.
In case of call transaction the log will be displayed at the end of BDC.
In case of Session method the log will be stored in the log file with that session name.
With this you can execute the BDC onceagain with the corrected records
‎2007 Oct 17 10:48 AM
call transaction using N mode...
CALL TRANSACTION 'PA30' USING it_bdcdata MODE 'N'
UPDATE 'A' MESSAGES INTO it_bdcmsg.
‎2007 Oct 17 10:52 AM
Hello Debroy,
YOu have to suplly an internal table to the call transaction which would be filled up with the messages that are populated in the transaction like this:
data: it_bdcmsgcoll type standard table of bdcmsgcoll occurs 0 with header line.
call transaction <tcode> using it_bdcdata messages into it_bdcmsgcoll.
if sy-subrc <> 0.
loop at it_bdcmsgcoll.
call function 'FORMAT_MESSAGE'
.
.
EXPORTING message = lv_msg.
write:/ lv_msg.
endloop.
endif.
This way you can have a list of records that have errors and what errro is that.
With Regards,
Vidya
‎2007 Oct 17 10:53 AM
Hello ,
Check this....
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
With Regards,
Vidya