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>

Similar Messages

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

  • 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

  • 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

  • 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

  • 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

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

  • Problem in BDC for VA01 transaction TEXTS tab(Upgrading from 4.5b to ECC6)

    Hi All,
    I am working in upgrade project from 4.5b version to ECC6 version.
    I am facing problem in TEXTS tab of VA01 transaction. In earlier version it is a table control containing of Language, Description & First line but, in ECC6 the screen is modified with texteditor, a list box for language key and a Text type at the left.
    Now my problem is how to record this in BDC and how to read the text in the texteditor?
    Thanks in Advance,
    Ravi Kiran.

    Hi Seshagiri,
    In this case i would suggest the use of BAPI if there's no compulsion to use BDC.
    BAPI_SALESORDER_CHANGE                     Sales order: Change Sales Order
    BAPI_SALESORDER_CONFIRMDELVRY
    BAPI_SALESORDER_CREATEFROMDAT1    Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2    Sales order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA    Create Sales Order, No More
    BAPI_SALESORDER_GETLIST        Sales order: List of all Orders for Customer
    BAPI_SALESORDER_GETSTATUS      Sales Order: Display Status
    BAPI_SALESORDER_SIMULATE       Sales Order: Simulate Sales Order
    try using these for creation or change of orders instead of bdcs.
    hope this helps and revert for more clarifications if any.
    <b>Always reward points to useful suggestions.</b>
    regards,
    Vikas

  • Bdc for cs12 transaction.

    Hi all
      i am working in a object called cs12(bdc). In this transaction i am downloading the datas into a excel file and i have given the file path in my coding . when this bdc is running in a A MODE  i am getting a message that the file name already exists and if i click expand its writing the recors in the file. if the case is for some small amount of dats means each and everytime i can go with the above option if that is the case of 10000 records what needs to be done???
    Thanks in advance
    Arun.J

    try this BAPI   BAPI_EQUI_CREATE

  • 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

  • BDC for Z-transactions

    Hi all,
    I m facing a peculiar problem...
    I have a Z-transaction for FPE1 for printing purpose. My problem is I m unable to populate data into the ZFPE1 through BDC. For that matter for any of the other Z-transactions created for the standard ones.
    Though data can be populated into the corresponding standard transactions thru BDC.
    Can anyone suggest anything...
    Regards,
    Sudipto.

    hey ,
    good ans, for Z-tocde when u r using for bdc some addational code have to done , genraly this can be aviable in for all standard sap.
    code should before save like this, check for batch input.
    if sy-batch = 'x' and sy-bnipt = 'x'.
    leave screen 0.
    else.
    call transaction st-tcode.
    endif.
    if did'n under stand debug any standard tranasction and check before save that code.
    still any problem mail me to [email protected]
    Do Reward points..if found helpful

  • Can we use BAPI in place of BDC for the transaction KB15N?

    Hi,
      I have a requirement where in i need to upload an excel sheet using KB15N (transaction for MANUAL COST ALLOCATION).
    I have found an bapi BAPI_ACC_MANUAL_ALLOC_POST. Does this bapi serve my purpose completely.
    Thanks and Regards,
    Gatham

    Hi,
    The bapi <b>BAPI_ACC_MANUAL_ALLOC_POST</b> is for Accounting: Post Manual Cost Allocation.
    This is the correct BAPI, you can use this one, for more information, you can read the documentation of this BAPI
    Regards
    Sudheer

  • Bdc for mm01 transaction

    Hi friends,
        I have to upload data using mm01 transaction.
        My program has to select respective views according to material type.
        Can anybody help me.
    Thanks and regards,
    Pavani.

    Hi,
    You will save lot of time & energy if you opt to use BAPI_MATERIAL_SAVEDATA. Have a look @the sample code. Please note Do not allocate any points as this code doesn't belong to me, however I have tested it & it works fine.
    TABLES bapi_MVKEx.
    * FLAGS
    DATA: F_STOP. " Flag used to stop processing
    * DATA DECLARATIONS
    DATA : V_EMPTY TYPE I, " No. of empty records
           V_TOTAL TYPE I. " Total no. of records.
    * STRUCTURES & INTERNAL TABLES
    *--- BAPI structures
    DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control
                                      "Information
    BAPI_MAKT LIKE BAPI_MAKT, " Material Description
    BAPI_MARA1 LIKE BAPI_MARA, " Client Data
    BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
    BAPI_MARC1 LIKE BAPI_MARC, " Plant View
    BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
    BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
    BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
    BAPI_MVKE1 LIKE BAPI_MVKE, "Sales Data
    BAPI_RETURN LIKE BAPIRET2. " Return Parameter
    DATA: return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold excel file data
    DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold Matetrial descriptions
    DATA: BEGIN OF IT_MAKT OCCURS 100.
    INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF IT_MAKT.
    *--- Internal to hold the records in the text file
    DATA : BEGIN OF IT_DATA OCCURS 100,
    WERKS(4), " Plant
    MTART(4), " Material type
    MATNR(18), " Material number
    MATKL(9) , " Material group
    MBRSH(1), " Industry sector
    MEINS(3), " Base unit of measure
    GEWEI(3), " Weight Unit
    SPART(2), " Division
    EKGRP(3), " Purchasing group
    VPRSV(1), " Price control indicator
    STPRS(12), " Standard price
    PEINH(3), " Price unit
    SPRAS(2), " Language key
    MAKTX(40), " Material description
    MTPOS_MARA(4), "Item Category Group
    vkorg(4), "Sales Org
    vtweg(2), "Dist channel
    Prdha(18), "Prod Hierarchy
    ladgr(4), " Loading Group
    prctr(10), "Profit Centr
    xchpf(1), "Batch Mgmt
    kondm(2), "Material Pricing Grp
    ktgrm(2), "Account Assignment Grp
    mvgr1(4),
    mvgr2(4),
    mvgr3(4),
    versg(1), "Material Statistics Grp
    * Added fields not part of the layout
    sapmatnr(18),
    END OF IT_DATA.
    * SELECTION SCREEN. *
    SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
    PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
    'H:\DATA\Nova\rbc\zrbc129.xls'.
    PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
    PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
    P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
    P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
    P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK SCR1.
    * AT SELECTION-SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    *--- Validating file
    PERFORM VALIDATE_FILE USING P_FILE.
    * START-OF-SELECTION
    START-OF-SELECTION.
    *--- Perform to convert the Excel data into an internal table
    PERFORM CONVERT_XLS_ITAB.
    IF NOT IT_DATA[] IS INITIAL.
    *--- Perform to delete Header lines
    PERFORM DELETE_HEADER_EMPTY_RECS.
    ENDIF.
    * END OF SELECTION.
    END-OF-SELECTION.
    *--- Perform to upload Material Master data
    PERFORM UPLOAD_MATMAS.
    * Form : validate_input_file
    * Description : To provide F4 help for file if read from PC
    FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    exporting
    STATIC = 'X'
    CHANGING
    FILE_NAME = F_FILE
    EXCEPTIONS
    MASK_TOO_LONG = 1
    OTHERS = 2.
    IF SY-SUBRC <> 0.
    *MESSAGE S010" 'Error in getting filename'.
    ENDIF.
    ENDFORM. " validate_input_file
    *& Form CONVER_XLS_ITAB
    * To convert XLS to internal table
    FORM CONVERT_XLS_ITAB.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = P_FILE
    I_BEGIN_COL = P_BEGCOL
    I_BEGIN_ROW = P_BEGROW
    I_END_COL = P_ENDCOL
    I_END_ROW = P_ENDROW
    TABLES
    INTERN = IT_INTERN.
    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 to move the data into an internal data
    PERFORM MOVE_DATA.
    ENDFORM. " CONVERT_XLS_ITAB
    *& Form MOVE_DATA
    * text
    FORM MOVE_DATA.
    DATA : LV_INDEX TYPE I.
    FIELD-SYMBOLS: <fs> type any.
    *--- Sorting the internal table
    SORT IT_INTERN BY ROW COL.
    CLEAR IT_INTERN.
    LOOP AT IT_INTERN.
    MOVE IT_INTERN-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <fs>.
    *--- Asigning the field value to a field symbol
    <fs> = it_intern-value.
    *MOVE IT_INTERN-VALUE TO <fs>.
    AT END OF ROW.
    APPEND IT_DATA.
    CLEAR IT_DATA.
    ENDAT.
    ENDLOOP.
    ENDFORM. " MOVE_DATA
    *& Form DELETE_HEADER_EMPTY_RECS
    * To delete the Header and empty records
    FORM DELETE_HEADER_EMPTY_RECS.
    DATA: LV_TABIX LIKE SY-TABIX.
    IF NOT P_HEADER IS INITIAL.
    LOOP AT IT_DATA.
    IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
    DELETE IT_DATA FROM 1 TO P_HEADER.
    * P_HEADER = 0.
    EXIT.
    ENDIF.
    ENDLOOP.
    ENDIF.
    CLEAR IT_DATA.
    *--- To delete the empty lines from internal table
    LOOP AT IT_DATA.
    LV_TABIX = SY-TABIX.
    IF IT_DATA IS INITIAL.
    V_EMPTY = V_EMPTY + 1.
    DELETE IT_DATA INDEX LV_TABIX..
    ENDIF.
    ENDLOOP.
    CLEAR IT_DATA.
    *--- Total no of recs in file
    DESCRIBE TABLE IT_DATA LINES V_TOTAL.
    IF V_TOTAL = 0.
    *MESSAGE I013" No records in the file
    F_STOP = 'X'.
    STOP.
    ENDIF.
    ENDFORM. " DELETE_HEADER_EMPTY_RECS
    *& Form UPLOAD_MATMAS
    * to upload Material Master data
    FORM UPLOAD_MATMAS .
    LOOP AT IT_DATA.
    * Header
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        input              = it_data-matnr
    IMPORTING
       OUTPUT             =  it_data-sapmatnr
    EXCEPTIONS
       LENGTH_ERROR       = 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.
    BAPI_HEAD-MATERIAL = IT_DATA-sapMATNR.
    BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
    BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
    BAPI_HEAD-BASIC_VIEW = 'X'.
    BAPI_HEAD-PURCHASE_VIEW = 'X'.
    BAPI_HEAD-ACCOUNT_VIEW = 'X'.
    BAPI_HEAD-SALES_VIEW = 'X'.
    BAPI_HEAD-QUALITY_VIEW = 'X'.
    * Material Description
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = IT_DATA-SPRAS.
    IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
    APPEND IT_MAKT.
    * Client Data - Basic
    BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
    BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
    BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
    BAPI_MARA1-DIVISION = IT_DATA-SPART.
    BAPI_MARA1-item_cat = it_data-mtpos_mara.
    BAPI_MARA1-PROD_HIER = it_data-prdha.
    bapi_marax-item_cat = 'X'.
    bapi_marax-prod_hier = 'X'.
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-BASE_UOM = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-DIVISION = 'X'.
    * Plant - Purchasing
    BAPI_MARC1-PLANT = IT_DATA-WERKS.
    BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
    BAPI_MARC1-LOADINGGRP = IT_DATA-LADGR.
    BAPI_MARC1-PROFIT_CTR = IT_DATA-prctr.
    BAPI_MARC1-BATCH_MGMT = IT_DATA-xchpf.
    bapi_marc1-qm_authgrp = 'X'.
    bapi_marcx-qm_authgrp = 'X'.
    BAPI_MARCX-PLANT = IT_DATA-WERKS.
    BAPI_MARCX-PUR_GROUP = 'X'.
    BAPI_MARCX-LOADINGGRP = 'X'.
    BAPI_MARCX-PROFIT_CTR = 'X'.
    BAPI_MARCX-BATCH_MGMT = 'X'.
    * Accounting
    BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
    BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
    BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
    BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
    BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE = 'X'.
    BAPI_MBEWX-PRICE_UNIT = 'X'.
    * Sales Data
    BAPI_MVKE1-ITEM_CAT = IT_DATA-MTPOS_MARA.
    BAPI_MVKEX-ITEM_CAT = 'X'.
    BAPI_MVKE1-SALES_ORG = IT_DATA-vkorg.
    BAPI_MVKEX-SALES_ORG = IT_DATA-vkorg.
    BAPI_MVKE1-DISTR_CHAN = IT_DATA-vtweg.
    BAPI_MVKEX-DISTR_CHAN = IT_DATA-vtweg.
    BAPI_MVKE1-MAT_PR_GRP = IT_DATA-kondm.
    BAPI_MVKEX-MAT_PR_GRP = 'X'.
    BAPI_MVKE1-ACCT_ASSGT = IT_DATA-ktgrm.
    BAPI_MVKEX-ACCT_ASSGT = 'X'.
    BAPI_MVKE1-MATL_GRP_1 = IT_DATA-mvgr1.
    BAPI_MVKEX-MATL_GRP_1 = 'X'.
    BAPI_MVKE1-MATL_GRP_2 = IT_DATA-mvgr2.
    BAPI_MVKEX-MATL_GRP_2 = 'X'.
    BAPI_MVKE1-MATL_GRP_3 = IT_DATA-mvgr3.
    BAPI_MVKEX-MATL_GRP_3 = 'X'.
    BAPI_MVKE1-matl_stats = IT_DATA-versg.
    BAPI_MVKEX-matl_stats = 'X'.
    *--- BAPI to create material
    call function 'BAPI_MATERIAL_SAVEDATA'
    exporting
    HEADDATA = BAPI_HEAD
    CLIENTDATA = BAPI_MARA1
    CLIENTDATAX = BAPI_MARAX
    PLANTDATA = BAPI_MARC1
    PLANTDATAX = BAPI_MARCX
    SALESDATA = BAPI_MVKE1
    SALESDATAX = BAPI_MVKEX
    IMPORTING
    RETURN = BAPI_RETURN
    TABLES
    MATERIALDESCRIPTION = IT_MAKT
    IF BAPI_RETURN-TYPE = 'E'.
    WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,it_data-matnr.
    ELSEIF BAPI_RETURN-TYPE = 'S'.
    WRITE: 'Successfully created/Changed material' ,it_data-matnr.
          CLEAR return.
          REFRESH return.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
               IMPORTING
                    return = return.
    ENDIF.
    ENDLOOP.
    ENDFORM. " UPLOAD_MATMAS
    Regards
    Raju Chitale

