BDC  for FB01  Transaction.

Hi Experts,
I am having the bdc recording of the transaction FB01 in shdb transaction.I have converted the recording into an program.I am finding difficulty in Line items posting. As I am new to FI module.
How to go about for the line item positng with respect to  psoting key is NEWBS.
Thanks in Advance
Irfan Hussain

Hi,
FB01 is a transaction very nice to learn BDC
Here a code (with french comment)
report z_fi_in_01 no standard page heading
                  line-size 80
                  line-count 65.
*-------------------------------- DATA --------------------------------*
data : v_infile(200) type c ,              " Chemin physique fich.
       v_periode(4)  type n ,              " Periode
       v_t_code(20)  type c value 'FB01' , " Code transaction.
       v_count(3)    type n ,              " Compteur de poste piec
       v_decimal(1)  type c ,              " Representation decimal
       v_nb_blanc(6) type n ,              " Nb ligne montant nul
       v_date(8)     type c .              " Date comptable
data : begin of itab_fichier_in occurs 0,
         societe(4)   type c ,                  " Société
         poste(2)     type c ,                  " Poste -> type piece
         centre(8)    type c ,                  " Centre de couts
         compte(10)   type c ,                  " Compte comptable
         code_dc(1)   type c ,                  " Code debit/credit C/D
         montantc(13) type p decimals 2 ,       " Montant credit
         montantd(13) type p decimals 2 ,       " Montant debit
       end of itab_fichier_in.
data: begin of bdc_tab occurs 100.
        include structure bdcdata.
data: end of bdc_tab.
data : begin of itab_piece occurs 0 ,
         typepiece(2) type c ,
         montantc(13) type p decimals 2 ,       " Montant credit
         montantd(13) type p decimals 2 ,       " Montant debit
         solde(13)    type p decimals 2 ,       " Solde
       end of itab_piece.
*--------------------------- PARAMETERS -------------------------------*
parameters : p_infile(100) type c
                           default '.dat'
                           lower case
                           obligatory ,
             p_nom(12) type c
                        default 'Z_PAIE'
                        obligatory ,
             p_waers like t001-waers
                        obligatory .
*-------------------------------- MAIN --------------------------------*
start-of-selection.
* Recherche des chemins physique à partir des chemins logiques.
  perform p_recherche_chemin.
* Copie du contenu du fichier dans la table interne ITAB_FICHIER_IN.
  perform p_lecture_input.
* Test si les données sont bien equilibrées.
  perform p_test_donnee.
* Ouverture du dossier.
  perform open_bdc using p_nom.
* Transformation des données type pleiade au format SAP.
  perform p_creation_batch.
* Fermeture du dossier.
  perform close_bdc.
* Edition.
  perform p_edition.
end-of-selection.
*------------------------------ PROCEDURE -----------------------------*
*   Procédure P_RECHERCHE_CHEMIN.                                      *
*   Recherche des chemins de fichiers physiques à partir des chemins   *
*   de fichiers logiques.                                              *
form p_recherche_chemin.
* Fonction de recherche du chemin physique depuis le chemin logique
* On passe en parametre le nom du fichier.
  call function 'FILE_GET_NAME'
       exporting
            client           = sy-mandt
            logical_filename = 'Z_FI_PAIE_PLEIADE_FILE'
            operating_system = sy-opsys
            parameter_1      = p_infile
       importing
            file_name        = v_infile
       exceptions
            file_not_found   = 1
            others           = 2.
* Si probleme d ouverture message et on arrete tout.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    stop.
  endif.
endform.                               " P_RECHERCHE_CHEMIN
*   Procédure P_LECTURE_INPUT.                                         *
*   Ouverture, lecture, fermeture du fichier de paie.                  *
form p_lecture_input.
  data : v_msg(100)    type c ,     " Message d erreur ouverture fichier
         v_buffer(200) type c.      " Buffer lecture fichier
* Ouverture du fichier en entrée.
  open dataset v_infile for input in text mode message v_msg.
  if sy-subrc ne space.
    write : /1 'ERREUR FATALE !' color 3,
               'IMPOSSIBLE D OUVRIR LE FICHIER EN ENTREE :',
               p_infile ,
            /1 v_msg.
    stop.
  endif.
* Lecture sequentiele du fichier en entrée.
  do.
    read dataset v_infile into v_buffer.
*   Test fin de fichier.
    if sy-subrc ne space.
      exit.
    endif.
*   Transfert du buffer dans la table interne.
    move : v_buffer+6(4)   to v_periode ,
           v_buffer+10(8)  to itab_fichier_in-centre ,
           v_buffer+18(10) to itab_fichier_in-compte ,
           v_buffer+28(2)  to itab_fichier_in-poste ,
           v_buffer+32(1)  to itab_fichier_in-code_dc ,
           v_buffer+33(18) to itab_fichier_in-montantc ,
           v_buffer+51(18) to itab_fichier_in-montantd .
*   Allimente le code société.
    if     v_buffer+0(2) eq '04'.
      move '1614' to itab_fichier_in-societe.
    elseif v_buffer+0(2) eq '09'.
      move '2826' to itab_fichier_in-societe.
    else.
      write : /1 'Société inconnue ! traitement interrompu !' ,
                 v_buffer+0(2) .
    endif.
*   On replace la decimale sur le montant.
    itab_fichier_in-montantc = itab_fichier_in-montantc / 100.
    itab_fichier_in-montantd = itab_fichier_in-montantd / 100.
*   Enregistrement de la ligne dans la table interne ITAB_FICHIER_IN.
    append itab_fichier_in.
    clear  itab_fichier_in.
  enddo.
* Fermeture du fichier en entrée.
  close dataset v_infile.
* Trie de la table interne ITAB_FICHIER_IN.
  sort itab_fichier_in by societe poste compte centre.
endform.                               " P_LECTURE_INPUT.
*   Procédure P_TEST_DONNEE.                                           *
*   Verifie si la somme des debits est egale a la somme des credits.   *
*   Verifie si n y a pas de montant nul.                               *
*   Verifie que les differents type de piece sont equilibrés entre     *
*   eux.                                                               *
*   Force le centre de cout à 91001038 pour les comptes comptables     *
*   commencent par 481801.                                             *
form p_test_donnee.
  data : v_montantc(13) type p decimals 2 ,
         v_montantd(13) type p decimals 2 .
