Powered By

Free XML Skins for Blogger

Powered by Blogger

Tuesday, October 7, 2008

SAP ABAP BDC 9

Error Analysis and Restart Capability

Unlike "classical" batch input processing using sessions, CALL TRANSACTION USING processing does not provide any special handling for incorrect transactions. There is no restart capability for transactions that contain errors or produce update failures.

You can handle incorrect transactions by using update mode S (synchronous updating) and checking the return code from CALL TRANSACTION USING. If the return code is anything other than 0, then you should do the following:


write out or save the message table
use the BDCDATA table that you generated for the CALL TRANSACTION USING to generate a batch input session for the faulty transaction. You can then analyze the faulty transaction and correct the error using the tools provided in the batch input management facility.

20) USING CALL DIALOG WITH BATCH INPUT:

A program that uses CALL DIALOG to submit batch input should perform the following steps:

1. For the screens you want processed, fill all desired fields.
2. Use a CALL DIALOG statement to call the dialog module and to pass it to the BDCDATA table.



The MODE parameter in the CALL statement is explained in Using CALL TRANSACTION USING for Batch Input(19).

Example

CALL DIALOG 'DIALOG1' USING BDCDATA MODE 'E'.


(21) DIRECT INPUT:

To enhance the batch input procedure, the system offers the direct input technique, especially for transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but stores the data directly. It does not process screens.

To enter the data into the corresponding database tables directly, the system calls a number of function modules that execute any necessary checks. In case of errors, the direct input technique provides a restart mechanism. However, to be able to activate the restart mechnism, direct input programs must be executed in the background only.

To maintain and start these programs, use program RBMVSHOW or the transaction BMV0.

Examples for direct input programs are:

Program Application

RFBIBL00 FI
RMDATIND MM
RVAFSS00 SD
RAALTD11 AM
RKEVEXT0 CO-PA
For more information, see the respective program documentation.

22) SAMPLE BATCH INPUT PROGRAM:

The following program demonstrates both the creation of sessions, and the use of CALL TRANSACTION USING.
REPORT RJBDC200 LINE-SIZE 120.
*----------------------------------------------------------------*
* Add a line in a report *
*----------------------------------------------------------------*
PARAMETERS : BDCTYPE TYPE C DEFAULT 'M',
" M = Create batch input session
" T = Call transaction
"---------------------------------------------------*
" Only used for batch input sessions *
"---------------------------------------------------*
GROUP(12) TYPE C DEFAULT 'BDCTEST',
" group name of session
USER(12) TYPE C DEFAULT SY-UNAME,
" user name for starting the
" session in background
KEEP(1) TYPE C,
" ' ' = delete session after processing
" 'X' = keep session after successful
" processing
HOLDDATE LIKE SY-DATUM,
"---------------------------------------------------*
" Only used for call transaction *
"---------------------------------------------------*
DMODE TYPE C DEFAULT 'A'.
" Display mode
" 'A' = display all screens
" 'E' = display only errors
" 'N' = display nothing
*----------------------------------------------------------------*
* Batch input data for a single transaction *
*----------------------------------------------------------------*
DATA: BEGIN OF BDCDATA OCCURS 0.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.
*----------------------------------------------------------------*
* Generate batch input *
* *
*----------------------------------------------------------------*
CASE BDCTYPE.
WHEN 'M'.
PERFORM CREATE_GROUP.
EXIT.
WHEN 'T'.
PERFORM CALL_TRANSACTION.
EXIT.
ENDCASE.
*----------------------------------------------------------------*
* *
* Create batch input session *
* *
*----------------------------------------------------------------*
FORM CREATE_GROUP.
WRITE: / 'Create group'.
"------------------------------------------------------------*
" Open batch input group *
"------------------------------------------------------------*
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GROUP
USER = USER
KEEP = KEEP
HOLDDATE = HOLDDATE.
WRITE: / 'BDC_OPEN_GROUP rc ='(999), SY-SUBRC.
"------------------------------------------------------------*
" Insert first transaction *
"------------------------------------------------------------*
PERFORM GEN_BDC_DATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'SE38'
TABLES
DYNPROTAB = BDCDATA.
WRITE: / 'BDC_INSERT rc ='(999), SY-SUBRC.
"------------------------------------------------------------*
" Insert second transaction *
"------------------------------------------------------------*
PERFORM GEN_BDC_DATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'SE38'
TABLES
DYNPROTAB = BDCDATA.
WRITE: / 'BDC_INSERT rc ='(999), SY-SUBRC.
"------------------------------------------------------------*
" Close batch input group *
"------------------------------------------------------------*
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: / 'BDC_CLOSE_GROUP rc ='(999), SY-SUBRC.
ENDFORM. " End CREATE_GROUP
*----------------------------------------------------------------*
* *
* Call Transaction Using *
* *
*----------------------------------------------------------------*
FORM CALL_TRANSACTION.
WRITE: / 'Call Transaction RC ='(999).
PERFORM GEN_BDC_DATA.
CALL TRANSACTION 'SE38' USING BDCDATA MODE DMODE MESSAGES INTO
MESSTAB.
WRITE: SY-SUBRC, SY-MSGTY, SY-MSGID, SY-MSGNO, SY-MSGV1.
WRITE: / ' ', SY-MSGV2.
WRITE: / ' ', SY-MSGV3.
WRITE: / ' ', SY-MSGV4.
ENDFORM. " End CALL_TRANSACTION
*----------------------------------------------------------------*
* *
* Create batch input data for *
* transaction SE38 *
* *
*----------------------------------------------------------------*
FORM GEN_BDC_DATA.
DATA: LINE LIKE BDCDATA-FVAL.
REFRESH BDCDATA.
*------------------------------------------------------------*
* First screen of transaction *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMS38M' '0100'.
PERFORM BDC_FIELD USING 'RS38M-PROGRAMM' 'RJBDC999'.
PERFORM BDC_FIELD USING 'bdc_cursor' 'chap'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
*------------------------------------------------------------*
* In editor, go to bottom of report *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMSEDT' '2310'.
PERFORM BDC_FIELD USING 'RSTXP-TDCOMMLINE' 'BOT'.
*------------------------------------------------------------*
* Insert line into report *
*----------------------------------------------------- ------*
PERFORM BDC_DYNPRO USING 'SAPMSEDT' '2310'.
PERFORM BDC_FIELD USING 'RSTXP-TDLINECOM(17)' 'I'.
*------------------------------------------------------------*
* Go to bottom of report again *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMSEDT' '2310'.
PERFORM BDC_FIELD USING 'RSTXP-TDCOMMLINE' 'BOT'.
*------------------------------------------------------------*
* Modify line in report and save report *
* (Enter f11 in ok-code) *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMSEDT' '2310'.
LINE = 'Batchinput'.
LINE+20 = SY-DATUM.
LINE+30 = SY-UZEIT.
PERFORM BDC_FIELD USING 'RSTXP-TDLINE(17)' LINE.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/11'.
*------------------------------------------------------------*
* Leave the editor (enter f3 in ok-code) *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMSEDT' '2310'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/3'.
*------------------------------------------------------------*

* Leave transaction se38 (enter f15 in *
* ok-code) *
*------------------------------------------------------------*
PERFORM BDC_DYNPRO USING 'SAPMS38M' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/15'.
ENDFORM. "End GEN_BDC_DATA
*----------------------------------------------------------------*
* *
* In the batch input data, start a new screen *
* *
*----------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "End BDC_DYNPRO
*----------------------------------------------------------------*
* *
* In the batch input data, insert a field *
* *
*----------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM.

------------------------------------------------------------------------------------------------

No comments:

Archives