BDC_INSERT Problem

hi,
I am trying to create BDC program using transaction fv50.
when i am execute the program,it is giving error like "BDC_INSERT,SCREEN.& IS INVALID".
Will you plz tell me what's the reason .
Thanks in Advance...
Anjali Samadhiya.

hi,
it is very simple just do debuging  trace out where extractly u r getting proble.
other wise post u r code so that easly we can identfly the problem
because it is very trick tcode there u need to pass the data properly and if pasible sit with FI Fucntinal Consultant and do the recording . and ensure that all the scenarios should be recorded. according to that data in file should be prepaired .
~linganna

Similar Messages

  • Bdc transaction problem

    hi,
    i am create a programm for f-27 type DG by bdc session method
    when i execute it on 3rd screen of execution it ask for the values for PAYMENT TERMS but in manual entry OF F-27 it does not TAKE ANY PAYMENT TERMS. plz check my code and tell me where is the problem in coding.
    CODES:
    REPORT zcrdtdgupld
           NO STANDARD PAGE HEADING LINE-SIZE 255.
    *INCLUDE zdata_declarations.
              I N T E R N A L  T A B L E                           *
    DATA: BEGIN OF wa_data,
           bldat     TYPE  BDC_FVAL, "Document Date10
           blart     TYPE  BDC_FVAL, "Document Type
           bukrs     TYPE  BDC_FVAL, "Company Code
           budat     TYPE  BDC_FVAL, "Posting Date10
           monat     TYPE  BDC_FVAL, "Period
           waers     TYPE  BDC_FVAL, "Currency
           xblnr     TYPE  BDC_FVAL, "Reference Field
           docid     TYPE  BDC_FVAL, "Document ID
           newbs     TYPE  BDC_FVAL, "Posting  Key
           newko     TYPE  BDC_FVAL, "Account Code
           wrbtr     TYPE  BDC_FVAL, "Amount in Documentcurrency
           zfbdt     TYPE  BDC_FVAL, "Baseline Date10
           newbs2    TYPE  BDC_FVAL, "Account Key2
           newko2    TYPE  BDC_FVAL, "Account code2
           wrbtr2    TYPE  BDC_FVAL, "bseg-wrbtr,"Amount2
           kostl     TYPE  BDC_FVAL, " cost center
           prctr     TYPE  BDC_FVAL, " profit center
           END OF wa_data.
                          D A T A                                     *
    DATA: it_data    LIKE TABLE OF wa_data.
    DATA: it_bdcdata TYPE TABLE OF bdcdata.
    DATA: wa_bdcdata LIKE LINE OF it_bdcdata.
    DATA: v_file     TYPE string.
                 S E L E C T I O N  S C R E E N                       *
    SELECTION-SCREEN BEGIN OF BLOCK b.
    PARAMETERS : pa_file LIKE fc03tab-pl00_file OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b.
                    AT SELECTION-SCREEN                               *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.
      PERFORM get_file USING pa_file.
               S T A R T  O F  S E L E C T I O N                      *
    START-OF-SELECTION.
      v_file = pa_file.
    *uploading flat file into internal table
      PERFORM upload_file USING v_file CHANGING it_data.
    *open the session
      PERFORM open_session.
    *POPULATING THE BDCDATA
      LOOP AT it_data INTO wa_data.
        REFRESH it_bdcdata.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0100' 'X'.
        PERFORM bdc_field       USING 'BDC_CURSOR' 'RF05A-NEWKO'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '/00'.
        PERFORM bdc_field       USING 'BKPF-BLDAT'  wa_data-bldat.
        PERFORM bdc_field       USING 'BKPF-BLART'  wa_data-blart.
        PERFORM bdc_field       USING 'BKPF-BUKRS'  wa_data-bukrs.
        PERFORM bdc_field       USING 'BKPF-BUDAT'  wa_data-budat.
        PERFORM bdc_field       USING 'BKPF-MONAT'  wa_data-monat.
        PERFORM bdc_field       USING 'BKPF-WAERS'  wa_data-waers.
        PERFORM bdc_field       USING 'BKPF-XBLNR'  wa_data-xblnr.
        PERFORM bdc_field       USING 'FS006-DOCID' wa_data-docid.
        PERFORM bdc_field       USING 'RF05A-NEWBS' wa_data-newbs.
        PERFORM bdc_field       USING 'RF05A-NEWKO' wa_data-newko.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0301' 'X'.
        PERFORM bdc_field       USING 'BDC_CURSOR' 'BSEG-WRBTR'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '/00'.
        PERFORM bdc_field       USING 'BSEG-WRBTR'  wa_data-wrbtr.
        PERFORM bdc_field       USING 'BSEG-ZFBDT'  wa_data-zfbdt.
        PERFORM bdc_field       USING 'RF05A-NEWBS' wa_data-newbs2.
        PERFORM bdc_field       USING 'RF05A-NEWKO' wa_data-newko2.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0300' 'X'.
        PERFORM bdc_field       USING 'BDC_CURSOR' 'BSEG-WRBTR'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=BU'.
        PERFORM bdc_field       USING 'BSEG-WRBTR' wa_data-wrbtr2.
        PERFORM bdc_dynpro      USING 'SAPLKACB' '0002' 'X'.
        PERFORM bdc_field       USING 'BDC_CURSOR' 'COBL-PRCTR'.
        PERFORM bdc_field       USING 'BDC_OKCODE' '=ENTE'.
       PERFORM bdc_field       USING 'COBL-KOSTL' wa_data-kostl. "'101902'
        PERFORM bdc_field       USING 'COBL-PRCTR' wa_data-prctr.
        PERFORM bdc_insert USING 'F-27' it_bdcdata.
      ENDLOOP.
    *close the session
      PERFORM close_session.
    *&      Form  get_file
          text
         -->P_PA_FILE  text
    FORM get_file  USING    p_pa_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name = syst-repid
          field_name   = 'PA_FILE'
        CHANGING
          file_name    = pa_file.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " get_file
    *&      Form  upload_file
          text
         -->P_V_FILE  text
         <--P_IT_DATA  text
    FORM upload_file  USING    p_v_file
                      CHANGING p_it_data LIKE it_data.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = p_v_file
       filetype                      = 'DAT'
        has_field_separator           = '#'
        TABLES
          data_tab                      = p_it_data.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " upload_file
    *&      Form  open_session
          text
    -->  p1        text
    <--  p2        text
    FORM open_session .
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         client                    = sy-mandt
      DEST                      = FILLER8
         group                     = 'JAYANT'
      HOLDDATE                  = FILLER8
         keep                      = 'X'
         user                      = sy-uname.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " open_session
    *&      Form  bdc_dynpro
          text
         -->P_0043   text
         -->P_0044   text
    FORM bdc_dynpro  USING  program TYPE BDC_PROG
                            dynpro  TYPE BDC_DYNR
                            dynbegin TYPE BDC_START.
      wa_bdcdata-program  = program.
      wa_bdcdata-dynpro   = dynpro.
      wa_bdcdata-dynbegin = dynbegin.
      APPEND wa_bdcdata TO it_bdcdata.
      CLEAR wa_bdcdata.
    ENDFORM.                    " bdc_dynpro
    *&      Form  bdc_field
          text
         -->P_0048   text
         -->P_0049   text
    FORM bdc_field  USING  fnam TYPE FNAM_____4
                           fval TYPE BDC_FVAL.
      wa_bdcdata-fnam = fnam.
      wa_bdcdata-fval = fval.
      APPEND wa_bdcdata TO it_bdcdata.
      CLEAR wa_bdcdata.
    ENDFORM.                    " bdc_field
    *&      Form  bdc_insert
          text
         -->P_0183   text
         -->P_IT_BDCDATA  text
    FORM bdc_insert  USING    p_tcode TYPE sytcode
                              p_it_bdcdata LIKE it_bdcdata.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          tcode     = p_tcode
        TABLES
          dynprotab = p_it_bdcdata.
    ENDFORM.                    " bdc_insert
    *&      Form  close_session
          text
    -->  p1        text
    <--  p2        text
    FORM close_session .
      CALL FUNCTION 'BDC_CLOSE_GROUP'.
    ENDFORM.                    "close_session
    plz help me in this programm
    thanks
    jayant.

    why not post this in the ABAP forum?
    You expect Basis people to help you on this one?

  • Problem in bdc session method for tcode FS00

    Hi Experts,
    problem in bdc session method, when i run this program no output is shown.
    Even it is not calling the transaction.
    code as follows.
    *& Report  Z_GL_MASTER
    *& CATEGORY         =  BDC.
    *& DESCRIPTION      =  UPLOADING G/L MASTER RECORDS.
    *& TECHNICAL CONST  =  FRANCIS REDDY.
    *& FUNTIONAL CONST  =  FICO.
    REPORT  Z_GL_MASTER.
    *& Internal  Table
    DATA : BEGIN OF IT_UPLOAD OCCURS 0,
           SAKNR LIKE  GLACCOUNT_SCREEN_KEY-SAKNR,          " ACCOUNT NUMBER.
           BUKRS LIKE  GLACCOUNT_SCREEN_KEY-BUKRS,          " COMPANY CODE.
           KTOKS LIKE GLACCOUNT_SCREEN_COA-KTOKS,           " ACCOUNT GROUP.
           XPLACCT LIKE GLACCOUNT_SCREEN_COA-XPLACCT,       " P&L STATEMEMENT.
           GVTYP LIKE  GLACCOUNT_SCREEN_COA-GVTYP,          " P&L STATEMENT TYPE.
           XBILK LIKE GLACCOUNT_SCREEN_COA-XBILK,           " BALANCE SHEET STATEMENT
           SHORT LIKE GLACCOUNT_SCREEN_COA-TXT20_ML,        " SHORT TEXT.
           LONG LIKE GLACCOUNT_SCREEN_COA-TXT50_ML,         " LONG TEXT.
           WAERS LIKE GLACCOUNT_SCREEN_CCODE-WAERS,         " ACCOUNT CURRENCY.
           XSALH LIKE GLACCOUNT_SCREEN_CCODE-XSALH,         " ONLY BALANCES IN LOCAL CURRENCY.
           MITKZ LIKE GLACCOUNT_SCREEN_CCODE-MITKZ,         " RECONCILATION ACCOUNT FOR ACCOUNT TYPEGLACCOUNT_SCREEN_CCODE-MITKZ
           XOPVW LIKE GLACCOUNT_SCREEN_CCODE-XOPVW,         " OPEN ITEM MANAGEMENT.
           XKRES LIKE GLACCOUNT_SCREEN_CCODE-XKRES,         " LINE ITEM DISPLAY.
           ZUAWA LIKE GLACCOUNT_SCREEN_CCODE-ZUAWA,         " SORT KEY.
           FSTAG LIKE GLACCOUNT_SCREEN_CCODE-FSTAG,         " FIELD STATUS GROUP.
           XGKON LIKE GLACCOUNT_SCREEN_CCODE-XGKON,         " RELAVENT CASH FLOW.
           END OF IT_UPLOAD.
    *& Internal  Table FOR BDC DATA.
    DATA : IT_BDCDATA TYPE  BDCDATA OCCURS 0  WITH HEADER LINE.
    *& DATA DECLARATIONS.
    DATA : V_FILE LIKE RLGRAP-FILENAME.
    *&  SELECTION SCREEN.
    PARAMETER : P_FILE LIKE V_FILE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
         PERFORM GET_FILENAME.
    START-OF-SELECTION.
          PERFORM UPLOAD_DATA.
          PERFORM BDCDATA_OPEN.
          PERFORM BDC_POPULATE.
          PERFORM BDC_CLOSE.
    *&      Form  GET_FILENAME
    form GET_FILENAME .
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         PROGRAM_NAME        = SYST-CPROG
         DYNPRO_NUMBER       = SYST-DYNNR
         FIELD_NAME          = 'P_FILE'
       IMPORTING
         FILE_NAME           = P_FILE.
    endform.                    " GET_FILENAME
    *&      Form  UPLOAD_DATA
    form UPLOAD_DATA .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      =  P_FILE
       FILETYPE                      = 'DAT'
      TABLES
        data_tab                     = IT_UPLOAD.
    endform.                    " UPLOAD_DATA
    *&      Form  BDCDATA_OPEN
       FORM FOR BDC_OPEN_GROUP.
    form BDCDATA_OPEN .
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
       CLIENT                    = SY-MANDT
       GROUP                     = 'GLMASTER'
       HOLDDATE                  = SY-DATUM
       KEEP                      = 'X'
       USER                      = SY-UNAME.
    endform.                    " BDCDATA_OPEN
    *&      Form  BDC_POPULATE
      POPULATING BDC DATA .
    form BDC_POPULATE .
    loop at it_upload.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=ACC_CRE'.
    PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_KEY-SAKNR'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-SAKNR'    IT_UPLOAD-SAKNR.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-BUKRS'    IT_UPLOAD-BUKRS.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_GROUP'.
    PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-KTOKS'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-KTOKS'    IT_UPLOAD-KTOKS.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XPLACCT'  IT_UPLOAD-XPLACCT.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_BS_PL'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-GVTYP'    IT_UPLOAD-GVTYP.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XBILK'    IT_UPLOAD-XBILK.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-TXT20_ML'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT20_ML' IT_UPLOAD-SHORT.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT50_ML' IT_UPLOAD-LONG.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING  'BDC_OKCODE' '=TAB02'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-WAERS'  IT_UPLOAD-WAERS.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XSALH'  IT_UPLOAD-XSALH.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-MITKZ'  IT_UPLOAD-MITKZ.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XOPVW'  IT_UPLOAD-XOPVW.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XKRES'  IT_UPLOAD-XKRES.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-ZUAWA'  IT_UPLOAD-ZUAWA.
    PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
    PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=TAB03'.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-FSTAG' IT_UPLOAD-FSTAG.
    PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XGKON' IT_UPLOAD-XGKON.
    CALL FUNCTION 'BDC_INSERT'
      EXPORTING
        TCODE                  = 'FS00'
       TABLES
         dynprotab              = IT_BDCDATA.
    endloop.
    endform.                    " BDC_POPULATE
    *&      Form  BDC_CLOSE
    FORM FOR CLOSING BDC_GROUP
    form BDC_CLOSE .
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    endform.                    " BDC_CLOSE
    *&      Form  BDC_SUB1
       FORM FOR BDCDATA.
    form BDC_SUB1   USING  A  B  C.
    CLEAR  IT_BDCDATA.
    IT_BDCDATA-DYNBEGIN = A.
    IT_BDCDATA-PROGRAM =  B.
    IT_BDCDATA-DYNPRO =   C.
    APPEND IT_BDCDATA.
    endform.                    " BDC_SUB1
    *&      Form  BDC_SUB2
          text
    form BDC_SUB2   USING  A  B.
    CLEAR  IT_BDCDATA.
      IT_BDCDATA-FNAM = A.
      IT_BDCDATA-FVAL = B.
      APPEND IT_BDCDATA.
    endform.                    " BDC_SUB2
    Points will be  rewarded.
    Thanks in advance.
    Francis.

    Hi,
    Once the program is executed..It will a BDC session..
    THen you have to use the transaction SM35..To process the BDC session..
    Thanks,
    Naren

  • Problem in doing BDC for XK01

    Hi all,
    i am doing BDC for XK01 with Line Item for Bank Details(Table Control..)
    With 3 Internal table
    IT_dummy to get the flat file
    IT_vend  for Header details
    IT_bank  for Item Details
    in this there is a Nested loop
    Loop at it_vend.
    perform bdc
    loop at it_bank.
    concatenate................
    endloop.
    endloop.
    because of the above nested loops..it's bit slow..
    & i am trying to do with a single internal table..
    The problem is..
    with the header data it's not picking all the item data(it's picking only one..)..help me in resolving the problem..
    Below the code..
    REPORT  ZMM_BDCTC1 NO STANDARD PAGE HEADING LINE-SIZE 255.
    PARAMETER:P_FILE TYPE RLGRAP-FILENAME.
    DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF IT_DUMMY OCCURS 0,
          TYP,
          DES(255) TYPE C,
          END OF IT_DUMMY.
    DATA:DELIMITER VALUE ',',
         cnt(4) TYPE N,
         L_FNAM(30) TYPE C,
         FILENAME TYPE STRING.
    TYPES:BEGIN OF TY_FINAL,
          N(4) TYPE C,
          LIFNR TYPE RF02K-LIFNR,
          BUKRS TYPE RF02K-BUKRS,
          EKORG TYPE RF02K-EKORG,
          KTOKK TYPE RF02K-KTOKK,
          NAME1 TYPE LFA1-NAME1,
          SORTL TYPE LFA1-SORTL,
          LAND1 TYPE LFA1-LAND1,
          AKONT TYPE LFB1-AKONT,
          FDGRV TYPE LFB1-FDGRV,
          WAERS LIKE LFM1-WAERS,
          M(4) TYPE C,
          BANKS TYPE LFBK-BANKS,
          BANKL TYPE LFBK-BANKL,
          BANKN TYPE LFBK-BANKN,
          KOINH TYPE LFBK-KOINH,
          END OF TY_FINAL.
    DATA: IT_FINAL TYPE TABLE OF TY_FINAL,
          WA_FINAL TYPE TY_FINAL.
    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.
         FILENAME = P_FILE.
         CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
             filename                      = FILENAME
            FILETYPE                      = 'ASC'
           tables
             data_tab                      = IT_DUMMY.
    START-OF-SELECTION.
    LOOP AT it_dummy.
        IF it_dummy-typ = 'H'.
          SPLIT  it_dummy-des AT delimiter INTO WA_FINAL-lifnr "Populating Header Table
                                                WA_FINAL-bukrs
                                                WA_FINAL-ekorg
                                                WA_FINAL-ktokk
                                                WA_FINAL-name1
                                                WA_FINAL-sortl
                                                WA_FINAL-land1
                                                WA_FINAL-akont
                                                WA_FINAL-fdgrv
                                                WA_FINAL-waers.
          WA_FINAL-N = WA_FINAL-N + 1.
          WA_FINAL-M = WA_FINAL-M + 1.
        ELSEIF it_dummy-typ = 'I'.
          SPLIT it_dummy-des AT delimiter INTO WA_FINAL-BANKS
                                               WA_FINAL-BANKL
                                               WA_FINAL-BANKN
                                               WA_FINAL-KOINH.
          APPEND WA_FINAL TO IT_FINAL.
        ENDIF.
      ENDLOOP.
    LOOP AT IT_FINAL INTO WA_FINAL.
    WRITE:/ WA_FINAL-N,
            WA_FINAL-LIFNR,
            WA_FINAL-BUKRS,
            WA_FINAL-EKORG,
            WA_FINAL-KTOKK,
            WA_FINAL-NAME1,
            WA_FINAL-SORTL,
            WA_FINAL-LAND1,
            WA_FINAL-AKONT,
            WA_FINAL-FDGRV,
            WA_FINAL-WAERS,
            WA_FINAL-M,
            WA_FINAL-BANKS,
            WA_FINAL-BANKL,
            WA_FINAL-BANKN,
            WA_FINAL-KOINH.
    ENDLOOP.
    data: WA_FINAL1 like line of IT_FINAL.
    clear WA_FINAL1.
    ******************BDC STARTS***********************
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT      = SY-MANDT
    GROUP       = 'ZMM_BDCTAB'
    KEEP        = 'X'
    USER        = SY-UNAME.
    Clear wa_final.
    LOOP AT IT_FINAL INTO WA_FINAL.
    WA_FINAL1 = WA_FINAL.
    CLEAR BDCDATA[].
    AT NEW N.
    cnt = 1.
    perform bdc_dynpro      using 'SAPMF02K' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-KTOKK'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                                  WA_FINAL1-LIFNR.
    perform bdc_field       using 'RF02K-BUKRS'
                                  WA_FINAL1-BUKRS.
    perform bdc_field       using 'RF02K-EKORG'
                                  WA_FINAL1-EKORG.
    perform bdc_field       using 'RF02K-KTOKK'
                                  WA_FINAL1-KTOKK.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-LAND1'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  WA_FINAL1-NAME1.
    perform bdc_field       using 'LFA1-SORTL'
                                  WA_FINAL1-SORTL.
    perform bdc_field       using 'LFA1-LAND1'
                                  WA_FINAL1-LAND1.
    perform bdc_dynpro      using 'SAPMF02K' '0120'. "ERROR CLEARED
    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(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    ENDAT.
    *ENDON.
    IF WA_FINAL1-N = WA_FINAL1-M.
    CONCATENATE  'LFBK-BANKS(' cnt ')'  INTO L_FNAM.
    perform bdc_field       using L_FNAM
                                  WA_FINAL1-BANKS.
    CONCATENATE  'LFBK-BANKL(' cnt ')'  INTO L_FNAM.
    perform bdc_field       using L_FNAM
                                  WA_FINAL1-BANKL.
    CONCATENATE  'LFBK-BANKN(' cnt ')'  INTO L_FNAM.
    perform bdc_field       using L_FNAM
                                  WA_FINAL1-BANKN.
    CONCATENATE  'LFBK-KOINH(' cnt ')'  INTO L_FNAM.
    perform bdc_field       using L_FNAM
                                  WA_FINAL1-KOINH.
    *ENDDO.
    cnt = cnt + 1.
    ENDIF.
    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'.
    *AT NEW LIFNR.
    perform bdc_field       using 'LFB1-AKONT'
                                  WA_FINAL1-AKONT.
    perform bdc_field       using 'LFB1-FDGRV'
                                  WA_FINAL1-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'
                                  WA_FINAL1-WAERS.
    perform bdc_dynpro      using 'SAPMF02K' '0320'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-LIFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    AT END OF M.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE     = 'XK01'
    TABLES
    DYNPROTAB = BDCDATA.
    ENDAT.
    CLEAR WA_FINAL1.
    CLEAR WA_FINAL.
    ENDLOOP.
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    *********************BDC ENDS***********************
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
    IF FVAL <> NODATA.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
    ENDIF.
    ENDFORM.
    Flat File is..
    HAAA45,1000,1000,0002,NAME45,N,IN,31000,A1,USD
    IIN,1000,1021,Name45
    IIN,1000,1022,Name45
    HAAA50,1000,1000,0002,NAME50,N,IN,31000,A1,USD
    IIN,1000,1023,Name50
    IIN,1000,1024,Name50

    Regarding avoiding the loop I have a suggestion, though I have not tried this .
    SAP help says " Using the internal table bdc_tab, you can provide any number of screens of the called transaction with input and user actions. " .
    Above implies you can load all records in the itab bdc_tab when doing call transaction. Say, your bdc_tabl has 30 records for 1 pass of the transaction. You need to update 10 vendor records. You simply load up all 300 records into bdc_tab. After every 30 record loads, you simulate a 'SAVE' press in your program but do not leave the transaction. Rather you simulate the keystroke that takes you to the first screen of XK01 after the save if not aready there, and start loading up the next transaction.

  • Problem in the BDC Table Control for the T.Code VA01

    Hi,
      I faced probelm in the BDC of the VA01. In the Table Control
    the records are entered upto 12 line items. after 13th line item overwrites the first record. How to solve the Problem.
    Please help me.

    or use this
    Internal table definition *
    data : begin of bdcdata occurs 0.
            include structure bdcdata.
    data : end of bdcdata.
    data: begin of messtab occurs 0.
            include structure bdcmsgcoll.
    data: end of messtab.
    data: v_chr_opengrp type c,
          r_matnr like mara-matnr,                       "variable for material conversion
          r_werks like marc-werks,                       "variable for plant
          v_str_fname   type string.
    data: begin of count2,
          inrec(9) type n,                               " input I_MATERIAL count
          create(9) type n,                              " create count
          error(9) type n,                               " error count
          bdc(9) type n,                                 " count of BDC creates
          end of count2.
    types: begin of ty_source,
    partn_numb(10) type n ,"Customer Number 1
    ref(035),
    sales_org(4) , "Sales Organization
    distr_chan(2) , "Distribution Channel
    division(002), "DIVISION
    doc_type(4) , "Sales Document Type
    purch_no(020), "Purchase order
    material like vbap-matnr,
    reqqty(018),
    reqdate(010),
    end of ty_source,
    begin of ty_header ,
    partn_numb(10) ,"Customer Number 1
    ref(035),
    sales_org(4) , "Sales Organization
    distr_chan(2) , "Distribution Channel
    division(002), "DIVISION
    doc_type(4) , "Sales Document Type
    purch_no(020), "Purchase order
    end of ty_header,
    begin of ty_item,
    partn_numb(10) ,"Customer Number 1
    ref(035),
    material like vbap-matnr,
    reqqty(018),
    reqdate(010),
    end of ty_item.
    data : msg(240) type c, " Return Message
    e_rec(8) type c, " Error Records Counter
    rec_no(8) type c, " Records Number Indicator
    s_rec(8) type c, " Successful Records Counter
    t_rec(8) type c, " Total Records Counter
    v_matnr like mara-matnr.
    data: val(2) type n value 01.
    data : begin of bdc_itab occurs 0.
            include structure bdcdata.
    data : end of bdc_itab.
    data : t_source type standard table of ty_source   with header line,
    t_header type standard table of ty_header initial size 1,
    t_item type standard table of ty_item initial size 1,
    t_target type standard table of bdcdata initial size 1.
    data : w_source type ty_source,
    w_source1 type ty_source,
    w_header type ty_header,
    w_item type ty_item,
    w_target type bdcdata,
    count type i,
    count1 type n.
    Variable Declaration
    data: w_fname type string,
    fnam(20),
    date1(10),
    i(2) type n,
    v_count type i,
    v_group type apqi-groupid.
    *& selection screen
    selection-screen :begin of block bl1 with frame title  text-001.
    parameters : p_fname type rlgrap-filename,                         "Input file
                 p_update(1) default 'N',                              "Input for update mode
                 p_bdcgrp(12) default 'SD_ORDERS'.                     "Input for session name
    selection-screen end of block bl1.
    **&SELECTION SCREEN VALIDATIONS
    at selection-screen on value-request for p_fname.
      call function 'KD_GET_FILENAME_ON_F4'
        exporting
          program_name  = 'ZMATERIAL'
          dynpro_number = '1000'
          field_name    = 'P_FNAME'
        changing
          file_name     = p_fname.
    *& Start of selection
    start-of-selection.
      if  p_fname is initial.
        message i016(rp) with 'Please enter a file name'.
        leave list-processing.
      else.
        move p_fname to  v_str_fname.
      endif.
      call function 'GUI_UPLOAD'
        exporting
          filetype                = 'ASC'
          filename                = v_str_fname
          has_field_separator     = 'X'
        tables
          data_tab                = t_source
        exceptions
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          others                  = 17.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      sort t_source by ref partn_numb.
      loop at t_source into w_source.
        add 1 to count2-inrec.
        w_source1 = w_source.
       AT NEW PARTN_NUMB.  "10/31 KVB
        at new ref.
          w_header-doc_type = w_source1-doc_type..
          w_header-sales_org = w_source1-sales_org .            "'0001'
          w_header-distr_chan = w_source1-distr_chan.           "'01'
          w_header-division = w_source1-division.               " '01'
          w_header-purch_no = w_source1-purch_no.
          w_header-partn_numb = w_source1-partn_numb.
          w_header-ref = w_source1-ref.
          append w_header to t_header.
        endat.
        w_item-partn_numb = w_source1-partn_numb.
        w_item-material = w_source1-material.
        w_item-reqqty = w_source1-reqqty.
        w_item-ref = w_source1-ref.
        w_item-reqdate = w_source1-reqdate.
        append w_item to t_item.
        clear :w_item,w_header.
      endloop.
      loop at t_header into w_header.
        perform bdc_dynpro      using         'SAPMV45A'                  '0101'       .
        perform bdc_field       using         'BDC_CURSOR'                'VBAK-SPART'.
        perform bdc_field       using         'BDC_OKCODE'                '/00'.
        perform bdc_field       using         'VBAK-AUART'                w_header-doc_type.
        perform bdc_field       using         'VBAK-VKORG'                w_header-sales_org.
        perform bdc_field       using         'VBAK-VTWEG'                w_header-distr_chan.
        perform bdc_field       using         'VBAK-SPART'                w_header-division.
        perform bdc_dynpro      using         'SAPMV45A'                  '4001'     .
        perform bdc_field       using         'BDC_OKCODE'                '/00'.
        perform bdc_field       using         'BDC_CURSOR'               'VBKD-BSTKD'.
        perform bdc_field       using         'VBKD-BSTKD'                w_header-purch_no.
        perform bdc_field       using         'KUWEV-KUNNR'               w_header-partn_numb.
        i = 1.
        loop at t_item into w_item where partn_numb = w_header-partn_numb
                                         and ref = w_header-ref.
          at new partn_numb.
            clear count1.
            count = 0.
          endat.
          count = count + 1.
          if count gt 5.
            clear i.
            i = 2.
            perform bdc_dynpro      using 'SAPMV45A' '4001'      .
            perform bdc_field       using 'BDC_OKCODE' '=POAN'.
          endif.
          count1 = count1 + 1.
          concatenate 'VBAP-POSNR(' i ')' into fnam.
          perform bdc_field       using  fnam
                                        count1.
          concatenate 'RV45A-MABNR(' i ')' into fnam.
          perform bdc_field    using fnam                            w_item-material.
          concatenate 'RV45A-KWMENG(' i ')' into fnam.
          perform bdc_field       using  fnam                        w_item-reqqty..
          concatenate 'RV45A-ETDAT(' i ')' into fnam.
          perform bdc_field       using  fnam                         w_item-reqdate.
          concatenate 'VBKD-BSTKD_E(' i ')' into fnam.
          perform bdc_field       using  fnam                         w_item-ref.
          i = i + 1.
          clear:  w_item.
        endloop.
        clear w_header.
        perform bdc_dynpro      using 'SAPMV45A' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=SICH'.
        perform post_transaction.
        refresh bdc_itab.
        clear   bdc_itab.
      endloop.
    *endloop.
    end-of-selection.
      perform finalization.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear bdc_itab.
      bdc_itab-program  = program.
      bdc_itab-dynpro   = dynpro.
      bdc_itab-dynbegin = 'X'.
      append bdc_itab.
    endform.                    "bdc_dynpro
           Insert field                                                  *
    form bdc_field using fnam fval.
      if fval <> ''.
        clear bdc_itab.
        bdc_itab-fnam = fnam.
        bdc_itab-fval = fval.
        append bdc_itab.
      endif.
    endform.                    "bdc_field
    **&      Form  get_filename
          text
    -->  p1        text
    <--  p2        text
    *form get_filename .
    *call function 'WS_FILENAME_GET'
       exporting
         def_filename     = space
         def_path         = file
         mask             = ',.,..'
         mode             = 'N'
         title            = text-015
       importing
         filename         = file
       exceptions
         inv_winsys       = 1
         no_batch         = 2
         selection_cancel = 3
         selection_error  = 4
         others           = 5.
    *endform.                    " get_filename
    *&      Form  post_transaction
          text
    -->  p1        text
    <--  p2        text
    form post_transaction .
      refresh messtab.
      clear   messtab.
      call transaction  'VA01' using bdc_itab
                  mode   p_update
                update  'S'
              messages into messtab.
      read table messtab with key msgtyp = 'E'.
      if sy-subrc eq 0.
        perform process_error_messages.
        add 1 to count2-bdc.
        if v_chr_opengrp is initial.
          perform bdc_open_group.
        endif.
        call function 'BDC_INSERT'
          exporting
            tcode          = 'VA01'
          tables
            dynprotab      = bdc_itab
          exceptions
            internal_error = 1
            not_open       = 2
            queue_error    = 3
            tcode_invalid  = 4
            others         = 5.
        if sy-subrc <> 0.
          case sy-subrc.
            when 1.
              write: / 'Internal error'.
            when 2.
              write: / 'Not open error'.
            when 3.
              write: / 'queue error'.
            when 4.
              write: / 'tcode invalid error'.
            when others.
              write: / 'other error'.
          endcase.
        endif.
      else.
        add +1 to count2-create.
        format intensified off.
        format color col_normal.
        format color col_normal off.
      endif.
      clear   bdc_itab.
      refresh bdc_itab.
    endform.                    " post_transaction
    *&      Form  finalization
          text
    -->  p1        text
    <--  p2        text
    form finalization .
      if v_chr_opengrp = 'X'.
        call function 'BDC_CLOSE_GROUP'
          exceptions
            not_open    = 1
            queue_error = 2
            others      = 3.
      endif.
      get time.
      skip 2.
      write: / 'Time', sy-uzeit.
      skip.
      format color col_total on.
      write: / 'Total Records: ',           40 count2-inrec.
      write: / 'PERNR not of Emp Group 6 ', 40 count2-error.
      write: / 'Records Created: ',         40 count2-create.
      write: / 'BDC Create in group: ',     40 count2-bdc.
      if v_chr_opengrp = 'X'.
        skip 1.
        format intensified on.
        format color col_negative on.
        write: / 'PLEASE USE TRANSACTION "SM35" ',
                 'TO PROCESS THE GENERATED BDC SESSION ... ',
                 p_bdcgrp.
      endif.
    endform.                    " finalization
    *&      Form  bdc_open_group
          text
    -->  p1        text
    <--  p2        text
    form bdc_open_group .
      call function 'BDC_OPEN_GROUP'
        exporting
          client              = sy-mandt
          group               = p_bdcgrp
          holddate            = sy-datum
          keep                = 'X'
          user                = sy-uname
        exceptions
          client_invalid      = 1
          destination_invalid = 2
          group_invalid       = 3
          group_is_locked     = 4
          holddate_invalid    = 5
          internal_error      = 6
          queue_error         = 7
          running             = 8
          system_lock_error   = 9
          user_invalid        = 10
          others              = 11.
      if sy-subrc eq 0.
        v_chr_opengrp = 'X'.
      endif.
    endform.                    " bdc_open_group
    *&      Form  process_error_messages
          text
    -->  p1        text
    <--  p2        text
    form process_error_messages .
      data: begin of loc_aux_message.
              include structure message.
      data: end of loc_aux_message.
      data : msgno type sy-msgno.
      loop at messtab.
        move messtab-msgnr to msgno.
        call function 'WRITE_MESSAGE'
          exporting
            msgid  = messtab-msgid
            msgno  = msgno
            msgty  = messtab-msgtyp
            msgv1  = messtab-msgv1
            msgv2  = messtab-msgv2
            msgv3  = messtab-msgv3
            msgv4  = messtab-msgv4
          importing
            messg  = loc_aux_message
          exceptions
            others = 1.
        if sy-subrc eq 0.
          format color col_negative on.
          write: /10 loc_aux_message.
          format color col_negative off.
        else.
          format color col_negative on.
          write: /10 t_source-partn_numb.
          write: / 'Error creating message'.
          format color col_negative off.
          exit.
        endif.
      endloop.
    endform.                    " process_error_messages

  • LSMW - Error BDC_INSERT, Transaction code .. is invalid XD01

    Dear all.
    I have done the following Steps:
    1 - Maintain Object Attributes. Chose the Object type Batch Recording, then created a Record using the name (CLI_PMR). And created the Batch record and then assign the fields name.
    2 - Maintain Source Structures – Created the Struture (CLI_PMR1)
    3 - Maintain Source Fields – Assign the fields name and length that I used in my program. (CLI_PMR1).
    4 - Maintain Structure Relations – Assign the Struture (CLI_PMR1 to CLI_PMR)
    5 - Maintain Field Mapping and Conversion Rules – The normal thing in this point.
    6 - Specify Files - Specified the Legacy Data, path for the file.
    7 - Generate Read Program – Generated the Program.
    8 – Read Data – Executed this Step and every thing is correct
    9 - Generate Conversion Program – Generated the program
    10 - Convert Data – Convert data
    11 - Display Converted Data – Every thing is fine, with no errors
    12 - Create Batch Input Session- At this the error message appears Error BDC_INSERT, Transaction code .. is invalid  time.
    At the time we have created other LSMW programs for this T-Code and every thing is OK.
    I'm using the T-CODE=XD01
    Best Regards
    Pedro Miguel Rodrigues

    Hi, I had the same problem in LSMW when generating a batch input for trx IE01. The cause was that there were tab/newline-characters in my text file (some descriptions contained tab-characters). Since I used a tab delimited file, these tabs/newlines in the fields messed up my file.
    The excel file contained multiple lines per cell in some description fields. When this was exported to tab delimited text, it contained additional tabs. After checking the contents and removing the tabs/newlines from Excel and performed a new export to txt-file, it was solved.
    Best regards,
    Jan-Peter Molenaar
    SAP EAM Consultant

  • SUBMIT RSBDCSUB  in a program after a BDC_INSERT doesn't work

    Hi,
    I have a program with create a batch-input, after the call function BDC_INSERT, I use a SUBMIT RSBDCSUB to call the execution of the BI.
    My problem is, the batch still doesn't exist when I call the program. This problem only occurs in one server, the productive server.
    Do you have already facing this problem ?
    Fred

    Sorry, I have also the BDC_CLOSE_GROUP.
    Here my code, I have add a COMMIT ... to test.
      DATA : w_nom      TYPE apq_grpn ,
             w_kbetr(16) ,
             w_datab(10) ,
             w_datbi(10) ,
             w_kpein(5)  ,
             w_kmein(3)  .
      CHECK is_data-flag EQ 'A' OR
            is_data-flag EQ 'B' OR
            is_data-flag EQ 'C'.
      REFRESH itg_bdcdata.
    * Batch-input name.
      CONCATENATE 'Hauss_'
                  sy-uzeit
    *              is_data-knumh+4(6)
                  INTO w_nom.
    * Open Batch-input.
      PERFORM p_open_bdc USING w_nom.
    * Choix type cond.
      PERFORM p_bdc_dynpro      USING 'SAPMV13A'
                                      '0100'.
      PERFORM p_bdc_field       USING 'BDC_OKCODE'
                                      '=ANTA'.
      PERFORM p_bdc_field       USING 'RV13A-KSCHL'
                                      gw_kschl.
    * Choix de la clef.
      PERFORM p_bdc_dynpro      USING 'SAPLV14A'
                                      '0100'.
      PERFORM p_bdc_field       USING 'BDC_OKCODE'
                                      '=WEIT'.
      PERFORM p_bdc_field       USING 'RV130-SELKZ(01)'
                                      'X'.
    * Enregistre la nouvelle condition.
      PERFORM p_bdc_dynpro      USING 'SAPMV13A'
                                      '1510'.
      PERFORM p_bdc_field       USING 'BDC_OKCODE'
                                      '=SICH'.
      PERFORM p_bdc_field       USING 'KOMG-VKORG'
                                      is_data-vkorg.
      PERFORM p_bdc_field       USING 'KOMG-VTWEG'
                                      is_data-vtweg.
      PERFORM p_bdc_field       USING 'KOMG-KUNNR'
                                      is_data-kunnr.
      PERFORM p_bdc_field       USING 'KOMG-MATNR'
                                      is_data-matnr.
      PERFORM p_bdc_field       USING 'KOMG-WERKS'
                                      is_data-werks.
      PERFORM p_bdc_field       USING 'KOMG-AUART_SD'
                                      is_data-auart_sd.
      PERFORM p_bdc_field       USING 'KOMG-INCO1(01)'
                                      is_data-inco1.
      WRITE is_data-kbetr2 TO w_kbetr.
      PERFORM p_bdc_field       USING 'KONP-KBETR(01)'
                                      w_kbetr.
      WRITE is_data-kpein TO w_kpein.
      PERFORM p_bdc_field       USING 'KONP-KPEIN(01)'
                                      w_kpein.
      WRITE is_data-kmein TO w_kmein.
      PERFORM p_bdc_field       USING 'KONP-KMEIN(01)'
                                      w_kmein.
      WRITE is_data-datab TO w_datab.
      PERFORM p_bdc_field       USING 'RV13A-DATAB(01)'
                                      w_datab.
      WRITE is_data-datbi TO w_datbi.
      PERFORM p_bdc_field       USING 'RV13A-DATBI(01)'
                                      w_datbi.
    * Save the transaction.
      PERFORM p_insert_bdc USING 'VK11'.
    * Close the Batch-input..
      PERFORM p_close_bdc.
      COMMIT WORK AND WAIT.
      SUBMIT rsbdcsub WITH mappe = w_nom
                      WITH von   = sy-datum
                      WITH bis   = sy-datum
                      EXPORTING LIST TO MEMORY
                      AND RETURN.

  • LSMW Routing- Standard Batch Input BDC_INSERT, screen .&. is invalid

    Hello All,
    I am preparing LSMW for routing upload along with inspection characteristics with standard batch input method.
    At the time of 'Create batch input session' I am facing an error 'BDC_INSERT, screen .&. is invalid'.
    I have checked the forums for the same issue but it wasn't fruitful. However I cam across one thread which mentions to ensures the data in falt file, which I did checke and confirmed.
    What could be the reason?
    Awaiting your replies...
    Mimiri

    Hello all.
    I was facing the same problem.
    To solve,I filled BI001-TCODE with 'QP01' (constant) in Maintain Field Mapping and Conversion Rules.
    I know, this is a old question, but when I was searching I didn't find anything with this.
    Regards.
    Cássio Oliveira

  • Error in BDC_INSERT

    Hello Everyone,
    i have created a BDC in session method,
    the screens and all are supposed to be correct and still i am getting this error.
    "BDC_INSERT, screen .&. is invalid"
    i am using the same screens in many different programs, so i strongly feel that there is no problem with the screen. i have come across this error for the first time
    in debugging, it is going into at end of xblnr, but when going to perform bdc_insert there is some error there...
    the following is the code...
    FORM SESSION.
      LOOP AT RECORD.
        REFRESH BDCDATA.
    AT NEW XBLNR.
        PERFORM HEADER_DATA.
    ENDAT.
            IF RECORD-NEWBS EQ '40' OR
               RECORD-NEWBS EQ '50'.
              PERFORM LINEITEM_40_50.
            ELSEIF RECORD-NEWBS EQ '01' OR
                   RECORD-NEWBS EQ '11'.
              PERFORM LINEITEM_01_11.
            ELSEIF RECORD-NEWBS EQ '25' OR
                   RECORD-NEWBS EQ '35' OR
                   RECORD-NEWBS EQ '21' OR
                   RECORD-NEWBS EQ '31'.
              PERFORM LINITEM_25_35_21_31.
            ELSEIF RECORD-NEWBS EQ '29' OR
                   RECORD-NEWBS EQ '39'.
              PERFORM LINEITEM_29_39.
            ELSE.
       MESSAGE E999 WITH RECORD-NEWBS 'POST KEY NOT USED IN THIS UPLOAD'.
            ENDIF.
    AT END OF XBLNR.
      PERFORM BDC_DYNPRO      USING 'ZSAPMF05A' '0700'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR' 'RF05A-NEWBS'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE' '=BU'.
        PERFORM BDC_INSERT.
        ENDAT.
      ENDLOOP.
      PERFORM BDC_CLOSE.
    so, pls let me know what i have to do to avoid this error.....
    Thanks in Advance,
    CAPC

    change ur code:
    existed code:
    AT END OF XBLNR.
    PERFORM BDC_DYNPRO USING 'ZSAPMF05A' '0700'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RF05A-NEWBS'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE' '=BU'.
    PERFORM BDC_INSERT.
    ENDAT.
    ENDLOOP.
    new code:
    once control reaches to at end of xblnr.
    do not perfrom any thing there, set a flag value = X.
    AT END OF XBLNR.
    v_flag = 'X'.
    ENDAT.
    if v_flag = 'X'.
    PERFORM BDC_DYNPRO USING 'ZSAPMF05A' '0700'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RF05A-NEWBS'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE' '=BU'.
    PERFORM BDC_INSERT.
    clear: v_flag.
    endif.
    ENDLOOP.
    at end of xblnr, all the fields next to the xblnr becomes zero.
    so u can't do this inside the control statetment.
    try this, def. it will work.

  • Problem Reg BDC

    hii,
    as iam working on a BDC.
    Iam facing a problem during the tcode execution.
    During execution whenver i add a record that is allowing only when there is already an existing record.
    If there is no record in that it is not allowing the ok code.
    so please suggest any remedy for this.
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Aug 6, 2008 1:47 PM

    hii,
    hope this code may useful to u.
    FORM load_data .
      IF t_soft_succ[] IS NOT INITIAL.
        PERFORM open_group.
       perform insert_data.
        LOOP AT t_soft_succ INTO w_soft_temp.
          w_soft = w_soft_temp.
          AT NEW doknr.
            SELECT COUNT(*) FROM ztemst1 INTO w_count WHERE doknr = w_soft-doknr.
          ENDAT.
          PERFORM bdc_dynpro      USING 'SAPMZEST' '9000'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=ENTR'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'ZSEMST-DOKNR'.
          PERFORM bdc_field       USING 'ZSEMST-DOKNR'
                                        w_soft-doknr.
          IF w_count > 0.
    *IF ALREADY THE ENTRIES ARE EXISTING THEN IT WILL EXECUTE THIS PART OF THE CODE.
            PERFORM bdc_dynpro      USING 'SAPMZEST' '9001'.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                          '=ADD'.
            PERFORM bdc_field       USING 'BDC_CURSOR'
                                           '%#AUTOTEXT012'.
          ENDIF.
          PERFORM bdc_dynpro      USING 'SAPMZEST' '9001'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=SAVE'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'ZSEMST-MSMXV(01)'.
    *THIS PART OF THE CODE IS USED FOR DESELCTING THE ROW WHEN WE ADD NEW ENTRIES.
          perform bdc_field       using 'T_SOFT1-FLAG(01)'
          PERFORM bdc_field       USING 'ZSEMST-IPCN(01)'
                                        w_soft-ipcn.
          PERFORM bdc_field       USING 'ZSEMST-ATWRT(01)'
                                        w_soft-atwrt.
          PERFORM bdc_field       USING 'ZSEMST-ATNAM(01)'
                                        w_soft-atnam.
          PERFORM bdc_field       USING 'ZSEMST-MSMNV(01)'
                                        w_soft-msmnv.
          PERFORM bdc_field       USING 'ZSEMST-MSMXV(01)'
                                        w_soft-msmxv.
          PERFORM bdc_dynpro      USING 'SAPMZEST' '9001'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '/EBACK'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        '%#AUTOTEXT012'.
          PERFORM bdc_dynpro      USING 'SAPLSPO1' '0100'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=YES'.
          PERFORM bdc_dynpro      USING 'SAPMZEST' '9000'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '/EBACK'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'ZSEMST-DOKNR'.
       PERFORM bdc_transaction USING 'ZE01'.
          CALL FUNCTION 'BDC_INSERT'
            EXPORTING
              tcode            = 'ZE01'  "TCODE
            TABLES
              dynprotab        = 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.
          CLEAR :w_soft, w_soft_temp.
          REFRESH bdcdata.
          AT NEW doknr.
            w_count = w_count + 1.
          ENDAT.
          AT END OF doknr.
            CLEAR w_count.
          ENDAT.
        ENDLOOP.
        PERFORM close_group.
       SUBMIT rsbdcsub WITH mappe = 'ZSOFT_BS' AND RETURN.
      ENDIF.
    ENDFORM.                    " LOAD_DATA

  • QM- Bdc Problem

    hi
    experts iam doing a bdc for change in qp02 ..inspection plan
    here i got a problem in this tcode i will enter
    matnr,werks,group, then i have to select the group counter and click the opeartion push button .i will get multiple characterstic i have to select one among them and goto inspection characterstic and again there are multiple charctersic and there among those one or
    two had to be changed .
    The problem is when  i enter to first screen ..i wil get grpc ,werks and usage that is from flat file ..but if there any multiple suppose1,2,3, but in file there is only 2 or 2 and 3 then iam not getting the logic to select 2 or 3 and got to operations .in operation for
    that material had aslo same problem mutiple operation how to select the particular operation number from file and goto characterstic.
    will be helpfull .
    if provide logic and example code .
    regards

    REPORT  zqmb_qp02.
    DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF itab OCCURS 0,
    *            test,
          matnr TYPE rc27m-matnr,
          werks TYPE rc27m-werks,
          sttag TYPE rc271-sttag,
          verwe TYPE plkod-verwe,
          statu TYPE plkod-statu,
          arbpl TYPE plpod-arbpl,
          steus TYPE plpod-steus,
          ltxa1 TYPE plpod-ltxa1,
          END   OF itab.
    DATA: lv_count(2) TYPE c VALUE 01.
    DATA: lv_data(20).
    DATA: BEGIN OF i_itab OCCURS 0,
    *            test,
          lv_formula,
          matnr TYPE rc27m-matnr,
          werks TYPE rc27m-werks,
          sttag(10),
          verwe TYPE plkod-verwe,
          statu TYPE plkod-statu,
          arbpl TYPE plpod-arbpl,
          steus TYPE plpod-steus,
          ltxa1 TYPE plpod-ltxa1,
          verwmerkm TYPE plmkb-verwmerkm,
          kurztext TYPE plmkb-kurztext,
          pmethode TYPE plmkb-pmethode,
          stichprver TYPE plmkb-stichprver,
          formel1(60)," TYPE plmkb-formel1,
          END   OF i_itab.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(20) text_1_1.
    PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1.
    INITIALIZATION.
      text_001 = 'File path selection'.
      text_1_1 = 'File Path'.
    * At Selection Screen Event
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = p_file.
    START-OF-SELECTION.
      PERFORM data_upload.
      IF i_itab[] IS NOT INITIAL.
        PERFORM open_group.
        REFRESH bdcdata.
        PERFORM bdcdata.
        PERFORM close_group.
      ENDIF.
    *&      Form  DATA_UPLOAD
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM data_upload.
      DATA: loc_filename TYPE string.
      loc_filename = p_file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = loc_filename
          filetype                = 'ASC'
          has_field_separator     = 'X'
        TABLES
          data_tab                = i_itab
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " DATA_UPLOAD
    *        Start new screen                                              *
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    *        Insert field                                                  *
    FORM bdc_field USING fnam fval.
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
    ENDFORM.                    "BDC_FIELD
    *&      Form  OPEN_GROUP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM open_group .
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          client = sy-mandt
          group  = 'QP01'
          user   = sy-uname
          keep   = 'X'.
    ENDFORM.                    " OPEN_GROUP
    *&      Form  CLOSE_GROUP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM close_group .
      CALL FUNCTION 'BDC_CLOSE_GROUP'.
      CALL TRANSACTION 'SM35'.
    ENDFORM.                    " CLOSE_GROUP
    *&      Form  bdcdata
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM bdcdata .
      LOOP AT i_itab.
        itab-matnr = i_itab-matnr.
        itab-werks = i_itab-werks.
        itab-sttag = i_itab-sttag.
        itab-verwe = i_itab-verwe.
        itab-statu = i_itab-statu.
        itab-arbpl = i_itab-arbpl.
        itab-steus = i_itab-steus.
        itab-ltxa1 = i_itab-ltxa1.
        APPEND itab.
        CLEAR itab.
      ENDLOOP.
      DELETE ADJACENT DUPLICATES FROM itab.
      CLEAR itab.
    *---->>> Insert Recording Here
      LOOP AT itab.
        REFRESH bdcdata.
        PERFORM bdc_dynpro      USING 'SAPLCPDI' '8010'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RC27M-MATNR'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'RC27M-MATNR'
                                      itab-matnr.
    *                              'RAWMMMMMMMMMMMMMMM'.
        PERFORM bdc_field       USING 'RC27M-WERKS'
                                      itab-werks.
    *                              '2010'.
        PERFORM bdc_field       USING 'RC271-STTAG'
                                      itab-sttag.
    *                              '06.09.2008'.
        PERFORM bdc_dynpro      USING 'SAPLCPDA' '1200'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
    *  PERFORM bdc_field       USING 'PLKOD-PLNAL'
    *                                itab-plnal.
    **                              '1'.
    *  PERFORM bdc_field       USING 'PLKOD-KTEXT'
    *                                itab-ktext.
    *                              'Printing and Stationary'.
    *perform bdc_field       using 'PLKOD-WERKS'
    *                              '2010'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'PLKOD-STATU'.
        PERFORM bdc_field       USING 'PLKOD-VERWE'
                                      itab-verwe.
    *                              '5'.
        PERFORM bdc_field       USING 'PLKOD-STATU'
                                      itab-statu.
    *                              '4'.
    *perform bdc_field       using 'PLKOD-LOSBS'
    *                              '99,999,999'.
    *perform bdc_field       using 'PLKOD-PLNME'
    *                              'EA'.
        PERFORM bdc_dynpro      USING 'SAPLCPDA' '1200'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=VOUE'.
    *  PERFORM bdc_field       USING 'PLKOD-KTEXT'
    *                                'Printing and Stationary'.
    *  PERFORM bdc_field       USING 'PLKOD-WERKS'
    *                                '2010'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'PLKOD-STATU'.
    *  PERFORM bdc_field       USING 'PLKOD-VERWE'
    *                                '5'.
    *  PERFORM bdc_field       USING 'PLKOD-STATU'
    *                                '4'.
    *  PERFORM bdc_field       USING 'PLKOD-LOSBS'
    *                                '99,999,999'.
    *  PERFORM bdc_field       USING 'PLKOD-PLNME'
    *                                'EA'.
        PERFORM bdc_dynpro      USING 'SAPLCPDI' '1400'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'PLPOD-LTXA1(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'PLPOD-ARBPL(01)'
                                      itab-arbpl.
    *                                'qclab'.
        PERFORM bdc_field       USING 'PLPOD-STEUS(01)'
                                      itab-steus.
    *                                'qm01'.
        PERFORM bdc_field       USING 'PLPOD-LTXA1(01)'
                                      itab-ltxa1.
    *                                'TESTING'.
        PERFORM bdc_dynpro      USING 'SAPLCPDI' '1400'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'PLPOD-VORNR(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=QMUE'.
        PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
                                      '1'.
        PERFORM bdc_field       USING 'RC27X-FLG_SEL(01)'
                                      'X'.
        LOOP AT i_itab WHERE matnr = itab-matnr
                         AND werks = itab-werks
                         AND steus = itab-steus   "CONTROL KEY
                         AND ltxa1 = itab-ltxa1.    "DESCRIPTION
          PERFORM bdc_dynpro      USING 'SAPLQPAA' '0150'.
          CONCATENATE 'PLMKB-STICHPRVER(' lv_count ')' INTO lv_data.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        lv_data.
    *                                    'PLMKB-STICHPRVER(01)'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '/00'.
          CONCATENATE 'PLMKB-VERWMERKM(' lv_count ')' INTO lv_data.
          PERFORM bdc_field       USING lv_data
                                        i_itab-verwmerkm.
    *                                  'flange'.
          CONCATENATE 'PLMKB-KURZTEXT(' lv_count ')' INTO lv_data.
          PERFORM bdc_field       USING lv_data
                                        i_itab-kurztext.
    *                                  'FLANGE CUSTOMER MOUNTING SEAT DIA'.
          CONCATENATE 'PLMKB-PMETHODE(' lv_count ')' INTO lv_data.
          PERFORM bdc_field       USING lv_data
                                        i_itab-pmethode.
    *                                  '10000000'.
          CONCATENATE 'PLMKB-STICHPRVER(' lv_count ')' INTO lv_data.
          PERFORM bdc_field       USING lv_data
                                        i_itab-stichprver.
    *                                  'FIXED-1'.
          PERFORM bdc_dynpro      USING 'SAPLQPAA' '1501'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=ENT1'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'PLMKB-VERWMERKM'.
          PERFORM bdc_field       USING 'PLMKB-VERWMERKM'
                                        i_itab-verwmerkm.
    *                                  'FLANGE'.
          PERFORM bdc_field       USING 'PLMKB-QPMK_WERKS'
                                        i_itab-werks.
    *                                  '2010'.
          PERFORM bdc_field       USING 'PLMKB-PMETHODE'
                                        i_itab-pmethode.
    *                                  '10000000'.
          PERFORM bdc_field       USING 'PLMKB-QMTB_WERKS'
                                        i_itab-werks.
    *                                  '2010'.
          PERFORM bdc_dynpro      USING 'SAPLQPAA' '1502'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=ENT1'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'PLMKB-PMETHODE'.
          PERFORM bdc_field       USING 'PLMKB-PMETHODE'
                                        i_itab-pmethode.
    *                                  '10000000'.
          PERFORM bdc_field       USING 'PLMKB-QMTB_WERKS'
                                        i_itab-werks.
    *                                  '2010'.
          PERFORM bdc_dynpro      USING 'SAPLQPAA' '1502'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=ENT1'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'PLMKB-PMETHODE'.
          PERFORM bdc_field       USING 'PLMKB-PMETHODE'
                                        i_itab-pmethode.
    *                                  '10000000'.
          PERFORM bdc_field       USING 'PLMKB-QMTB_WERKS'
                                        i_itab-werks.
    *                                  '2010'.
          IF i_itab-lv_formula IS NOT INITIAL.
            PERFORM bdc_dynpro      USING 'SAPLQPAA' '1522'.
            PERFORM bdc_field       USING 'BDC_CURSOR'
                                          'PLMKB-FORMEL1'.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                          '=ENT1'.
            PERFORM bdc_field       USING 'PLMKB-FORMELSL'
                                          'X'.
            PERFORM bdc_field       USING 'PLMKB-FORMEL1'
                                          i_itab-formel1.
    *                              'c010'.
          ENDIF.
          lv_count = lv_count + 1.
        ENDLOOP.
        lv_count = 01.
        PERFORM bdc_dynpro      USING 'SAPLQPAA' '0150'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RQPAS-ENTRY_ACT'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=QMBU'.
        PERFORM bdc_field       USING 'RQPAS-ENTRY_ACT'
                                      '1'.
    *    ENDLOOP.
        PERFORM bdc_insert.
      ENDLOOP.
    ENDFORM.                    " bdcdata
    *&      Form  bdc_insert
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM bdc_insert.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          tcode     = 'QP01'
        TABLES
          dynprotab = bdcdata.
    ENDFORM.                    " bdc_insert
    Edited by: PRAKASH VARUN on Apr 18, 2009 1:36 PM

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

Maybe you are looking for

  • Loading Ex Gain/loss on material with CKMLCP

    Hi Gurus, I am facing one issue with material ledger and seeking you suggestion. There are 2 accounts 514000 (for ex gain) and 514001( for ex loss). Whenever there is gain/loss posting to these accounts wrt import MIRO, such gain/loss would get loade

  • IR posting without DCIn happening for PO

    Hi Gurus, I have a scenario, where the Invoice Receipt is happening without DCIn(Del. Cost Invoice) in Purchase Order, we were expecting a error for Exchange rate while posting the IDoc. Is there any setting or a way to determine the solution. Please

  • Don't want to trigger alert in mapping failure

    Hi Experts, I have defined one alert category and corresponding rule in RWB to trigger alert for any failure like Receiver determination error, mapping error etc for all interfaces like Create order, cost center, shipments etc. I have done complete c

  • Why are many tracks in my library now just labeled "track 9" etc ?

    why are many tracks in my library now just labeled "track 9" etc ?

  • Markup Hyperlink in Report

    Hi, I want to build a forum like this one with HTML DB, now I search a function that replaces URLs with a hyperlink inside the text (CLOB). Is there a built in-function with HTML DB or should I search the Oracle Text doc? Bye, Rumburak