* Cumul les montants debit et credit.
  loop at itab_fichier_in.
    v_montantc = v_montantc + itab_fichier_in-montantc.
    v_montantd = v_montantd + itab_fichier_in-montantd.
  endloop.
* Test si debit = credit.
  if v_montantc ne v_montantd.
    skip 2.
    write : /1 'ATTENTION LE FICHIER N EST PAS EQUILIBRE !!' color 3.
    skip 2.
    write : /5 'Total montant debit  :',
               v_montantd ,
            /5 'Total montant credit :' ,
               v_montantc .
    stop.
  endif.
* Verifie s il n y a pas de montant nul. Si oui on efface.
  loop at itab_fichier_in.
    if itab_fichier_in-montantc eq space and
       itab_fichier_in-montantd eq space.
      v_nb_blanc = v_nb_blanc + 1.
      delete itab_fichier_in.
    endif.
  endloop.
* Verifie que les differents postes sont equilibrés.
  clear : v_montantc, v_montantd.
  loop at itab_fichier_in.
    v_montantc = v_montantc + itab_fichier_in-montantc.
    v_montantd = v_montantd + itab_fichier_in-montantd.
    at end of poste.
      if v_montantc ne v_montantd.
        skip 2.
        write : /1 'ATTENTION LE FICHIER N EST PAS EQUILIBRE !!'
                    color 3 ,
                /1 'Au moins un type de piece n''est pas equilibré.'.
        skip 2.
        write : /5 'Montant debit  :',
                   v_montantd ,
                /5 'Montant credit :' ,
                   v_montantc .
        stop.
      endif.
      clear : v_montantc, v_montantd.
    endat.
  endloop.
* Si le compte comptable commence par 481801 on force le centre de
* couts à 91001038.
  loop at itab_fichier_in
       where compte(6) = '481801'.
    move '91001038' to itab_fichier_in-centre.
    modify itab_fichier_in.
  endloop.
endform.                               " P_TEST_DONNEE.
*   Procédure P_CREATION_BATCH.                                        *
*   Application de regle de gestion :                                  *
*     - La date est obtenue à partir de la zone période. On prend le   *
*       dernier jour du mois indiqué dans le fichier en entrée.        *
*     - Si le poste est PR alors le type de document est AC sinon il   *
*       est SA.                                                        *
*     - Si c est un debit la clé est 40, si c est un credit 50.        *
*     - Le montant du fichier en entrée est exprimé en centime.        *
form p_creation_batch.
  data : v_totald(13)  type p decimals 2 ,   " Total debit
         v_totalc(13)  type p decimals 2 ,   " Total credit
         v_total(13)   type p decimals 2 ,   " Total general
         v_clef(2)     type n ,              " Clef 50/40
         v_montant(13) type p decimals 2 ,   " Montant temporaire
         v_flag_fin(1) type n .              " Indicateur fin piece
* Recherche de la date de fin de mois de la periode
  perform p_last_day_of_month using    v_periode
                              changing v_date.
* Recherche de la constante utilisateur sur la decimal.
  perform p_decimal.
* Boucle sur la table interne.
  loop at itab_fichier_in.
*   Compteur de poste de piece.
    v_count = v_count + 1.
*   Gestion du cumul des montants.
    if itab_fichier_in-code_dc eq 'D'.
      v_total  = v_total  + itab_fichier_in-montantd.
      v_totald = v_totald + itab_fichier_in-montantd.
    else.
      v_total  = v_total  - itab_fichier_in-montantc.
      v_totalc = v_totalc + itab_fichier_in-montantc.
    endif.
*   -= Au changement de poste. =-
    at new poste.
*     Nouvelle entete
      perform p_entete_piece using itab_fichier_in-societe
                                   itab_fichier_in-poste
                                   v_date.
*     Initialisation compteur de poste de piece.
      v_count = 1.
    endat.
*   -= A la fin du poste. =-
    at end of poste.
*     Modifie l indicateur de dernier poste.
      v_flag_fin = 1.
    endat.
*   Si c est le dernier poste de la piece on ferme...
    if v_flag_fin = 1.
      if itab_fichier_in-code_dc eq 'D'.
        move 40 to v_clef.
        perform p_fermeture_piece using v_clef
                                        itab_fichier_in-compte
                                        itab_fichier_in-centre
                                        itab_fichier_in-montantd.
      else.
        move 50 to v_clef.
        perform p_fermeture_piece using v_clef
                                        itab_fichier_in-compte
                                        itab_fichier_in-centre
                                        itab_fichier_in-montantc.
      endif.
*     Gestion de l indicateur de fin de piece.
      move 0 to v_flag_fin.
*     Gestion de la table des pieces pour l edition.
      move : itab_fichier_in-poste  to itab_piece-typepiece ,
             v_totalc               to itab_piece-montantc ,
             v_totald               to itab_piece-montantd .
      append itab_piece.
      clear : v_totalc, v_totald, itab_piece.
*   Cas normal d un poste de la piece.
    else.
*     Recherche de la clef.
      if itab_fichier_in-code_dc eq 'D'.
        move 40 to v_clef.
        perform p_poste_piece using itab_fichier_in-societe
                                    v_clef
                                    itab_fichier_in-compte
                                    itab_fichier_in-centre
                                    itab_fichier_in-montantd
                                    v_date.
      else.
        move 50 to v_clef.
        perform p_poste_piece using itab_fichier_in-societe
                                    v_clef
                                    itab_fichier_in-compte
                                    itab_fichier_in-centre
                                    itab_fichier_in-montantc
                                    v_date.
      endif.
    endif.
*   -= Poste de piece. =-
*   Si plus de 900 postes dans la piece on equilibre et on contre-passe
*   dans une nouvelle piece.
    if v_count gt 900.
*     Recherche de la clef pour l'equilibrage (inverse de la normal).
      if v_total gt 0.
        move 50 to v_clef.
        v_montant = v_total.
      elseif v_total lt 0.
        move 40 to v_clef.
        v_montant = 0 - v_total.
      endif.
*     Equilibrage.
      perform p_fermeture_piece using v_clef
                                      '2122010900'
                                      v_montant.
*     Nouvelle entete de piece.
      perform p_entete_piece using itab_fichier_in-societe
                                   itab_fichier_in-poste
                                   v_date.
