To handle errors

Advertisement
November 30

Hi, if tr r 100 records to be updated, if  3, 52 and 99 records are failed ,what happens in case of session  and calltransaction method, how we can correct the errors in both cases and what happens they will update remaining fields or not.

Advertisement

Replay

hi,
if you use session u can check unprocessed records using SM35 tcode.In sm35 after processing the session you can check error log for unprocessed records depending up on the error message we can modify that particular record.
In the call transaction method we have to explicitly catch errors using BDCMSGCOLL and FORMAT_messages.
just check the below coding.
Handling errors in calltransaction using XK01 tcode.
REPORT  ZSR_BDC_CT_ERROR1.
TABLES : RF02K,LFA1.
DATA: BEGIN OF ITAB OCCURS 0,
         LIFNR LIKE RF02K-LIFNR,
         KTOKK LIKE RF02K-KTOKK,
         NAME1 LIKE LFA1-NAME1,
         SORTL LIKE LFA1-SORTL,
         LAND1 LIKE LFA1-LAND1,
         SPRAS LIKE LFA1-SPRAS,
      END OF ITAB.
DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
       BDCMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
INCLUDE BDCRECX1.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'z:\flatfiles\sr1.txt'
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
  HEADER_LENGTH                 = 0
  READ_BY_LINE                  = 'X'
  DAT_MODE                      = ' '
  CODEPAGE                      = ' '
  IGNORE_CERR                   = ABAP_TRUE
  REPLACEMENT                   = '#'
  CHECK_BOM                     = ' '
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.
*perform open_group.
LOOP AT ITAB.
PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0100'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                              'RF02K-KTOKK'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '/00'.
PERFORM BDC_FIELD       USING 'RF02K-LIFNR'
                              ITAB-LIFNR.
PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                              ITAB-KTOKK.
PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                              'LFA1-SPRAS'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '/00'.
PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                              ITAB-NAME1.
PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                              ITAB-SORTL.
PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                              ITAB-LAND1.
PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                              ITAB-SPRAS.
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' '0130'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                              'LFBK-BANKS(01)'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '=ENTR'.
PERFORM BDC_DYNPRO      USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                              '=YES'.
PERFORM BDC_TRANSACTION USING 'XK01'.
IF SY-SUBRC <> 0.
*LOOP AT bdcmsg.
*WRITE: bdcmsg-DYNAME,
      bdcmsg-DYNUMB,
      bdcmsg-MSGTYP,
      bdcmsg-MSGSPRA,
      bdcmsg-MSGID,
      bdcmsg-MSGNR,
      bdcmsg-MSGV1,
      bdcmsg-MSGV2,
      bdcmsg-MSGV3,
      bdcmsg-MSGV4.
*ENDLOOP.
READ TABLE BDCMSG WITH KEY MSGTYP = 'E'.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
   ID              = BDCMSG-MSGID
   LANG            = SY-LANGU
   NO              = BDCMSG-MSGNR
   V1              = BDCMSG-MSGV1
   V2              = BDCMSG-MSGV2
   V3              = BDCMSG-MSGV3
   V4              = BDCMSG-MSGV4
IMPORTING
   MSG             = BDCMSG-MSGV1
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 : / BDCMSG-MSGV1.
ENDIF.
ENDLOOP.
*perform close_group.

View 3 Replies

Tags:

  1. B8000_A422_000_085_140402_WW_WIFI
  2. nokia n81 stuck on nokia logo
  3. A422_000_085_140402_WW_WIFI
  4. Profitability Segment Number service PO
  5. in report manager scroll issues in ssrs
  6. BAPI_OUTB_DELIVERY_CREATE_STO
  7. lateru2t
  8. youhm5
  9. famous498
  10. gardengt4
Copyrights 2019 Fcffair BigData Resource, All rights reserved