Handling errors in bdc

Hi,
How to handle errors in bdc call transaction method.
what is the steps to download errors from bdcmsgcoll into flat file  in call transaction method
uday

Hi friend,
  Here is a beautiful example which explains how to trap erroreneous records ..if help full then please give me max reward point.
REPORT  zgopi_report
NO STANDARD PAGE HEADING
                        LINE-SIZE 255
                        MESSAGE-ID ZRASH.
                Internal Table Declarations                          *
*--Internal Table for Data Uploading.
DATA : BEGIN OF IT_FFCUST OCCURS 0,
         KUNNR(10),
         BUKRS(4),
         KTOKD(4),
         ANRED(15),
         NAME1(35),
         SORTL(10),
         STRAS(35),
         ORT01(35),
         PSTLZ(10),
         LAND1(3),
         SPRAS(2),
         AKONT(10),
       END OF IT_FFCUST.
*--Internal Table to Store Error Records.
DATA : BEGIN OF IT_ERRCUST OCCURS 0,
         KUNNR(10),
         EMSG(255),
       END OF IT_ERRCUST.
*--Internal Table to Store Successful Records.
DATA : BEGIN OF IT_SUCCUST OCCURS 0,
         KUNNR(10),
         SMSG(255),
       END OF IT_SUCCUST.
*--Internal Table for Storing the BDC data.
DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*--Internal Table for storing the messages.
DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_FLAG1(1) VALUE ' ',
"Flag used for opening session.
       V_TLINES LIKE SY-TABIX,
       "For storing total records processed.
       V_ELINES LIKE SY-TABIX,
       "For storing the no of error records.
       V_SLINES LIKE SY-TABIX.
       "For storing the no of success records.
         Selection screen                                            *
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
             V_SESNAM  LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
         Start-of-selection                                          *
START-OF-SELECTION.
*-- Form to upload flatfile data into the internal table.
  PERFORM FORM_UPLOADFF.
       TOP-OF-PAGE                                                   *
TOP-OF-PAGE.
  WRITE:/ 'Details of the error and success records for the transaction'
  ULINE.
  SKIP.
         End of Selection                                            *
END-OF-SELECTION.
*-- Form to Generate a BDC from the Uploaded Internal table
  PERFORM FORM_BDCGENERATE.
*--To write the totals and the session name.
  PERFORM FORM_WRITEOP.
*&      Form  form_uploadff
    Form to upload flatfile data into the internal table.
FORM FORM_UPLOADFF .
*--Variable to change the type of the parameter file name.
  DATA : LV_FILE TYPE STRING.
  LV_FILE = V_FNAME.
*--Function to upload the flat file to the internal table.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      =  LV_FILE
    FILETYPE                      = 'ASC'
      HAS_FIELD_SEPARATOR           = 'X'
    HEADER_LENGTH                 = 0
    READ_BY_LINE                  = 'X'
    DAT_MODE                      = ' '
  IMPORTING
    FILELENGTH                    =
    HEADER                        =
    TABLES
      DATA_TAB                      = IT_FFCUST
    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.
*--Deleting the headings from the internal table.
    DELETE IT_FFCUST INDEX 1.
*--Getting the total number of records uploaded.
    DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
  ENDIF.
ENDFORM.                    " form_uploadff
*&      Form  Form_bdcgenerate
    Form to Generate a BDC from the Uploaded Internal table
FORM FORM_BDCGENERATE .
*--Generating the BDC table for the fields of the internal table.
  LOOP AT IT_FFCUST.
    PERFORM POPULATEBDC USING :
                                'X' 'SAPMF02D' '0105',
                                ' ' 'BDC_OKCODE'  '/00' ,
                                ' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
                                ' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
                                ' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
                                'X' 'SAPMF02D' '0110' ,
                                ' ' 'BDC_OKCODE'  '/00',
                                ' ' 'KNA1-ANRED'  IT_FFCUST-ANRED,
                                ' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
                                ' ' 'KNA1-SORTL'  IT_FFCUST-SORTL,
                                ' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
                                ' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
                                ' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
                                ' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
                                ' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
                                'X' 'SAPMFO2D' '0120', 
                                ' ' 'BDC_OKCODE'  '/00',
                                'X' 'SAPMF02D' '0125',
                                ' ' 'BDC_OKCODE'  '/00',
                                'X' 'SAPMF02D' '0130',
                                ' ' 'BDC_OKCODE'  '=ENTR',
                                'X' 'SAPMF02D' '0340', 
                                ' ' 'BDC_OKCODE'  '=ENTR',
                                'X' 'SAPMF02D' '0360',
                                ' ' 'BDC_OKCODE'  '=ENTR',
                                'X' 'SAPMF02D' '0210',
                                ' ' 'KNB1-AKONT'  IT_FFCUST-AKONT,
                                ' ' 'BDC_OKCODE'  '/00',
                                'X' 'SAPMF02D' '0215',
                                ' ' 'BDC_OKCODE'  '/00',
                                'X' 'SAPMF02D' '0220', 
                                ' ' 'BDC_OKCODE'  '/00',
                                'X' 'SAPMF02D' '0230',
                                ' ' 'BDC_OKCODE'  '=UPDA'.
*--Calling the transaction 'fd01'.
    CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
    MESSAGES INTO IT_CUSTMSG.
    IF SY-SUBRC <> 0.
*--Populating the error records internal table.
      IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
      APPEND IT_ERRCUST.
      CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
      IF V_FLAG1 = ' '.
        PERFORM FORM_OPENSESSION.
        V_FLAG1 = 'X'.
      ENDIF.
*--Inserting the error records into already open session.
      IF V_FLAG1 = 'X'.
        PERFORM FORM_INSERT.
      ENDIF.
*--Populating the Success records internal table.
    ELSE.
      IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
      APPEND IT_SUCCUST.
      CLEAR IT_SUCCUST.
    ENDIF.
*--Displaying the messages.
    IF NOT IT_CUSTMSG[] IS INITIAL.
      PERFORM FORM_FORMATMSG.
    ENDIF.
*--Clearing the message and bdc tables.
    CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
  ENDLOOP.
*--Getting the total no of error records.
  DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
  DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
  IF V_FLAG1 = 'X'.
    PERFORM FORM_CLOSESESS.
  ENDIF.
ENDFORM.                    " Form_bdcgenerate
*&      Form  populatebdc
      FOrm to Populate the BDC table.
FORM POPULATEBDC  USING    VALUE(P_0178)
                           VALUE(P_0179)
                           VALUE(P_0180).
  IF P_0178 = 'X'.
    IT_CUSTBDC-PROGRAM = P_0179.
    IT_CUSTBDC-DYNPRO = P_0180.
    IT_CUSTBDC-DYNBEGIN = 'X'.
  ELSE.
    IT_CUSTBDC-FNAM = P_0179.
    IT_CUSTBDC-FVAL = P_0180.
  ENDIF.
  APPEND IT_CUSTBDC.
  CLEAR IT_CUSTBDC.
ENDFORM.                    " populatebdc
*&      Form  FORM_OPENSESSION
      Form to Open a session.