*     Initialization de la variable de poste de piece.
      v_count = 1.
*     Recherche de la clef pour la contre-partie.
      if v_total gt 0.
        move 40 to v_clef.
        v_montant = v_total.
      elseif v_total lt 0.
        move 50 to v_clef.
        v_montant = 0 - v_total.
      endif.
*     Contre-partie.
      perform p_poste_piece using itab_fichier_in-societe
                                  v_clef
                                  '2122010900'
                                  v_montant
                                  v_date.
*     Gestion de la table des pieces pour l edition.
      move : itab_fichier_in-poste  to itab_piece-typepiece ,
             v_totalc               to itab_piece-montantc ,
             v_totald               to itab_piece-montantd .
      append itab_piece.
      clear : v_totalc, v_totald, itab_piece.
    endif.                  " Supperieur 900 lignes.
  endloop.
endform.                               " P_CREATION_BATCH
*   Procédure P_LAST_DAY_OF_MONTH.                                     *
*   Calcul du dernier jour du mois.                                    *
form p_last_day_of_month using    i_datum
                         changing e_tt.
  data: datmm   type i ,
        datjj   type i ,
        year(4) type n ,
        date(8) type n ,
        rest    type i ,
        zw_tt   type i .
* Initialization
  clear e_tt.
* Recherche du mois.
  datmm = i_datum+2(2).
* Nombre de jour par mois.
  case datmm.
    when 1.  zw_tt = 31.
    when 2.  zw_tt = 28.
    when 3.  zw_tt = 31.
    when 4.  zw_tt = 30.
    when 5.  zw_tt = 31.
    when 6.  zw_tt = 30.
    when 7.  zw_tt = 31.
    when 8.  zw_tt = 31.
    when 9.  zw_tt = 30.
    when 10. zw_tt = 31.
    when 11. zw_tt = 30.
    when 12. zw_tt = 31.
  endcase.
* Cas particulier du mois de fevrier.
  if datmm = 2.
    move : '20'          to year(2) ,
            i_datum+0(2) to year+2(2) .
    datjj = year.
    rest  = datjj mod 4.
    if rest = 0.
      zw_tt = 29.
    endif.
  endif.
  move : '20'         to date+4(2) ,
         i_datum+0(2) to date+6(2) ,
         i_datum+2(2) to date+2(2) ,
         zw_tt        to date+0(2) .
  e_tt = date.
endform.
*   Procédure P_ENTETE_PIECE.                                          *
*   Regles :                                                           *
*            Si le poste est PR alors le type de piece est AC, sinon   *
*            il est SA.                                                *
form p_entete_piece using v_bukrs
                          poste
                          v_date.
* Lancement ecran en-tete de piece.
  perform bdc_dynpro using 'SAPMF05A' '0100'.
* Validation.
  perform bdc_field using 'BDC_OKCODE' '/00'.
* Date de piece.
  perform bdc_field using 'BKPF-BLDAT' v_date.
* Date comptable.
  perform bdc_field using 'BKPF-BUDAT' v_date.
* Type de piece.
  if poste eq 'PR'.
    perform bdc_field using 'BKPF-BLART' 'AC'.
  else.
    perform bdc_field using 'BKPF-BLART' 'SA'.
  endif.
* Société.
  perform bdc_field using 'BKPF-BUKRS' v_bukrs.
* Devise.
  perform bdc_field using 'BKPF-WAERS' p_waers.
endform.
*   Procédure P_POSTE_PIECE.                                           *
*   En fonction de la marque de decimale choisi par l'utilisateur      *
*   on passe les ',' en '.'  ou inversement.                           *
form p_poste_piece using v_bukrs
                         v_clef
                         v_compte
                         v_centre
                         v_total
                         v_date.
  data : v_data(25) type c ,           " data temporaire pour valeurs
         v_text like bseg-sgtxt ,      " Texte du poste de la piece
         v_fdlev like skb1-fdlev.      " Niveau trésorerie
* Vérifie que le compte est traité en trésorerie.
  select single fdlev
         into v_fdlev
         from skb1
         where bukrs eq v_bukrs
         and   saknr eq v_compte.
* Gestion de la zone texte de poste de la piece.
  move : v_compte to v_text ,
         '/'      to v_text+10 ,
         v_centre to v_text+11 ,
         '/'      to v_text+19 ,
         text-001 to v_text+22 .
* Gestion zone P -> C
  move v_total to v_data.
  shift v_data left deleting leading space.
* Test la constante utilisateur marquant la decimale.
  if v_decimal eq 'X'.
    replace ',' with '.' into v_data.
  else.
    replace '.' with ',' into v_data.
  endif.
* Test s il sagit du premier poste de la piece.
  if v_count eq 1.
*   Clé de comptabilisation.
    perform bdc_field using 'RF05A-NEWBS' v_clef.
*   Compte comptable.
    perform bdc_field using 'RF05A-NEWKO' v_compte.
  else.
    perform bdc_dynpro using 'SAPMF05A' '0300'.
    perform bdc_field using 'BDC_OKCODE' '/00'.
*   Clé de comptabilisation.
    perform bdc_field using 'RF05A-NEWBS' v_clef.
*   Compte comptable.
    perform bdc_field using 'RF05A-NEWKO' v_compte.
*   Inconnu ...
    perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
*   Indique de ne pas repasser sur la saisie des centres de couts ...
    perform bdc_field using 'DKACB-FMORE' ' '.
  endif.
* Lancement ecran poste de piece.
  perform bdc_dynpro using 'SAPMF05A' '0300'.
* Validation.
  perform bdc_field using 'BDC_OKCODE' '/00'.
* Si compte gestion tresorerie alors on positionne la date.
  if v_fdlev ne space.
    perform bdc_field using 'BSEG-VALUT' v_date.
  endif.
* Montant.
  perform bdc_field using 'BSEG-WRBTR' v_data.
* Texte du poste de la piece.
  perform bdc_field using 'BSEG-SGTXT' v_text.
* Inconnu ...
  perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
* Si le centre de couts est vide on ne traite pas l ecran
* de saisie du centre de couts.
  if v_centre ne space.
*   Indique de passer sur le dynpro de saisie centre de couts ...
    perform bdc_field using 'DKACB-FMORE' 'X'.
