How to upload error records in call transaction method

Hi all,
While uploading data by using call transaction. If any errors occured, how can we process that  error records to database.
If all records are processed. How can we display the recent records which where uploaded.
AdvanceThanks for all.

Hi Bharath
You can handle this in many ways. But the easiest option to do is as below,
once the call transaction ends in error, move that particular upload data to a separate internal table. Then finally download all these data to an error file.
Besides this after processing all the records diplay the log for error. So that users can modify the error in the file and can use the same for uploading again. For the data that has been processed successfully you can display the log similarly.
The error as well as sucess messages can be obtained from the messages table.
    CALL TRANSACTION TCODE USING BDCDATA
                     MODE   CTUMODE
                     UPDATE CUPDATE
                     MESSAGES INTO MESSTAB.
Regards
Kathirvel

Similar Messages

  • How will you  collect error records in call transaction method

    hello
    how will handle errors in call transaction method...

    DATA: BEGIN OF ITAB OCCURS 0,
          F1(10) TYPE C,
          F2(18) TYPE C,
          F3(15) TYPE C,
          END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0,
          F1(2) TYPE C,
          F2(10) TYPE C,
          F3(18) TYPE C,
          F4(15) TYPE C,
          END OF ITAB1.
    DATA : ITAB2 LIKE ITAB OCCURS 0 WITH HEADER LINE,
                IT_SUCCESS LIKE ITAB OCCURS 0 WITH HEADER LINE,
                IT_ERROR LIKE ITAB OCCURS 0 WITH HEADER LINE.
    DATA : BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
               T_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
      CALL TRANSACTION 'VA01' USING BDCDATA MODE 'N' UPDATE 'S'
                                MESSAGES INTO T_BDCMSGCOLL.
      PERFORM ERRORHANDLING TABLES ITAB2 USING COUNT1 COUNT2.
      REFRESH BDCDATA.
    FORM ERRORHANDLING TABLES   P_ITAB2 STRUCTURE ITAB
                       USING    P_COUNT1
                                 P_COUNT2.
      IF SY-SUBRC <> 0.
        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       = T_BDCMSGCOLL
          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.
        IF P_COUNT1 = 1.
          WRITE : / ' The records not loaded are '.
          P_COUNT1 = P_COUNT1 + 1.
        ENDIF.
        LOOP AT P_ITAB2.
          WRITE : / P_ITAB2-F1 , P_ITAB2-F2 , P_ITAB2-F3 .
          CLEAR P_ITAB2.
          DELETE P_ITAB2 INDEX 1.
        ENDLOOP.
        WRITE : /.
      ELSE.
        IF P_COUNT2 = 1.
          WRITE : /  ' The records loaded are '.
          P_COUNT2 = P_COUNT2 + 1.
        ENDIF.
        LOOP AT P_ITAB2.
          WRITE : / P_ITAB2-F1 , P_ITAB2-F2 , P_ITAB2-F3 .
          CLEAR P_ITAB2.
          DELETE P_ITAB2 INDEX 1.
        ENDLOOP.
        WRITE : /.
      ENDIF.
    ENDFORM.                    " errorhandling

  • Track error records in Call Transaction method

    Hi
    I have used call transaction method for uploading legacy data.
    I need to track the error record.
    Please help me to find out the solution.
    Thanks in advance
    Reagards
    shriraam

    HI,
    !. Obtain  the  messaged into an Interal table of type BDCMSGCOLL using Call Transaction  syntax..
                   Call Transactio <Tcode>
                           using <BDC Table>
                          mode  <A/N/P>
                          update  <A/S>
                         messages  INTO <mSGTAB>
    2. Read the Msg table for eroors and success messages
    3. Then format the messge with the help of Function Module  :'Format_messages'.
    4. Display the respective messges with the help of write statements or with the help of ALV.
    Rgds
    Umakanth

  • How to create a session using call transaction method.

    hi , this is nagaraju,
    How to create a session using call transaction method.

    Hi,
    About Data Transfer In R/3 System
    When a company decides to implement the SAP R/3 to manage business-critical data, it usually does not start from a no-data situation. Normally, a SAP R/3 project comes into replace or complement existing application.
    In the process of replacing current applications and transferring application data, two situations might occur:
    •     The first is when application data to be replaced is transferred at once, and only once.
    •     The second situation is to transfer data periodically from external systems to SAP and vice versa.
    •     There is a period of time when information has to be transferred from existing application, to SAP R/3, and often this process will be repetitive.
    The SAP system offers two primary methods for transferring data into SAP systems. From non-SAP systems or legacy system. These two methods are collectively called “batch input” or “batch data communication”.
    1. SESSION METHOD
    2. CALL TRANSACTION
    3. DIRECT INPUT
    First step for both the methods is to upload the data to internal table. From Internal Table, the data is transferred to database table by two ways i.e., Session method and Call transaction.
    Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.
    When the program has finished generating the session, you can run the session to execute the SAP transactions in it. Unless session is processed, the data is not transferred to database table.
    A technique similar to SESSION method, while batch input is a two-step procedure, Call Transaction does both steps online, one after the other. In this method, you call a transaction from your program.
    SESSION METHOD
    Data is not updated in database table unless Session is processed.
    No sy-subrc is returned.
    Error log is created for error records.
    Updation in database table is always synchronous
    CALL TRANSACTION
    Immediate updation in database table.
    Sy-subrc is returned.
    Errors need to be handled explicitly
    Updation in database table can be synchronous Or Asynchronous.
    Regards,
    Sruthi.

  • Error in BDC CALL TRANSACTION METHOD..

    hai i got an error in  doing BDC  CALL TRANSACTION METHOD
    Error:diffrent number of parameters in  FORM  and PERFORM(routine :FILL_SCREEN_DETAILS:,number of formal parameters :3,number of actual parameters:1)
    PROGRAM
    REPORT  ZDEMO_UPLOAD_COST_CENTER_DATA.
    DATA:BEGIN OF WA_DATA,
    KOKRS TYPE KOKRS,"CONTROLLING AREA
    KOSTL TYPE KOSTL,"COST CENTER
    DATAB TYPE DATAB,"START DATE
    DATBI TYPE DATBI,"END DATE
    KTEXT TYPE KTEXT,"NAME
    LTEXT TYPE LTEXT,"DESCRIPTION
    VERAK TYPE VERAK,"PERSON RESPONSIBLE
    KOSAR TYPE KOSAR, "COST CENTER CATEGORY
    KHINR TYPE KHINR,"HIERARCHY AREA
    BUKRS TYPE BUKRS,"COMPANY CODE
    GSBER TYPE GSBER,"BUISINESS AREA
    END OF WA_DATA.
    *TYPES:IT_DATA TYPE STANDARD TABLE OF TY_DATA.
    DATA:IT_DATA LIKE TABLE OF WA_DATA,
          IT_BDCDATA LIKE TABLE OF BDCDATA,
          WA_BDCDATA LIKE LINE OF IT_BDCDATA,
          IT_BDCMSGCOLL LIKE TABLE OF BDCMSGCOLL,
          WA_BDCMSGCOLL LIKE LINE OF IT_BDCMSGCOLL.
    DATA :V_FILE TYPE STRING.
    CONSTANTS :C_KS01(4) TYPE C  VALUE 'KS01',
                C_X(1) TYPE C VALUE 'X',
                C_A(1) TYPE C VALUE 'A'.
    SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
    PARAMETER :PA_FILE LIKE FC03TAB-PL00_FILE OBLIGATORY.
    SELECTION-SCREEN:END OF BLOCK B1.
    *AT SELECTION SCREEN ON VALUE REQUEST
    * EVENT TO BE TRIGGERED WHEN WE PRESS F4.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
    PERFORM GET_F4_FOR_FILE USING PA_FILE.
    *         START-OF-SELECTION
    START-OF-SELECTION.
    *WE NEED TO MOVE THE PA_FILE INTO ANOTHER VARIABLE OF TYPE STRING
    *AS WE ARE GOING TO USE THE SAME IN THE FM:GUI_UPLOAD THERE THE FILE TYPE IS STRING
    V_FILE = PA_FILE.
    PERFORM UPLOAD_FILE_T0_ITAB USING V_FILE CHANGING IT_DATA.
    *FILL THE SCREEN AND FIELD DETAILS
    LOOP AT IT_DATA INTO WA_DATA.
    REFRESH IT_BDCDATA.
    *FIRST SCREEN DETAILS
    PERFORM FILL_SCREEN_DETAILS USING 'SAPLKMA1''0200''X'.
    *CURSOR DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR''CSKSZ-KOKRS'.
    *OK CODE DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE''/00'.
    *CONTROLLING AREA
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-KOKRS' WA_DATA-KOKRS.
    *COST CENTER DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-KOSTL' WA_DATA-KOSTL.
    * START DATE
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-DATAB_ANFO' WA_DATA-DATAB.
    *END DATE
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-DATBI_ANFO' WA_DATA-DATBI.
    *NEXT SCREEN DETAILS
    PERFORM FILL_SCREEN_DETAILS USING 'SAPLKMA1''0299''X'.
    *OKCODE DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE''=BU'.
    *SUBSCRN FIELD DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'BDC_SUBSCR''BDC-SUBSCR'.
    *CURSOR DETAILS
    PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR''CSKSZ-WAERS'.
    *NAME
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-KTEXT' WA_DATA-KTEXT.
    *DESCRIPTION
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-LTEXT' WA_DATA-LTEXT.
    *PERSON RESPONSIBLE
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-VERAK' WA_DATA-VERAK.
    *COST CENTER CATEGORY
    PERFORM FILL_FIELD_DETAILS USING'CSKSZ-KOSAR' WA_DATA-KOSAR.
    *HIERARCHY AREA
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-KHINR' WA_DATA-KHINR.
    *COMPANY CODE
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-BUKRS' WA_DATA-BUKRS.
    *BUISINESS AREA
    PERFORM FILL_FIELD_DETAILS USING 'CSKSZ-GSBER' WA_DATA-GSBER.
    *CALL THE TRANSACTION
    CALL TRANSACTION C_KS01 USING IT_BDCDATA
                              MODE C_A "ALL SCREENS
                                       "N-NO SCREENS
                                       "E-ERROR SCREENS ONLY
                              UPDATE 'A' "ASYNCHRONOUS
                                          "SYNCHRONOUS
                              MESSAGES INTO IT_BDCMSGCOLL.
    ENDLOOP.
    * FORM FILL SCREEN_DETAILS
    FORM FILL_SCREEN_DETAILS  USING PROGRAM LIKE BDCDATA-PROGRAM
                           DYNPRO LIKE BDCDATA-DYNPRO
                           DYNBEGIN LIKE BDCDATA-DYNBEGIN.
    CLEAR WA_BDCDATA.
    WA_BDCDATA-PROGRAM = PROGRAM.
    WA_BDCDATA-DYNPRO = DYNPRO.
    WA_BDCDATA-DYNBEGIN = DYNBEGIN.
    APPEND WA_BDCDATA TO IT_BDCDATA.
    ENDOFRM.
    * FORM FILL_FIELD_DETAILS
    FORM FILL_FIELD_DETAILS USING FNAM FVAL.
    CLEAR WA_BDCDATA.
    WA_BDCDATA-FNAM = FNAM.
    WA_BDCDATA-FVAL = FVAL.
    APPEND WA_BDCDATA TO IT_BDCDATA.
    ENDFORM.
    * FORM GETE_F4_FOR_FILE
    *DISPLAY ALL THE  FILES IN THE SYSTEM FOR SELECTION
    *P_PA_FILE NAME OF THE FILE
    FORM GET_F4_FOR_FILE USING P_PA_FILE.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    *  EXPORTING
    *    PROGRAM_NAME        = SYST-REPID
    *    DYNPRO_NUMBER       = SYST-DYNNR
        FIELD_NAME          = 'PA_FILE'
    *    STATIC              = ' '
    *    MASK                = ' '
       CHANGING
         FILE_NAME           = PA_FILE.
    *  EXCEPTIONS
    *    MASK_TOO_LONG       = 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.
    ENDFORM.
    * FORM UPLOAD_FILE_TO_ITAB
    * FP_V_FILE = FILE NAME
    *FP_IT_DATA =  INTERNAL TABLE TO STORE THE DATA
    FORM UPLOAD_FILE_TO_ITAB USING FP_V_FILE CHANGING FP_IT_DATA LIKE IT_DATA.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = FP_V_FILE
      HAS_FIELD_SEPARATOR           = ' X'
      TABLES
        DATA_TAB                      =FP_IT_DATA.
    ENDFORM.
    Edited by: saifudheenc on Aug 7, 2010 5:09 PM

    hi
    try to add spaces between parameters :
    example:
    PERFORM FILL_SCREEN_DETAILS USING 'SAPLKMA1' '0200' 'X'.
    regards,darek

  • How to track error message when calling Transaction: va02

    Hi all,
        As we all know, when we change an order through T-Code: VA02, system will update modified data to corresponding database. Meanwhile, if our operate is not legal or incorrect on T-code: VA02, system will call corresponding error messages to us.
        Now I want to know:
       1. how to track the error messages
       2. Is there any Tcode such as: SM21 that we can see the message logs after our operation?
    Thanks.

    Hi ,
    message table for call transaction
    DATA: BEGIN OF G_T_MSG OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF G_T_MSG.
    Exucute transaction via Call Transaction
      CALL TRANSACTION  'FB01'
                     USING g_t_bdcdata
                     MODE g_l_mode
                     UPDATE 'S'
                     MESSAGES INTO g_t_msg          .
    errors will be stpored in the table g_t_msg ..
    Thanks .

  • How to download error records after the session method executed in BDC?

    Dear Experts,
    How to download errors in session method after executing session method. Please dn't say for BDCMSGCOLL  i have goggled all . every one answer for call transaction. In session method after executing we fill find all the success and errors in log file . But how to download this log file?
    please help me.
    Thanks
    Ravilla

    Hi Laxman,
    Please find the below process .I hope this will suits to your requirement .
    1)Write an error report.
    2)Send the record(s) in error to an error file.
    3)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.
    Regards,
    Bharat Kumar

  • Doubt in uploading using call transaction method

    hi all
    i am uploading f-29 in call transaction method .. i have a problem in currency field, the currency field is not picking up it shows a error that input field is longer than screen field .. i have declared currency field as type BSEG-WRBTR(same as screen field ...how to go about
    thanks
    lokesh

    Hi,
    When you use the database value directly in your BDC, you will have this issue. It is always advisable to use character fields when doing BDC. so change it to charecter field and try it..
    Regards
    Sudheer

  • Hi all, BDC call transaction METHOD, trapping ERRORS

    hi
    i have developed BDC (recording via call transaction method) for VB01. 
    could u please tell me how to display records having errors after running recording or to give index of records having errors.
    and is it possible to give transaction code for recording since my bdc is executable program.
    plase answer both the questions.
    thanx

    Here is the flow that Raja is explaining to you.
    DATA: v_index LIKE sy-tabix.
    LOOP AT itab.
      v_index = sy-tabix.
    *-- prepare the BDC data
      CALL TRANSACTION 'VB01' USING bdcdata
                               MODE 'N'
                              MESSAGES INTO bdcmsgcoll.
      READ TABLE bdcmsgcoll WITH KEY msgtyp = 'E'.
      IF sy-subrc = 0.
    *-- Error occured for the record with index <b>v_index</b>
      ELSE.
    *-- unless there is a success message with this number,
    *   it is not succesfull because 'No data for screen xxx'
    *   will not show up as an error message type, but will be
    *  a success message type
        READ TABLE bdcmsgcoll WITH KEY msgnr = '312'.
        IF sy-subrc = 0.
    *-- success
        ELSE.
    *-- error with index <b>v_index</b>
        ENDIF.
      ENDIF.
    ENDLOOP.
    As you can see, now you have the index of the record where the error occured. Now this will become complicated if you are combining several records into one transaction call. In that case you need to find how you can know all the records that you just accumulated.
    As an example, let us say you have an internal table with external number, customer, material, quantity and at every new external number, you want to create a sales order. Until you get a new external number, you will not do the call transaction because until then it will be items of the same sales order. So in this case, after the call transaction, you will have get all the records that belong to making this sales order by using the external number and then prepare your messages.
    I hope this is clear.
    Srinivas
    Message was edited by: Srinivas Adavi

  • How can we update mk01 with BDC call transaction method

    can any one send the sample code for upload of MK01 using call transaction method.
    its urgent..

    Use the following code.
    *& Report  ZMK01_VA01                                                  *
    REPORT  Z_MK01                              .
    SOURCE INTERNAL TABLE
    DATA: BEGIN OF T_SOURCE OCCURS 0,
            LIFNR TYPE LIFNR,
            EKORG TYPE EKORG,
            KTOKK TYPE KTOKK,
            NAME1 TYPE NAME1,
            SORTL TYPE SORTL,
            LAND1 TYPE LAND1,
            WAERS TYPE WAERS,
          END OF T_SOURCE.
    *DATA: E_MESSAGE TYPE C.
    ERROR MESSAGE TABLE
    DATA: T_ERRORMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    TARGET TABLE LIKE BDCDATA
    DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    TO UPLOAD DATA FROM LEGACY SYSTEM
          CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
            CODEPAGE                      = ' '
             FILENAME                      = 'D:\MK01.TXT'
             FILETYPE                      = 'DAT'
          IMPORTING
            FILELENGTH                    =
            TABLES
              data_tab                      = T_SOURCE
           EXCEPTIONS
             CONVERSION_ERROR              = 1
             FILE_OPEN_ERROR               = 2
             FILE_READ_ERROR               = 3
             INVALID_TYPE                  = 4
             NO_BATCH                      = 5
             UNKNOWN_ERROR                 = 6
             INVALID_TABLE_WIDTH           = 7
             GUI_REFUSE_FILETRANSFER       = 8
             CUSTOMER_ERROR                = 9
             NO_AUTHORITY                  = 10
             OTHERS                        = 11
          IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    TRANSFERING DATA FROM INTERNAL SOURCE TABLE TO TARGET TABLE
    LOOP AT T_SOURCE.
    REFRESH BDCDATA.
    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'
                                  T_SOURCE-LIFNR.
    perform bdc_field       using 'RF02K-EKORG'
                                  T_SOURCE-EKORG.
    perform bdc_field       using 'RF02K-KTOKK'
                                  T_SOURCE-KTOKK.
    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'
                                  T_SOURCE-NAME1.
    perform bdc_field       using 'LFA1-SORTL'
                                  T_SOURCE-SORTL.
    perform bdc_field       using 'LFA1-LAND1'
                                  T_SOURCE-LAND1.
    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'
                                  T_SOURCE-WAERS.
    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'.
    CALL TRANSACTION 'MK01' USING BDCDATA MODE 'A' MESSAGES INTO T_ERRORMSG.
    ENDLOOP.
    LOOP AT T_ERRORMSG.
    WRITE:/ 'MESSAGE TYPE',T_ERRORMSG-MSGTYP,
             'FIELDNAME WERE ERROR OCCURED', T_ERRORMSG-FLDNAME.
    *CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      ID              = T_ERRORMSG-MSGID
      LANG            = SY-LANGU
      NO              = T_ERRORMSG-MSGNR
      V1              = T_ERRORMSG-MSGV1
      V2              = T_ERRORMSG-MSGV2
      V3              = T_ERRORMSG-MSGV3
      V4              = T_ERRORMSG-MSGV4
    IMPORTING
      MSG             = E_MESSAGE
    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:/ E_MESSAGE.
    ENDLOOP.
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> SPACE.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.
    With Regards
    K Srinivas

  • Program for call transaction method

    can any body  help  me , how to write a  call transaction method . how to create error logs for call transaction method

    hi
    REPORT  ZCALL.
    TYPES : BEGIN OF itab,
    lifnr TYPE rf02k-lifnr,
    ktokk TYPE rf02k-ktokk,
    END OF itab.
    DATA : i_tab TYPE TABLE OF itab INITIAL SIZE 0,
    wa_tab TYPE itab.
    DATA : i_bdc TYPE TABLE OF bdcdata INITIAL SIZE 0,
    wa_bdc TYPE bdcdata.
    DATA : i_message LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
    wa_message TYPE bdcmsgcoll.
    DATA : fname TYPE string VALUE 'd:\manish.txt'.
    DATA: p_text(100) TYPE c.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = fname
    filetype = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = i_tab.
    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 i_tab INTO wa_tab.
    PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
    PERFORM bdc_field USING 'RF02K-LIFNR' wa_tab-lifnr.
    PERFORM bdc_field USING 'RF02K-KTOKK' wa_tab-ktokk.
    PERFORM bdc_field USING 'BDC_OKCODE' '= AUSW'.
    CALL TRANSACTION 'XK01' USING i_bdc MODE 'N'. " UPDATE 'S' MESSAGES
    "INTO i_message.
    REFRESH i_bdc.
    ENDLOOP.
    IF sy-subrc NE 0.
    READ TABLE i_message WITH KEY msgtyp = 'E'.
    IF sy-subrc = 0.
    LOOP AT i_message INTO wa_message.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    id = i_message-msgid
    lang = 'EN'
    no = i_message-msgnr
    v1 = i_message-msgv1
    v2 = i_message-msgv2
    v3 = i_message-msgv3
    v4 = i_message-msgv4
    IMPORTING
    msg = p_text
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    WRITE:/ p_text.
    ENDLOOP.
    ENDIF.
    ENDIF.
    *& Form bdc_dynpro
    text
    -->PROGRAM text
    -->DYNPRO text
    FORM bdc_dynpro USING program dynpro.
    CLEAR wa_bdc.
    wa_bdc-program = program.
    wa_bdc-dynpro = dynpro.
    wa_bdc-dynbegin = 'X'.
    APPEND wa_bdc TO i_bdc.
    ENDFORM. "bdc_dynpro
    *& Form bdc_field
    text
    -->FNAM text
    -->FVAL text
    reward if u find useful
    regards
    Nagesh.Paruchuri

  • Passing select-options values using call transaction method

    Hi Experts,
    I have a scenario in which i have three fields BUKRS,WERKS and MATKL in an internal table i_tab and I have MATNR as a selection-option.
    After this I have to use call transaction <tcode> for all the line items in the internal table and the MATNR select-option values I have to pass directly for each line of i_tab using call transaction method.
    TYPES:  BEGIN OF t_tab,
              bukrs TYPE bukrs,
              werks TYPE werks_d,
              matkl TYPE matkl,
            END OF t_tab.
    DATA:  w_tab TYPE t_tab,
                i_tab      TYPE STANDARD TABLE OF t_tab.
    SELECT-OPTIONS: s_matnr FOR marc-matnr.
    Now I am putting a loop at i_tab and have to use CALL TRANSACTION <TCODE> for each line with the SELECT-OPTIONS for MATNR.
    Please tell me whether we can pass multiple ranges for MATNR using call transcation method.
    for example there can be multiple single values/multiple ranges/excluded ranges for MATNR. so please suggest me how tho achieve this sceanrio using CALL transaction method of BDC.
    Thanks a lot.
    Regards,
    Krishan

    Hi Krishan,
    For the Call transaction TCODE there is extension ....OPTIONS from OPT. Just Check it out. I think it is possible like this.
    ... OPTIONS FROM opt
    *Effect*
    This addition gives you control using the values of the components of the structure opt, which must be of the Dictionary type CTU_PARAMS. The components have the following meaning:
    DISMODE
    Processing mode (comparable with the MODE addition)
    UPDMODE
    Update mode (comparable with the UPDATE addition)
    CATTMODE
    CATT mode (controlling a CATT procedure)
    The CATT mode can have the following values:
    ' ' No CATT procedure active
    'N' CATT procedure without single screen control
    'A' CATT procedure with single screen control
    DEFSIZE
    Use standard window size
    RACOMMIT
    COMMIT WORK does not end CATT procedure
    NOBINPT
    No batch input mode, that s SY-BINPT = SPACE.
    NOBIEND
    No batch input mode after BDC data has been read
    The components DEFSIZE , RACOMMIT, NOBINPT, NOBIEND always take the following values:
    'X' Yes
    ' ' No
    If the OPTIONS addition is omitted, the following settings are valid for the control parameters:
    DISMODE from the MODE addition
    UPDMODE
    from the UPDATE addition
    CATTMODE
    No CATT procedure active
    DEFSIZE
    Do not use standard window size
    RACOMMIT
    COMMIT WORK ends procedure successfully
    NOBINPT
    Batch input mode, that is SY-BINPT =X.
    NOBIEND
    Batch input mode also active after BDC data has been read
    Regards,
    Swapna.

  • How to send error record to session in call transaction method

    Hi experts,
    I want to send only the error record to session while executing the program in call transaction method. please give me example on this
    regards,
    siva kumar

    One logiv that I can suggest is that after you have got the details of the record in error, you write another perform build_Session and put the below logic in that.
    Logic:
    1. Build a internal table for the error records similar to the internal table you used for looping for the call transaction. In short this internal table will have only the records that have an error in call transaction.
    2. Copy the recordign that you have done before and put it in the perform inside the loop and build the BDC table.
    3. Then .using this BDC table you can build the BDC session.
    - Guru
    Reward points for helpful answers
    3.

  • How bapi different from session and call transaction?

    how bapi different from session and call transaction?
    thanks in advance.

    For one, Batch Data Communication (BDC) is older. Business Application Programming Interface (BAPI) came later, about 10 years ago (you can see this already from the name, which contains marketese like "business" ).
    More important though, they are different technologies. With BDC you build the "batch input transaction" yourself, with an ABAP program which creates the "batch input session" ("Batch-Input-Mappe" in german). You then take that session, like an object, and "run" it on a system (most of the time, this is done on a local system by the administrators, after it has been tested for correctness).
    With BAPI, a system (local or remote) exposes its interface to you through some kind of Remote Function Call (RFC). Practically, it tells you: "What do you want to do? Insert that data into Materials Management? Here is the function and the the parameters you have to use for each record". You only work with the Interface - the exposed function. How this function works does not have to interest you. You don't have sessions to "run", you fire your function calls filled with data, one after another and you're done.
    BAPI can be run remotely. With BDC, you probably have to call the administrators of the remote system and send them the session you created for them to run. With BDC you go through the whole transaction in one BDC session, with BAPI you may need more than one "BAPI calls" to do this.
    With BAPI you don't fill obcure field names with values, you just fill the parameters. You can use a BAPI from inside your ABAP program to let a "business object" do some clearly defined work for you, then you can continue with your code doing other things. You don't do this with BDC. With BDC you write a dedicated program that creates the "session", which is then executed separately.
    Batch Data Communication (BDC) is the oldest batch interfacing technique that SAP provided since the early versions of R/3. BDC is not a
    typical integration tool, in the sense that, it can be only be used for uploading data into R/3 and so it is not bi-directional.
    BDC works on the principle of simulating user input for transactional screen, via an ABAP program. Typically the input comes in the form of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The transaction is then started using this internal table as the input and executed in the background.
    In Call Transaction, the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling.
    It can also be used for real-time interfaces and custom error handling & logging features. Whereas in Batch Input Sessions, the ABAP
    program creates a session with all the transactional data, and this session can be viewed, scheduled and processed (using Transaction SM35) at a later time. The latter technique has a built-in error processing mechanism too.
    Batch Input (BI) programs still use the classical BDC approach but doesnt require an ABAP program to be written to format the
    BDCDATA. The user has to format the data using predefined structures and store it in a flat file. The BI program then reads this and
    invokes the transaction mentioned in the header record of the file.
    Direct Input (DI) programs work exactly similar to BI programs. But the only difference is, instead of processing screens they validate
    fields and directly load the data into tables using standard function modules. For this reason, DI programs are much faster (RMDATIND - Material Master DI program works at least 5 times faster) than the BDC counterpart and so ideally suited for loading large volume data. DI programs are
    not available for all application areas.
    Business Add-In (BADI) are a new SAP enhancement technique based on ABAP Objects.
    They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.
    As with customer exits two different views are available:
    In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object.
    In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.
    In contrast to customer exits, Business Add-Ins no longer assume a two-level infrastructure (SAP and customer solutions), but instead allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.

  • How to capture errors records in flat file in BDC

    hi ,
        i would like to know how to capture error records while  uploading a flat file to screen through BDC .
    appreciatable solutions are rewarded.
    thanks,
    shan

    Hi shan,
    write this code, it will solve your problem.
    DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA : I_MSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF I_ERR OCCURS 0,
              MATNR(18),
              FLAG(1),
              MSG(100),
           END OF I_ERR.
    DATA :V_LINES TYPE I.
    LOOP AT ITAB.
    REFRESH BDCTAB.
    PERFORM SCREEN USING: 'SAPLMGMM' '0060'.
    PERFORM FIELD USING: 'RMMG1-MATNR'  ITAB-MATNR,
                          'RMMG1-MBRSH' ITAB-MBRSH ,
                          'RMMG1-MTART' ITAB-MTART,
                          'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '0070'.
    PERFORM FIELD USING: 'MSICHTAUSW-KZSEL(01)' 'X' ,
                         'MSICHTAUSW-KZSEL(02)' 'X' ,
                         'MSICHTAUSW-KZSEL(09)' 'X' ,
                         'BDC_OKCODE' '=ENTR'.
    PERFORM SCREEN USING: 'SAPLMGMM' '0080'.
    PERFORM FIELD USING: 'RMMG1-WERKS' ITAB-WERKS,
                         'BDC_OKCODE' '=ENTR'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4004'.
    PERFORM FIELD USING:  'MAKT-MAKTX' ITAB-MAKTX,
                          'MARA-MEINS' 'EA' ,
                          'MARA-MATKL' '001',
                          'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4004'.
    PERFORM FIELD USING:  'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4000'.
    PERFORM FIELD USING:  'MAKT-MAKTX' ITAB-MAKTX,
                          'MARA-MEINS' 'EA',
                          'MARC-EKGRP' '001',
                          'MARA-MATKL' '001',
                          'BDC_OKCODE' '=BU'.
    CALL TRANSACTION 'MM01' USING BDCTAB
                            MODE 'A'
                            MESSAGES INTO I_MSG.
    FINDING LAST MESSAGE IN THE I_MSG TABLE*****
    DESCRIBE TABLE I_MSG LINES V_LINES.
    ACCORDING TO THE V_LINES NUMBER TABLE WILL BE READ****
    READ TABLE I_MSG INDEX V_LINES.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
       ID              = I_MSG-MSGID
       LANG            = '-D'
       NO              = I_MSG-MSGNR
       V1              = I_MSG-MSGV1
       V2              = I_MSG-MSGV2
       V3              = I_MSG-MSGV3
       V4              = I_MSG-MSGV4
    IMPORTING
       MSG             = I_ERR-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.
    IF I_MSG-MSGID EQ 'M3' AND I_MSG-MSGNR EQ '800'.
    I_ERR-FLAG = 'S'.
    ELSE.
    I_ERR-FLAG = 'E'.
    ENDIF.
    I_ERR-MATNR = ITAB-MATNR.
    APPEND I_ERR.
    CLEAR I_ERR.
    ENDLOOP.
    WRITE:/ 'SUCCESS RECORDS' COLOR COL_POSITIVE.
    SKIP.
    WRITE:/ 'MATERIAL' COLOR COL_HEADING, 20 'MESSAGE' COLOR COL_HEADING.
    LOOP AT I_ERR WHERE FLAG EQ 'S'.
    WRITE:/ I_ERR-MATNR, 20 I_ERR-MSG.
    ENDLOOP.
    SKIP 2.
    WRITE:/ 'ERROR RECORDS' COLOR COL_NEGATIVE.
    SKIP.
    WRITE:/ 'MATERIAL' COLOR COL_HEADING, 20 'MESSAGE' COLOR COL_HEADING.
    LOOP AT I_ERR WHERE FLAG EQ 'E'.
    WRITE:/ I_ERR-MATNR, 20 I_ERR-MSG.
    ENDLOOP.
    *&      Form  SCREEN
         SCREEN
    form SCREEN  using P_PROG P_SCREEN.
    BDCTAB-PROGRAM = P_PROG.
    BDCTAB-DYNPRO = P_SCREEN.
    BDCTAB-DYNBEGIN = 'X'.
    APPEND BDCTAB.
    CLEAR  BDCTAB.
    endform.                    " SCREEN
    *&      Form  FIELD
       FIELD
    form FIELD  using  FNAME FVAL .
    BDCTAB-FNAM = FNAME.
    BDCTAB-FVAL = FVAL.
    APPEND BDCTAB.
    CLEAR BDCTAB.
    endform.                    " FIELD
    Thanks,
    Murali

Maybe you are looking for