Hi error log in call transaction

How did you handle errors in Call Transaction?
Among the Call Transaction and Session Method, which is faster?

Hi,
1. Go to bdcrecx1 include.
go to form BDC_TRANSACTION .
check   LOOP AT MESSTAB.
This is the way to handle errors.
2. Call Transaction is faster.
Reward if useful!

Similar Messages

  • Caprturing error log in call transaction?

    hoiw can i get all the error in call transaction method, can any one guide me?

    see this
    *& Report ZMATERIAL
    report zmaterial_fert.
    selection-screen :begin of block bl1 with frame title  text-001.
    parameters : p_fname type rlgrap-filename,
                   p_lgort type rlgrap-filename,
                   p_update(1) default 'N',
                 p_bdcgrp(12) default 'MM_MASTER'.
    selection-screen end of block bl1.
    data: v_chr_opengrp type c,
          r_matnr like mara-matnr,
          r_werks like marc-werks,
          v_str_fname   type string.
    data : begin of bdc_itab occurs 0.
            include structure bdcdata.
    data : end of bdc_itab.
    data: begin of messtab occurs 0.
            include structure bdcmsgcoll.
    data: end   of messtab.
    data: begin of count,
            inrec(9) type n,               " input I_MATERIAL count
            create(9) type n,              " create count
            error(9) type n,               " error count
            bdc(9) type n,                 " count of BDC creates
          end of count.
    data : begin of i_material occurs 0,
         matnr(018) type c,  "Material number
         mbrsh(001) type c,  "Industry sector
         mtart(004) type c,  "Material type
         werks(004) type c,  "Plant
         lgort(004),
         lgnum(004),
         vkorg(004),
         vtweg(002),
         mtpos_mara(004),
         spart(002),
         dwerk(004),
         taxkm(001),
         versg(001),
       MTPOS(004),
         maktx(040) type c,  "Material description
         meins(003) type c,  "Base unit of measure
        matkl(009) type c,  "Material group
        bismt(018),         "old material code
        brgew(017) type c,  "Gross weight
        gewei(003) type c,  "Weight unit
        ntgew(017) type c,  "Net weight
        magrv(004) type c,  "Matl grp pack matls
        tragr(004),         "
        ladgr(004),
        prctr(007),
      EKGRP(004),
      EKWSL(004),
        chap(012),
        mattype(001),
        nogrs(001),
        outmat(018),
        valid(010),
        curr(005),
        netdeal(018),
        asess(018),
        disgr(004),
        dismm(002) type c,
        dispo(003),
       LGORT(004),
        disls(002),
        maabc(001),
       lgpro(004),
       webaz(003),
       lgfsb(004),
        plifz(003),
       STRGR(002),
        fhori(003),
        sfepr(004),
        fevor(003),
        sfcpf(006),
        beskz(001),
       perkz(001),
      VRMOD(001),
      VINT1(003),
      VINT2(003),
      ALTSL(001),
      SBDKZ(001),
      FERVOR(002),
      SFCPF(006),
       stprs(015),
      AWSLS(006),
       mtvfp(002),
    STGRP(002),
    *PRCTR(007),
      bklas(004),
      vprsv(001),
      peinh(006),
    *EKALR(015),
      verpr(015),
      hrkft(002),
    *HKMAT,
    kosgr(010),
    *LOSGR(018),
    end of i_material.
    at selection-screen on value-request for p_fname.
      call function 'KD_GET_FILENAME_ON_F4'
        exporting
          program_name  = 'Z_MM_MATERIAL_UPLOAD'
          dynpro_number = '1000'
          field_name    = 'P_FNAME'
        changing
          file_name     = p_fname.
    at selection-screen on value-request for p_lgort.
    call function 'KD_GET_FILENAME_ON_F4'
        exporting
          program_name  = 'ZMATERIAL'
          dynpro_number = '1000'
          field_name    = 'P_FNAME'
        changing
          file_name     = p_lgort.
    start-of-selection.
      if p_fname is initial.
        message i016(rp) with 'Please enter a file name'.
        leave list-processing.
      else.
        move p_fname to  v_str_fname.
      endif.
      call function 'GUI_UPLOAD'
        exporting
          filetype                = 'ASC'
          filename                = v_str_fname
          has_field_separator     = 'X'
        tables
          data_tab                = i_material
        exceptions
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          others                  = 17.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      loop at i_material.
      r_matnr = i_material-matnr.
        r_werks = i_material-werks.
        add 1 to count-inrec.
        perform bdc_dynpro      using 'SAPLMGMM' '0060'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RMMG1-MATNR'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'RMMG1-MATNR'
                                      i_material-matnr.
        perform bdc_field       using 'RMMG1-MTART'
                                      i_material-mtart.
        perform bdc_field       using 'RMMG1-MBRSH'
                                      i_material-mbrsh.
        perform bdc_dynpro using 'SAPLMGMM' '0070'.
    perform bdc_field using 'BDC_CURSOR'
    'MSICHTAUSW-DYTXT(17)'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(03)'
    'X'.
    *PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(07)'
    *'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(08)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(05)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(06)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(09)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(10)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(11)'
    'X'.
    *PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(12)'
    *'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(14)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(15)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(16)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(17)'
    'X'.
    perform bdc_field using 'BDC_OKCODE' '=P+'.
    perform bdc_dynpro using 'SAPLMGMM' '0070'.
    perform bdc_field using 'BDC_CURSOR'
    'MSICHTAUSW-DYTXT(07)'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(03)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
    'X'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(05)'
    'X'.
        perform bdc_dynpro      using 'SAPLMGMM' '0080'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RMMG1-LGNUM'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=ENTR'.
        perform bdc_field       using 'RMMG1-WERKS'
                                      i_material-werks.
        perform bdc_field       using 'RMMG1-LGORT'
                                      i_material-lgort.
        perform bdc_field       using 'RMMG1-LGNUM'
                                      i_material-lgnum.
        perform bdc_field       using 'RMMG1-VKORG'
                                      i_material-vkorg.
        perform bdc_field       using 'RMMG1-VTWEG'
                                      i_material-vtweg.
        perform bdc_dynpro      using 'SAPLMGMM' '4004'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'MAKT-MAKTX'
                                      i_material-maktx.
        perform bdc_field       using 'MARA-MEINS'
                                      i_material-meins.
        perform bdc_field       using 'MARA-MATKL'
                                      i_material-matkl.
        perform bdc_field       using 'MARA-BISMT'
                                      i_material-bismt.
        perform bdc_field       using 'MARA-BRGEW'
                                      i_material-brgew.
        perform bdc_field       using 'MARA-GEWEI'
                                      i_material-gewei.
        perform bdc_field       using 'MARA-NTGEW'
                                      i_material-ntgew.
        perform bdc_field       using 'MARA-MAGRV'
                                  i_material-magrv.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                i_material-maktx.
        perform bdc_dynpro      using 'SAPLMGMM' '4000'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'MAKT-MAKTX'
                                      i_material-maktx.
        perform bdc_field       using 'MARA-MEINS'
                                      i_material-meins.
        perform bdc_field       using 'MARA-MATKL'
                                      i_material-matkl.
         perform bdc_field       using 'MARA-SPART'
                                      i_material-spart.
        perform bdc_field       using 'MVKE-DWERK'
                                      i_material-dwerk.
        perform bdc_field       using 'BDC_CURSOR'
                                      'MG03STEUER-TAXKM(01)'.
        perform bdc_field       using 'MG03STEUER-TAXKM(01)'
                                      i_material-taxkm.
        perform bdc_dynpro      using 'SAPLMGMM' '4200'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'MAKT-MAKTX'
                                      i_material-maktx.
       perform bdc_dynpro      using 'SAPLMGMM' '4000'.
       perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
       perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                 i_material-maktx.
    perform bdc_field       using 'MARA-MTPOS_MARA'
                                  i_material-mtpos_mara.
    perform bdc_field       using 'MVKE-versg'
                                  i_material-versg.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
        perform bdc_field       using 'MARA-BRGEW'
                                      i_material-brgew.
        perform bdc_field       using 'MARA-GEWEI'
                                      i_material-gewei.
        perform bdc_field       using 'MARA-NTGEW'
                                      i_material-ntgew.
        perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MAGRV'.
      perform bdc_field       using 'MARA-MAGRV'
                                  i_material-magrv.
    perform bdc_field       using 'MARA-TRAGR'
                                  i_material-tragr.
    perform bdc_field       using 'MARC-LADGR'
                                  i_material-ladgr.
    perform bdc_field       using 'MARC-PRCTR'
                                  i_material-prctr.
    perform bdc_field       using 'MARC-MTVFP'
                                 i_material-mtvfp.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  i_material-maktx.
    perform bdc_field       using 'BDC_CURSOR'
                                  'J_1IASSVAL-J_1IVALASS'.
    perform bdc_field       using 'J_1IMTCHID-J_1ICHID'
                                  i_material-chap.
    perform bdc_field       using 'J_1IMTCHID-J_1ISUBIND'
                                 'X'..
    perform bdc_field       using 'J_1IMTCHID-J_1ICAPIND'
                                 i_material-mattype.
    perform bdc_field       using 'J_1IMTCHID-J_1IGRXREF'
                                  i_material-nogrs.
    perform bdc_field       using 'J_1IMODDET-J_1IMOOM'
                                  i_material-outmat.
    perform bdc_field       using 'J_1IASSVAL-J_1IFRDATE'
                                  i_material-valid.
    perform bdc_field       using 'J_1IASSVAL-J_1IWAERS'
                                  i_material-curr.
    perform bdc_field       using 'J_1IASSVAL-J_1IVALNDP'
                                 i_material-netdeal.
    perform bdc_field       using 'J_1IASSVAL-J_1IVALASS'
                                  i_material-asess.
    *perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    *perform bdc_field       using 'BDC_OKCODE'
                                 '/00'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'MAKT-MAKTX'.
    *perform bdc_field       using 'MAKT-MAKTX'
                                 I_MATERIAL-MAKTX.
    *perform bdc_field       using 'MVKE-MTPOS'
                                 I_MATERIAL-MTPOS.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  'ENTR'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  i_material-maktx.
    perform bdc_field       using 'MARA-MEINS'
                                  i_material-meins.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARC-DISMM'.
    perform bdc_field       using 'MARC-DISMM'
                                  i_material-dismm.
    perform bdc_field       using 'MARC-DISPO'
                                  i_material-dispo.
    perform bdc_field       using 'MARC-DISLS'
                                  i_material-disls.
    perform bdc_field       using 'MARC-MAABC'
                                  i_material-maabc.
    perform bdc_field       using 'MARC-DISGR'
                                  i_material-disgr.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  i_material-maktx.
    perform bdc_field       using 'MARC-FHORI'
                                  i_material-fhori.
    perform bdc_field       using 'MARC-LGPRO'
                                  i_material-lgpro.
    perform bdc_field       using 'MARC-LGFSB'
                                  i_material-lgfsb.
    perform bdc_field       using 'MARC-PLIFZ'
                                      i_material-plifz.
    *perform bdc_field       using 'MARC-STRGR'
                               I_MATERIAL-STRGR.
    perform bdc_field       using  'MARC-BESKZ'
                                 i_material-beskz.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    *perform bdc_field       using 'MARC-STRGR'
                               I_MATERIAL-STRGR.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
       perform bdc_field       using 'MARC-SAUFT'
                                  'X'.
    perform bdc_field       using 'MARC-SFEPR'
                                  i_material-sfepr.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_field       using 'MArc-FEVOR'
                                  i_material-fevor.
    perform bdc_field       using 'MARC-SFCPF'
                                  i_material-sfcpf.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
                                   perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                    i_material-maktx.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MBEW-BKLAS'.
    perform bdc_field       using 'MBEW-BKLAS'
                                  i_material-bklas.
    perform bdc_field       using 'MBEW-VPRSV'
                                  i_material-vprsv.
    perform bdc_field       using 'MBEW-PEINH'
                                  i_material-peinh.
    perform bdc_field       using 'MBEW-STPRS'
                                  i_material-stprs.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    perform bdc_field       using 'Mbew-kosgr'
                                   i_material-kosgr.
    perform bdc_field       using 'Mbew-HKMAT'
                                 'X'.
    perform bdc_field       using 'Mbew-HRKFT'
                                  i_material-hrkft.
    perform bdc_dynpro      using 'SAPLMGMM' '4000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                   i_material-maktx.
    *perform bdc_field       using 'Mbew-KOSGR'
                                 I_MATERIAL-KOSGR.
        perform bdc_dynpro      using 'SAPLSPO1' '0300'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=YES'.
        perform post_transaction.
        refresh bdc_itab.
        clear   bdc_itab.
      endloop.
    end-of-selection.
      perform finalization.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear bdc_itab.
      bdc_itab-program  = program.
      bdc_itab-dynpro   = dynpro.
      bdc_itab-dynbegin = 'X'.
      append bdc_itab.
    endform.                    "bdc_dynpro
           Insert field                                                  *
    form bdc_field using fnam fval.
      if fval <> ''.
        clear bdc_itab.
        bdc_itab-fnam = fnam.
        bdc_itab-fval = fval.
        append bdc_itab.
      endif.
    endform.                    "bdc_field
    *&      Form  POST_TRANSACTION
    form post_transaction.
      refresh messtab.
      clear   messtab.
      call transaction 'MM01' using bdc_itab
                  mode p_update
                update 'S'
              messages into messtab.
    submit zrpt_plantext with flatfile = p_lgort
                          with p_matnr = r_matnr
                          with p_werks = r_werks and return.
      read table messtab with key msgtyp = 'E'.
      if sy-subrc eq 0.
        perform process_error_messages.
        add 1 to count-bdc.
        if v_chr_opengrp is initial.
          perform bdc_open_group.
        endif.
        call function 'BDC_INSERT'
          exporting
            tcode          = 'MM01'
          tables
            dynprotab      = bdc_itab
          exceptions
            internal_error = 1
            not_open       = 2
            queue_error    = 3
            tcode_invalid  = 4
            others         = 5.
        if sy-subrc <> 0.
          case sy-subrc.
            when 1.
              write: / 'Internal error'.
            when 2.
              write: / 'Not open error'.
            when 3.
              write: / 'queue error'.
            when 4.
              write: / 'tcode invalid error'.
            when others.
              write: / 'other error'.
          endcase.
        endif.
      else.
        add +1 to count-create.
        format intensified off.
        format color col_normal.
        format color col_normal off.
      endif.
      clear   bdc_itab.
      refresh bdc_itab.
    endform.                               " POST_TRANSACTION
    *&      Form  PROCESS_ERROR_MESSAGES
    form process_error_messages.
      data: begin of loc_aux_message.
              include structure message.
      data: end of loc_aux_message.
      data : msgno type sy-msgno.
      loop at messtab.
        move messtab-msgnr to msgno.
        call function 'WRITE_MESSAGE'
          exporting
            msgid  = messtab-msgid
            msgno  = msgno
            msgty  = messtab-msgtyp
            msgv1  = messtab-msgv1
            msgv2  = messtab-msgv2
            msgv3  = messtab-msgv3
            msgv4  = messtab-msgv4
          importing
            messg  = loc_aux_message
          exceptions
            others = 1.
        if sy-subrc eq 0.
          format color col_negative on.
          write: /10 i_material-matnr.
          write: /10 loc_aux_message.
          format color col_negative off.
        else.
          format color col_negative on.
          write: /10 i_material-matnr.
          write: / 'Error creating message'.
          format color col_negative off.
          exit.
        endif.
      endloop.
    endform.                               " PROCESS_ERROR_MESSAGES
    *&      Form  BDC_OPEN_GROUP
    form bdc_open_group.
      call function 'BDC_OPEN_GROUP'
        exporting
          client              = sy-mandt
          group               = p_bdcgrp
          holddate            = sy-datum
          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 eq 0.
        v_chr_opengrp = 'X'.
      endif.
    endform.                               " BDC_OPEN_GROUP
    *&      Form  FINALIZATION
    form finalization.
      if v_chr_opengrp = 'X'.
        call function 'BDC_CLOSE_GROUP'
          exceptions
            not_open    = 1
            queue_error = 2
            others      = 3.
      endif.
      get time.
      skip 2.
      write: / 'Time', sy-uzeit.
      skip.
      format color col_total on.
      write: / 'Total Records: ',           40 count-inrec.
      write: / 'PERNR not of Emp Group 6 ', 40 count-error.
      write: / 'Records Created: ',         40 count-create.
      write: / 'BDC Create in group: ',     40 count-bdc.
      if v_chr_opengrp = 'X'.
        skip 1.
        format intensified on.
        format color col_negative on.
        write: / 'PLEASE USE TRANSACTION "SM35" ',
                 'TO PROCESS THE GENERATED BDC SESSION ... ',
                 p_bdcgrp.
      endif.
    endform.                               " FINALIZATION

  • Display error messages in Call transaction

    Hi Gurus,
    I have donme BDC using call transaction..can anybody help me in displaying the error messages in call transaction..
    A detailed code wud be very much helpful..
    full marks wud given
    regards
    Sahil

    hi check this,
    PERFORM Z11_BDC_VA02.
          ELSE.
            MESSAGE I013 WITH TEXT-013.
          ENDIF.
    ELSE.
              CLEAR V_FLAG.
           MESSAGE E012 WITH TEXT-012.
    ENDIF.
    FORM z11_bdc_va02 .
    *COVER 1
    perform bdc_dynpro      using 'SAPMV45A' '0102'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'VBAK-VBELN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'VBAK-VBELN'
                                  wa_head_detail-vbeln.
    *COVER 2
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=T\03'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-MABNR(01)'.
    *COVER 3
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ITNE'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-MABNR(01)'.
    *COVER 4
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SICH'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RV45A-KWMENG'.
    perform bdc_field       using 'VBAP-MATNR'
                                  wa_head_detail-matnr.
    perform bdc_field       using 'RV45A-KWMENG'
                                  v_kwmeng.
    perform bdc_field       using 'VBAP-VRKME'
                                  wa_head_detail-meins.
    *COVER 5
    perform bdc_dynpro      using 'SAPLSPO2' '0101'.
    perform bdc_field       using 'BDC_OKCODE'
                                 '=OPT1'.
    call transaction 'VA02' using it_tab1 mode 'A' UPDATE 'S' MESSAGES INTO
    IT_TAB_ERROR.
    "CAlling transaction with all screen
    Loop at it_tab_error.
    if it_tab_ERROR-MSGTYP = 'E' .
    clear v_flag.
    message I014 with TEXT-014.
    else.
    clear v_flag.
    message I019 with TEXT-019.
    endif.
    endloop.
    refresh it_tab1.
    clear V_KWMENG.
    ENDFORM.                    " z11_bdc_va02
    Reward if helpful,
    Gaurav J.
    Edited by: GAURAV on Feb 4, 2008 9:10 AM

  • 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 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

  • 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

  • Error log of failed transaction in csv format

    Hi All,
    I need to generate an error log of all failed transaction in .csv file. It needs to have the failed file name(that comes in xml) and the error. How do i do it?
    Thanks

    You should have an Error batch file being created that lists those transactions in error. If you have a particular piece of data that you want, you may have to add to the RCBDFDFL.DFD (the recipient batch DFD) file and then map the content to a GVM of the appropriate name.  But start by looking at the Error batch - assuming you don't have it set to NULL.  That isn't a CSV file, but is a plain ASCII file that you can probably read.

  • Pls tell me how to check the errors in  BDC CALL TRANSACTION

    lemme know

    HI ,
    check for the bold part..
    REPORT ZCONCUR_UPLOAD_TO_SAP NO STANDARD PAGE HEADING
                                 LINE-SIZE 170
                                 LINE-COUNT 58
                                 MESSAGE-ID ZM.
                 Internal Table                                         *
    *-Internal table for the Header input data from the Comma Delimited file
    DATA: BEGIN OF IT_DATA_HEADER OCCURS 0,
              ID    TYPE C,      "Identifier
              BUKRS(6),          "Company Code
              WAERS(7),          "Currency
              NEWKO(12),         "Vendor
              XBLNR(16),         "First Name
              XBLNR1(16),        "Last Name
              BLDAT(12),         "Document/Posting date
              PK(15),            "Reference
              WRBTR(15),         "Amount
              BKTXT(27),         "Doc.header text
              BKTXT1(27),        "Item text
              SELNO(8),          "Serial No
          END OF IT_DATA_HEADER.
    *-Internal table for the item input data from the Comma Delimited file
    DATA: BEGIN OF IT_DATA_ITEM OCCURS 0,
              ID    TYPE C,      "Identifier
              NEWKO(19),         "Vendor
              BUKRS(6),          "Company Code
              KOSTL(12),         "Cost center
              WRBTR(15),         "Amount
              SGTXT(50),         "Text
              SELNO(8),          "Serial No Header
              SELNO1(8),         "Serial No item
          END OF IT_DATA_ITEM      .
    *-Internal table for the Header input data from the Comma Delimited file
    *-Removing " " From Comma Delimited file
    DATA: BEGIN OF IT_FINAL_HEADER OCCURS 0,
              ID     TYPE C,           "Identifier
              BUKRS  LIKE BKPF-BUKRS,  "Company Code
              WAERS  LIKE BKPF-WAERS,  "Currency
              NEWKO  TYPE RF05A-NEWKO, "Vendor
              XBLNR  LIKE BKPF-XBLNR,
              XBLNR1 LIKE BKPF-XBLNR,
              BLDAT(10), " LIKE BKPF-BLDAT,  "Date
              PK(15),                  "Reference
              WRBTR(15),               "Amount
              BKTXT  LIKE BKPF-BKTXT,  "Doc.header text
              BKTXT1 LIKE BKPF-BKTXT,  "Item text
              SELNO  TYPE I,           "Serial No
              FLAG   TYPE C,
          END OF IT_FINAL_HEADER.
    *-Internal table for the Item input data from the Comma Delimited file
    *-Removing " " From Comma Delimited file
    DATA: BEGIN OF IT_FINAL_ITEM OCCURS 0,
              ID     TYPE C,           "Identifier
              NEWKO  TYPE RF05A-NEWKO, "Account
              BUKRS  LIKE BKPF-BUKRS,  "Company Code
              KOSTL  LIKE BSEG-KOSTL,  "Cost Center
              WRBTR(15),               "Amount
              SGTXT  LIKE BSEG-SGTXT,  "Text
              SELNO  TYPE I,           "Serial No
              SELNO1 TYPE I,           "Serial No
          END OF IT_FINAL_ITEM.
    **-Internal table for the  input data from the file
    DATA : BEGIN OF P_DOWNLOAD  OCCURS 0,
            V_FILEREC(1000) TYPE C,
           END OF P_DOWNLOAD.
    *--- Internal Table for Success messages
    DATA : BEGIN OF I_SUCC OCCURS 0,
             HEADER(50),
             MSG(100),                     "SUCCESS message
           END OF I_SUCC.
    *--- Internal Table for error messages
    DATA : BEGIN OF I_ERROR_LOG OCCURS 0,
             HEADER(50),
             MSG(100),                     "Error message
           END OF I_ERROR_LOG.
    *--- Internal table for getting the BDC data
    DATA : BEGIN OF IT_BDCDATA OCCURS 0.
            INCLUDE STRUCTURE BDCDATA.     " Table to hold BDC data
    DATA : END OF IT_BDCDATA.
    *--- Internal table for reading the messages of call transaction
    DATA : BEGIN OF IT_MESSAGE_TAB OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.  "Table to hold messages
    DATA : END OF IT_MESSAGE_TAB.
                          DATA DECLARATIONS                              *
    DATA:
          V_ERROR_COUNTER   TYPE I,        " error records counter
          V_MSG(100),                      " used for Error message
          V_LINES TYPE I,                  " used for format message
          V_HEAD LIKE SY-CPROG,            " Heading for report
          XMODE VALUE 'N',                 " EXECUTION MODE
          V_SUCCESS_COUNTER TYPE I,        " Success records counter
          V_UNAME LIKE APQI-USERID,        " User Name
          V_TOTAL TYPE I.                  " Total records uploaded
    DATA : V_SELNO TYPE I.
    DATA : V_CHECK TYPE I.
    DATA : V_HEADER(50) TYPE C.             "Header Information
    DATA : V_SUCC_MSG LIKE BDCMSGCOLL-MSGV1."Success Message
    DATA : V_ZERO(4) VALUE '0.00'.          "Checking Zero
    DATA : V_CHECK_ZERO  LIKE BSEG-WRBTR.   "Checking Zero
    DATA : V_CHECK_ZERO1 LIKE BSEG-WRBTR.   "Checking Zero
    DATA : V_SYSTEMDATE  LIKE BKPF-BUDAT.
    DATA : V_VALUE TYPE I.
    DATA : V_VALUE1 TYPE I.
    DATA : V_VALUE2 TYPE I.
    Flags
    DATA:
           F_BDC_OPEN,                   " BDC session open check.
           F_CONTINUE_PROCESSING.        " To continue further processing
                             CONSTANTS                                   *
    CONSTANTS:
           C_SESSION_NAME LIKE APQI-GROUPID VALUE 'F-43',  "Session
           C_X VALUE 'X'.                                  " Used for falgs
                        SELECTION SCREEN                                 *
    *--- Selection Screen with Block and title
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-038.
    PARAMETER: P_FNAME LIKE RLGRAP-FILENAME DEFAULT
                       'C:\Concur.txt'.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION SCREEN ON VALUE-REQUEST
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
      CALL FUNCTION 'F4_FILENAME'
           IMPORTING
                FILE_NAME = P_FNAME
           EXCEPTIONS
                OTHERS    = 1.
      IF SY-SUBRC <> 0.
        MESSAGE E999 WITH 'Error in opening a file'(009).
      ENDIF.
                              Top-of-page                                *
    TOP-OF-PAGE .
    *---perform to display the standard header
      PERFORM STANDARD_HEADER.
    --START OF SELECTION--
    START-OF-SELECTION.
    Upload data
      PERFORM UPLOAD_DATA.
    move data to bdcdata internal table
      PERFORM MOVE_DATA_F43.
    *--- Posting the valid data to F-43
      IF F_BDC_OPEN = C_X.
    *---perform to close bdc group
        PERFORM CLOSE_GROUP.
      ENDIF.
                             END OF SELECTION                            *
    END-OF-SELECTION.
      CHECK F_CONTINUE_PROCESSING IS INITIAL.
      PERFORM DISPLAY_REPORT.
    *&      Form  MESSAGE_FORMAT
                MESSAGE FORMAT
    FORM MESSAGE_FORMAT.
      CLEAR V_MSG.
      CALL FUNCTION 'FORMAT_MESSAGE'
           EXPORTING
                ID        = IT_MESSAGE_TAB-MSGID
                LANG      = 'EN'
                NO        = IT_MESSAGE_TAB-MSGNR
                V1        = IT_MESSAGE_TAB-MSGV1
                V2        = IT_MESSAGE_TAB-MSGV2
                V3        = IT_MESSAGE_TAB-MSGV3
                V4        = IT_MESSAGE_TAB-MSGV4
           IMPORTING
                MSG       = V_MSG
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC <> 0.
        V_MSG = SPACE.
      ENDIF.
    ENDFORM.                               " MESSAGE_FORMAT
    *&      Form  F4_HELP
    FORM F4_HELP.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_FILENAME     = ' '
                DEF_PATH         = 'C:\'
                MODE             = 'O'
                TITLE            = TEXT-025  "'Upload File'
           IMPORTING
                FILENAME         = P_FNAME
           EXCEPTIONS
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4.
      CASE SY-SUBRC.
        WHEN 3.
          MESSAGE I000 WITH TEXT-007.      " Selection Cancel.
        WHEN 4.
          MESSAGE I000 WITH TEXT-008.      " Selection Error.
      ENDCASE.
    ENDFORM.                                                    " F4_HELP
    *&      Form  STANDARD_HEADER
           STANDARD_HEADER
    FORM STANDARD_HEADER.
      FORMAT COLOR COL_HEADING INTENSIFIED OFF.
      CASE V_HEAD.
        WHEN 'Summary Report'(001).
        WHEN 'SUCC_REPORT'.
    **---To display the field headings for Success report.
          ULINE (154).
          WRITE : /001 SY-VLINE,
                   002 'Header Details '(011),
                   052 SY-VLINE,
                   053 'Document Number'(036),
                  154 SY-VLINE.
          ULINE (154).
        WHEN 'Error Report'.
    **---To display the field headings for error report.
          ULINE (154).
          WRITE : /001 SY-VLINE,
                   002 'Header Details '(011),
                   052 SY-VLINE,
                   053 'Error Message/Text'(035),
                  154 SY-VLINE.
          ULINE (154).
      ENDCASE.
    ENDFORM.                               " STANDARD_HEADER
    *&      Form  DISPLAY_REPORT
          Display Report Details
    FORM DISPLAY_REPORT.
      PERFORM SUMMARY_REPORT.
      PERFORM SUCC_REPORT.
      PERFORM ERROR_REPORT.
    ENDFORM.                               " DISPLAY_REPORT
    *&      Form  SUMMARY_REPORT
           Success & Error Count Number
    FORM SUMMARY_REPORT.
      WRITE : /030 SY-TITLE.
      SKIP 1.
      WRITE : /005 'Program Name : '(032),
               024 SY-REPID,
               080 'Date :'(033),
               088 SY-DATUM.
      SKIP 1.
      V_HEAD = 'Summary Report'(001).
      ULINE (132).
      WRITE : /1 SY-VLINE,
               5 'No. of Records read from the Data file'(014),
               45 ':', V_TOTAL LEFT-JUSTIFIED,
               132 SY-VLINE,
              /1 SY-VLINE,
               5 'No. of Records successfully posted'(015),
               45 ':', V_SUCCESS_COUNTER LEFT-JUSTIFIED,
               132 SY-VLINE,
              /1 SY-VLINE,
               5 'No. of Records Failed'(023),
               45 ':'(031), V_ERROR_COUNTER LEFT-JUSTIFIED,
               132 SY-VLINE.
      IF NOT F_BDC_OPEN IS INITIAL.
        WRITE:  /1 SY-VLINE,
                5 'Session Name'(022),
                45 ':'(031), C_SESSION_NAME LEFT-JUSTIFIED,
                132 SY-VLINE.
      ENDIF.
      ULINE (132).
      IF NOT F_BDC_OPEN IS INITIAL.
        WRITE:  /1 SY-VLINE,
                5 'Session Name'(022),
                45 ':'(031), C_SESSION_NAME LEFT-JUSTIFIED,
                132 SY-VLINE.
      ENDIF.
    ULINE (132).
    ENDFORM.                               " SUMMARY_REPORT
    *&      Form  ERROR_REPORT
          Error Report
    FORM ERROR_REPORT.
      IF NOT I_ERROR_LOG[] IS INITIAL.
        SORT I_ERROR_LOG.                  " by tcode.
        V_HEAD = 'Error Report'(013).
        NEW-PAGE.
        LOOP AT I_ERROR_LOG.
          WRITE: /001 SY-VLINE,
                  002 I_ERROR_LOG-HEADER,
                  052 SY-VLINE,
                  053 I_ERROR_LOG-MSG,
                  154 SY-VLINE.
          ULINE (154).
        ENDLOOP.
      ENDIF.
    ENDFORM.                               " ERROR_REPORT
    *&      Form  ERROR_REPORT
          Success Report
    FORM SUCC_REPORT.
      IF NOT I_SUCC[] IS INITIAL.
        SORT I_SUCC.                  " by tcode.
        V_HEAD = 'SUCC_REPORT'(034).
        NEW-PAGE.
        LOOP AT I_SUCC.
          WRITE: /001 SY-VLINE,
                  002 I_SUCC-HEADER,
                  052 SY-VLINE,
                  053 I_SUCC-MSG,
                  154 SY-VLINE.
          ULINE (154).
        ENDLOOP.
      ENDIF.
    ENDFORM.                               " SUCC_REPORT
    *&      Form  OPEN_SESSION
    FORM OPEN_SESSION.
      DATA : V_DATE LIKE SY-DATUM.         " For Hold Date.
      V_DATE = SY-DATUM - 1.               " Hold date
      V_UNAME = SY-UNAME.                  " User name
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                CLIENT              = SY-MANDT
                GROUP               = C_SESSION_NAME
                HOLDDATE            = V_DATE
                KEEP                = 'X'
                USER                = V_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 <> 0.
        MESSAGE I000 WITH 'Session can not be opened'(019).
        STOP.
      ENDIF.
      F_BDC_OPEN = 'X'.
    ENDFORM.                               " OPEN_SESSION
    *&      Form  BDC_INSERT
    FORM BDC_INSERT USING P_TCODE TYPE ANY.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                TCODE            = P_TCODE
           TABLES
                DYNPROTAB        = IT_BDCDATA
           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.
        MESSAGE I000 WITH 'Unable to insert, Error record'(037).
        STOP.
      ENDIF.
    ENDFORM.                               " BDC_INSERT
    *&      Form  CLOSE_GROUP
    FORM CLOSE_GROUP.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
           EXCEPTIONS
                NOT_OPEN    = 1
                QUEUE_ERROR = 2
                OTHERS      = 3.
      IF SY-SUBRC <> 0.
        MESSAGE I000 WITH 'Session can not be closed'(021).
        STOP.
      ENDIF.
    ENDFORM.                               " CLOSE_GROUP
    *&      Form  UPLOAD_DATA
          Upload Data From the text file
    FORM UPLOAD_DATA.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME                = P_FNAME
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = P_DOWNLOAD
           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
                OTHERS                  = 10.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH 'File does not Exist'(003).
      ELSEIF P_DOWNLOAD[] IS INITIAL.
        MESSAGE E000 WITH 'Input file is empty'(004).
      ENDIF.
      DATA: V_INDEX LIKE SY-TABIX.
      IF NOT P_DOWNLOAD[] IS INITIAL.
        LOOP AT P_DOWNLOAD.
          V_INDEX = SY-TABIX.
    *Removing double quotes
          DO.
            REPLACE '"' WITH '' INTO P_DOWNLOAD.
            IF SY-SUBRC NE 0.
              EXIT.
            ENDIF.
          ENDDO.
          MODIFY P_DOWNLOAD INDEX V_INDEX.
          CONDENSE P_DOWNLOAD.
          IF P_DOWNLOAD(1) = '1'.
    *Finding the header information, creating key field
            V_SELNO =  SY-TABIX.
          ENDIF.
    WE ARE NOT HAVING KEY FIELD IN HEADER/ITEM IN THE FILE.
    SO WE ARE CREATING MANUAL KEY FIELD IN INTERNAL TABLE (SELNO).
          IF P_DOWNLOAD(1) = '1'.
    Moving header information into IT_DATA_HEADER Internal Table
            SPLIT P_DOWNLOAD AT ',' INTO
                  IT_DATA_HEADER-ID
                  IT_DATA_HEADER-BUKRS
                  IT_DATA_HEADER-WAERS
                  IT_DATA_HEADER-NEWKO
                  IT_DATA_HEADER-XBLNR
                  IT_DATA_HEADER-XBLNR1
                  IT_DATA_HEADER-BLDAT
                  IT_DATA_HEADER-PK
                  IT_DATA_HEADER-WRBTR
                  IT_DATA_HEADER-BKTXT
                  IT_DATA_HEADER-BKTXT1.
            IT_DATA_HEADER-SELNO = V_SELNO.
            CONDENSE : IT_DATA_HEADER-ID,     IT_DATA_HEADER-BUKRS,
                       IT_DATA_HEADER-WAERS,  IT_DATA_HEADER-NEWKO,
                       IT_DATA_HEADER-XBLNR,  IT_DATA_HEADER-XBLNR1,
                       IT_DATA_HEADER-BLDAT,  IT_DATA_HEADER-PK,
                       IT_DATA_HEADER-WRBTR,  IT_DATA_HEADER-BKTXT,
                       IT_DATA_HEADER-BKTXT1, IT_DATA_HEADER-SELNO.
            APPEND IT_DATA_HEADER.
            CLEAR  IT_DATA_HEADER.
          ELSEIF P_DOWNLOAD(1) = '2'.
    Moving header information into IT_DATA_ITEM Internal Table
            SPLIT P_DOWNLOAD AT ',' INTO
                  IT_DATA_ITEM-ID
                  IT_DATA_ITEM-NEWKO
                  IT_DATA_ITEM-BUKRS
                  IT_DATA_ITEM-KOSTL
                  IT_DATA_ITEM-WRBTR
                  IT_DATA_ITEM-SGTXT.
            IT_DATA_ITEM-SELNO  = V_SELNO.
            IT_DATA_ITEM-SELNO1 = SY-TABIX.
            CONDENSE: IT_DATA_ITEM-ID,IT_DATA_ITEM-NEWKO,IT_DATA_ITEM-BUKRS,
                      IT_DATA_ITEM-KOSTL,IT_DATA_ITEM-WRBTR,
                      IT_DATA_ITEM-SGTXT,IT_DATA_ITEM-SELNO,
                      IT_DATA_ITEM-SELNO1.
            APPEND IT_DATA_ITEM.
            CLEAR  IT_DATA_ITEM.
          ENDIF.
        ENDLOOP.
    *SORT HEADER & ITEM INTERNAL Table
        SORT IT_DATA_HEADER BY SELNO.
        SORT IT_DATA_ITEM   BY SELNO SELNO1.
    *Header Information
        LOOP AT IT_DATA_HEADER.
          IT_FINAL_HEADER-ID    = IT_DATA_HEADER-ID.
          IT_FINAL_HEADER-BUKRS = IT_DATA_HEADER-BUKRS.
          IT_FINAL_HEADER-WAERS = IT_DATA_HEADER-WAERS.
          IT_FINAL_HEADER-NEWKO = IT_DATA_HEADER-NEWKO.
          CONCATENATE IT_DATA_HEADER-XBLNR IT_DATA_HEADER-XBLNR1
                      INTO IT_FINAL_HEADER-XBLNR.
          IT_FINAL_HEADER-BLDAT  = IT_DATA_HEADER-BLDAT.
          IT_FINAL_HEADER-PK     = IT_DATA_HEADER-PK.
          IT_FINAL_HEADER-WRBTR  = IT_DATA_HEADER-WRBTR.
          IT_FINAL_HEADER-BKTXT  = IT_DATA_HEADER-BKTXT.
          IT_FINAL_HEADER-BKTXT1 = IT_DATA_HEADER-BKTXT1.
          IT_FINAL_HEADER-SELNO  = IT_DATA_HEADER-SELNO.
          APPEND IT_FINAL_HEADER.
          CLEAR  IT_FINAL_HEADER.
        ENDLOOP.
    *Item Information
        LOOP AT IT_DATA_ITEM.
    CHECKING ZERO IN THE IT_DATA_ITEM-WRBTR FIELD
    It will not append the IT_FINAL_ITEM
          V_CHECK_ZERO = IT_DATA_ITEM-WRBTR.
          IF V_CHECK_ZERO NE V_CHECK_ZERO1. "V_ZERO.
            IT_FINAL_ITEM-ID     = IT_DATA_ITEM-ID.
            IT_FINAL_ITEM-NEWKO  = IT_DATA_ITEM-NEWKO.
            IT_FINAL_ITEM-BUKRS  = IT_DATA_ITEM-BUKRS.
            IT_FINAL_ITEM-KOSTL  = IT_DATA_ITEM-KOSTL.
            IT_FINAL_ITEM-WRBTR  = IT_DATA_ITEM-WRBTR.
            IT_FINAL_ITEM-SGTXT  = IT_DATA_ITEM-SGTXT.
            IT_FINAL_ITEM-SELNO  = IT_DATA_ITEM-SELNO.
            IT_FINAL_ITEM-SELNO1 = IT_DATA_ITEM-SELNO1.
            APPEND IT_FINAL_ITEM.
            CLEAR  IT_FINAL_ITEM.
            CLEAR : V_CHECK_ZERO,V_CHECK_ZERO1.
          ENDIF.
        ENDLOOP.
        SORT IT_FINAL_HEADER BY SELNO.
        SORT IT_FINAL_ITEM BY SELNO.
      ENDIF.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  MOVE_DATA_F43
          Call Transaction F-43
    FORM MOVE_DATA_F43.
    *MOVE THE SYSTEM DATE TO
      CLEAR V_SYSTEMDATE.
      V_SYSTEMDATE = SY-DATUM.
      LOOP AT IT_FINAL_HEADER.
        CLEAR V_CHECK.
        V_CHECK = IT_FINAL_HEADER-SELNO.
      MOVE HEADER DATA TO BDCDATA INTERNAL TABLE
        PERFORM BDC_BUILD_HEADER.
      MOVE ITEM DATA TO BDCDATA INTERNAL TABLE
        PERFORM BDC_BUILD_ITEM.
    <b>*   Call Transcation (F-43)
        CALL TRANSACTION 'F-43' USING IT_BDCDATA
                                MODE XMODE
                                UPDATE 'S'
                                MESSAGES INTO IT_MESSAGE_TAB.</b>
    IF error record found, it will move to batch Input session
        IF SY-SUBRC <> 0.
          V_ERROR_COUNTER = V_ERROR_COUNTER + 1.      " Inc the counter
          CLEAR V_LINES.
          DESCRIBE TABLE IT_MESSAGE_TAB LINES V_LINES.
          READ TABLE IT_MESSAGE_TAB INDEX V_LINES.
    *--- <b>Perform to read the messages
          PERFORM MESSAGE_FORMAT.</b>*--- Appending the error records into error table
          CONDENSE IT_FINAL_HEADER-BUKRS.
          CONDENSE IT_FINAL_HEADER-NEWKO.
          CONDENSE IT_FINAL_HEADER-XBLNR.
          CONDENSE IT_FINAL_HEADER-BLDAT.
          CONCATENATE IT_FINAL_HEADER-BUKRS ','
                      IT_FINAL_HEADER-NEWKO ','
                      IT_FINAL_HEADER-XBLNR ','
                      IT_FINAL_HEADER-BLDAT
                      INTO V_HEADER.
          I_ERROR_LOG-HEADER = V_HEADER.
          I_ERROR_LOG-MSG = V_MSG.
          APPEND I_ERROR_LOG.
          CLEAR I_ERROR_LOG.
    *--  Posting the error record to Session
          IF F_BDC_OPEN IS INITIAL.
            PERFORM OPEN_SESSION.
          ENDIF.
          PERFORM BDC_INSERT USING 'F-43'.
        ELSE.
          V_SUCCESS_COUNTER = V_SUCCESS_COUNTER + 1.
    *--  READING ONLY SUCCESS MESSAGE(MSGNR 312)
          LOOP AT IT_MESSAGE_TAB WHERE MSGNR = '312'.
            V_SUCC_MSG = IT_MESSAGE_TAB-MSGV1.
          ENDLOOP.
    *--- Perform to read the messages
          PERFORM MESSAGE_FORMAT.
    *--- Appending the Success records into Success table
          CONDENSE IT_FINAL_HEADER-BUKRS.
          CONDENSE IT_FINAL_HEADER-NEWKO.
          CONDENSE IT_FINAL_HEADER-PK.
          CONDENSE IT_FINAL_HEADER-XBLNR.
          CONDENSE IT_FINAL_HEADER-BLDAT.
          CONCATENATE IT_FINAL_HEADER-BUKRS ','
                      IT_FINAL_HEADER-NEWKO ','
                      IT_FINAL_HEADER-PK ','
                      IT_FINAL_HEADER-XBLNR ','
                      IT_FINAL_HEADER-BLDAT
                      INTO V_HEADER.
          I_SUCC-HEADER = V_HEADER.
          I_SUCC-MSG = V_SUCC_MSG.
          APPEND I_SUCC.
          CLEAR  I_SUCC.
        ENDIF.
        V_TOTAL = V_TOTAL + 1.
        REFRESH: IT_BDCDATA,
                 IT_MESSAGE_TAB.
        CLEAR:   IT_BDCDATA,
                 IT_MESSAGE_TAB.
      ENDLOOP.
    ENDFORM.                    " MOVE_DATA_F43
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-PROGRAM  = PROGRAM.
      IT_BDCDATA-DYNPRO   = DYNPRO.
      IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-FNAM = FNAM.
      IT_BDCDATA-FVAL = FVAL.
      APPEND IT_BDCDATA.
    ENDFORM.
    *&      Form  BDC_BUILD_HEADER
          Header Information
    FORM BDC_BUILD_HEADER.
    Header Details
      PERFORM BDC_DYNPRO      USING 'SAPMF05A'    '0100'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'  '/00'.
      PERFORM BDC_FIELD       USING 'BKPF-BLDAT'
                                     IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-BLART'
                                    'KR'.
      PERFORM BDC_FIELD       USING 'BKPF-BUKRS'
                                    IT_FINAL_HEADER-BUKRS.
    Moveing System date to Posting date in the document
      CLEAR IT_FINAL_HEADER-BLDAT.
      CONCATENATE V_SYSTEMDATE4(4) V_SYSTEMDATE0(4)
                       INTO  IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-BUDAT'
                                  IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-WAERS'
                                    IT_FINAL_HEADER-WAERS.
      PERFORM BDC_FIELD       USING 'BKPF-XBLNR'
                                    IT_FINAL_HEADER-PK.
      PERFORM BDC_FIELD       USING 'BKPF-BKTXT'
                                    IT_FINAL_HEADER-BKTXT.
      PERFORM BDC_FIELD       USING 'FS006-DOCID'  '*'.
      IF IT_FINAL_HEADER-WRBTR CA '-'.
        REPLACE '-' WITH SPACE INTO IT_FINAL_HEADER-WRBTR.
        CONDENSE IT_FINAL_HEADER-WRBTR.
        PERFORM BDC_FIELD       USING 'RF05A-NEWBS'  '25'.
      ELSE.
        PERFORM BDC_FIELD       USING 'RF05A-NEWBS'  '31'.
      ENDIF.
      PERFORM BDC_FIELD       USING 'RF05A-NEWKO'
                                     IT_FINAL_HEADER-NEWKO.
    *-- Item Vendor Details
      PERFORM BDC_DYNPRO      USING 'SAPMF05A' '0302'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'BSEG-WRBTR'
                                    IT_FINAL_HEADER-WRBTR.
      PERFORM BDC_FIELD       USING 'BSEG-SGTXT'
                                    IT_FINAL_HEADER-BKTXT1.
    ENDFORM.                    " BDC_BUILD_HEADER
    *&      Form  BDC_BUILD_ITEM
          Item Information
    FORM BDC_BUILD_ITEM.
      DATA L_FIRST TYPE C.
      LOOP AT IT_FINAL_ITEM WHERE SELNO = V_CHECK.
        IF L_FIRST IS INITIAL.
          L_FIRST = C_X.
    Line Item ( PstKy,Account & New Company Code)
         CONDENSE IT_FINAL_HEADER-BLDAT.
          IF IT_FINAL_ITEM-WRBTR CA '-'.
            REPLACE '-' WITH SPACE INTO IT_FINAL_ITEM-WRBTR.
            CONDENSE IT_FINAL_ITEM-WRBTR.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0302'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '50',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ELSE.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0302'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '40',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ENDIF.
    Amount & Text
          PERFORM BDC_DYNPRO    USING  'SAPMF05A' '0300'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                       'BSEG-WRBTR'   IT_FINAL_ITEM-WRBTR,
                                       'BSEG-SGTXT'   IT_FINAL_ITEM-SGTXT,
                                       'DKACB-FMORE'  'X'.
    Cost Center
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'    '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE',
                                       'COBL-KOSTL' IT_FINAL_ITEM-KOSTL.
        ELSE.
    Line Item ( PstKy,Account & New Company Code)
          IF IT_FINAL_ITEM-WRBTR CA '-'.
            REPLACE '-' WITH SPACE INTO IT_FINAL_ITEM-WRBTR.
            CONDENSE IT_FINAL_ITEM-WRBTR.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '50',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ELSE.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '40',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ENDIF.
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'   '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE'.
    Amount & Text
          PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE'  '/00',
                                       'BSEG-WRBTR'  IT_FINAL_ITEM-WRBTR,
                                       'BSEG-SGTXT'  IT_FINAL_ITEM-SGTXT,
                                       'DKACB-FMORE' 'X'.
    Cost Center
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'    '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE',
                                       'COBL-KOSTL' IT_FINAL_ITEM-KOSTL.
        ENDIF.
      ENDLOOP.
    *Save Details
      PERFORM BDC_DYNPRO        USING  'SAPMF05A' '0300'.
      PERFORM BDC_FIELD         USING  'BDC_OKCODE'
                                       '=BU'.
      PERFORM BDC_DYNPRO        USING  'SAPLKACB'    '0002'.
      PERFORM BDC_FIELD         USING: 'BDC_OKCODE' 'ENTE'.
    ENDFORM.                    " BDC_BUILD_ITEM
    Thanks
    Mahesh

  • Bdc error message in call transaction

    Hi all,
            Can anyone send me a program where they have used the ' BDCMSGCOLL ' structure and format_message FM. I need only complete program, please don't send sample codings or just a part of coding.
    Points are assured.
    Thanks and regards,
    subbu.

    Hi,
    Here is the BDC recording program  for updating  a custom field (out of 3 custom fields)  in CALL TRANSACTION method depends upon which value is given in text file, based on that the corresponding radio button will be selected for that PERNR in PA30.(For 3 custom fields in PA0007) created.
    Flat file contains 1) PENR    2) Custom field1      3) CF2        4) CF3.
    The values are like [ '636363', ' ', 'X', ' ' ] .
    Here is the complete program using BDCMSGCOLL structure.
    report Y0007_BDC NO STANDARD PAGE HEADING MESSAGE-ID RP LINE-SIZE 180." LINE-COUNT 28.
                  DATA DECLARATION                                     *
    TYPES : BEGIN OF TY_0007,
              PERNR      TYPE PERNR,      " PERNR
              SCHKZ      TYPE SCHKN,      " Work Schudule
              ZTERF      TYPE PT_ZTERF,   " Time Magmt Status
              R1         TYPE C,
              R2         TYPE C,
              R3         TYPE C,
            END OF TY_0007.
    DATA  : INT_0007  TYPE STANDARD TABLE OF TY_0007 WITH HEADER LINE,
            WA_0007   TYPE TY_0007.
    DATA: P_FNAME TYPE IBIPPARMS-PATH.
    DATA : begin of int_out occurs 0,
      pernr type persno,
      mesg(300),
      end of int_out.
    DATA : BEGIN OF int_err occurs 0,
      pernr type persno,
      mesg(300),
      end of int_err.
    include bdcrecx1.
              SELECTION SCREEN                                         *
    SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME.
    PARAMETERS : P_PATH TYPE string.
    SELECTION-SCREEN END OF BLOCK B.
    SELECTION-SCREEN END OF BLOCK A.
          CALL FUNCTION FOR INPUT FILE NAME                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_path.
      CALL FUNCTION 'F4_FILENAME' 
      EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = ' '
        IMPORTING
          FILE_NAME     = P_FNAME.
      p_path = p_fname.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    start-of-selection.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = P_PATH
          FILETYPE                = 'ASC'
          HAS_FIELD_SEPARATOR     = 'X'
        TABLES
          DATA_TAB                = INT_0007
        EXCEPTIONS
          FILE_OPEN_ERROR         = 1
          FILE_READ_ERROR         = 2
          NO_BATCH                = 3
          GUI_REFUSE_FILETRANSFER = 4
          INVALID_TYPE            = 5
          NO_AUTHORITY            = 6
          UNKNOWN_ERROR           = 7
          BAD_DATA_FORMAT         = 8
          HEADER_NOT_ALLOWED      = 9
          SEPARATOR_NOT_ALLOWED   = 10
          HEADER_TOO_LONG         = 11
          UNKNOWN_DP_ERROR        = 12
          ACCESS_DENIED           = 13
          DP_OUT_OF_MEMORY        = 14
          DISK_FULL               = 15
          DP_TIMEOUT              = 16
          OTHERS                  = 17.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      perform open_group.
    *Looping pernr values*
      LOOP AT INT_0007 INTO WA_0007.
        perform bdc_dynpro      using 'SAPMP50A' '1000'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
    *INSERTING THE PERNR VALUE*
        perform bdc_field       using 'RP50G-PERNR'
                                      WA_0007-PERNR.            "'00001011'.
        perform bdc_field       using 'RP50G-TIMR6'
                                      'X'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RP50G-CHOIC'.
        perform bdc_field       using 'RP50G-CHOIC'
                                      '0007'.
        perform bdc_dynpro      using 'SAPMP50A' '1000'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RP50G-PERNR'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=INS'.
        perform bdc_field       using 'RP50G-PERNR'
                                      WA_0007-PERNR.            "'1011'.
        perform bdc_field       using 'RP50G-TIMR6'
                                      'X'.
        perform bdc_field       using 'RP50G-CHOIC'
                                      'Planned Working Time - 0007'.
        perform bdc_dynpro      using 'MP000700' '2000'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=UPD'.
        perform bdc_field       using 'P0007-BEGDA'
                                      '12/01/2007'.
        perform bdc_field       using 'P0007-ENDDA'
                                      '12/31/9999'.
    *INSERTING THE WORK SCHEDULE*
        perform bdc_field       using 'P0007-SCHKZ'
                                      WA_0007-SCHKZ.            "'N12'.
        perform bdc_field       using 'P0007-ZTERF'
                                      WA_0007-ZTERF.            "'1'.
    *INSERTING THE OVERTIME CLASS*
        IF WA_0007-R1 = 'X'.
          perform bdc_field       using 'ZHQ0007-OVT_ELGBLE'
                                        'X'.
        ELSEIF WA_0007-R2 = 'X'.
          perform bdc_field       using 'ZHQ0007-OVT_NOTELG'
                                              'X'.
        ELSEIF WA_0007-R3 = 'X'.
          perform bdc_field       using 'ZHQ0007-OVT_TMPELG'
                                            'X'.
        ENDIF.
    *BDC output for transaction code*
       perform bdc_transaction using 'pa30'.  (STD)
        perform f_bdc_output using 'pa30'.  (write on our own)
      ENDLOOP.
    **Writing the output**
      PERFORM f_write_output.
      perform close_group.
    *&      Form  f_write_output
          text
    -->  p1        text
    <--  p2        text
    FORM f_write_output .
    *For Successfull  Records*
      if int_OUT[] IS NOT INITIAL.
        WRITE : /50 TEXT-004 color 4.
        write : / sy-uline.
        LOOP AT INT_OUT.
          WRITE : /40 int_out-pernr,50 '-->',54 int_out-mesg.
        ENDLOOP.
      ENDIF.
      write / sy-uline.
      SKIP 2.
    *For Error records*
      if int_err[] IS NOT INITIAL.
        WRITE /53 text-005 color 6.
        write / sy-uline.
        LOOP AT int_err.
          write :/40 int_err-pernr,50 '-->',54 int_err-mesg.
        ENDLOOP.
      endif.
      write / sy-uline.
    ENDFORM.                    " f_write_output
    *&      Form  f_bdc_output
          text
         -->P_0369   text
    FORM f_bdc_output  USING    VALUE(P_0369).
      DATA: L_MSTRING(480).
      DATA: L_SUBRC LIKE SY-SUBRC.
      REFRESH MESSTAB.
    *Capturing the output message*
      CALL TRANSACTION 'PA30' USING BDCDATA
                       MODE   CTUMODE
                       UPDATE CUPDATE
                       MESSAGES INTO MESSTAB.
    L_SUBRC = SY-SUBRC.
      IF SMALLLOG <> 'X'.
        LOOP AT MESSTAB.
    *Selection for capturing the text for records*
          SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
                                    AND   ARBGB = MESSTAB-MSGID
                                    AND   MSGNR = MESSTAB-MSGNR.
          IF SY-SUBRC = 0.
    *Moving the text from T100 to local variable*
            L_MSTRING = T100-TEXT.
            IF ( MESSTAB-MSGTYP = 'W' or
                MESSTAB-MSGTYP = 'S' OR
                MESSTAB-MSGTYP = 'E' ).
    *Moving the success records pernr and text to internal table*
              IF MESSTAB-MSGTYP = 'S'.
                INT_OUT-PERNR = WA_0007-PERNR.
                INT_OUT-MESG  = L_MSTRING.
                APPEND INT_OUT.
                CLEAR INT_OUT.
    *Moving the success records pernr and text to internal table*
              ELSEIF MESSTAB-MSGTYP = 'E'.
    *For getting the error text exactly*
                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.
                INT_ERR-PERNR = WA_0007-PERNR.
                INT_ERR-MESG  = L_MSTRING.
                APPEND INT_ERR.
                CLEAR  INT_ERR.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
        SKIP.
      ENDIF.
    *&     CALL FUNCTION 'BDC_OPEN_GROUP'
      IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
        IF E_GROUP_OPENED = ' '.
          CALL FUNCTION 'BDC_OPEN_GROUP'
            EXPORTING
              CLIENT   = SY-MANDT
              GROUP    = E_GROUP
              USER     = E_USER
              KEEP     = E_KEEP
              HOLDDATE = E_HDATE.
          E_GROUP_OPENED = 'X'.
        ENDIF.
    *&     CALL FUNCTION 'BDC_INSERT'
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = 'PA30'
          TABLES
            DYNPROTAB = BDCDATA.
    *&     CALL FUNCTION 'BDC_CLOSE_GROUP'
        CALL FUNCTION 'BDC_CLOSE_GROUP'
          EXCEPTIONS
            NOT_OPEN    = 1
            QUEUE_ERROR = 2
            OTHERS      = 3.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      REFRESH BDCDATA.
    ENDFORM.                    " f_bdc_output
    Hope it helps u..
    Kindly reward points if helpful
    Regards,
    Shanthi

  • Error message during call transaction

    Hi all,
    I want to get the message type after calling the transaction method. I've simulated an input for error, and I expect that the returned message type should be 'E' or 'W'. But it (SY-MSGTY and msgtab-MSGTYP) still returns 'S' even there is error. What's wrong ?
    Call transaction 'VL02N' USING BTAB MODE 'N' UPDATE 'S'.
    messages into msgtab.

    CALL TRANSACTION tcode USING bdcdata
                       MODE   ctumode
                       UPDATE cupdate
                       MESSAGES INTO messtab.
    LOOP AT messtab.
        msgtype = messtab-msgtyp.
    Check what the actual tranaction is giving as message for eg. mm01 does give u a sucess message saying data for the matnr is already maintained.

  • Error in BDC Call transaction

    Hi,
    I am uplaoding CoA profile data using BDC call transaction method, but records could not be uplaoded because of the error " Screen  0000 is too large for internal batch input Area". I didnt understand what is the reason for  this error.
    Could you plesae help in this?

    Hi,
    Keep the REFRESH KTAB after first Endloop.
    Like
    LOOP AT ITAB.
         LOOP AT KTAB.
        ENDLOOP.
        REFRESH KTAB.
    ENDLOOP.
    Edited by: subas  Bose on Mar 26, 2010 7:17 PM

  • Runtime error on BDC call transaction.

    Hi Everyone,
    I'm getting a run time error: "Runtime error SYNTAX_ERROR has occurred"
    Diagnosis
    Error texts from the batch input are not output
    Only a placeholder
    while debugging the error comes at the following line:
    CALL TRANSACTION 'DSZ46C_DSAL' USING bdcdata.
    can anyone help me out..
    Regards
    Rishika Bawa

    Hi ,
    There might be a problem in transaction but not in BDC. Please run the transaction, out of the program and try to post the data.
    Regards,
    Sai

  • 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

  • Abort processing when error encountered in CALL TRANSACTION

    Is there a way to abort transaction in CALL TRANSACTION <tcode> USING <bdcdata> when an error has encountered?
    If there is, what should it be?

    In CALL TRANSACTION the standard behavior of the called transaction will be replicated. So if in VA01 the billing plan population is aborted if an error is encountered your CALL TRANSACTION will behave the same way.
    BR,
    Suhas

  • 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

Maybe you are looking for

  • Can I delete the Itunes update 10.6 and go back to 1.2?

    Can I delete the Itunes update 10.6 and go back to 1.2?

  • Business Area for Depot Sales

    One of our clients who has implemented SAP thru us 3 months back has now acquired a depot for trading in excisable goods. He has acquired a dealers registration for the depot and will be shortly starting his trading activity from the depot. I have be

  • Service entry sheet - Smartform configuration

    Hi, I need to configure Smartform for the Service entry layout. Currently I can see that it is only allowing Sap Scripts for this. Can anyone please let me know on how can I assign smartform to the service entry sheet. Regards, Shahu

  • Error TT12080: No subscriber found to swap with

    Hi all, I set up active/standby replication and face with problems when duplicating data to the standby db. - I have DSN tt_twin1 on host 192.168.208.189 (active), and DSN tt_twin2 on host 192.168.208.86 (standby). - At active server: create active s

  • Need new Connect development info

    For Connect/Breeze 5 and 6, our company had been granted access to the "Breeze Telephony Adapter Reference" and the "Telephony Adapter API". We used this to integrate our own teleconferencing product into a Connect licensed server. When I try calling