*   Ecran de saisie des centres de couts.
*   Saisie des données du poste de la piéce.
    perform bdc_dynpro using 'SAPLKACB' '0002'.
    perform bdc_field using 'BDC_OKCODE' '/EENTE'.
*   Centre de coûts.
    perform bdc_field using 'COBL-KOSTL' v_centre.
*   Encore un inconnu ...
    perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
  else.
*   Indique de passer sur le dynpro de saisie centre de couts ...
    perform bdc_field using 'DKACB-FMORE' ' '.
  endif.
endform.
*   Procédure P_FERMETURE_PIECE.                                       *
form p_fermeture_piece using v_clef
                             v_compte
                             v_centre
                             v_total.
  data : v_data(25) type c ,           " data temporaire pour valeurs
         v_text like bseg-sgtxt.
* Gestion de la zone texte de poste de la piece.
  move : v_compte to v_text ,
         '/'      to v_text+10 ,
         v_centre to v_text+11 ,
         '/'      to v_text+19 ,
         text-001 to v_text+22 .
* Gestion zone P -> C
  move v_total to v_data.
  shift v_data left deleting leading space.
* Test la constante utilisateur marquant la decimale.
  if v_decimal eq 'X'.
    replace ',' with '.' into v_data.
  else.
    replace '.' with ',' into v_data.
  endif.
  perform bdc_dynpro using 'SAPMF05A' '0300'.
  perform bdc_field using 'BDC_OKCODE' '/00'.
* Clé de comptabilisation.
  perform bdc_field using 'RF05A-NEWBS' v_clef.
* Compte comptable.
  perform bdc_field using 'RF05A-NEWKO' v_compte.
* Inconnu ...
  perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
* Indique de ne pas repasser sur la saisie des centres de couts ...
  perform bdc_field using 'DKACB-FMORE' ' '.
  perform bdc_dynpro using 'SAPMF05A' '0300'.
  perform bdc_field using 'BDC_OKCODE' '=BU'.
* Montant.
  perform bdc_field using 'BSEG-WRBTR' v_data.
* Texte du poste de la piece.
  perform bdc_field using 'BSEG-SGTXT' v_text.
* Inconnu ...
  perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
  if v_centre ne space.
*   Indique de passer sur la saisie des centres de couts ...
    perform bdc_field using 'DKACB-FMORE' 'X'.
*   Ecran de saisie des centres de couts.
*   Saisie des données du poste de la piéce.
    perform bdc_dynpro using 'SAPLKACB' '0002'.
    perform bdc_field using 'BDC_OKCODE' '/EENTE'.
*   Centre de coûts.
    perform bdc_field using 'COBL-KOSTL' v_centre.
*   Encore un inconnu ...
    perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
  else.
*   Indique de ne pas repasser sur la saisie des centres de couts ...
    perform bdc_field using 'DKACB-FMORE' ' '.
  endif.
* Transfert du dossier.
  perform insert_bdc using v_t_code.
  refresh bdc_tab.
  clear bdc_tab.
endform.
*   Form OPEN_BDC                                                      *
*   Ouverture du dossier Batch-Input.                                  *
form open_bdc using v_nom_dossier.
  call function 'BDC_OPEN_GROUP'
       exporting
            client              = sy-mandt          " Numéro de mandant
            group               = v_nom_dossier     " Nom dossier batch
            keep                = 'X'               " Code
            user                = sy-uname          " Nom utilisateur
       exceptions
            client_invalid      = 1
            destination_invalid = 2
            group_invalid       = 3
            group_is_locked     = 4
            holddate_invalid    = 5
            internal_error      = 6
            queue_error         = 7
            running             = 8
            system_lock_error   = 9
            user_invalid        = 10
            others              = 11.
  if sy-subrc ne 0.
    write : /1 text-001 ,
            /1 'Erreur :' , sy-subrc.
  endif.
  refresh bdc_tab.
  clear   bdc_tab.
  exit.
endform.                       " OPEN_BDC
*   Form CLOSE_BDC                                                     *
*   Fermeture du dossier BTCI                                          *
form close_bdc.
  call function 'BDC_CLOSE_GROUP'
       exceptions
            not_open    = 1
            queue_error = 2
            others      = 3.
  if sy-subrc ne 0.
    write : /1 text-002 ,
            /1 'Erreur :' , sy-subrc.
  endif.
endform.                     " CLOSE_BDC
*   Form BDC_DYNPRO                                                    *
*   Alimentation de la ligne d'entête de BDCTAB                        *
form bdc_dynpro using value(progname)
                      value(dynpronr).
* Efface la header-line.
  clear bdc_tab.
* Insertion des valeurs.
  bdc_tab-program  = progname.
  bdc_tab-dynpro   = dynpronr.
  bdc_tab-dynbegin = 'X'.
* Enregistrement des valeurs.
  append bdc_tab.
endform.                    " BDC_DYNPRO
*   Form BDC_FIELD                                                     *
*   Traitement des enregistrements de la structure BDCTAB              *
*      --> FIELDNAME  Nom du champ                                     *
*      --> FIELDVALUE Valeur du champ                                  *
form bdc_field using value(fieldname) value(fieldvalue).
* Efface la header-line.
  clear bdc_tab.
* Insertion des valeurs.
  bdc_tab-fnam = fieldname.
  bdc_tab-fval = fieldvalue.
* Enregistrement des valeurs.
  append bdc_tab.
endform.                " BDC_FIELD
* Form BDC_CURSOR                                                      *
* Positionnement du curseur sur un champ particulier                   *
form bdc_cursor using value(fieldname) value(fieldvalue).
* Efface la header-line.
  clear bdc_tab.
* Insertion des valeurs.
  bdc_tab-fnam = fieldname.
  bdc_tab-fval = fieldvalue.
* Enregistrement des valeurs.
  append bdc_tab.
endform.              " BDC_CURSOR
*   Form  INSERT_BDC                                                   *
*   Insertion dans le dossier BTCI                                     *
*   Attention : la transaction est codée en dur                        *
form insert_bdc using t_code.
  call function 'BDC_INSERT'
       exporting
            tcode            = t_code
       tables
            dynprotab        = bdc_tab
       exceptions
            internal_error   = 1
            not_open         = 2
            queue_error      = 3
            tcode_invalid    = 4
            printing_invalid = 5
            posting_invalid  = 6
            others           = 7.
  if sy-subrc ne 0.
    write : /1 text-003 ,
            /1 'Erreur :' , sy-subrc.
  endif.