FORM FORM_OPENSESSION .
*--Variable to convert the given session name into reqd type.
  DATA : LV_SESNAM(12).
  LV_SESNAM = V_SESNAM.
*--Opening a session.
  CALL FUNCTION 'BDC_OPEN_GROUP'
   EXPORTING
     CLIENT                    = SY-MANDT
     GROUP                     = LV_SESNAM
     HOLDDATE                  = '20040805'
     KEEP                      = 'X'
     USER                      = SY-UNAME
     PROG                      = SY-CPROG
IMPORTING
   QID                       =
   EXCEPTIONS
     CLIENT_INVALID            = 1
     DESTINATION_INVALID       = 2
     GROUP_INVALID             = 3
     GROUP_IS_LOCKED           = 4
     HOLDDATE_INVALID          = 5
     INTERNAL_ERROR            = 6
     QUEUE_ERROR               = 7
     RUNNING                   = 8
     SYSTEM_LOCK_ERROR         = 9
     USER_INVALID              = 10
     OTHERS                    = 11
  IF SY-SUBRC <> 0.
    WRITE :/ 'Session not open'.
  ENDIF.
ENDFORM.                    " FORM_OPENSESSION
*&      Form  FORM_INSERT
      fORM TO INSERT ERROR RECOED INTO A SESSION.
FORM FORM_INSERT .
*--Inserting the record into session.
  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      TCODE                  = 'FD01'
    POST_LOCAL             = NOVBLOCAL
    PRINTING               = NOPRINT
    SIMUBATCH              = ' '
    CTUPARAMS              = ' '
    TABLES
      DYNPROTAB              = IT_CUSTBDC
    EXCEPTIONS
      INTERNAL_ERROR         = 1
      NOT_OPEN               = 2
      QUEUE_ERROR            = 3
      TCODE_INVALID          = 4
      PRINTING_INVALID       = 5
      POSTING_INVALID        = 6
      OTHERS                 = 7
  IF SY-SUBRC <> 0.
    WRITE :/ 'Unable to insert the record'.
  ENDIF.
ENDFORM.                    " FORM_INSERT
*&      Form  FORM_CLOSESESS
      Form to Close the Open Session.
FORM FORM_CLOSESESS .
  CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
      NOT_OPEN    = 1
      QUEUE_ERROR = 2
      OTHERS      = 3.
  IF SY-SUBRC <> 0.
  ENDIF.
ENDFORM.                    " FORM_CLOSESESS
*&      Form  FORM_FORMATMSG
      Form to format messages.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
  DATA : LV_MSG(255).
  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      ID        = SY-MSGID
      LANG      = SY-LANGU
      NO        = SY-MSGNO
      V1        = SY-MSGV1
      V2        = SY-MSGV2
      V3        = SY-MSGV3
      V4        = SY-MSGV4
    IMPORTING
      MSG       = LV_MSG
    EXCEPTIONS
      NOT_FOUND = 1
      OTHERS    = 2.
  IF SY-SUBRC = 0.
    WRITE :/ LV_MSG.
  ENDIF.
  ULINE.
ENDFORM.                    " FORM_FORMATMSG
*&      Form  form_writeop
      To write the totals and the session name.
FORM FORM_WRITEOP .
  WRITE :/ 'Total Records Uploaded :',V_TLINES,
           / 'No of Error Records :',V_ELINES,
           / 'No of Success Records :',V_SLINES,
           / 'Name of the Session :',V_SESNAM.
  ULINE.
ENDFORM.                    " form_writeop

