BDC for ME21n

Hi All,
I need to create a BDC program for the creation of purchase orders using tcode ME21n.
I have Header data & Item data to upload while creating the purchase order.
How to handle the uploading of header data & item data.
How should we code the program & how the flatfile should be designed.
Regards,
Sudhir

Hi
Here I am giving you a sample code..where we need to create PO's from Z table...
Regarding the structure of the flat file, it is purely based on the client and the functional team.. they will know better which fields are to be filled. So, you have to sit with the functional guy and do the recording using SHDB tcode and then decide with the flat file.
*& Report  ZZPO_BDC
REPORT  ZZPO_BDC no standard page heading line-size 255.
tables: zzpo_staging.
DATA  id type string..
DATA: fnam(20) type c,
       matnr type bstmg.
data: quan(13) type c,
      netpr(15) type c,
      qty(13) type c,
      gp(15) type c.
DATA  idx type string.
data: i_bdcdata like bdcdata occurs 1 with header line,
      i_msg like bdcmsgcoll occurs 1 with header line.
DATA  W_STR type string.
DATA: IT_STAGING TYPE STANDARD TABLE OF ZZPO_STAGING WITH HEADER LINE,
      ti_staging type standard table of zzpo_staging with header line,
      KT_STAGING TYPE STANDARD TABLE OF ZZPO_STAGING WITH HEADER LINE.
*CALL FUNCTION 'BDC_OPEN_GROUP'
* EXPORTING
*   CLIENT                    = SY-MANDT
*   DEST                      = 'zzpo'
*   GROUP                     =  'zzpo'
**   HOLDDATE                  = FILLER8
*   KEEP                      = 'X'
*   USER                      =  sy-uname
**   RECORD                    = FILLER1
**   PROG                      = SY-CPROG
**   DCPFM                     = '%'
**   DATFM                     = '%'
** IMPORTING
**   QID                       =
** EXCEPTIONS
**   CLIENT_INVALID            = 1
**   DESTINATION_INVALID       = 2
**   GROUP_INVALID             = 3
**   GROUP_IS_LOCKED           = 4
**   HOLDDATE_INVALID          = 5
**   INTERNAL_ERROR            = 6
**   QUEUE_ERROR               = 7
**   RUNNING                   = 8
**   SYSTEM_LOCK_ERROR         = 9
**   USER_INVALID              = 10
**   OTHERS                    = 11
*IF SY-SUBRC <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
start-of-selection.
*perform open_group.
  SELECT * FROM ZZPO_STAGING INTO TABLE IT_STAGING.
  select * from zzpo_staging into table ti_staging.
  SELECT * fROM ZZPO_STAGING INTO TABLE KT_sTAGING.
    delete adjacent duplicates from it_staging comparing vendor docdate.
  loop at IT_STAGING.
    perform bdc_dynpro      using 'SAPMM06E' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKKO-EKGRP'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'EKKO-LIFNR'
                                   IT_STAGING-vendor.
    perform bdc_field       using 'RM06E-BSART'
                                  'NB'.
    perform bdc_field       using 'RM06E-BEDAT'
                                   IT_STAGING-docdate.
    perform bdc_field       using 'EKKO-EKORG'
                                   IT_STAGING-purorg.
    perform bdc_field       using 'EKKO-EKGRP'
                                   IT_STAGING-purgrp.
    perform bdc_field       using 'RM06E-LPEIN'
                                  'T'.