Maybe you are looking for

  • Windows 8.1 Pro Bitlocker with HP Envy 700

    I just got a new HP Envy 700-249. I upgraded to Windows 8.1 Pro immediately for Bitlocker and Remote Access. The PC will be stored in a relatively unsecure location and is for public use - but will have a few users who have access to install software

  • Error message "unsupported image format" over red screen

    Working my way through a project making corrections to a series of jpegs, when the image preview disappears and turns red with the error message "unsupported image format" in small print over the top, the thumbnail is fine and I know the image to be

  • Designing Swing Applications - Layout

    When using JDeveloper to design a Swing application (not ADF Swing) is it possible to; 1. when viewing the design of a frame for example, is it possible to display a grid so that you can align components correctly? 2. when you have selected a layout

  • SSH to Mac using a Windows Client

    I was just wondering if anyone knew of an easy (GUI) client program for a Windows XP/Vista computer to SSH into a Mac for file sharing? Also is there a SSH client program for Windows that will broadcast the Bonjour services that are found on the host

  • Logistics Execution -sd

    Dear birds, I am looking for sd LE config template on this  Text Removed   Please help in current proj regards, Lisa Edited by: Lisa Holland BMW on Feb 17, 2012 12:08 PM Edited by: Lakshmipathi on Feb 17, 2012 6:57 PM Dont ask any SAP information to