endform.                  " INSERT_BDC
*   Procédure P_DECIMAL.                                               *
form p_decimal.
* Recherche de la constante utilisateur sur la virgule decimale.
  select single dcpfm
         into v_decimal
         from usr01
         where bname eq sy-uname.
endform.
*   Procédure P_EDITION.                                               *
*   Procédure d'edition du resultat de la génération du dossier        *
*   Batch-Input.                                                       *
form p_edition.
  data : v_solde(13) type p decimals 2.
  skip 1.
  write : /1 'Comptabilisation de la paie venant de Pléïades.'.
* Le mois.
  skip 2.
  case v_periode+2(2).
    when 01.
      write : /1 'Mois : Janvier'.
    when 02.
      write : /1 'Mois : Fevrier'.
    when 03.
      write : /1 'Mois : Mars'.
    when 04.
      write : /1 'Mois : Avril'.
    when 05.
      write : /1 'Mois : Mai'.
    when 06.
      write : /1 'Mois : Juin'.
    when 07.
      write : /1 'Mois : Juillet'.
    when 08.
      write : /1 'Mois : Aout'.
    when 09.
      write : /1 'Mois : Septembre'.
    when 10.
      write : /1 'Mois : Octobre'.
    when 11.
      write : /1 'Mois : Novembre'.
    when 12.
      write : /1 'Mois : Decembre'.
  endcase.
* La date comptable.
  skip 1.
  write : /1  'Date comptable :' ,
           18 v_date+0(2) ,
           20 '/' ,
           21 v_date+2(2) ,
           23 '/' ,
           24 v_date+4(4).
* Piece SA.
  skip 2.
  write : /1  'Piece(s) SA :' ,
          /10 'Montant Debit' ,
           40 'Montant Credit' ,
           70 'Solde'.
  loop at itab_piece where typepiece ne 'PR'.
    v_solde = itab_piece-montantd - itab_piece-montantc.
    write : /1  itab_piece-montantd ,
             31 itab_piece-montantc ,
             61 v_solde.
  endloop.
* Piece AC.
  skip 2.
  write : /1  'Piece(s) AC :' ,
          /10 'Montant Debit' ,
           40 'Montant Credit' ,
           70 'Solde'.
  loop at itab_piece where typepiece eq 'PR'.
    v_solde = itab_piece-montantd - itab_piece-montantc.
    write : /1  itab_piece-montantd ,
             31 itab_piece-montantc ,
             61 v_solde.
  endloop.
  skip 4.
  write : /1 'Anomalie :' ,
          /1 'Nombre de lignes dont le montant est nul :' ,
             v_nb_blanc no-zero.
endform.