*  endloop.
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM06E-EPSTP(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=DETA'.
    perform bdc_dynpro      using 'SAPMM06E' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'EKPO-WERKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    move 1 to id.
    loop at TI_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE.
      concatenate 'RM06E-EPSTP(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-itmcategory.
      concatenate 'EKPO-KNTTP(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-accassignment.
      concatenate 'EKPO-EMATN(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-material.
      concatenate 'EKPO-TXZ01(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-shortxt.
      quan = ti_staging-poqty.
      concatenate 'EKPO-MENGE(0' id ')' into fnam.
      perform bdc_field       using fnam quan.
      concatenate 'RM06E-EEIND(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-deliverydate.
      netpr = ti_staging-netpr.
      concatenate 'EKPO-NETPR(0' id ')' into fnam.
      perform bdc_field       using fnam netpr.
      concatenate 'EKPO-MATKL(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-mategroup.
      concatenate 'EKPO-WERKS(0' id ')' into fnam.
      perform bdc_field       using fnam TI_STAGING-plant.
      ID = ID + 1.
    ENDLOOP.
*    perform bdc_dynpro      using 'SAPMM06E' '0111'.
*    perform bdc_field       using 'BDC_CURSOR'
*                                  'EKPO-MENGE'.
*    perform bdc_field       using 'BDC_OKCODE'
*                                  '/00'.
*perform bdc_field       using 'EKPO-KNTTP'
*                              'N'.
*perform bdc_field       using 'EKPO-TXZ01'
*                              'Office Supplies'.
*perform bdc_field       using 'EKPO-MENGE'
*                              '2'.
*    perform bdc_field       using 'EKPO-SPINF'
*                                  'B'.
*    perform bdc_field       using 'EKPO-BPUMN'
*                                  '1'.
*    perform bdc_field       using 'EKPO-BPUMZ'
*                                  '1'.
*    perform bdc_field       using 'EKPO-PRSDR'
*                                  'X'.
*perform bdc_field       using 'RM06E-EEIND'
*                              '06/24/2008'.
*perform bdc_field       using 'RM06E-LPEIN'
*                              'D'.
*    perform bdc_field       using 'EKPO-WEPOS'
*                                  'X'.
*    perform bdc_field       using 'EKPO-REPOS'
*                                  'X'.
    loop at TI_STAGING where vendor = it_staging-vendor and docdate = it_staging-docdate.
      perform bdc_dynpro      using 'SAPMM06E' '0511'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=ENTE'.
      perform bdc_field       using 'EKKN-SAKTO'
                                     TI_STAGING-glaccount.
      perform bdc_field       using 'BDC_CURSOR'
                                    'DKACB-FMORE'.
      perform bdc_field       using 'DKACB-FMORE'
                                    'X'.
      perform bdc_dynpro      using 'SAPLKACB' '0002'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'COBL-VORNR'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=ENTE'.
      perform bdc_field       using 'COBL-NPLNR'
                                     TI_STAGING-networkid.
      perform bdc_field       using 'COBL-VORNR'
                                     TI_STAGING-activity.
*    perform bdc_dynpro      using 'SAPMM06E' '0120'.
*    perform bdc_field       using 'BDC_CURSOR'
*                                  'RM06E-EPSTP(02)'.
*    perform bdc_field       using 'BDC_OKCODE'
*                                  '=DETA'.
*    perform bdc_field       using 'RM06E-EBELP'
*                                  '10'.
*    perform bdc_dynpro      using 'SAPMM06E' '0120'.
*    perform bdc_field       using 'BDC_CURSOR'
*                                  'EKPO-WERKS(02)'.
*    perform bdc_field       using 'BDC_OKCODE'
*                                  '/00'.
*    perform bdc_field       using 'RM06E-EBELP'
*                                  '10'.
*perform bdc_field       using 'RM06E-EPSTP(02)'
*                              'd'.
*perform bdc_field       using 'EKPO-KNTTP(02)'
*                              'n'.
*perform bdc_field       using 'EKPO-TXZ01(02)'
*                              'adage artwork'.
*perform bdc_field       using 'EKPO-MENGE(02)'
*                              '                1'.
*perform bdc_field       using 'RM06E-EEIND(02)'
*                              '06242008'.
*perform bdc_field       using 'EKPO-MATKL(02)'
*                              'm1'.
*perform bdc_field       using 'EKPO-WERKS(02)'
*                              'a001'.
*    perform bdc_field       using 'BDC_OKCODE'
*                                  '/00'.
      perform bdc_dynpro      using 'SAPMM06E' '0111'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'EKPO-MENGE'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '/00'.
*    perform bdc_field       using 'EKPO-MATKL'
*                                  'M1'.
*    perform bdc_field       using 'EKPO-TXZ01'
*                                   wa_jtab-j4.
*    perform bdc_field       using 'EKPO-PRSDR'
*                                  'X'.
*    perform bdc_field       using 'RM06E-EEIND'
*                                   wa_jtab-j6.
      perform bdc_field       using 'RM06E-LPEIN'
                                    'D'.
      perform bdc_field       using 'EKPO-WEPOS'
                                    'X'.
      perform bdc_field       using 'EKPO-UEBTK'
                                    'X'.
      perform bdc_field       using 'EKPO-WEBRE'
                                    'X'.
      perform bdc_field       using 'BDC_OKCODE'
                                   '/00'.
      perform bdc_field       using 'BDC_OKCODE'
                                     '=ENTE'.
      move 1 to idx.
      perform bdc_dynpro      using 'SAPLMLSP' '0200'.
      perform bdc_field       using 'BDC_OKCODE'
                                   '/00'.
      perform bdc_field       using 'BDC_OKCODE'
                                     '=ENTE'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '/00'.
      perform bdc_field       using 'RM11P-HEADTEXT'
                                      'adage'.
      perform bdc_field       using  'BDC_CURSOR' 'ESLL-TBTWR(01)'.
      perform bdc_field       using 'RM11P-NEW_ROW'
                                     '10'.
*      concatenate 'ESLL-KTEXT1(0' idx ')' into fnaml.
*      perform bdc_field       using fnaml wa_ktab-k1.
*      concatenate 'ESLL-MENGE(0' idx ')' into fnaml.
*      perform bdc_field       using fnaml wa_ktab-k2.
*      concatenate 'ESLL-MEINS(0' idx ')' into fnaml.
*      perform bdc_field       using fnaml wa_ktab-k3.
*      concatenate 'ESLL-TBTWR(0' idx ')' into fnaml.
*      perform bdc_field       using fnaml wa_ktab-k4.
*      IDX = IDX + 1.
*      loop at KT_STAGING where vendor = it_staging-vendor and docdate = it_staging-docdate and itmcategory is not initial.
        IF TI_STAGING-ITMCATEGORY IS NOT INITIAL.
        qty = ti_staging-serqty.
        gp  = ti_staging-sergrossprice.
        perform bdc_field       using 'ESLL-KTEXT1(01)' TI_STAGING-sertext.
        perform bdc_field       using 'ESLL-MENGE(01)'  qty.
        perform bdc_field       using 'ESLL-MEINS(01)'  TI_STAGING-seruom.
        perform bdc_field      using 'ESLL-TBTWR(01)'   gp.
*    endloop.
*    move 1 to cnt.
*    loop at KT_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE and itmcategory is not initial.
        perform bdc_dynpro      using 'SAPLMLSK' '0200'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RM11K-VORNR(01)'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'VRTKZ1'
                                      'X'.
*      concatenate 'ESKN-SAKTO(0' IDX ')' into fnamk.
*      perform bdc_field       using fnam wa_ktab-k5.
*      concatenate 'ESKN-NPLNR(0' IDX ')' into fnamk.
*      perform bdc_field       using fnam wa_ktab-k6.
*      concatenate 'RM11K-VORNR(0' IDX ')' into fnamk.
*      perform bdc_field       using fnam wa_ktab-k7.
*      cnt = cnt + 1.
        PERFORM BDC_FIELD USING 'ESKN-SAKTO(01)' TI_STAGING-serglaccount.
        PERFORM BDC_FIELD USING 'ESKN-NPLNR(01)' TI_STAGING-sernetwork.
        PERFORM BDC_FIELD USING 'RM11K-VORNR(01)' TI_STAGING-seractivity.
*      endloop.
      perform bdc_dynpro      using 'SAPLKACB' '0002'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'COBL-NPLNR'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=ENTE'.
      perform bdc_field       using 'COBL-NPLNR'
                                     kt_STAGING-sernetwork.
      perform bdc_field       using 'COBL-VORNR'
                                     kt_STAGING-seractivity.
      perform bdc_dynpro      using 'SAPLMLSK' '0200'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'ESLL-INTROW'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '/00'.
      perform bdc_field       using 'VRTKZ1'
                                    'X'.
    perform bdc_dynpro      using 'SAPMM06E' '0200'.
    perform bdc_field       using 'BDC_CURSOR'
                              'RM06E-EBELP'.
    perform bdc_field       using 'BDC_OKCODE'
                              '=BACK'.
    perform bdc_dynpro      using 'SAPLMLSP' '0200'.
    perform bdc_field       using 'BDC_OKCODE'
                                     '=SAV'.
  ELSE.
    perform bdc_dynpro      using 'SAPMM06E' '0100'.
    perform bdc_field       using 'BDC_OKCODE'
                                     '=SAV'.
  ENDIF.
endloop.
*perform bdc_field       using 'RM11P-HEADTEXT'
*                              'adage artwork'.
*    perform bdc_field       using 'BDC_CURSOR'
*                                  'ESLL-KTEXT1(01)'.
*perform bdc_field       using 'RM11P-NEW_ROW'
*                              '10'.
*perform bdc_transaction using 'ME21'.
CALL TRANSACTION 'ME21' USING I_BDCDATA MODE 'A' messages into i_msg.
*clear: kt_staging,ti_staging,it_staging,i_bdcdata.
  endloop.
*    CALL FUNCTION 'BDC_INSERT'
*     EXPORTING
*       TCODE                  = 'ME21'
**    POST_LOCAL             = NOVBLOCAL
**    PRINTING               = NOPRINT
**    SIMUBATCH              = ' '
**    CTUPARAMS              = ' '
*      TABLES
*        DYNPROTAB              = I_BDCDATA
**  EXCEPTIONS
**    INTERNAL_ERROR         = 1
**    NOT_OPEN               = 2
**    QUEUE_ERROR            = 3
**    TCODE_INVALID          = 4
**    PRINTING_INVALID       = 5
**    POSTING_INVALID        = 6
**    OTHERS                 = 7
*    IF SY-SUBRC <> 0.
*      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*    ENDIF.
*Using Call Transaction Statement Call the transaction in back ground mode/fore ground mode
  LOOP AT I_MSG.
    CALL FUNCTION 'FORMAT_MESSAGE'
     EXPORTING
       ID              = I_MSG-MSGID
       LANG            = SY-LANGU
       NO              = I_MSG-MSGNR
       V1              = I_MSG-MSGV1
       V2              = I_MSG-MSGV2
       V3              = I_MSG-MSGV3
       V4              = I_MSG-MSGV4
     IMPORTING
       MSG             = W_STR
*  EXCEPTIONS
*    NOT_FOUND       = 1
*    OTHERS          = 2
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE:/ i_msg-msgnr,w_str.
  endloop.
*  CALL FUNCTION 'BDC_CLOSE_GROUP'.
*** EXCEPTIONS
***   NOT_OPEN          = 1
***   QUEUE_ERROR       = 2
***   OTHERS            = 3
**  IF SY-SUBRC <> 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
***         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
**  ENDIF.
*perform close_group.
*        Start new screen                                              *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR I_BDCDATA.
  I_BDCDATA-PROGRAM  = PROGRAM.
  I_BDCDATA-DYNPRO   = DYNPRO.
  I_BDCDATA-DYNBEGIN = 'X'.
  APPEND I_BDCDATA.
ENDFORM.                    "BDC_DYNPRO
*        Insert field                                                  *
FORM BDC_FIELD USING FNAM FVAL.
*  IF FVAL <> SPACE.
  CLEAR I_BDCDATA.
  I_BDCDATA-FNAM = FNAM.
  I_BDCDATA-FVAL = FVAL.
  APPEND I_BDCDATA.
*  ENDIF.
ENDFORM.                    "BDC_FIELD

Similar Messages

  • 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

  • BDC for ME21N (Flat file format)

    Hello,
         I have to write a BDC for ME21N(stock transfer).... Someone pls give me the format of flat file... we need separate files for header and items or only one file is enough??? pls someone send me the format and code......
    my email id is [email protected]
    Thanks in advance...
    Regards,
    Maya.

    Hi
    see this and do accordingly
    REPORT zmm_bdcp_purchaseorderkb02
    NO STANDARD PAGE HEADING LINE-SIZE 255.
    Declaring internal tables *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
    dummy(255) TYPE c,
    END OF it_dummy.
    *-----Internal table for line items
    DATA : BEGIN OF it_idata OCCURS 0,
    ematn(18), "Material Number.
    menge(13), "Qyantity.
    netpr(11), "Net Price.
    werks(4), "Plant.
    ebelp(5), "Item Number.
    END OF it_idata.
    *-----Deep structure for header data and line items
    DATA : BEGIN OF it_me21 OCCURS 0,
    lifnr(10), "Vendor A/c No.
    bsart(4), "A/c Type.
    bedat(8), "Date of creation of PO.
    ekorg(4), "Purchasing Organisation.
    ekgrp(3), "Purchasing Group.
    x_data LIKE TABLE OF it_idata,
    END OF it_me21.
    DATA : x_idata LIKE LINE OF it_idata.
    DATA : v_delimit VALUE ','.
    DATA : v_indx(3) TYPE n.
    DATA : v_fnam(30) TYPE c.
    DATA : v_count TYPE n.
    DATA : v_ne TYPE i.
    DATA : v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
    Search help for file *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION.
    To upload the data into line structure *
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = p_file
    filetype = 'DAT'
    TABLES
    data_tab = it_dummy.
    Processing the data from line structure to internal tables *
    REFRESH:it_me21.
    CLEAR :it_me21.
    LOOP AT it_dummy.
    IF it_dummy-dummy+0(01) = 'H'.
    v_indx = v_indx + 1.
    CLEAR it_idata.
    REFRESH it_idata.
    CLEAR it_me21-x_data.
    REFRESH it_me21-x_data.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
    it_me21-bsart
    it_me21-bedat
    it_me21-ekorg
    it_me21-ekgrp.
    APPEND it_me21.
    ELSEIF it_dummy-dummy+0(01) = 'L'.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_idata-ematn
    it_idata-menge
    it_idata-netpr
    it_idata-werks
    it_idata-ebelp.
    APPEND it_idata TO it_me21-x_data.
    MODIFY it_me21 INDEX v_indx.
    ENDIF.
    ENDLOOP.
    To open the group *
    PERFORM open_group.
    To populate the bdcdata table for header data *
    LOOP AT it_me21.
    v_count = v_count + 1.
    REFRESH it_bdcdata.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0100',
    ' ' 'BDC_CURSOR' 'EKKO-LIFNR',
    ' ' 'BDC_OKCODE' '/00',
    ' ' 'EKKO-LIFNR' it_me21-lifnr,
    ' ' 'RM06E-BSART' it_me21-bsart,
    ' ' 'RM06E-BEDAT' it_me21-bedat,
    ' ' 'EKKO-EKORG' it_me21-ekorg,
    ' ' 'EKKO-EKGRP' it_me21-ekgrp,
    ' ' 'RM06E-LPEIN' 'T'.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
    LOOP AT it_me21-x_data INTO x_idata.
    CONCATENATE 'EKPO-EMATN(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-ematn.
    CONCATENATE 'EKPO-MENGE(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-menge.
    CONCATENATE 'EKPO-NETPR(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-netpr.
    CONCATENATE 'EKPO-WERKS(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-werks.
    v_indx = v_indx + 1.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    ENDLOOP.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '=BU'.
    PERFORM bdc_transaction USING 'ME21'.
    ENDLOOP.
    PERFORM close_group.
    End of selection event *
    END-OF-SELECTION.
    IF session NE 'X'.
    *-----To display the successful records
    WRITE :/10 text-001. "Sucess records
    WRITE :/10 SY-ULINE(20).
    SKIP.
    IF it_sucess IS INITIAL.
    WRITE :/ text-002.
    ELSE.
    WRITE :/ text-008, "Total number of Succesful records
    35 v_ns.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_sucess.
    WRITE:/4 it_sucess-lifnr,
    17 it_sucess-tabix CENTERED,
    30 it_sucess-sucess_rec.
    ENDLOOP.
    SKIP.
    *-----To display the erroneous records
    WRITE:/10 text-006. "Error Records
    WRITE:/10 SY-ULINE(17).
    SKIP.
    IF it_error IS INITIAL.
    WRITE:/ text-007. "No error records
    ELSE.
    WRITE:/ text-009, "Total number of erroneous records
    35 v_ne.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_error.
    WRITE:/4 it_error-lifnr,
    17 it_error-tabix CENTERED,
    30 it_error-error_rec.
    ENDLOOP.
    REFRESH it_sucess.
    REFRESH it_error.
    ENDIF.
    CODE IN INCLUDE.
    Include ZMM_INCL_PURCHASEORDERKB01
    DATA: it_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA: it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA: E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    sucess_rec(125),
    END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    error_rec(125),
    END OF it_error.
    Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu. "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12). "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12). "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
    at selection screen *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
    IF SESSION = 'X' AND
    GROUP = SPACE. "OR USER = SPACE.
    MESSAGE E613(MS).
    ENDIF.
    create batchinput session *
    FORM OPEN_GROUP.
    IF SESSION = 'X'.
    SKIP.
    WRITE: /(20) 'Create group'(I01), GROUP.
    SKIP.
    *----open batchinput group
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = GROUP
    USER = sy-uname.
    WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ENDIF.
    ENDFORM. "OPEN_GROUP
    end batchinput session *
    FORM CLOSE_GROUP.
    IF SESSION = 'X'.
    *------close batchinput group
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ELSE.
    IF E_GROUP_OPENED = 'X'.
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /.
    WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
    ENDIF.
    ENDIF.
    ENDFORM. "CLOSE_GROUP
    Start new transaction according to parameters *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
    DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
    IF SESSION = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    WRITE: / 'BDC_INSERT'(I03),
    TCODE,
    'returncode:'(I05),
    SY-SUBRC,
    'RECORD:',
    SY-INDEX.
    ELSE.
    REFRESH it_MESSTAB.
    CALL TRANSACTION TCODE USING it_BDCDATA
    MODE CTUMODE
    UPDATE CUPDATE
    MESSAGES INTO it_MESSTAB.
    L_SUBRC = SY-SUBRC.
    WRITE: / 'CALL_TRANSACTION',
    TCODE,
    'returncode:'(I05),
    L_SUBRC,
    'RECORD:',
    SY-INDEX.
    ENDIF.
    Message handling for Call Transaction *
    perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
    IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
    IF E_GROUP_OPENED = ' '.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = E_GROUP
    USER = sy-uname
    KEEP = E_KEEP.
    E_GROUP_OPENED = 'X'.
    ENDIF.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    ENDIF.
    REFRESH it_BDCDATA.
    ENDFORM. "BDC_TRANSACTION
    Form subr_bdc_table *
    text
    -->P_0220 text *
    -->P_0221 text *
    -->P_0222 text *
    FORM subr_bdc_table USING VALUE(P_0220) TYPE ANY
    VALUE(P_0221) TYPE ANY
    VALUE(P_0222) TYPE ANY.
    CLEAR it_bdcdata.
    IF P_0220 = ' '.
    CLEAR it_bdcdata.
    it_bdcdata-fnam = P_0221.
    it_bdcdata-fval = P_0222.
    APPEND it_bdcdata.
    ELSE.
    it_bdcdata-dynbegin = P_0220.
    it_bdcdata-program = P_0221.
    it_bdcdata-dynpro = P_0222.
    APPEND it_bdcdata.
    ENDIF.
    ENDFORM. " subr_bdc_table
    Form subr_mess_hand *
    text *
    -->P_G_MESS text *
    FORM subr_mess_hand USING P_G_MESS TYPE ANY.
    LOOP AT IT_MESSTAB.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    ID = it_messtab-msgid
    LANG = it_messtab-msgspra
    NO = it_messtab-msgnr
    v1 = it_messtab-msgv1
    v2 = it_messtab-msgv2
    IMPORTING
    MSG = P_G_MESS
    EXCEPTIONS
    OTHERS = 0.
    CASE it_messtab-msgtyp.
    when 'E'.
    it_error-error_rec = P_G_MESS.
    it_error-lifnr = it_me21-lifnr.
    it_error-tabix = v_count.
    APPEND IT_ERROR.
    when 'S'.
    it_sucess-sucess_rec = P_G_MESS.
    it_sucess-lifnr = it_me21-lifnr.
    it_sucess-tabix = v_count.
    APPEND IT_SUCESS.
    endcase.
    ENDLOOP.
    Describe table it_sucess lines v_ns.
    Describe table it_error lines v_ne.
    ENDFORM. " subr_mess_hand
    Regards
    Anji

  • Bdc to me21n

    Hi is it possible to write bdc for me21n
    i m try it but it int trnasfer data
    Moderator Message: Vague question.
    Edited by: kishan P on Dec 13, 2010 8:30 PM

    Hi Sandeep,
    Please use standard Bapi for creating purchase order using the Enjoy Transaction. BAPI_PO_CREATE1.
    Your previous thread, title "bapi to create PO", will give you the details.
    Regards
    Bhanu

  • BAPI for ME21N with Material Configuration

    Hi friends,
    I need to create a Z Program which will create the purchase order and during creation of purchase order it will also make the configuration of material in Material Data. I know the BAPI name BAPI_PO_CREATE1, but it will not do the configuration in Material Data.
    I have tryed the BDC but it is working for only one line item only.
    Please suggest any suitable way for the solution.
    Thanks in advance.
    Krishan

    Can you explain what exactly you mean by Material Configuration?
    BAPI_PO_CREATE1 is the right bapi for ME21N.
    YOu cannot do a BDC on this tansaction as it is a SAP Enjoy transaction.
    Regards,
    ravi

  • BDC for Open Po

    Dear Gurus,
    Any one can send me the BDC code For ME21N.
    Kl. Help me... I recorded but not working in multi line items...
    Rewards will be sure..
    Regards,
    Murugesh R

    Hi Try this code...
    *& Report YBAPI_PO_CREATE1
    REPORT YBAPI_PO_CREATE1.
    data:
    header like BAPIMEPOHEADER,
    headerx like BAPIMEPOHEADERX,
    it_item like standard table of BAPIMEPOITEM,
    it_itemx like standard table of BAPIMEPOITEMX,
    return like standard table of BAPIRET2,
    wa_item like BAPIMEPOITEM,
    wa_itemx like BAPIMEPOITEMX,
    p_int type i,
    p_matnr like mara-matnr,
    p_pono like ekko-ebeln.
    constants:
    c_x type c value 'X'.
    header-comp_code = '3000'.
    header-doc_type = 'DP25'.
    header-creat_date = sy-datum.
    header-item_intvl = '10'.
    header-vendor = 'ARAMI-00'.
    header-langu = sy-langu.
    header-pmnttrms = '0001'.
    header-purch_org = '3000'.
    header-pur_group = '010'.
    header-currency = 'USD'.
    headerx-comp_code = c_x.
    headerx-doc_type = c_x.
    headerx-creat_date = c_x.
    headerx-item_intvl = c_x .
    headerx-vendor = c_x.
    headerx-langu = c_x.
    headerx-pmnttrms = c_x .
    headerx-purch_org = c_x.
    headerx-pur_group = c_x.
    *LOOP AT it_final2 INTO wa_final2.
    p_int = p_int + 10.
    wa_item-po_item = p_int.
    p_matnr = 'T-SRM01'.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
    input = p_matnr
    IMPORTING
    output = p_matnr
    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.
    wa_item-material = p_matnr.
    wa_item-plant = '3200'.
    wa_item-quantity = 100.
    wa_item-conf_ctrl = 'Z01'.
    wa_item-ACKN_REQD = 'X'.
    WA_ITEM-ERS = ''.
    APPEND wa_item TO it_item.
    wa_itemx-po_item = p_int.
    wa_itemx-material = c_x.
    wa_itemx-plant = c_x .
    wa_itemx-stge_loc = c_x .
    wa_itemx-quantity = c_x .
    wa_itemx-item_cat = c_x .
    wa_itemx-acctasscat = c_x .
    wa_itemx-conf_ctrl = 'X'.
    wa_itemx-ACKN_REQD = 'X'.
    WA_ITEMX-ERS = 'X'.
    APPEND wa_itemx TO it_itemx.
    *ENDLOOP.
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = header
    poheaderx = headerx
    IMPORTING
    exppurchaseorder = p_pono
    TABLES
    return = return
    poitem = it_item
    poitemx = it_itemx.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    RETURN =
    write:/ p_pono.

  • 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

  • Problem in creation of BDC for transaction phap_create

    Hello Friends,
    I am trying to create BDC for PHAP_CREATE.
    When you run a transaction a pop up window appears to select the template id.
    And in BDC it is selected by cursor position. So once selected, the value of template id cannot be changed.
    I want this as a parameter.So that each time I run a BDC I will be able to create different types of Appraisal documents i.e with different template ids.
    How to go about it???
    Regards,
    Bhushan

    Hi,
    For selecting the id, while doing recording,
    record with
    CTRL + F ( Where u can give ur id) and proceed further.

  • How to give line items in flatfile while doing BDC for Table control

    Hi all,
    I am writing BDC for Multiple line items and Transaction  is : FSE5N.
    How do i give the data in the flat file. I mean how do we give the multiple line items in flat file , i.e for second line item again we have to header data or not ?
    ex:
    1015;ALL;demo;kr;INR;01;0001;3000172;100
    1015;ALL;demo;kr;INR;01;0001;3000172;200
    for first lineitem  : 3000172;100
    for 2nd line item : 3000172; 200.
    header data : 1015;ALL;demo;kr;INR;01;0001.
    Thanks in advance
    krupali

    Hii ,
    u can give in the same format as u have done in the example.
    A       B    C     D  E    F   G        H          I
    1015;ALL;demo;kr;INR;01;0001;3000172;100
    1015;ALL;demo;kr;INR;01;0001;3000172;200
    and while writing the loop u can give
    loop at it_head.
    loop at it_head where a = it_head-A and b = it_head-B ..........upto G = it_head-G.
      endloop.
    endloop.
    check this
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    Neeraj

  • BDC for TCODE F150

    Hi Friends,
    I am facing problem while developing BDC for tcode F150. The last action i.e. scheduling for particular dunning date is not getting executed in my BDC.
    I am also pasting the end part of my BDC recording. Please review it and advise.
    PERFORM bdc_dynpro      USING 'SAPLF150_JOBS' '1000'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'F150V-STRZT'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=JOBS'.
      PERFORM bdc_field       USING 'F150V-STRDT'
                                    rdate.
      PERFORM bdc_field       USING 'F150V-XSTRF'
                                    'X'.
        select single SPLD into p_out from USR01 where bname = sy-uname.
      perform bdc_field       using 'ITCPO-TDDEST'
                                     p_out.
      CALL TRANSACTION 'F150'
    Thank you,
    Swapnil
    Edited by: Swapnil Tawade on Sep 22, 2008 3:15 PM

    Hi,
       If u want it for  some specific plants then before populating data  to bdcdata internal table  check the conditions for which the plant fields required values to be passed  and if the condition is satisfied then pass the plant field to bdcdata table . If the condition is not satisfied then dont pass that plant field to bdcdata table bcoz  if  u r not passing any field to bdcdata table then that field is going have default values.
    Regards,
    Shafi

  • User Exit and BDC for ME22N

    Hello All,
    A code has been written in the User exit for Tcode ME22N, Which sets the indicator on PO line item. This has been done by modifying the standard itab POT by using field symbols, because the fields to be modified are shown in display mode in the tcode ME22N and cannot be done in BDC. See the below code in user exit ZXM06U43.
    DATA char(50) VALUE '(SAPLMEPO)POT[]'.
    CLEAR wa_ind.
        FIELD-SYMBOLS <f1> TYPE ANY.
    Move memory of internal table POT to field symbol f1.
        ASSIGN (char) TO <f1>.
    Move content of f1 to internal table i_ind
        i_ind[] = <f1> .
        LOOP AT i_ind INTO wa_ind.
          IF wa_ind-pstyp = '9'.            " Service PO - item category
    IF PO Line item has History per Purchasing Document as 'D'
    Set indicators on, for the line item.
            CLEAR v_cnt.
            SELECT COUNT( * ) INTO v_cnt FROM ent5100
                                         WHERE ebeln = wa_ind-ebeln
                                           AND ebelp = wa_ind-ebelp
                                           AND bewtp = 'D'.
            IF sy-subrc = 0.
              wa_ind-wepos = 'X'.            " Set Goods Receipt Indicator
              wa_ind-webre = 'X'.            " Set GR-based IV Indicator
              wa_ind-lebre = 'X'.            " Set Srv-based IV Indicator
            ELSE.
    *End of addition SAP-20070910104025 - SL36 - D01K963369
              wa_ind-wepos = ' '.            " Clear Goods Receipt Indicator
              wa_ind-webre = ' '.            " Clear GR-based IV Indicator
              wa_ind-lebre = ' '.            " Clear Srv-based IV Indicator
              wa_ind-xersy = ' '.            " Clear ERS Indicator
            ENDIF.                                           
            MODIFY i_ind FROM wa_ind INDEX sy-tabix.
          ENDIF.
        ENDLOOP.
        <f1> = i_ind[].
      ENDIF.          
    ENDIF.
    This code is in production and has been working fine.
    The requirnment is now to make this indicator work for all the Purchase order before this code has been written in the Exit. For this my functional suggests that to write a separate program using BDC for PO change and jus add a period/dot  in the short text and save it. The code has been written, the user exit and the above code is getting triggrred values are updated in internal table correctly.
    However the flags was not set or cleared when seen in the tcode ME22N . This works fine if the tcode me22n is run directly and not working in BDC.
    I have tried with ME22 without enjoy transaction in BDC changing the POT Program to SAPMM06E. It does not work.
    Please help me as why it is not uodating in the table when using BDC.
    Thanks in Advance.
    Senthil Kumar

    Hi All,
    Any luck on this??
    Thanks

  • BDC For T-Code F-02

    Dear Friends,
    Do anybody has the code for BDC for Transaction Code F-02.
    If anybody has plz send me.
    Thanks & Reg,
    Nishant

    try this:
    REPORT zfir_f02
           NO STANDARD PAGE HEADING LINE-SIZE 255.
    INCLUDE bdcrecx1.
    TYPES : BEGIN OF tp_flatfile,
            bldat(10),
            doctyp(2),
            comp(4),
            postdate(10),
            period(2),
            currency(5),
            reference(16),
            htext(25),
            postkey(2),
            account(17),
            amount(16),
            profit(10),
            assign(18),
            text(50),
            busarea(4),
            cost(10),
            bline(10),
            base(16),
            postkey2(2),
            account2(17),
            amount2(16),
            profit2(10),
            assign2(18),
            text2(50),
            busarea2(4),
            END OF tp_flatfile.
    DATA : t_flatfile TYPE TABLE OF tp_flatfile WITH HEADER LINE.
    DATA : g_file TYPE string.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    CONSTANTS:con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
    PARAMETERS :  p_file LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK blk1.
    *C-- Selection Screen VALUE-REQUEST FOR File path
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
      g_file = p_file.
    *START-OF-SELECTION.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = g_file
          filetype                = 'ASC'
          has_field_separator     = 'X'
        TABLES
          data_tab                = t_flatfile
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
         loop at t_flatfile.
         write:/ t_flatfile-doctyp,t_flatfile-amount.
         endloop.
    START-OF-SELECTION.
      PERFORM open_group.
      LOOP AT t_flatfile.
        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'
                                      t_flatfile-bldat.
        PERFORM bdc_field       USING 'BKPF-BLART'
                                      t_flatfile-doctyp.
        PERFORM bdc_field       USING 'BKPF-BUKRS'
                                      t_flatfile-comp.
        PERFORM bdc_field       USING 'BKPF-BUDAT'
                                      t_flatfile-postdate.
        PERFORM bdc_field       USING 'BKPF-MONAT'
                                      t_flatfile-period.
        PERFORM bdc_field       USING 'BKPF-WAERS'
                                      t_flatfile-currency.
        PERFORM bdc_field       USING 'BKPF-XBLNR'
                                      t_flatfile-reference.
        PERFORM bdc_field       USING 'BKPF-BKTXT'
                                      t_flatfile-htext.
        PERFORM bdc_field       USING 'FS006-DOCID'
        PERFORM bdc_field       USING 'RF05A-NEWBS'
                                      t_flatfile-postkey.
        PERFORM bdc_field       USING 'RF05A-NEWKO'
                                      t_flatfile-account.
        CASE t_flatfile-postkey.
          WHEN '40' OR '50'.
            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'
                                          t_flatfile-amount.
            PERFORM bdc_field       USING 'BSEG-ZUONR'
                                          t_flatfile-assign.
            PERFORM bdc_field       USING 'BSEG-SGTXT'
                                          t_flatfile-text.
        IF t_flatfile-postkey = '40' and t_flatfile-account > '300000'.
                PERFORM bdc_field       USING 'DKACB-FMORE'
                                          'X'.
        ENDIF.
            PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
            PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'COBL-KOSTL'.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                          '=ENTE'.
            PERFORM bdc_field       USING 'COBL-GSBER'
                                          t_flatfile-busarea.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=ENTE'.
            PERFORM bdc_field       USING 'COBL-KOSTL'
                                          t_flatfile-cost.
            PERFORM bdc_field       USING 'COBL-PRCTR'
                                          t_flatfile-profit.
            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 'RF05A-NEWBS'
                                          t_flatfile-postkey2.
            PERFORM bdc_field       USING 'RF05A-NEWKO'
                                          t_flatfile-account2.
            PERFORM debit_credit.
          WHEN '21' OR '31' OR '24' OR '34'.
    **perform bdc_field       using 'RF05A-NEWBS'
                                 '31'.
    **perform bdc_field       using 'RF05A-NEWKO'
                                 '25000'.
         PERFORM bdc_field       USING 'DKACB-FMORE'
                                       'X'.
         PERFORM bdc_dynpro      USING 'SAPMF05A' '0302'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'RF05A-NEWKO'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '/00'.
         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'
                                       t_flatfile-busarea.
         PERFORM bdc_field       USING 'COBL-KOSTL'
                                       t_flatfile-cost.
            PERFORM bdc_dynpro      USING 'SAPMF05A' '0302'.
            PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'RF05A-NEWKO'.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                          '/00'.
            PERFORM bdc_field       USING 'BSEG-WRBTR'
                                          t_flatfile-amount.
            PERFORM bdc_field       USING 'BSEG-GSBER'
                                          t_flatfile-busarea.
            PERFORM bdc_field       USING 'BSEG-ZFBDT'
                                          t_flatfile-bline.
            PERFORM bdc_field       USING 'BSEG-SKFBT'
                                          t_flatfile-base.
            PERFORM bdc_field       USING 'BSEG-ZUONR'
                                          t_flatfile-assign.
            PERFORM bdc_field       USING 'BSEG-SGTXT'
                                          t_flatfile-text.
            PERFORM bdc_field       USING 'RF05A-NEWBS'
                                          t_flatfile-postkey2.
            PERFORM bdc_field       USING 'RF05A-NEWKO'
                                          t_flatfile-account2.
           PERFORM bdc_dynpro      USING 'SAPLFWTD' '0100'.
           PERFORM bdc_field       USING 'BDC_CURSOR'
                                         'WITH_ITEM-WT_WITHCD(01)'.
           PERFORM bdc_field       USING 'BDC_OKCODE'
                                         '=GO'.
            PERFORM debit_credit.
         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'
                                       t_flatfile-amount2.
         PERFORM bdc_field       USING 'BSEG-ZUONR'
                                       t_flatfile-assign2.
         PERFORM bdc_field       USING 'BSEG-SGTXT'
                                       t_flatfile-text2.
         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'
                                       t_flatfile-busarea2.
         PERFORM bdc_field       USING 'COBL-KOSTL'
                                       t_flatfile-cost.
         PERFORM bdc_field       USING 'COBL-PRCTR'
                                       t_flatfile-profit2.
         PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'RF05A-NEWKO'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '=BU'.
         PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
         PERFORM bdc_field       USING 'BDC_CURSOR'
                                       'COBL-GSBER'.
         PERFORM bdc_field       USING 'BDC_OKCODE'
                                       '=ENTE'.
          WHEN '01' OR '11' OR '04' OR '14' OR '07' OR '17'.
    *perform bdc_field       using 'RF05A-NEWBS'
                                 '11'.
    *perform bdc_field       using 'RF05A-NEWKO'
                                 '1'.
            PERFORM bdc_dynpro      USING 'SAPMF05A' '0301'.
            PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'BSEG-SGTXT'.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                          '/00'.
            PERFORM bdc_field       USING 'BSEG-WRBTR'
                                          t_flatfile-amount.
            PERFORM bdc_field       USING 'BSEG-MWSKZ'
            PERFORM bdc_field       USING 'BSEG-GSBER'
                                          t_flatfile-busarea.
            IF NOT t_flatfile-bline IS INITIAL.
              PERFORM bdc_field       USING 'BSEG-ZFBDT'
                                            t_flatfile-bline.
            ENDIF.
            IF NOT t_flatfile-base IS INITIAL.
              PERFORM bdc_field       USING 'BSEG-SKFBT'
                                            t_flatfile-base.
            ENDIF.
            PERFORM bdc_field       USING 'BSEG-ZUONR'
                                          t_flatfile-assign.
            PERFORM bdc_field       USING 'BSEG-SGTXT'
                                          t_flatfile-text.
            PERFORM bdc_field       USING 'RF05A-NEWBS'
                                          t_flatfile-postkey2.
            PERFORM bdc_field       USING 'RF05A-NEWKO'
                                          t_flatfile-account2.
            PERFORM debit_credit.
        ENDCASE.
    *perform bdc_dynpro      using 'SAPMF05A' '0301'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'BSEG-WRBTR'.
    *perform bdc_field       using 'BDC_OKCODE'
                                 '=AB'.
    *perform bdc_field       using 'BSEG-WRBTR'
                                 '3,000.00'.
    *perform bdc_field       using 'BSEG-MWSKZ'
    *perform bdc_field       using 'BSEG-GSBER'
                                 'VUSO'.
    *perform bdc_field       using 'BSEG-ZFBDT'
                                 '19.07.2005'.
    *perform bdc_field       using 'BSEG-SKFBT'
                                 '3,000.00'.
    *perform bdc_field       using 'BSEG-ZUONR'
                                 'ASSIGN'.
    *perform bdc_field       using 'BSEG-SGTXT'
                                 'TEXT'.
    PERFORM bdc_dynpro      USING 'SAPMF05A' '0700'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'RF05A-NEWBS'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=BU'.
    *perform bdc_field       using 'BKPF-XBLNR'
                                 'REF'.
    *perform bdc_field       using 'BKPF-BKTXT'
                                 'text'.
        PERFORM bdc_transaction USING 'F-02'.
      ENDLOOP.
      PERFORM close_group.
    *&      Form  debit_credit
          text
    FORM debit_credit.
    **SRINI
    IF t_flatfile-postkey = '40' OR t_flatfile-postkey = '50'.
      PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'COBL-GSBER'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ENTE'.
    ENDIF.
    ***SRINI
      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'
                                    t_flatfile-amount2.
      PERFORM bdc_field       USING 'BSEG-ZUONR'
                                    t_flatfile-assign2.
      PERFORM bdc_field       USING 'BSEG-SGTXT'
                                    t_flatfile-text2.
      PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                   'COBL-KOSTL'.
                                    'COBL-GSBER'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ENTE'.
      PERFORM bdc_field       USING 'COBL-GSBER'
                                    t_flatfile-busarea2.
         PERFORM bdc_field       USING 'COBL-KOSTL'
                                       t_flatfile-cost.
      PERFORM bdc_field       USING 'COBL-PRCTR'
                                    t_flatfile-profit2.
      PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RF05A-NEWKO'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=BU'.
      PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'COBL-GSBER'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ENTE'.
    ENDFORM.                    "debit_credit
    regards,
    Bikash

  • To Record  J1IS BDC  For Multiple Line Items

    Hi,
      Iam trying to record BDC for J1IS transaction.
    while  recording  material document which contains more than  8 line items , Only 8 line items get saved and the rest of the items doesn't get saved ,
        But when I  do this manually then  all the line items get saved,
        Can anyone give the remedy for this Problem (to record J1IS for multiple line items).
      Thanks in Advance.
    Regards,
    S.Janani.

    Hi Janani / Leo
    The problem might be that the scroll down functionality after 8 line items is not recorded in your recording.
    In order to overcome the issue, you need to check OK__CODE whicle page down and add it in recording after Number of line items are greater than 8.
    Please check below link for details:
    http://scn.sap.com/thread/1106677
    http://scn.sap.com/thread/797827
    http://scn.sap.com/thread/2037271
    Best Regards,
    Sachin

  • BDC for multiple line items (VA01)

    Hi Experts,
      I create a BDC for VA01 transaction for single line item in that now i want to upload multiple line items also with  o/p of total no. of records uploaded, no. of records posted and the no. of error records...
    Can any body explain with sample code...

    Hi,
    if the flat file is containing header and item records...
    first split those records tooo two internal tables header and item..
    Loop at header ...
      process of recording steps for header....
    Loop at item...
    here create a varialbe with char 2 .. for index value....
      process of item recording steps..
      increment the index value by 1....
      here u have to pass  'p+'  OK_CODE..
    Endloop ..(item)
    Endloop...(header)
    for more info goo through this link...
    http://www.sap-img.com/bdc.htm
    hope helpful
    Raghunath.S

  • "BDC for multiple line items of PO"

    I am using this code to move data for multiple line items of a PO. But only one is getting transferred. I am using BDC for this.
    FORM transaction_bdc .
      DATA :
      v_cnt(2) TYPE n,
      v_bst(2) TYPE n,
      v_bn TYPE i,
      v_bstpo(25),
      v_ebtyp(25),
      v_menge(25),
      v_eeind(25),
      v_xblnr(25),
      v_xblnr1(25),
      v_ebelp(2) TYPE n,
      v_ebelpt(2),
      v_menge1(11),
      v_ebt TYPE i,
      v_vebtyp LIKE ekes-ebtyp,
      v_eb(2) TYPE n,
      v_tcselflag(40),
      v_tem(2) TYPE n,
      v_correct TYPE i,
      v_file TYPE string.
      DATA: ls_outtab TYPE tb_struc.
      DATA: l_valid TYPE c,
            l_locked TYPE c.
      CALL METHOD g_grid->check_changed_data
        IMPORTING
          e_valid = l_valid.
      IF l_valid EQ 'X'.
        LOOP AT tb_output WHERE check EQ 'X' .
          MOVE-CORRESPONDING tb_output TO itab_output.
          APPEND itab_output.
          CLEAR itab_output.
        ENDLOOP.
        IF tb_output-check <> 'X'.
          MESSAGE e003 WITH text-004.
        ENDIF.
      ENDIF.
      IF itab_output[] IS NOT INITIAL.
        PERFORM open_group.
    ***looping at purchase order level.
        LOOP AT itab_output where ebelp is not initial .
          CLEAR v_bn.
          CLEAR v_ebt.
          PERFORM bdc_dynpro USING 'SAPMM06E' '0105'.
          PERFORM bdc_field USING 'BDC_CURSOR'
          'RM06E-BSTNR'.
          PERFORM bdc_field USING 'BDC_OKCODE'
          '/00'.
          PERFORM bdc_field USING 'RM06E-BSTNR'
          itab_output-ebeln.
    ***Changing alphanumeric fields and quantity fields to character type**
    *v_ebelp = tB_OUTPUT-ebelp.
    *clear v_ebelpt.
    *v_menge1 = tB_OUTPUT-menge.
    *v_ebelpt = v_ebelp.
    ***End Of Changing**
    *Checking for the exact number of the item**
          LOOP AT tb_output where ebeln = itab_output-ebeln.
            READ TABLE itab_output INDEX 1.
            IF tb_output-ebelp = itab_output-ebelp.
              exit.
            ELSE.
              v_bn = v_bn + 1.
            ENDIF.
          ENDLOOP.
    v_bst = v_bn + 1.
    *End Of Checking**
    **Mapping items**
            v_tem = 1.
            CONCATENATE 'RM06E-BSTPO(' v_bst ')' INTO v_bstpo.
            CONCATENATE 'RM06E-TCSELFLAG(' v_tem ')' INTO v_tcselflag.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_bstpo.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=DETA'.
            PERFORM bdc_field USING 'RM06E-EBELP'
            v_ebelpt.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0111'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            'EKPO-BSTAE'.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '/00'.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_bstpo.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=BSTA'.
            PERFORM bdc_field USING 'RM06E-EBELP'
            v_ebelpt.
            PERFORM bdc_field USING v_tcselflag
            'X'.
    **Checking weather Confirmation category already exists**
            SELECT ebtyp FROM ekes INTO v_vebtyp WHERE ebelp =
            itab_output-ebelp AND ebeln = itab_output-ebeln.
            ENDSELECT.
            IF sy-dbcnt > 0.
              v_ebt = sy-dbcnt.
            ENDIF.
            v_eb = v_ebt + 1.
    **End Of Checking**
    **For Line items**
            CONCATENATE 'EKES-EBTYP(' v_eb ')' INTO v_ebtyp.
            CONCATENATE 'EKES-MENGE(' v_eb ')' INTO v_menge.
            CONCATENATE 'RM06E-EEIND(' v_eb ')' INTO v_eeind.
            CONCATENATE 'EKES-XBLNR(' v_eb ')' INTO v_xblnr.
    **End**
            PERFORM bdc_dynpro USING 'SAPLEINB' '0200'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_xblnr.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=BU'.
            PERFORM bdc_field USING v_ebtyp
            itab_output-ebtyp.
            PERFORM bdc_field USING v_eeind
            itab_output-eindt.
            PERFORM bdc_field USING v_menge
            v_menge1.
            PERFORM bdc_field USING v_xblnr
            itab_output-xblnr.
    **End Of Mappings**
    *loop at itab_output.
            MOVE-CORRESPONDING itab_output TO ekes.
            modify ekes.
           MOVE-CORRESPONDING itab_output TO eket.
           MODIFY eket.
           MOVE-CORRESPONDING tb_output TO ekpo.
           MODIFY ekpo.
         ENDLOOP.
          CALL TRANSACTION 'ME22N'
          USING itbdc
          MODE   'E'.
          commit work.
    perform bdc_transaction using 'ME22N'.
    **End Of Purchase Order Loop**
        PERFORM close_group.
        endloop.
         endif.

    Hi Asha,
    check the below code once...
    LOOP AT tb_output where ebeln = itab_output-ebeln.
    READ TABLE itab_output INDEX 1.
    IF tb_output-ebelp = itab_output-ebelp.
    exit.
    ELSE.
    v_bn = v_bn + 1.
    ENDIF.
    ENDLOOP.
    Here you are reading the table itab_output with index 1, it means you alway reading the first record of that internal table.
    Regards,
    Satya.

