‎2007 Dec 07 5:35 AM
Hi,
I am using BDC call transaction method in my report program. And if I schedule my report in background Please tell me how to handle errors.
‎2007 Dec 07 5:42 AM
data : it type table of BDCMSGCOLL With header line.
now in call transaction...
call trandaction 'xxxx' mode 'x' update 'x' messages into IT.
end-of-selection.
loop at it.
if it-msgtyp = 'e'.
write:/ 'message'.
endif.
endloop.
‎2007 Dec 07 5:46 AM
‎2007 Dec 07 5:48 AM
Hi Kishan,
If I am uploading lakhs of records. Will there be any problem?
‎2007 Dec 07 5:50 AM
We can handle the Errors in Call transaction method through BDCMSGCOLL Strcture and one Important function module is Format_message.
For Example :
DATA : BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE,
BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.
CALL TRANSACTION 'MM01' USING BDCDATA MODE N UPDATE S MESSAGES INTO BDCMSGCOLL.
IF SY-SUBRC <> 0.
PERFORM ERR.
CLEAR I_MSG.
REFRESH I_MSG.
ENDIF.
&----
*& Form ERR
&----
text
----
--> p1 text
<-- p2 text
----
form ERR .
DATA V_MSG(255) TYPE C.
READ TABLE I_MSG WITH KEY MSGTYP = 'E'.
IF SY-SUBRC = 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = I_MSG-MSGID
LANG = 'E'
NO = I_MSG-MSGNR
V1 = I_MSG-MSGV1
V2 = I_MSG-MSGV2
V3 = I_MSG-MSGV3
V4 = I_MSG-MSGV4
IMPORTING
MSG = V_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 V_MSG. " Error Message Displayed Here.
CLEAR V_MSG.
ENDIF.
endform. " ERR
‎2007 Dec 07 6:10 AM
I am using FORMAT_MESSAGE FM to capture errors.
It is not giving me the material no. It is just printing Material does not exist. How to get material no also in the error message?
‎2007 Dec 07 6:10 AM
hi!!!!!!!!!!!!!!!!!!!!!!
this link will help u ,
http://help.sap.com/saphelp_nw04/helpdata/en/fa/09714d543b11d1898e0000e8322d00/frameset.htm
SM36 - Define Background Jobs
SM37 - Background Jobs Overview
Execute transaction SM36
Define Job name, Job class, Target server
Click on 'START CONDITION' button
Click on 'Date/Time' button
Enter Scheduled start DATE & TIME. Check mark 'Periodic Job' field. Click on 'Period values' button and select 'Hourly' or 'Dialy' or 'Weekly' or 'Monthly' or Other period and SAVE. Go back to main screen.
Click on 'STEPS' button and enter Program name and Variant under box 'ABAP Program'. Click on 'Print Specification' button and enter Printer name under 'Output device' and SAVE
Click on SAVE button until you get message on bottom of the screen that describes 'Job XYZ saved with status: Scheduled'.
Click on 'Job overview' button or execute SM37 transaction.
Select the appropriate 'Job name', 'User name', 'Job Status' & Schedule date under 'Job start condition' and click on 'Execute' button or press F8.
You will now see all your scheduled JOBS.
In session method ,
Prerequisites
The ABAP program RSBDCSUB must be scheduled as a periodic job in the R/3 background processing system. RSBDCSUB checks for and starts any batch input sessions that have not yet been run. It schedules such sessions for immediate execution in the background processing system.
Procedure
Schedule RSBDCSUB to run periodically in one or more background jobs.
If you have regularly scheduled batch input runs, you can schedule separate jobs for each of the scheduled data transfers. The start time for the RSBDCSUB job can be set according to the batch input schedule. And you can use a variant to restrict RSBDCSUB only to the batch input sessions that you expect.
With RSBDCSUB, you can use all of the selection criteria offered on the batch input main menu to select sessions to run:
session name
date and time of generation
status: ready to run or held in the queue because of errors
Result
Batch input sessions are started automatically rather than by hand. The RSBDCSUB program can be set up to start all sessions that arrive in an R/3 System, or it can be fine-tuned to start only batch input sessions that you expect.
plz reward if useful..
‎2007 Dec 07 6:30 AM
if the call tranasaction for MM01 is successfully executed then it will create a materialno and the message will be with msgtyp = 'S'.
and in that message text : it will be shown as so and so materil 20000XX created.
in this case the generated material no can be catched with this statement also:
get parameter id 'MAT' field v_matnr.
( this is should be after call transaction statement )
‎2007 Dec 11 4:58 AM
Hi,
Here is a simple example for handling errors in BDC Call Transaction.
REPORT z_bdc01 NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE bdcrecx1.0
DATA : BEGIN OF itab OCCURS 1,
f1 TYPE lifnr,
f2 TYPE ekorg,
f3 TYPE ktokk,
f4 TYPE name1,
f5 TYPE sortl,
f6 TYPE land1,
f7 TYPE waers,
END OF itab.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA : END OF ITAB1.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename ='D:\sudhir\BDC.TXT'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
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.
LOOP AT ITAB.
REFRESH BDCDATA.
*perform open_group.
PERFORM bdc_dynpro USING 'SAPMF02K' '0107'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
ITAB-F1.
PERFORM bdc_field USING 'RF02K-EKORG'
ITAB-F2.
PERFORM bdc_field USING 'RF02K-KTOKK'
ITAB-F3.
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'
ITAB-F4.
PERFORM bdc_field USING 'LFA1-SORTL'
ITAB-F5.
PERFORM bdc_field USING 'LFA1-LAND1'
ITAB-F6.
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'
ITAB-F7.
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 MODE 'A' UPDATE 'S' MESSAGES INTO
ITAB1.
ENDLOOP.
LOOP AT ITAB1.
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 =
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 😕 ITAB1-MSGV1,
ITAB1-MSGV2,
ITAB1-MSGV3.
ENDLOOP.