Similar Messages

  • Need help in BDC for FB01 transaction

    My requirement is like this,
    I have a selection screen in which I need to give file name in and have two radio buttons 1)test mode 2)Update mode
    u2022     On execution of the program in test mode a pop up screen should appear for user stating any errors in the line items.
    u2022     On execution of the program in the Update mode...a pop up screen should appear stating the documents numbers posted.
    u2022     On successful execution the system will open a new screen stating the document number which was generated. In case       of error the new screen should show the error and should not post  any items in that file.
    Could anybody help me in this. And which BDC method is best for this scenario.
    Regards
    Tom

    Hi
    The COMMIT before and after CALL TRANSACTION is useless, The transaction FB01 calls the commit by itself, so u need only:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    Now ITAB is like structure BDCMSGCOLL, so after CALL Transaction u can use message statament in order to show a popup with message:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    LOOP AT ITAB.
    MESSAGE ID ITAB-MSGID TYPE 'I' NUMBER ITAB-MSGNR
             WITH ITAB-MSGV1 ITAB-MSGV2 ITAB-MSGV3 ITAB-MSGV4.
    ENDLOOP.
    Max

  • Please help in finding the bug in this BDC for FB01

    Please find the bug in the following BDC for FB01 of mine. It picks up the entries from the very first record of the excel file, every time.
    report ZFI_BDC
           no standard page heading line-size 255.
    data: bdcdata1 like bdcdata occurs 0 with header line.
    data : vf_index type i.
    DATA: BEGIN OF ENTRIES occurs 0,
            BLDAT(8),
            BUKRS(4),
            BLART(2),
            WAERS(5),
            BUDAT(8),
            RECNO(5),
            NEWBS(2),
            NEWKO(17),
            NEWNUM(1),
            WRBTR(13),
            GSBER(4),
            SECCO(4),
            zuonr(18),
            SGTXT(50),
            NEWBS_2(2),
            NEWKO_2(17),
            NEWNUM_2(1),
            WRBTR_2(13),
            GSBER_2(4),
            SECCO_2(4),
            zuonr_2(18),
            SGTXT_2(50),
            no type i,
    END OF ENTRIES.
    DATA: BEGIN OF ENTRIES2 OCCURS 0 ,
            BLDAT(8),
            BUKRS(4),
            BLART(2),
            WAERS(5),
            BUDAT(8),
            RECNO(5),
            NEWBS(2),
            NEWKO(17),
            NEWNUM(1),
            WRBTR(13),
            GSBER(4),
            SECCO(4),
            zuonr(18),
            SGTXT(50),
            NEWBS_2(2),
            NEWKO_2(17),
            NEWNUM_2(1),
            WRBTR_2(13),
            GSBER_2(4),
            SECCO_2(4),
            zuonr_2(18),
            SGTXT_2(50),
            no type i,
    END OF ENTRIES2.
    DATA: TEMP(8),
          DOCDATE(8),
          SPLGL(1),
          PKEY(2),
          GL(17),
          VCHAMT(13),
          BUSAREA(4),
          SECCODE(4),
          zzuonr(18),
          COSTCEN(10),
          AUFNR(3),
          SGTXT(50),
          item(50)           TYPE c,
          DS TYPE I,
          DS2 TYPE I.
    data : vf_start_col type i value '1',      "start column
           vf_start_row type i value '1',      "start row
           vf_end_col   type i value '256',    "maximum column
           vf_end_row   type i value '65536',  "maximum row
           p_text(20).                         "stores error messages
    Internal Table
    data : it_excel type  kcde_cells occurs 0 with header line.
    */ Field symbol
    field-symbols : <fs>.
    parameters: p_file   LIKE rlgrap-filename MEMORY ID M01,
                NOHEADER AS CHECKBOX.
    parameters: COMPANY(4) TYPE C DEFAULT 'SCL',
                GROUP(12) TYPE C DEFAULT 'BDCTEST',
                USER(12) TYPE C DEFAULT SY-UNAME,
                KEEP(1) TYPE C DEFAULT 'X',
                POSTDATE LIKE SY-DATUM DEFAULT SY-DATUM,
                DOC_TYPE(2) TYPE C DEFAULT 'SA',
                HOLDDATE LIKE SY-DATUM.
    ***********************************************upload data from excel
    CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
      EXPORTING
        filename                      = p_file
        i_begin_col                   = VF_START_COL
        i_begin_row                   = VF_START_ROW
        i_end_col                     = VF_END_COL
        i_end_row                     = VF_END_ROW
      tables
        intern                        = IT_EXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3 .
    IF sy-subrc <> 0.
              WRITE: / 'EXCEL UPLOAD FAILED :', p_file, SY-SUBRC.
    else.
      sort it_excel by row col.
          loop at it_excel.
         IF NOHEADER = 'X'
        AND It_EXCEL-row = 1.
          CONTINUE.
        ENDIF.
         vf_index = it_excel-col.
       assign component vf_index of structure ENTRIES to <fs>.
            move  it_excel-value to <fs>.
          at end of row.
            append ENTRIES.
            clear ENTRIES.
          endat.
          endloop.
      endif.
    start-of-selection.
    DS = 1.
    LOOP AT ENTRIES.
    ENTRIES-NO = DS.
    MODIFY ENTRIES.
    DS = DS + 1.
    *ON CHANGE OF ENTRIES-zuonr.
    *DS = 1.
    *ENTRIES-NO = DS.
    *MODIFY ENTRIES.
    *DS = DS + 1.
    *ENDON.
    ENDLOOP.
    LOOP AT ENTRIES where no = 1.
        MOVE-CORRESPONDING  ENTRIES TO ENTRIES2.
    APPEND ENTRIES2.
    CLEAR ENTRIES2.
      ENDLOOP.
    DS2 = 1.
    LOOP AT ENTRIES2.
    ENTRIES2-NO = DS2.
    MODIFY ENTRIES2.
    DS2 = DS2 + 1.
    *ON CHANGE OF ENTRIES2-zuonr.
    *DS2 = 1.
    *ENTRIES2-NO = DS2.
    *MODIFY ENTRIES2.
    *DS2 = DS2 + 1.
    *ENDON.
    ENDLOOP.
    LOOP AT ENTRIES.
    REFRESH BDCDATA1.
      WRITE: /  ENTRIES-RECNO,
                ENTRIES-NEWBS,
                ENTRIES-NEWKO,
                ENTRIES-NEWNUM,
                ENTRIES-WRBTR,
                ENTRIES-GSBER,
                ENTRIES-SECCO,
                ENTRIES-ZUONR,
                ENTRIES-SGTXT.
    ENDLOOP.
    WRITE: / 'THIS IS THE BDC PROGRAM FOR SAMTEL'.
    TEMP = POSTDATE.
    DOCDATE = TEMP+6(2).
    DOCDATE2(2) = TEMP4(2).
    DOCDATE4(4) = TEMP0(4).
    *delete ENTRIES where no = 1.
    delete ENTRIES2 where no = 2.
    clear ENTRIES.
    clear ENTRIES2.
    LOOP AT ENTRIES .
    if ENTRIES-no = 2.
    perform bdc_dynpro      using 'SAPMF05A' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-BLDAT'            "DOCDATE.
                                   ENTRIES-BLDAT.
    perform bdc_field       using 'BKPF-BLART'            "DOC_TYPE.
                                   ENTRIES-BLART.
    perform bdc_field       using 'BKPF-BUKRS'            "COMPANY.
                                   ENTRIES-BUKRS.
    perform bdc_field       using 'BKPF-BUDAT'            "DOCDATE.
                                   ENTRIES-BUDAT.
    perform bdc_field       using 'BKPF-WAERS'            "INR'.
                                   ENTRIES-WAERS.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-SGTXT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'BSEG-SGTXT_2'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-WRBTR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    call transaction 'F-02' using bdcdata1 mode 'A'.
    else.
    perform bdc_dynpro      using 'SAPMF05A' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-BLDAT'            "DOCDATE.
                                   ENTRIES-BLDAT.
    perform bdc_field       using 'BKPF-BLART'            "DOC_TYPE.
                                   ENTRIES-BLART.
    perform bdc_field       using 'BKPF-BUKRS'            "COMPANY.
                                   ENTRIES-BUKRS.
    perform bdc_field       using 'BKPF-BUDAT'            "DOCDATE.
                                   ENTRIES-BUDAT.
    perform bdc_field       using 'BKPF-WAERS'            "INR'.
                                   ENTRIES-WAERS.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-SGTXT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS_2.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO_2.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    **perform bdc_field       using 'BDC_CURSOR'
                                 'BSEG-SGTXT_2'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-WRBTR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    call transaction 'F-02' using bdcdata1 mode 'A'.
    endif.
    ENDLOOP.
    clear entries.
    refresh entries.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
       clear bdcdata1.
      bdcdata1-program  = program.
      bdcdata1-dynpro   = dynpro.
      bdcdata1-dynbegin = 'X'.
    append bdcdata1.
    endform.
           Insert field                                                  *
    form bdc_field using fnam fval.
       clear bdcdata1.
        bdcdata1-fnam = fnam.
        bdcdata1-fval = fval.
    append bdcdata1.
    endform.

    Alok,
    1) Write upload data from excel in Start of selection
    2) I could not find any need for table entries2 in the logic.
    3) I feel the data mapping from the uploaded file is wrong. Can you look into http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm for the proper usage. Actually, this logic will work. Similar way you can map the data to your internal table <b>entries</b>
    4) BDC part I feel its ok.
    Let me know if you have still error after these steps.
    Rgds,
    TM

  • Error while running a BDC for the Transaction F-02

    Hi,
           I'm getting an error <b><i>"Parking not possible during Batch Input"</i></b> while running a BDC for the transaction F-02.
           When i click on the error message it displays the message [b<i>]"In Customizing, you can control whether an error message is issued."</b></i>
            How to solve this issue?.
            Waiting for ur replies.........
    Regards
    N.Senthil

    Hi,
    When you are doing the recording in SHDB, and in the same screen where the TCODE to be recorded is given, there are options that you can choose called "Recording Parameters"...Select the checkbox which says "Not a Batch Input Session", this will set the sy-binpt variable to " "(in a recording by default it is "X")...and you will not get this error...
    Also make sure while writing the BDC program to make use of the "bdc options" parameter which has this property to switch of sy-binpt...
        Refer below theard for sample bdc code for f-02.
    https://forums.sdn.sap.com/click.jspa?searchID=5126766&messageID=1538409
    Regards

  • BDC For FB01

    Hi Friends,
    Anyone who had developed the BDC for FB01 T-code, please send me the source code . I am not able to create BDC for both header and line itemswise.
    Deepak.

    Hi Deepak,
    check BDC standard program RFBIBL00 or FM
    BAPI_ACC_GL_POSTING_POST
    BAPI_ACC_DOCUMENT_POST
    Also check
    Re: LSMW: problem with object RFBIBL00 tx FB01 (sapmf05a no data)
    Hope this helps
    Thanks
    Lakshman

  • Bdc for 3 transactions

    Hi gurus
    I am writing a bdc for 3 transaction , it runs fines if i execute them seperately , can u let me know who do i merge 3 transactions in one BDC . transactions used are FBRA, F.80 and F-04 .
    is their any specific way .... pls send the code if possible.....
    thanks in advance.
    its urgent

    Hi Shweta
    do u want to run all 3 transaction at a time or run separtely..
    If u want 3 at a time then
    define 3 internal table and 3 BDC struture.
    In FM BDC_INSERT use appropriate internal for correct transactio.
    Like...
    FM BDC_OPEN_GROUP..
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'FRBA'
    importing
    table = itab1.
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'F-04'
    importing
    table = itab2.
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'F.80'
    importing
    table = itab3.
    call FM "BDC_CLOSE_GROUP.
    Reward me if its useful
    Regards
    Ravi

  • Need help on BDC  for MB1A transaction.

    Hello Abapers,
    I need to create a BDC for t-code MB1A to do the Goods Issue with reference to reservation.
    I am not able to use the BAPI 'BAPI_GOODSMVT_CREATE' to do the goods issue as there are some additional functionalities (Stock Determination) to be included.
    The problem I am facing is, The stock determination will determine the Quantity, Storage Location and Valuation type for every item of the reservation. The quantity will be picked up from multiple storage locations and as a result the line item of reservation will be split into two or more for Goods Issue.
    When this happens, If the reservation is having multiple line items, tracking the next item becomes a problem.
    Please suggest a way to approach this problem.
    Usefull answers will be rewarded.
    Thanks in Advance,
    Vinutha.

    Hi
    The COMMIT before and after CALL TRANSACTION is useless, The transaction FB01 calls the commit by itself, so u need only:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    Now ITAB is like structure BDCMSGCOLL, so after CALL Transaction u can use message statament in order to show a popup with message:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    LOOP AT ITAB.
    MESSAGE ID ITAB-MSGID TYPE 'I' NUMBER ITAB-MSGNR
             WITH ITAB-MSGV1 ITAB-MSGV2 ITAB-MSGV3 ITAB-MSGV4.
    ENDLOOP.
    Max

  • BDC for ME21N Transaction

    Dear All,
    I have a requirement to create PO using transaction ME21N. I had written a code to create PO using BDC for transaction ME21. But the user wants it to be modified to ME21N. The user wants the PO created in the foreground like the one i created fro ME21. But is it possible to use BDC for ME21N or is there any other way i can change the BAPI to foreground processing like in BDC?
    Regards,
    Karthik

    Hi Raghavender,
    This is a report to display and validate the RFQ's. And once the user selects the RFQ and clicks on Create PO from RFQ push button, it should go to transaction 'ME21N' with values from RFQ. ( similar to what we do in ME21N, when we drag RFQ from the documents overview and drop it into cart, the values are populated). I want the similar functionality to happen when the user clicks on clicks on Create PO push button. But it should happen only in the foreground and not background.
    Regards,
    Karthik

  • Clarification relating to BDC for MD61 transaction

    Hi,
        Did  any one made any development for MD61 transaction. I am planning to do an BDC for upload of planning data
    for the different periods and for different materials. DId any one found any complexities in this development and
    how it is suggestible.
      I am planning to bring sales quotation data and upload as demand in MD61
    Regards
    madan

    Hi,
        Sales quotations are the proposals & their is not any reference of delivery date that we could take as production finish date i.e material availablity/ promising date in demand manangement.
        So, you need to rethink on quotation data & try to fix peiod either month or week or day that could reduce development complexity.
    Rgd,
    Chetan

  • IDOC Message type for FB01 transaction.

    Hi,
    I am going to get a file which I will pass through PI (XI) and bring into IDOC and post into SAP ECC 6.0.
    I just wanted to know which IDOC message type / basic type I should use for posting an FI document i.e. FB01 transaction.
    Rgds

    Hi,
    please read SAP notes 892103 and 551035.
    The correct IDOC type should be FIDCC1 / FIDCC2.
    Best regards,
    Andreas

  • IDOC type for FB01 transaction

    Hi,
       Can anyone please let me know about the IDOC message type that I can use for posting a document
       in the FB01 transaction?
    Regards,
    Sudeep

    Hi Sudeep,
    These are the Idoc types.. for Posting transactions...
    ACLPAY01 Posting in acctng: InB invoice
    ACLREC01 Posting in acctng: Billing document
    ACPJOU01 Posting in acctng from Mat.s mgmt
    Go to we82(t-code) and enter the above idoc type then you will know the Message type,s for Posting..
    Regards,
    Prabhudas

  • About bdc for aiab transaction,urgent plzzzzzzzz

    hi all,
    i m doing BDC for tcode AIAB.
    here the table control is coming in to picture and i don know how to handle table control,
    so if anybody can help me to come over this issue??
    my wrk is still pending,plzz try it n giv me reply,my problm is in 2nd screen in transaction,
    plzz reply asap.
    thanks
    regards
    murty

    hi,
    Following is a sample code of handling table control in BDC.
    REPORT Y730_BDC5 .
    *HANDLING TABLE CONTROL IN BDC
    DATA : BEGIN OF IT_DUMMY OCCURS 0,
           DUMMY(100) TYPE C,
           END OF IT_DUMMY.
    DATA : BEGIN OF IT_XK01 OCCURS 0,
           LIFNR(10) TYPE C,
           BUKRS(4)  TYPE C,
           EKORG(4)  TYPE C,
           KTOKK(4)  TYPE C,
           NAME1(30) TYPE C,
           SORTL(10) TYPE C,
           LAND1(3)  TYPE C,
           SPRAS(2)  TYPE C,
           AKONT(6)  TYPE C,
           FDGRV(2)  TYPE C,
           WAERS(3)  TYPE C,
           END OF IT_XK01,
           BEGIN OF IT_BANK OCCURS 0,
           BANKS(3)  TYPE C,
           BANKL(10) TYPE C,
           BANKN(10) TYPE C,
           KOINH(30) TYPE C,
           LIFNR(10) TYPE C,
           END OF IT_BANK.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
           IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = 'C:\VENDOR.TXT'
       FILETYPE                      = 'ASC'
    TABLES
       DATA_TAB                      = IT_DUMMY.
    LOOP AT IT_DUMMY.
      IF IT_DUMMY-DUMMY+0(2) = '11'.
        IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
        IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
        IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
        IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
        IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
        IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
        IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
        IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
        IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
        IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
        IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
        APPEND IT_XK01.
      ELSE.
        IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
        IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
        IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
        IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
        IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
        APPEND IT_BANK.
      ENDIF.
    ENDLOOP.
    LOOP AT IT_XK01.
    REFRESH IT_BDCDATA.
    perform bdc_dynpro      using 'SAPMF02K' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-REF_LIFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                                  IT_XK01-LIFNR.
    perform bdc_field       using 'RF02K-BUKRS'
                                  IT_XK01-BUKRS.
    perform bdc_field       using 'RF02K-EKORG'
                                  IT_XK01-EKORG.
    perform bdc_field       using 'RF02K-KTOKK'
                                  IT_XK01-KTOKK.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-TELX1'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  IT_XK01-NAME1.
    perform bdc_field       using 'LFA1-SORTL'
                                  IT_XK01-SORTL.
    perform bdc_field       using 'LFA1-LAND1'
                                  IT_XK01-LAND1.
    perform bdc_field       using 'LFA1-SPRAS'
                                  IT_XK01-SPRAS.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-KOINH(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    DATA : FNAM(20) TYPE C,
           IDX      TYPE C.
      MOVE 1 TO IDX.
    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
      CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKS.
      CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKL.
      CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKN.
      CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-KOINH.
      IDX = IDX + 1.
    ENDLOOP.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-FDGRV'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFB1-AKONT'
                                  IT_XK01-AKONT.
    perform bdc_field       using 'LFB1-FDGRV'
                                  IT_XK01-FDGRV.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    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'
                                  IT_XK01-WAERS.
    perform bdc_dynpro      using 'SAPMF02K' '0320'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'WYT3-PARVW(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    CALL TRANSACTION 'XK01' USING IT_BDCDATA
                            MODE  'A'
                           UPDATE 'S'
                         MESSAGES INTO IT_BDCMSGCOLL.
    ENDLOOP.
    FORM BDC_DYNPRO USING PROG SCR.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-PROGRAM = PROG.
      IT_BDCDATA-DYNPRO  = SCR.
      IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDCDATA.
    ENDFORM.
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-FNAM = FNAM.
      IT_BDCDATA-FVAL  = FVAL.
      APPEND IT_BDCDATA.
    ENDFORM.
    <b>Hope this is helpful.</b>

  • BDC for TS01 Transaction

    Dear All
    Manual entry in the TS01(Create Security) transaction behaves for entering the amount values differently as manual entry in the amount field will get saved but the entry through program is not getting saved.
    Data is availabe in BDCDATA table but when it when it populates and gets saved, amount will be blank and transaction gets saved.
    Need urgent on this issue.
    Help is greatly appreciated.
    Thanks,
    Azhar.

    Hi Mohammed,
        The main program associated to this program is a report type program. You cannot do a BDC for such programs.
    Instead try the bapi: BAPI_FTR_SECURITY_CREATE
    Regards,
    Ravi

  • How to add new fields for FB01 transaction both at Header and Line item

    Hi Guys,
    I would like to add the new fields at header and item level in FB01 transaction. Can I acheive this by using transaction EEWB....please help me on this.
    Thanking you

    Hi,
    We are trying to copy a work flow objects from ECC6.0 to 4.6C...where we found the following Select statement.
    *Determine Top WorkItem Instance
      if im_top_wi_id is initial.
       select wi_id top_wi_id wi_rh_task into lw_top_id from sww_wi2obj
         up to 1 rows
         where wi_rh_task = im_wftask and
               catid      = 'BO'      and
               instid     = l_instid  and
               typeid     = 'FIPP'.
       endselect.
       endif
    As table sww_wi2obj can't be found in 4.6C, can any one help how to replace or implement the same logic as above statements.
    Thank you....

  • Problem with OPERATION TEXT(LTXA1) uploading using BDC For C202 Transaction

    Hi Experts,
    Im presently doing a BDC for the trransaction C202 (Change Master Recipe),my task was to upload the 'OPERATION TEXT' field PLPOD-LTXA1 which is actually Long text to an existing master recipe from a flat file during updation of the 'OPERATION TEXT the number of lines i was able to were 34 which we number lines on the displayed page and while updating the 35th line using the concept of bdc table control it is failing to insert the update text.
    I used all the ok codes but failed to update more than 34 lines.So,can someone tell me how to update the longtext beyound it.
    This is the Screenshot of my problem:
    [BDC_C202_error|http://www.freeimagehosting.net/uploads/79af6bac49.jpg]
    Thanx in advance.

    Hi,
    There is a better way of doing the long text upload in SAP. In your BDC, if I change the text editor, the BDC will not work.
    Hence ,
    Use function module " Save_Text" to update long texts in SAP.
    Please check its FM documentation or perform a search for this FM in SDN for more clarity.
    Write back in case you face further issues.
    Regards,
    Rijuraj
    Edited by: Rijuraj Raju on Sep 10, 2010 3:05 PM

Maybe you are looking for