Maybe you are looking for

  • Kdenlive not rendering with title clip

    After doing a system upgrade kdelive will no longer render my project, which rendered fine before the upgrade. After I click render, it either gets stuck in "waiting" or it gives an error saying that rendering crashed. If I turn off the title clip, r

  • Managed System SLM~ABAP is not configured (Step 10: Configuration Check)

    When I try to spend the last procedure "Configuration Check" (item 10 - Managed System Configuration) I get here is only an error message The definition of Technical System 'SLM~JAVA' is not correct: 'SLM~JAVA': Operating System 'Linux~2.6.32-358.23.

  • Can't open document in Numbers from iCloud

    I can not open a numbers document from Icloud.  When I try to open the document, which is listed with other documents I get a message saying I must have the newest version of numbers.  I have already updated to Mavericks and the upgraded Numbers.  Wh

  • No incoming calls with SPA9000.

    I just replaced our SPA9000 and now we can't get incoming calls. Outgoing calls works fine. We have all ports opened on our router and NAT Keep Alive is enabled. Any thoughts? I've reset the device and upgraded the firmware but still no luck.

  • WebObjects 5.3 WOHyperlink can't call an action with more than one argument

    Hi there, I recently upgraded from WebObjects 5.2.3 to 5.3. I used WOHyperlink with more than one ?<ARG> binding to build http requests... It used to work in 5.2.3, but not anymore in 5.3. The problem stems from the ampersand character that separates