Similar Messages

  • Handling errors in BDC/ Call transaction

    Hi,
    I have an excel sheet to upload using BDC.. I am validating the contents of the excel sheet before calling the BDC session and populating the errors. Now after the call transaction statement the BDCMSGCOll is getting populated... I am also collecting all these errors in the error tab...
    In the excel sheet the 3 & 4 row are having transaction errors for eg. "This entry already exits"... or Specify correct date... But in my output the 4th record is getting populated twice... I want the 3rd & the 4th record with correct reasons in the error tab. Please suggest

    Hi Ravi,
    I am writing
        LOOP AT MESSTAB WHERE MSGTYP = 'E'.
          CALL FUNCTION 'MESSAGE_TEXT_BUILD'
            EXPORTING
              MSGID               = MESSTAB-MSGID
              MSGNR               = MESSTAB-MSGNR
              MSGV1               = MESSTAB-MSGV1
              MSGV2               = MESSTAB-MSGV2
              MSGV3               = MESSTAB-MSGV3
              MSGV4               = MESSTAB-MSGV4
            IMPORTING
              MESSAGE_TEXT_OUTPUT = W_TEXTOUT.
        ENDLOOP.
      Build error table ready for output
    If sy-subrc = 0.
        MOVE : v_ctr           to t_error-ctr,
               T_INPUT-KURST   TO T_ERROR-KURST,
               T_INPUT-GDATU   TO T_ERROR-GDATU,
               T_INPUT-FCURR   TO T_ERROR-FCURR,
               T_INPUT-TCURR   TO T_ERROR-TCURR,
               T_INPUT-INUKURS TO T_ERROR-INUKURS,
               T_INPUT-DUKURS  TO T_ERROR-DUKURS,
               W_TEXTOUT       TO T_ERROR-MSG.
        APPEND T_ERROR.
        CLEAR: T_ERROR.
    endif.
    Perform to close the BDC session.
        PERFORM CLOSE_GROUP.

  • In call transaction how can we handle error records.

    hai..tellme how can we handle error records in call transaction..we can get error records into one flatfile ok...then we have to execute the same bdc program with dat flat file (error records) once again...is it wright ..

    Hi,
    check this program u will get idea
    seee this prog. its will help u .
    copy and run this prog.
    TYPES : BEGIN OF t_disp ,
    vendorno(9),
    compcc(13),
    purchorg(14),
    accgroup(15),
    title(7),
    name(5),
    country(8),
    ordcurr(14),
    END OF t_disp.
    TYPES : BEGIN OF t_err,
    msgtyp LIKE bdcmsgcoll-msgtyp,
    l_mstring(250),
    END OF t_err.
    DATA: i_disp TYPE STANDARD TABLE OF t_disp,
    wa_disp TYPE t_disp,
    i_err TYPE STANDARD TABLE OF t_err,
    wa_err TYPE t_err.
    data definition
    Batchinputdata of single transaction
    DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
    messages of call transaction
    DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
    error session opened (' ' or 'X')
    DATA: e_group_opened.
    message texts
    TABLES: t100.
    PARAMETER : p_file1 LIKE ibipparms-path,
    p_cmode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    *selction screen.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file1.
    AT SELECTION-SCREEN ON p_file1.
    IF p_file1 IS INITIAL.
    MESSAGE 'FILE IS NOT FOUND' TYPE 'E'.
    ENDIF.
    START-OF-SELECTION.
    PERFORM f_disp_file1.
    END-OF-SELECTION.
    PERFORM f_disp_errs.
    *& Form F_DISP_FILE1
    text
    --> p1 text
    <-- p2 text
    FORM f_disp_file1 .
    DATA: l_filename1 TYPE string.
    MOVE p_file1 TO l_filename1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = l_filename1
    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 = i_disp
    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.
    *? prepare BDC data
    DELETE i_disp INDEX 1.
    LOOP AT i_disp INTO wa_disp .
    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'
    wa_disp-vendorno.
    'ztest_1'.
    PERFORM bdc_field USING 'RF02K-BUKRS'
    wa_disp-compcc.
    '0001'.
    PERFORM bdc_field USING 'RF02K-EKORG'
    wa_disp-purchorg.
    '0001'.
    PERFORM bdc_field USING 'RF02K-KTOKK'
    wa_disp-accgroup.
    '0001'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFA1-SPRAS'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_field USING 'LFA1-ANRED'
    wa_disp-title.
    'Mr.'.
    PERFORM bdc_field USING 'LFA1-NAME1'
    wa_disp-name.
    'test name'.
    PERFORM bdc_field USING 'LFA1-SORTL'
    'TEST NAME'.
    PERFORM bdc_field USING 'LFA1-LAND1'
    wa_disp-country.
    'in'.
    PERFORM bdc_field USING 'LFA1-SPRAS'
    'en'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFA1-KUNNR'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB1-AKONT'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB1-ZTERM'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFB5-MAHNA'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=VW'.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
    PERFORM bdc_field USING 'BDC_CURSOR'
    'LFM1-WAERS'.
    PERFORM bdc_field USING 'BDC_OKCODE'
    '=UPDA'.
    PERFORM bdc_field USING 'LFM1-WAERS'
    wa_disp-ordcurr.
    'inr'.
    PERFORM bdc_transaction USING 'XK01'.
    WRITE:/ WA_DISP-VendorNo,
    WA_DISP-COMPCC,
    WA_DISP-PURCHORG,
    WA_DISP-ACCGROUP,
    WA_DISP-title,
    WA_DISP-name,
    WA_DISP-country,
    WA_DISP-ORDCURR.
    CLEAR: wa_disp.
    REFRESH bdcdata.
    ENDLOOP.
    ENDFORM. " F_DISP_FILE1
    Start new screen *
    FORM bdc_dynpro USING program dynpro.
    CLEAR bdcdata.
    bdcdata-program = program.
    bdcdata-dynpro = dynpro.
    bdcdata-dynbegin = 'X'.
    APPEND bdcdata.
    ENDFORM. "BDC_DYNPRO
    Insert field *
    FORM bdc_field USING fnam fval.
    IF FVAL NODATA.
    CLEAR bdcdata.
    bdcdata-fnam = fnam.
    bdcdata-fval = fval.
    APPEND bdcdata.
    ENDIF.
    ENDFORM. "BDC_FIELD
    *& Form bdc_transaction
    text
    -->P_0322 text
    FORM bdc_transaction USING tcode.
    DATA: l_mstring(480),
    l_subrc LIKE sy-subrc.
    REFRESH messtab.
    CALL TRANSACTION tcode USING bdcdata
    MODE p_cmode
    UPDATE 'L'
    MESSAGES INTO messtab.
    l_subrc = sy-subrc.
    IF SMALLLOG 'X'.
    WRITE: / 'CALL_TRANSACTION',
    TCODE,
    'returncode:'(I05),
    L_SUBRC,
    'RECORD:',
    SY-INDEX.
    LOOP AT messtab.
    SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
    AND arbgb = messtab-msgid
    AND msgnr = messtab-msgnr.
    IF sy-subrc = 0.
    l_mstring = t100-text.
    IF l_mstring CS '&1'.
    REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
    REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
    REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
    REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
    ELSE.
    REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
    REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
    REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
    REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
    ENDIF.
    CONDENSE l_mstring.
    WRITE: / messtab-msgtyp, l_mstring(250).
    *? Send this errors to err internal table
    wa_err-msgtyp = messtab-msgtyp.
    wa_err-l_mstring = l_mstring.
    APPEND wa_err TO i_err.
    ELSE.
    WRITE: / messtab.
    ENDIF.
    CLEAR: messtab, wa_err.
    ENDLOOP.
    SKIP.
    ENDIF.
    ENDFORM. " bdc_transaction
    *& Form f_disp_errs
    text
    --> p1 text
    <-- p2 text
    FORM f_disp_errs .
    SORT i_err BY msgtyp.
    LOOP AT i_err INTO wa_err.
    AT FIRST.
    WRITE : / text-002.
    ULINE.
    ENDAT.
    AT NEW msgtyp.
    IF wa_err-msgtyp = 'S'.
    WRITE : / text-003.
    ULINE.
    ELSEIF wa_err-msgtyp = 'E'.
    WRITE : / text-001.
    ULINE.
    ENDIF.
    ENDAT.
    WRITE : / wa_err-msgtyp, wa_err-l_mstring.
    CLEAR wa_err.
    ENDLOOP.
    ENDFORM. " f_disp_errs
    Regards

  • Hi guys please give me sample code for call transaction that handles error

    hi guys, please give me sample code for call transaction that handles error,
    please send me the sample code in which there should be all decleration part and everything, based on the sample code i will develop my code.
    please do help me as it is urgent.
    thanks and regards.
    prasadnn.

    Hi Prasad,
    Check this code.
    Source Code for BDC using Call Transaction
    *Code used to create BDC
    *& Report  ZBDC_EXAMPLE                                                *
    *& Example BDC program, which updates net price of item 00010 of a     *
    *& particular Purchase order(EBELN).                                   *
    REPORT  ZBDC_EXAMPLE  NO STANDARD PAGE HEADING
                          LINE-SIZE 132.
    Data declaration
    TABLES: ekko, ekpo.
    TYPES: BEGIN OF t_ekko,
        ebeln TYPE ekko-ebeln,
        waers TYPE ekko-waers,
        netpr TYPE ekpo-netpr,
        err_msg(73) TYPE c,
    END OF t_ekko.
    DATA: it_ekko  TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko  TYPE t_ekko,
          it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_error TYPE t_ekko,
          it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_success TYPE t_ekko.
    DATA: w_textout            LIKE t100-text.
    DATA: gd_update TYPE i,
          gd_lines TYPE i.
    *Used to store BDC data
    DATA: BEGIN OF bdc_tab OCCURS 0.
            INCLUDE STRUCTURE bdcdata.
    DATA: END OF bdc_tab.
    *Used to stores error information from CALL TRANSACTION Function Module
    DATA: BEGIN OF messtab OCCURS 0.
            INCLUDE STRUCTURE bdcmsgcoll.
    DATA: END OF messtab.
    *Screen declaration
    SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
                                        TITLE text-001. "Purchase order Num
    SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK block1.
    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME
                                        TITLE text-002. "New NETPR value
    PARAMETERS:  p_newpr(14)   TYPE c obligatory.  "LIKE ekpo-netpr.
    SELECTION-SCREEN END OF BLOCK block2.
    *START-OF-SELECTION
    START-OF-SELECTION.
    Retrieve data from Purchase order table(EKKO)
      SELECT ekkoebeln ekkowaers ekpo~netpr
        INTO TABLE it_ekko
        FROM ekko AS ekko INNER JOIN ekpo AS ekpo
          ON ekpoebeln EQ ekkoebeln
       WHERE ekko~ebeln IN so_ebeln AND
             ekpo~ebelp EQ '10'.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Check data has been retrieved ready for processing
      DESCRIBE TABLE it_ekko LINES gd_lines.
      IF gd_lines LE 0.
      Display message if no data has been retrieved
        MESSAGE i003(zp) WITH 'No Records Found'(001).
        LEAVE TO SCREEN 0.
      ELSE.
      Update Customer master data (instalment text)
        LOOP AT it_ekko INTO wa_ekko.
          PERFORM bdc_update.
        ENDLOOP.
      Display message confirming number of records updated
        IF gd_update GT 1.
          MESSAGE i003(zp) WITH gd_update 'Records updated'(002).
        ELSE.
          MESSAGE i003(zp) WITH gd_update 'Record updated'(003).
        ENDIF.
    Display Success Report
      Check Success table
        DESCRIBE TABLE it_success LINES gd_lines.
        IF gd_lines GT 0.
        Display result report column headings
          PERFORM display_column_headings.
        Display result report
          PERFORM display_report.
        ENDIF.
    Display Error Report
      Check errors table
        DESCRIBE TABLE it_error LINES gd_lines.
      If errors exist then display errors report
        IF gd_lines GT 0.
        Display errors report
          PERFORM display_error_headings.
          PERFORM display_error_report.
        ENDIF.
      ENDIF.
    *&      Form  DISPLAY_COLUMN_HEADINGS
          Display column headings
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records updated successfully:'(013).
      WRITE:/ sy-uline(42).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'Purchase Order'(004), sy-vline,
              (11) 'Old Netpr'(005), sy-vline,
              (11) 'New Netpr'(006), sy-vline.
      WRITE:/ sy-uline(42).
    ENDFORM.                    " DISPLAY_COLUMN_HEADINGS
    *&      Form  BDC_UPDATE
          Populate BDC table and call transaction ME22
    FORM bdc_update.
      PERFORM dynpro USING:
          'X'   'SAPMM06E'        '0105',
          ' '   'BDC_CURSOR'      'RM06E-BSTNR',
          ' '   'RM06E-BSTNR'     wa_ekko-ebeln,
          ' '   'BDC_OKCODE'      '/00',                      "OK code
          'X'   'SAPMM06E'        '0120',
          ' '   'BDC_CURSOR'      'EKPO-NETPR(01)',
          ' '   'EKPO-NETPR(01)'  p_newpr,
          ' '   'BDC_OKCODE'      '=BU'.                      "OK code
    Call transaction to update customer instalment text
      CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'
             MESSAGES INTO messtab.
    Check if update was succesful
      IF sy-subrc EQ 0.
        ADD 1 TO gd_update.
        APPEND wa_ekko TO it_success.
      ELSE.
      Retrieve error messages displayed during BDC update
        LOOP AT messtab WHERE msgtyp = 'E'.
        Builds actual message based on info returned from Call transaction
          CALL FUNCTION 'MESSAGE_TEXT_BUILD'
               EXPORTING
                    msgid               = messtab-msgid
                    msgnr               = messtab-msgnr
                    msgv1               = messtab-msgv1
                    msgv2               = messtab-msgv2
                    msgv3               = messtab-msgv3
                    msgv4               = messtab-msgv4
               IMPORTING
                    message_text_output = w_textout.
        ENDLOOP.
      Build error table ready for output
        wa_error = wa_ekko.
        wa_error-err_msg = w_textout.
        APPEND wa_error TO it_error.
        CLEAR: wa_error.
      ENDIF.
    Clear bdc date table
      CLEAR: bdc_tab.
      REFRESH: bdc_tab.
    ENDFORM.                    " BDC_UPDATE
          FORM DYNPRO                                                   *
          stores values to bdc table                                    *
    -->  DYNBEGIN                                                      *
    -->  NAME                                                          *
    -->  VALUE                                                         *
    FORM dynpro USING    dynbegin name value.
      IF dynbegin = 'X'.
        CLEAR bdc_tab.
        MOVE:  name TO bdc_tab-program,
               value TO bdc_tab-dynpro,
               'X'  TO bdc_tab-dynbegin.
        APPEND bdc_tab.
      ELSE.
        CLEAR bdc_tab.
        MOVE:  name TO bdc_tab-fnam,
               value TO bdc_tab-fval.
        APPEND bdc_tab.
      ENDIF.
    ENDFORM.                               " DYNPRO
    *&      Form  DISPLAY_REPORT
          Display Report
    FORM display_report.
      FORMAT COLOR COL_NORMAL.
    Loop at data table
      LOOP AT it_success INTO wa_success.
        WRITE:/      sy-vline,
                (10) wa_success-ebeln, sy-vline,
                (11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,
                (11) p_newpr, sy-vline.
        CLEAR: wa_success.
      ENDLOOP.
      WRITE:/ sy-uline(42).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                    " DISPLAY_REPORT
    *&      Form  DISPLAY_ERROR_REPORT
          Display error report data
    FORM display_error_report.
      LOOP AT it_error INTO wa_error.
        WRITE:/      sy-vline,
                (10) wa_error-ebeln, sy-vline,
                (11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,
                (73) wa_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    ENDFORM.                    " DISPLAY_ERROR_REPORT
    *&      Form  DISPLAY_ERROR_HEADINGS
          Display error report headings
    FORM display_error_headings.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'Purchase Order'(009), sy-vline,
              (11) 'Netpr'(010), sy-vline,
              (73) 'Error Message'(012), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    " DISPLAY_ERROR_HEADINGS
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Handling sessions in BDC

    Hi all,
             What do we code to create a new session in BDC Call transaction method.
             Let me explain the situation in brief.
        I have an issue where in i need to upload 5000 records. As per requirement i am supposed to upload only 1000 per session. Please let me know how to create new session dynamically and move the processed data to sessions. And also let me know how to handle the errors in those records after processing 500 records.
           I know that Message_format is the FM to know to errors but I need to handle them dynamically.
    Guess we need to go by session method to handle errors but how to do that dynamically.
    Thanks and Regards
    Amit.

    Hi Amit,
    Suppose all your records are in table infile.
    Keep a counter such that when each record in the table is processed, the counter is incremented.
    When 1000 records are processed, call the insert bdc function. Reset the function.
    Thus dynamically you create 5 sessions if there are five records.
    In the following table, I am creating bdc sessions for the transaction FBV1. It has two screens.
    1000 for the first screen(header details) and 3000 for all other records(line item details)
    LOOP AT infile.
        PERFORM create_bdc.
    ENDLOOP.
    IF abend_job = false.
        PERFORM format_scrn_0300_last.
        PERFORM insert_bdcdata.
      ENDIF.
    form create_bdc.
       sy-subrc = 0.
      IF new_bdc EQ true.
        PERFORM open_bdc.
        IF abend_job = true.
          EXIT.
        ENDIF.
      ENDIF.
      IF first_time = true.
        CLEAR ba_cnt_tab.
        PERFORM format_scrn_0100. /* to process first screen
        PERFORM format_break_fields.
      ELSEIF detail_rec_cnt = 999. /* When the number of records is 999 process the last record and insert the session
        PERFORM format_scrn_0300_last.
        PERFORM insert_bdcdata.
        IF abend_job = false.
          MOVE: true TO bdc_tab_created.
          PERFORM format_scrn_0100. /* Again call the header screen and put the header details.
          PERFORM format_break_fields.
        ENDIF.
      ELSE.
        PERFORM format_scrn_0300_detail. /* Processing of Details records otherwise.
        PERFORM format_break_fields.
      ENDIF.
      IF abend_job = false.
        IF first_time = true.
          MOVE: true          TO bdc_tab_created,
                false         TO first_time.
        ENDIF.
      ELSE.
        EXIT.
      ENDIF.
    ENDFORM.
    Format Break Fields
    FORM format_break_fields.
    This form format fields necessary for breaking logic and postions
    the BA_CNT_TAB at the Business Area being processed.
      MOVE: infile-cost_center   TO prev_cost_center,
            infile-business_area TO prev_business_area,
            infile-amount        TO prev_amount,
            infile-dollar_amt    TO prev_dollar_amt,
            infile-order+2(12)   TO prev_order,
            infile-wbs_element   TO prev_wbs_element,
            infile-text          TO prev_text,
            infile-due_on_date   TO prev_due_on_date.
      SHIFT prev_order LEFT DELETING LEADING space.
    ENDFORM.
    format screen 0100
    FORM format_scrn_0100.
    This form contains the logic to create screen 0100
      sy-subrc = 0.
      IF ba_cnt_tab-business_area NE infile-business_area.
    Position BA_CNT_TAB at business area currently processing.
        LOOP AT ba_cnt_tab.
          IF ba_cnt_tab-business_area = infile-business_area.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      PERFORM dynpro_saplf040_0100 USING infile-post_key infile-accnt.
    ENDFORM.
    FORMAT SCREEN 0300 FOR LAST DETAIL
    FORM format_scrn_0300_last.
    This form formats the last detail screen 0300 and a phantom entry
    if needed.  Screen 0002 is also formatted for each 0300.
      ADD: prev_dollar_amt TO phantom_accum,
           1               TO detail_rec_cnt.
      IF prev_dollar_amt GT 0.
        ADD: prev_dollar_amt TO amt_debit_added.
      ELSE.
        ADD: prev_dollar_amt TO amt_credit_added.
      ENDIF.
      IF detail_rec_cnt LT ba_cnt_tab-rec_cnt.
        IF phantom_accum LT 0.
    Reverse posting key since being posted as an offset to the accumulated
    Amount.
          MOVE debit_pk TO posting_key.
          num_data = phantom_accum * -1.
        ELSE.
          MOVE credit_pk  TO posting_key.
          num_data = phantom_accum.
        ENDIF.
        PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
          prev_due_on_date posting_key phantom_accnt.
        PERFORM dynpro_saplkacb_0002 USING prev_cost_center
          prev_business_area prev_order prev_wbs_element.
        MOVE num_data TO char_data.
        PERFORM dynpro_saplf040_0300 USING char_data '' '' '' ''.
        PERFORM bdc_value USING 'BDC_OKCODE' post.
        PERFORM dynpro_saplkacb_0002 USING ' ' prev_business_area ' ' ' '.
      ELSE.
        PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
          prev_due_on_date '' ''.
        PERFORM bdc_value USING 'BDC_OKCODE' post.
        PERFORM dynpro_saplkacb_0002 USING prev_cost_center
          prev_business_area prev_order prev_wbs_element.
      ENDIF.
      CLEAR:       detail_rec_cnt,
                   phantom_accum.
    ENDFORM.
    FORMAT DETAIL FOR SCREEN 0300
    FORM format_scrn_0300_detail.
    This FORM formats screen 0300 for a detail record along with its
    screen 0002
      ADD: prev_dollar_amt TO phantom_accum.
      PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
        prev_due_on_date infile-post_key infile-accnt.
      PERFORM dynpro_saplkacb_0002 USING prev_cost_center
        prev_business_area prev_order prev_wbs_element.
      IF prev_dollar_amt LT 0.
        ADD: prev_dollar_amt TO amt_credit_added.
      ELSE.
        ADD: prev_dollar_amt TO amt_debit_added.
      ENDIF.
      ADD: 1               TO detail_rec_cnt.
    ENDFORM.
    Dynpro for program SAPMF05A  Screen 0100
    FORM dynpro_saplf040_0100 USING post_key post_accnt.
    This FORM formats SCREEN 0100
    This PERFORM is done once for each screen.
      PERFORM bdc_dynpro USING 'SAPLF040' '0100'.
    This PERFORM is done as many times as there are fields to be
    populated for the screen being processed.
      PERFORM bdc_value  USING 'BKPF-BLDAT' header-doc_mdy.
      PERFORM bdc_value  USING 'BKPF-BUDAT' header-post_mdy.
      PERFORM bdc_value  USING 'BKPF-BLART' header-doc_type.
      PERFORM bdc_value  USING 'BKPF-BUKRS' header-company_code.
      PERFORM bdc_value  USING 'BKPF-MONAT' header-period.
      PERFORM bdc_value  USING 'BKPF-WAERS' header-currency.
      PERFORM bdc_value  USING 'BKPF-XBLNR' header-reference_doc.
      PERFORM bdc_value  USING 'BKPF-BKTXT' header-text.
    *Begin of change by Priya Vasudevan for including checkbox
    PERFORM BDC_VALUE  USING 'VBKPF-XBWAE' CONTROL.
    *End of change
      IF header-rate NE space.
        PERFORM bdc_value USING 'BKPF-KURSF' header-rate.
      ENDIF.
      IF header-translation_date NE space.
        PERFORM bdc_value USING 'BKPF-WWERT' header-translation_date.
      ENDIF.
      PERFORM bdc_value  USING 'RF05V-NEWBS' post_key.
      PERFORM bdc_value  USING 'RF05V-NEWKO' post_accnt.
    ENDFORM.
    Dynpro for program SAPLF040  Screen 0300
    FORM dynpro_saplf040_0300 USING amount text due_on_date
                                    post_key post_accnt.
    This FORM formats SCREEN 0300
    This PERFORM is done once for each screen.
      PERFORM bdc_dynpro USING 'SAPLF040' '0300'.
    This PERFORM is done as many times as there are fields to be
    populated for the screen being processed.
      PERFORM bdc_value  USING 'BSEG-WRBTR' amount.
    *Begin of change by Priya Vasudevan for addition of assign no and tax .
    PERFORM BDC_VALUE  USING 'BSEG-ZUONR' ASSIGNMENT_NUMBER.
    PERFORM BDC_VALUE  USING 'BKPF-XMWST' TAX_CALCULATE.
    *End of change
      PERFORM bdc_value  USING 'RF05V-NEWBS' post_key.
      PERFORM bdc_value  USING 'RF05V-NEWKO' post_accnt.
      IF due_on_date NE space.
        PERFORM bdc_value USING 'BSEG-ZFBDT' due_on_date.
      ENDIF.
      IF text NE space.
        PERFORM bdc_value USING 'BSEG-SGTXT' text.
      ENDIF.
    ENDFORM.
    Dynpro for program SAPLKACB  Screen 0002
    FORM dynpro_saplkacb_0002 USING cost_center business_area order wbs.
    This FORM formats SCREEN 0002 WHICH IS A POP-UP SCREEN
    THAT DOES NOT APPEAR DURING ON-LINE PROCESSING
    This PERFORM is done once for each screen.
      PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
    This PERFORM is done as many times as there are fields to be
    populated for the screen being processed.
      IF cost_center NE space.
        PERFORM bdc_value  USING 'COBL-KOSTL' cost_center.
      ENDIF.
      IF business_area NE space.
        PERFORM bdc_value  USING 'COBL-GSBER' business_area.
      ENDIF.
      IF order NE space.
        PERFORM bdc_value USING 'COBL-AUFNR' order.
      ENDIF.
      IF wbs NE space.
        PERFORM bdc_value USING 'COBL-PS_PSP_PNR'  wbs.
      ENDIF.
    ENDFORM.
    BDC Dynpro
    FORM bdc_dynpro USING pgm scrn.
    This FORM formats the transaction that tells the BDC which screen is
    to be populated.
      CLEAR bdc_tab.
      MOVE: pgm             TO bdc_tab-program,
            scrn            TO bdc_tab-dynpro,
            begin           TO bdc_tab-dynbegin.
      APPEND bdc_tab.
    ENDFORM.
    BDC Value
    FORM bdc_value USING field val.
    This FORM tells the BDC which field is to be populated and the value
    to use.
      CLEAR bdc_tab.
      MOVE: field           TO bdc_tab-fnam,
            val             TO bdc_tab-fval.
      APPEND bdc_tab.
    ENDFORM.
    FORM open_bdc.
    This routine opens the BDC data file
      sy-subrc = 0.
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                client              = sy-mandt
                group               = group_name
                keep                = 'X'
                user                = sy-uname
           EXCEPTIONS
                client_invalid      = 1
                destination_invalid = 2
                group_invalid       = 3
                group_is_locked     = 4
                holddate_invalid    = 5
                internal_error      = 6
                queue_error         = 7
                running             = 8
                system_lock_error   = 9
                user_invalid        = 10
                OTHERS              = 11.
      IF sy-subrc NE 0.
        MOVE: true TO abend_job.
        CASE sy-subrc.
          WHEN 01.
            PERFORM process_msg USING '109' sy-mandt 'BDC OPEN' ''.
          WHEN 02.
            PERFORM process_msg USING '109' 'BDC OPEN' '' ''.
          WHEN 03.
            PERFORM process_msg USING '111' 'BDC OPEN' '' ''.
          WHEN 04.
            PERFORM process_msg USING '124' 'BDC OPEN' '' ''.
          WHEN 05.
            PERFORM process_msg USING '112' 'BDC OPEN' '' ''.
          WHEN 06.
            PERFORM process_msg USING '113' 'BDC OPEN' '' ''.
          WHEN 07.
            PERFORM process_msg USING '114' 'BDC OPEN' '' ''.
          WHEN 08.
            PERFORM process_msg USING '115' 'BDC OPEN' '' ''.
          WHEN 09.
            PERFORM process_msg USING '125' 'BDC OPEN' '' ''.
          WHEN 10.
            PERFORM process_msg USING '116' 'BDC OPEN' '' ''.
          WHEN 11.
            PERFORM process_msg USING '126' 'BDC OPEN' '' ''.
        ENDCASE.
      ELSE.
        MOVE: true TO bdc_openned,
              false TO new_bdc.
      ENDIF.
    ENDFORM.
    Insert BDC data
    FORM insert_bdcdata.
    This routine inserts a scenario into the BDC batch session.
    Add the actual value of the particular Transaction code relevant
    to the scenario being processed for the constant TRANS_CODE.
      sy-subrc = 0.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                tcode          = trans_code
           TABLES
                dynprotab      = bdc_tab
           EXCEPTIONS
                internal_error = 1
                not_open       = 2
                queue_error    = 3
                tcode_invalid  = 4
                OTHERS         = 5.
      IF sy-subrc NE 0.
        MOVE: true TO abend_job.
        CASE sy-subrc.
          WHEN 01.
            PERFORM process_msg USING '113' 'BDC INSERT' '' ''.
          WHEN 02.
            PERFORM process_msg USING '117' 'BDC INSERT' '' ''.
          WHEN 03.
            PERFORM process_msg USING '114' 'BDC INSERT' '' ''.
          WHEN 04.
            PERFORM process_msg USING '118' 'BDC INSERT' '' ''.
          WHEN 05.
            PERFORM process_msg USING '126' 'BDC INSERT' '' ''.
        ENDCASE.
      ELSE.
        bdc_trans_cnt = bdc_trans_cnt + 1.
      ENDIF.
    Initialize table after inserting the processed BDC Transactions
    for one scenario
      REFRESH bdc_tab.
    ENDFORM.
    End of Job Routine
    FORM eoj_routine.
      IF bdc_openned = true.
        PERFORM close_bdc.
        IF bdc_tab_created = true AND
           abend_job = false.
          TRANSLATE submit TO UPPER CASE.
          IF submit = 'X'.
            PERFORM submit_bdc_to_batch.
           ELSE.
            CLEAR : msg1, msg2, msg3.
            CONCATENATE 'Session' group_name INTO msg1 SEPARATED BY space.
            msg2 = 'has been created. '.
            msg3 = 'Please use SM35 to process the session.'.
            MESSAGE i150 WITH msg1 msg2 msg3   .
          ENDIF.
          IF abend_job = false.
            PERFORM update_date_control_file.
          ENDIF.
        ENDIF.
      ENDIF.
      IF abend_job = true.
        PERFORM abend_job.
        PERFORM alert_check.
      ELSE.
    These writes are an example of control totals that would be included
    on a control report.
        PERFORM: process_msg USING '174' total_recs '' 'NC',
                 process_msg USING '176' bdc_trans_cnt '' 'NC',
                 process_msg USING '148' tot_debit '' 'NC',
                 process_msg USING '149' tot_credit '' 'NC',
                 process_msg USING '173' interface_id '' ''.
       WRITE: /1 ' End of Job Run'.
        TRANSLATE temp_unix_name TO LOWER CASE.
        SHIFT full_fil_name UP TO temp_unix_name+0(9).
        SUBMIT zuxmv WITH filename EQ full_fil_name
                    WITH frompath EQ temp_unix_path
                    WITH to_path  EQ temp_arc_path
                    exporting list to memory
                     AND RETURN.
      ENDIF.
      SUBMIT zuxlp WITH filename = temp_log_name
                   WITH path     = temp_log_path
                   WITH printer  = temp_printer
                   exporting list to memory
                    AND RETURN.
      IF abend_job = true.
        IF execution = 'ONLINE'.
          PERFORM process_msg USING '100' in_trailer-interface_id '' ''.
          MESSAGE a100 WITH in_trailer-interface_id.
        ENDIF.
      ENDIF.
      CLOSE DATASET logfile.
    ENDFORM.
    Close BDC data
    FORM close_bdc.
    This routine closes the BDC batch session.
      sy-subrc = 0.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
           EXCEPTIONS
                not_open    = 1
                queue_error = 2
                OTHERS      = 3.
      IF sy-subrc NE 0.
        MOVE: true TO abend_job.
        CASE sy-subrc.
          WHEN 01.
            PERFORM process_msg USING '117' 'BDC CLOSE' '' ''.
          WHEN 02.
            PERFORM process_msg USING '114' 'BDC CLOSE' '' ''.
          WHEN 03.
            PERFORM process_msg USING '126' 'BDC CLOSE' '' ''.
        ENDCASE.
      ENDIF.
    ENDFORM.
    Submit BDC to Batch
    FORM submit_bdc_to_batch.
    This FORM submits the completed BDC Table to Batch to be processed
    for all the transactions processed from the Interface input file.
    Changes made by sthomas on 11.16.2005
      SUBMIT rsbdcsub WITH mappe EQ group_name
                      with Z_VERARB EQ 'X'
    *Code inserted by sthomas on 16.11.2005
                      WITH fehler EQ ' '
                      EXPORTING LIST TO MEMORY
                      AND RETURN.
      WAIT UP TO 2 SECONDS.
      SELECT  * UP TO 1 ROWS INTO TABLE i_apqi
         FROM apqi
          WHERE groupid = group_name
          AND   credate <= sy-datum
          AND   cretime <= sy-uzeit
          ORDER BY cretime DESCENDING.
      READ TABLE i_apqi INDEX 1.
      clear : msg1, msg2, msg3.
      concatenate 'Session' group_name into msg1 SEPARATED BY SPACE.
      IF i_apqi-qstate = 'F'.
        msg2 = 'has been successfully processed'.
        MESSAGE i150 WITH msg1 msg2.
      ELSEIF i_apqi-qstate = 'E'.
         msg2 = 'has been processed with errors.'.
         msg3 = 'Please use SM35 to view the errors'.
        MESSAGE i150 WITH msg1 msg2 msg3 .
      ELSE.
        msg2 = 'has been transferred to the background for'.
        msg3 = 'processing. Please use SM35 to view the status'.
        MESSAGE i150 WITH msg1 msg2 msg3.
      ENDIF.
    End of code.
    End of change
    ENDFORM.
    Update date control file
    FORM update_date_control_file.
    This routine will update the Interface Date/Time Control File with
    the Date/Time Stamp of the current file just processed successfully.
    The parameter FILE_OPERATION indicates that the control file is to
    be updated with the new stamp and the status of the Interface/file
    will be set to 'C' for complete.
      CALL FUNCTION 'Z_PROCESS_INTERFACE_CTL_TABLE'
           EXPORTING
                file_id           = in_trailer-interface_id
                file_name         = in_trailer-file_name
                file_date         = in_trailer-date
                file_time         = in_trailer-time
                file_operation    = '2'
           EXCEPTIONS
                dup_file_error    = 1
                file_id_not_found = 2
                table_not_updated = 3
                OTHERS            = 4.
      IF sy-subrc NE 0.
        MOVE: true TO abend_job.
        CASE sy-subrc.
          WHEN 01.
            PERFORM process_msg USING '127' in_trailer-interface_id
              in_trailer-file_name 'OPERATION 2'.
          WHEN 02.
            PERFORM process_msg USING '128' in_trailer-interface_id
              in_trailer-file_name 'OPERATION 2'.
          WHEN 03.
            PERFORM process_msg USING '129' 'ZTAG' '' ''.
          WHEN 04.
            PERFORM process_msg USING '126' 'OPERATION 2' '' ''.
        ENDCASE.
      ENDIF.
    ENDFORM.
    Abend Job
    FORM abend_job.
    This form updates the Interface Date/Time Control File with a status
    of 'A' to indicate that this Interface has abended.  The Date/Time
    stamp on the Control file will not be updated with the date/time
    from the current file.  The parameter FILE_OPERATION OF '3' initiates
    this process.  Any time Operation '3' is used with the
    Date/Time Control File, the calling program must abend using an 'A'
    Message.  A generic abend message of 100 has been set up in the
    T100 table.
      CALL FUNCTION 'Z_PROCESS_INTERFACE_CTL_TABLE'
           EXPORTING
                file_id           = in_trailer-interface_id
                file_name         = in_trailer-file_name
                file_date         = in_trailer-date
                file_time         = in_trailer-time
                file_operation    = '3'
           EXCEPTIONS
                dup_file_error    = 1
                file_id_not_found = 2
                table_not_updated = 3
                OTHERS            = 4.
      IF sy-subrc NE 0.
        CASE sy-subrc.
          WHEN 01.
            PERFORM process_msg USING '127' in_trailer-interface_id
              in_trailer-file_name 'OPERATION 3'.
          WHEN 02.
            PERFORM process_msg USING '128' in_trailer-interface_id
              in_trailer-file_name 'OPERATION 3'.
          WHEN 03.
            PERFORM process_msg USING '129' 'ZTAG' 'OPERATION 3' ''.
          WHEN 04.
            PERFORM process_msg USING '126' 'OPERATION 3' '' ''.
        ENDCASE.
      ENDIF.
      PERFORM process_msg USING '100' in_trailer-interface_id '' ''.
    ENDFORM.
    INCLUDE zi000002.
    Feel free to ask any doubt in this logic.
    Regards,
    Susmitha

  • Trace errors in bdc

    how to trace errors in BDC ,pls send me code for any transaction

    if we use call transaction, then we have handle errors.
         if you use Session method, then system handles errors, you can check this in the transaction code SM35.
    check this link for more info.....
    Sample code for call transaction and session  in bdc
    regds,
    kiran

  • How to handle errors in data templates

    Hi
    What is the recommended way to handle errors for example if one of your SQL statement in a data template returned no data how and where would you be able to create an error message for the user to find and read.
    Thanks,
    Mark

    The closest I have come to doing this is to put conditional statements into the format template. If a value matches an expected (ex. is null) you can return a message (in the report) via the format template (ex. "No Data Found").
    I am not sure this really answers your question as this is in the format template, but I generally view them as a matched pair that work together. I try to stick with data extraction in the data define, and do all my conditional stuff in the format templates.
    Scott

  • A message will pop up (Exc in ev handl: Error: Bad NPObject as private data!) and the tab I was on will close out and reopen in a new window. Why is it happening and how do I stop it?

    Okay, I will have a window open with 4 tabs open. At first, everything is fine, but after a day or so, a message will pop up on screen saying "'''Exc in ev handl: Error: Bad NPObject as private data!'''" and after you close it out, the tab you were on will close and reopen in it's own window. I then have to shut down all both old and new windows and open a new window with my original 4 tabs again. It will work fine until a few days pass and it starts over again.

    This issue can be caused by the McAfee Site Advisor extension
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • After updating Firefox I am getting this message any time I do anything "Exc in ev handl:Error: Bad NPObject as private data"

    This error happens each time I use Mozilla. especially when I click on an extension or try to work in any of my e-mail accounts (Yahoo, Gmail, or RCN). Sometimes I am able to continue by just clicking OK and other times it prevents me from completing my task. This started happening right after I downloaded and installed your latest version of Firefox. I see others are having the same problem. Error message is "Exc in ev handl:Error: Bad NPObject as private data"

    That issue can be caused by the McAfee Site Advisor extension
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • How to handle errors in a file at sender side?

    Hi
    I have done a file to proxy scenario.
    I know how to handle errors on proxy.
    But on sender side when picking the file if one the record have worng fomat its throwing mapping error and its not processing any record..
    I wanted to process the records which have right format and data and  all remaining recrods which have wromg format should be send back to the sender as file.
    How to do this.
    How to handle error in sender file.
    Regards
    Sowmya

    Hello Sowmya,
    In your scenario Three ways you can validate the data.
    1) Before the data reaches into SAP system ie in XI system during Mapping or before mapping i,e in Adapter Module in the Sender side
    2) this option, is in the receiver applications side. ie. Validations will be taken care in the SAP system i.e in ABAP server proxy code.
    3)Through BPM, If Mapping Exception Occures then through exception Branch you can send bad formate file to sender again.
    Generally, it is prefer to more business critical validations in the Application System ie Receiver Application System (ABAP Server Proxy)
    In this, you can have more flexibility of the validations as you are validating some of the SAP payroll informations as Personal ID etc.
    Based on the complexity and flexibility of the requirement, you can either do this in the XI (if XI, ie Sender Adapter Module or Mapping) or in the ABAP proxy
    Thanks'
    Sunil Singh

  • Error in bdc

    Error in bdc ... cannot insert in the transaction pa30 , infotype 0105 , adding userid
    Error :- usrid does not exists in given time span
    Plz let me knw if u have any sol

    When u r creating a new user then check Start date. If start date is not equals to current date then it will give a message other wise message will not come it seems. Suppose message is coming while creating time then no issue go to PA0105 table and check it's creating or not. If it's creating that means your BDC is delimiting the record and entring new record into data base.
    Rajneesh Gupta

  • Can't open PDF's on my Mac coming in on MS Outlook 2010. Reinstalled Adobe software 4 x and still get "Adobe PDF Preview Handler" error message.

    Can't open PDF's on my Mac coming in on MS Outlook 2010. Reinstalled Adobe software 4 x and still get "Adobe PDF Preview Handler" error message.

    No. Reader will not damage files. It is only meant to read pdf files. PDF files are frequently damaged when sent as email due to encoding issues.

  • Event handler error

    I gets event handler error from the following applescript code if I leave the desktop space where "XLD" is running.
    Is there a way to avoid this error and keep running the applescript?
    tell application "System Events"
    set wnd to front window of application process "XLD"
    click button "Extract" of tool bar of wnd
    delay 1
    repeat while (name of front window of application process "XLD") = "Progress"
    end repeat
    end tell

    Do you have any Mail plug-ins installed? Mail Act-on, MailTags or whatever? If so, try disable them and then see if the scripts work.
    Alternatively, you can access the iPhoto Library from within Mail:
    Uploaded with plasq's Skitch!
    Just drag and drop to the message.
    Regards
    TD

  • Handle errors when makeing doc.submitForm()

    Hello,
    I am trying to submit PDF form by method doc.submitForm, example:
    doc.submitForm
            cURL: "http://localhost/reader_test.php?name=" + name.rawValue,
            cSubmitAs: "XML"
    A) With this approach, is it possible to handle connection errors and display custom error message (and cancel the original one) ?
    I have tried something like
    try{  doc.submitForm(...); } catch(e) { //handle code }
    but it seems to be run asynchronously.
    B) Is it possible to add custom HTTP headers to the POST ?
    I saw that FormCalc can do it in Post() funciton, but when using Post() function, the Reader displays Yello-bar security dialog, that made our previous SOAP-based solution too complicated for the end user.
    Appreciate any help.
    Radek

    Sofar I have not found the way how to handle errors when using doc.submitForms(), but there may be following workaround (mey be?):
    The server returns as a response to a submitForms() call a pdf content, which is displayed as a document in a new Reader's window. Is it possible to place some javascript into this new window, that would refer to parent window and send to it some message ? Or at least to detect at the "parent" window, that a "child" window was opened ?
    So is there any relation between the newly opened document with the response from server and the original document, that initiated calling of doc.submitForms()?
    Thanks.

  • How to handle error or exceptions in jsf

    Hi
    i have a code using DTO and DAO.I want to handle errors in jsf automatically(ie without return parameter in java code .).Hoe i can handlethose errors in faces.config.

    Declaratevly You can't do this.
    I use two event handler for state remembering:
    public static EventResult goToPage(BajaContext context,
    Page page,
    PageEvent pageEvent) {
    Page newPage = new Page(page.getProperty("nextPageName"));
    page.setProperty(NEXT_PAGE_NAME, null);
    newPage.setPropertyAsPage("returnPage", page, context.getPageEncoder());
    return new EventResult(newPage);
    public EventResult returnToPage(BajaContext context,
    Page page,
    PageEvent pageEvent) {
    Page oldPage = page.getPropertyAsPage("returnPage", context.getPageDecoder());
    return new EventResult(oldPage);
    StartPage.uix
    <handlers>
    <event name="nextPage">
    <bc4j:chaining>
    <bc4j:setPageProperty name="nextPageName" value="NextPage"/>
    <method class="..." method="goToPage"/>
    </bc4j:chaining>
    </event>
    </handlers>
    NextPage.uix
    <handlers>
    <event name="nextPage">
    <bc4j:chaining>
    <method class="..." method="returnToPage"/>
    </bc4j:chaining>
    </event>
    </handlers>
    method setPropertyAsPage save all page properties and state informations for page.
    On every page I use ctrl:page or ctrl:pageState DataObjectLists.
    On pages with search criteria I use ctrl:httpSession DataObjectList to save all criteria in one session. You must write event handler when you make search or trigger FIND event. In this event handler you must put every search form parameter in session.
    That's all from me! I hope this help You to resolve problems!

Maybe you are looking for

  • IPhoto won't open 9.4.2 and OSX 10.7.5

    I'm not sure about when this happened, but I can no longer open iPhoto.  It goes to an error log that says "iPhoto Unexpectedly Quit". Incidently, my Displays, Clock and Icon in the tool bar no longer show up either. I've tried reinstalling the 10.7.

  • Pricing access sequence

    I am experiencing a problem with a pricing error in retro-active billing when my access sequence is based on our own defined table (assigned in KOMP). Yet when using the SAP standard access sequence the retro-active billing works fine.  I have to re-

  • TROUBLE INSTALLING PHOTOSHOP

    SERIAL NUMBER DOES NOT WORK... WHERE DO I FIND THE CORRECT ONE

  • Syncing with wrong accounts

    I hope someone can help me!  I've just got a mini iPad and it seems it has synced with my husbands iPad and iPhone and I now have all of his contacts, calendars and reminders.  I didn't set it up like this and it's done it automatically.  We think pa

  • How to crop a QuickTime movie to delete black top and bottom areas?

    How to crop a QuickTime movie? I mean, a ".mov" movie that shows a black area on top and bottom, which I want to delete. I have tried with iMovie 8.0.5, yet its "Window - Cropping..." to fit, crop and Ken burns does not allow to select the area that